Skip to content

V6 biome #1218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: v6
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"$schema": "https://biomejs.dev/schemas/1.7.0/schema.json",
"organizeImports": {
"enabled": true
},
"files": {
"include": ["./src"],
"ignore": ["node_modules/**", "dist/**", "build/**", "coverage/**", "public/**", "docs/**", "./src/App.tsx"]
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"complexity": {
"useLiteralKeys": "off"
}
}
},
"javascript": {
"formatter": {
"semicolons": "asNeeded",
"lineWidth": 100,
"quoteStyle": "single",
"indentStyle": "space"
}
}
}
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -15,6 +15,9 @@
"bundlesize": "bundlesize",
"esbuild": "esbuild",
"test": "jest",
"biome:lint": "biome lint --max-diagnostics 1000 --apply ./src",
"biome:format": "biome format --max-diagnostics 1000 --write ./src",
"biome:pre-commit": "npm run biome:lint && npm run biome:format",
"postbuild": "npm run types && npm run bundlesize",
"prepublishOnly": "npm run build"
},
@@ -49,6 +52,7 @@
},
"homepage": "https://github.com/ReactTooltip/react-tooltip#readme",
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@rollup/plugin-commonjs": "26.0.1",
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-replace": "5.0.7",
2 changes: 1 addition & 1 deletion rollup.config.prod.mjs
Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ const config = allBuildFormats.map(
}),
]

if (specificPlugins && specificPlugins.length) {
if (specificPlugins?.length) {
plugins.push(...specificPlugins)
}

31 changes: 24 additions & 7 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable jsx-a11y/no-static-element-interactions */
/* eslint-disable jsx-a11y/click-events-have-key-events */
import { TooltipController as Tooltip } from 'components/TooltipController'
import { IPosition, TooltipRefProps } from 'components/Tooltip/TooltipTypes.d'
import type { IPosition, TooltipRefProps } from 'components/Tooltip/TooltipTypes.d'
import React, { useEffect, useRef, useState } from 'react'
import { inline, offset } from '@floating-ui/dom'
import styles from './styles.module.css'
@@ -81,13 +81,15 @@ function App() {
<p>
<button
id="button2"
type="button"
data-tooltip-content="Hello World from a Tooltip 2"
onClick={handleButtonClick}
>
Hover or focus me
</button>
<button
id="button3"
type="button"
data-tooltip-content="Hello World from a Tooltip 3"
onClick={handleButtonClick}
>
@@ -97,11 +99,19 @@ function App() {
</section>
<section id="section-anchor-select" style={{ marginTop: '100px' }}>
<p>
<button data-tooltip-id="anchor-select" data-tooltip-content="this content is different">
<button
type="button"
data-tooltip-id="anchor-select"
data-tooltip-content="this content is different"
>
Anchor select
</button>
<button data-tooltip-id="anchor-select">Anchor select 2</button>
<button data-tooltip-id="anchor-select">Anchor select 3</button>
<button type="button" data-tooltip-id="anchor-select">
Anchor select 2
</button>
<button type="button" data-tooltip-id="anchor-select">
Anchor select 3
</button>
</p>
<Tooltip id="anchor-select">Tooltip content</Tooltip>
<Tooltip
@@ -163,6 +173,7 @@ function App() {
/>
</div>
<button
type="button"
id="imperativeTooltipButton"
style={{ height: 40, marginLeft: 100 }}
onClick={() => {
@@ -184,7 +195,9 @@ function App() {
</div>

<div style={{ marginTop: '1rem' }}>
<button id="buttonCallbacks">Check the dev console</button>
<button type="button" id="buttonCallbacks">
Check the dev console
</button>
<Tooltip
place="bottom"
anchorSelect="#buttonCallbacks"
@@ -195,7 +208,9 @@ function App() {
content="Showing tooltip and calling afterShow method"
/>

<button id="buttonCallbacksClick">With click event</button>
<button type="button" id="buttonCallbacksClick">
With click event
</button>
<Tooltip
openOnClick
place="bottom"
@@ -207,7 +222,9 @@ function App() {
content="Showing tooltip and calling afterShow method"
/>

<button id="buttonCallbacksDelay">With delay</button>
<button type="button" id="buttonCallbacksDelay">
With delay
</button>
<Tooltip
delayShow={1000}
place="bottom"
5 changes: 4 additions & 1 deletion src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
@@ -508,7 +508,10 @@ const Tooltip = ({
window.addEventListener('click', handleClickOutsideAnchors)
}

const enabledEvents: { event: string; listener: (event?: Event) => void }[] = []
const enabledEvents: {
event: string
listener: (event?: Event) => void
}[] = []

const handleClickOpenTooltipAnchor = (event?: Event) => {
if (show && event?.target === activeAnchor) {
11 changes: 9 additions & 2 deletions src/components/TooltipController/TooltipController.tsx
Original file line number Diff line number Diff line change
@@ -224,7 +224,11 @@ const TooltipController = React.forwardRef<TooltipRefProps, ITooltipController>(

// do not check for subtree and childrens, we only want to know attribute changes
// to stay watching `data-attributes-*` from anchor element
const observerConfig = { attributes: true, childList: false, subtree: false }
const observerConfig = {
attributes: true,
childList: false,
subtree: false,
}

if (activeAnchor) {
const dataAttributes = getDataAttributesFromAnchorElement(activeAnchor)
@@ -264,7 +268,10 @@ const TooltipController = React.forwardRef<TooltipRefProps, ITooltipController>(
if (render) {
const actualContent =
activeAnchor?.getAttribute('data-tooltip-content') || tooltipContent || null
const rendered = render({ content: actualContent, activeAnchor }) as React.ReactNode
const rendered = render({
content: actualContent,
activeAnchor,
}) as React.ReactNode
renderedContent = rendered ? (
<div ref={contentWrapperRef} className="react-tooltip-content-wrapper">
{rendered}
12 changes: 10 additions & 2 deletions src/test/utils.spec.js
Original file line number Diff line number Diff line change
@@ -9,7 +9,11 @@ describe('compute positions', () => {
tooltipArrowReference: null,
})

expect(value).toEqual({ tooltipStyles: {}, tooltipArrowStyles: {}, place: 'top' })
expect(value).toEqual({
tooltipStyles: {},
tooltipArrowStyles: {},
place: 'top',
})
})

test('empty tooltip reference element', async () => {
@@ -20,7 +24,11 @@ describe('compute positions', () => {
tooltipArrowReference: null,
})

expect(value).toEqual({ tooltipStyles: {}, tooltipArrowStyles: {}, place: 'top' })
expect(value).toEqual({
tooltipStyles: {},
tooltipArrowStyles: {},
place: 'top',
})
})

test('empty tooltip arrow reference element', async () => {
2 changes: 1 addition & 1 deletion src/utils/compute-tooltip-position-types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CSSProperties } from 'react'
import type { CSSProperties } from 'react'
import type { Middleware, PlacesType } from '../components/Tooltip/TooltipTypes'

export interface IComputePositionArgs {
6 changes: 5 additions & 1 deletion src/utils/compute-tooltip-position.ts
Original file line number Diff line number Diff line change
@@ -82,7 +82,11 @@ const computeTooltipPosition = async ({
}
/* c8 ignore end */

return { tooltipStyles: styles, tooltipArrowStyles: arrowStyle, place: placement }
return {
tooltipStyles: styles,
tooltipArrowStyles: arrowStyle,
place: placement,
}
})
}

203 changes: 104 additions & 99 deletions tsconfig.json

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -310,6 +310,60 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==

"@biomejs/biome@1.8.3":
version "1.8.3"
resolved "https://registry.yarnpkg.com/@biomejs/biome/-/biome-1.8.3.tgz#3b5eecea90d973f71618aae3e6e8be4d2ca23e42"
integrity sha512-/uUV3MV+vyAczO+vKrPdOW0Iaet7UnJMU4bNMinggGJTAnBPjCoLEYcyYtYHNnUNYlv4xZMH6hVIQCAozq8d5w==
optionalDependencies:
"@biomejs/cli-darwin-arm64" "1.8.3"
"@biomejs/cli-darwin-x64" "1.8.3"
"@biomejs/cli-linux-arm64" "1.8.3"
"@biomejs/cli-linux-arm64-musl" "1.8.3"
"@biomejs/cli-linux-x64" "1.8.3"
"@biomejs/cli-linux-x64-musl" "1.8.3"
"@biomejs/cli-win32-arm64" "1.8.3"
"@biomejs/cli-win32-x64" "1.8.3"

"@biomejs/cli-darwin-arm64@1.8.3":
version "1.8.3"
resolved "https://registry.yarnpkg.com/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.8.3.tgz#be2bfdd445cd2d3cb0ff41a96a72ec761753997c"
integrity sha512-9DYOjclFpKrH/m1Oz75SSExR8VKvNSSsLnVIqdnKexj6NwmiMlKk94Wa1kZEdv6MCOHGHgyyoV57Cw8WzL5n3A==

"@biomejs/cli-darwin-x64@1.8.3":
version "1.8.3"
resolved "https://registry.yarnpkg.com/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.8.3.tgz#47d408edd9f5c04069fbcf8610bacf1db8c6c0d9"
integrity sha512-UeW44L/AtbmOF7KXLCoM+9PSgPo0IDcyEUfIoOXYeANaNXXf9mLUwV1GeF2OWjyic5zj6CnAJ9uzk2LT3v/wAw==

"@biomejs/cli-linux-arm64-musl@1.8.3":
version "1.8.3"
resolved "https://registry.yarnpkg.com/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.8.3.tgz#44df284383d57cf4f28daeedd080dad7be05df78"
integrity sha512-9yjUfOFN7wrYsXt/T/gEWfvVxKlnh3yBpnScw98IF+oOeCYb5/b/+K7YNqKROV2i1DlMjg9g/EcN9wvj+NkMuQ==

"@biomejs/cli-linux-arm64@1.8.3":
version "1.8.3"
resolved "https://registry.yarnpkg.com/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.8.3.tgz#6a6b1da1dfce0294a028cbb5d6c40d73691dd713"
integrity sha512-fed2ji8s+I/m8upWpTJGanqiJ0rnlHOK3DdxsyVLZQ8ClY6qLuPc9uehCREBifRJLl/iJyQpHIRufLDeotsPtw==

"@biomejs/cli-linux-x64-musl@1.8.3":
version "1.8.3"
resolved "https://registry.yarnpkg.com/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.8.3.tgz#ceef30a8ee1a00d4ad31e32dd31ba2a661f2719d"
integrity sha512-UHrGJX7PrKMKzPGoEsooKC9jXJMa28TUSMjcIlbDnIO4EAavCoVmNQaIuUSH0Ls2mpGMwUIf+aZJv657zfWWjA==

"@biomejs/cli-linux-x64@1.8.3":
version "1.8.3"
resolved "https://registry.yarnpkg.com/@biomejs/cli-linux-x64/-/cli-linux-x64-1.8.3.tgz#665df74d19fb8f83001a9d80824d3a1723e2123f"
integrity sha512-I8G2QmuE1teISyT8ie1HXsjFRz9L1m5n83U1O6m30Kw+kPMPSKjag6QGUn+sXT8V+XWIZxFFBoTDEDZW2KPDDw==

"@biomejs/cli-win32-arm64@1.8.3":
version "1.8.3"
resolved "https://registry.yarnpkg.com/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.8.3.tgz#0fb6f58990f4de0331a6ed22c47c66f5a89133cc"
integrity sha512-J+Hu9WvrBevfy06eU1Na0lpc7uR9tibm9maHynLIoAjLZpQU3IW+OKHUtyL8p6/3pT2Ju5t5emReeIS2SAxhkQ==

"@biomejs/cli-win32-x64@1.8.3":
version "1.8.3"
resolved "https://registry.yarnpkg.com/@biomejs/cli-win32-x64/-/cli-win32-x64-1.8.3.tgz#6a9dc5a4e13357277da43c015cd5cdc374035448"
integrity sha512-/PJ59vA1pnQeKahemaQf4Nyj7IKUvGQSc3Ze1uIGi+Wvr1xF7rGobSrAAG01T/gUDG21vkDsZYM03NAmPiVkqg==

"@cspotcode/source-map-support@^0.8.0":
version "0.8.1"
resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1"