refactor: migrate eslint to v9 (#5267)

* refactor: migrate eslint to v9

* chore: lint

* chore: update eslint command

* chore: fix lint warnings

* chore: separate lint and lint:fix

* chore: exclude contentlayer generated code

* fix(scripts): add missing await
This commit is contained in:
WK 2025-06-02 00:51:30 +08:00 committed by GitHub
parent 8df9716dfa
commit 8c2613713a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
60 changed files with 2545 additions and 1484 deletions

View File

@ -1,25 +0,0 @@
.now/*
.next/*
*.css
.changeset
dist
esm/*
public/*
tests/*
scripts/*
*.config.js
.DS_Store
node_modules
coverage
.next
build
!.storybook
/**/.storybook/**
!.commitlintrc.cjs
!.lintstagedrc.cjs
!jest.config.js
!plopfile.js
!react-shim.js
!tsup.config.ts
apps/docs/preinstall.js
apps/docs/next-redirect.js

View File

@ -1,93 +0,0 @@
{
"$schema": "https://json.schemastore.org/eslintrc.json",
"env": {
"browser": false,
"es2021": true,
"node": true
},
"extends": [
"plugin:react/recommended",
"plugin:prettier/recommended",
"plugin:react-hooks/recommended",
"plugin:jsx-a11y/recommended"
],
"plugins": ["react", "unused-imports", "import", "@typescript-eslint", "jsx-a11y", "prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"settings": {
"react": {
"version": "detect"
}
},
"rules": {
"no-console": "warn",
"react/prop-types": "off",
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
"react-hooks/exhaustive-deps": "off",
"jsx-a11y/click-events-have-key-events": "warn",
"jsx-a11y/interactive-supports-focus": "warn",
"prettier/prettier": "warn",
"no-unused-vars": "off",
"unused-imports/no-unused-vars": "off",
"unused-imports/no-unused-imports": "warn",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"args": "after-used",
"ignoreRestSiblings": false,
"argsIgnorePattern": "^_.*?$"
}
],
"import/order": [
"warn",
{
"groups": [
"type",
"builtin",
"object",
"external",
"internal",
"parent",
"sibling",
"index"
],
"pathGroups": [
{
"pattern": "~/**",
"group": "external",
"position": "after"
}
],
"newlines-between": "always"
}
],
"react/self-closing-comp": "warn",
"react/jsx-sort-props": [
"warn",
{
"callbacksLast": true,
"shorthandFirst": true,
"noSortAlphabetically": false,
"reservedFirst": true
}
],
"padding-line-between-statements": [
"warn",
{"blankLine": "always", "prev": "*", "next": "return"},
{"blankLine": "always", "prev": ["const", "let", "var"], "next": "*"},
{
"blankLine": "any",
"prev": ["const", "let", "var"],
"next": ["const", "let", "var"]
}
],
"import/consistent-type-specifier-style": ["error", "prefer-top-level"]
}
}

View File

@ -16,7 +16,7 @@ module.exports = {
"**/*.{js,ts,jsx,tsx}": async (files) => {
const filesToLint = await removeIgnoredFiles(files);
return [`eslint -c .eslintrc.json --max-warnings=0 --fix ${filesToLint}`];
return [`eslint --max-warnings=0 --fix ${filesToLint}`];
},
"**/*.css": async (files) => {
const filesToLint = await removeIgnoredFiles(files);

View File

@ -1,4 +1,3 @@
/* eslint-disable no-console */
"use client";
import * as React from "react";

View File

@ -1,4 +1,3 @@
/* eslint-disable jsx-a11y/no-onchange */
"use client";
import {

View File

@ -1,4 +1,3 @@
/* eslint-disable jsx-a11y/no-onchange */
"use client";
import {

View File

@ -91,7 +91,7 @@ export const CarbonAd: React.FC<unknown> = () => {
setShowEthicalAds(true);
}
});
} catch (error) {
} catch {
loadCarbonAds();
}
} else {

View File

@ -47,7 +47,6 @@ export default {
if (!document.hidden) {
if (typeof _carbonads !== "undefined" && isElementInViewport("#carbonads")) {
// eslint-disable-next-line no-undef
_carbonads.refresh();
}
}

View File

@ -1,4 +1,3 @@
/* eslint-disable jsx-a11y/media-has-caption */
"use client";
import {useInView} from "framer-motion";

View File

@ -210,7 +210,7 @@ export const Cmdk: FC<{}> = () => {
[query],
);
const items = !isEmpty(results) ? results : recentSearches ?? [];
const items = !isEmpty(results) ? results : (recentSearches ?? []);
// Toggle the menu when ⌘K / CTRL K is pressed
useEffect(() => {

View File

@ -19,14 +19,14 @@ const DynamicReactLiveDemo = dynamic(
() => import("./react-live-demo").then((m) => m.ReactLiveDemo),
{
ssr: false,
// eslint-disable-next-line react/display-name
loading: () => <Skeleton className="w-full h-24 rounded-xl" />,
},
);
const DynamicSandpack = dynamic(() => import("../../../sandpack").then((m) => m.Sandpack), {
ssr: false,
// eslint-disable-next-line react/display-name
loading: () => <Skeleton className="w-full h-32 rounded-xl" />,
});

View File

@ -1,6 +1,5 @@
"use client";
/* eslint-disable react/display-name */
import {
Button,
Image,

View File

@ -1,6 +1,5 @@
"use client";
/* eslint-disable react/display-name */
import {useMemo, useState} from "react";
import {Tabs, Tab, Card, CardBody, Image, Button, RadioGroup, Radio} from "@heroui/react";
import NextLink from "next/link";

View File

@ -1,6 +1,5 @@
"use client";
/* eslint-disable react/display-name */
import {Button, Link} from "@heroui/react";
import NextLink from "next/link";

View File

@ -1,6 +1,5 @@
"use client";
/* eslint-disable react/display-name */
import {Code, Button, Tooltip} from "@heroui/react";
import {useState} from "react";
import NextLink from "next/link";

View File

@ -1,5 +1,3 @@
/* eslint-disable react/display-name */
import {title, subtitle, titleWrapper, sectionWrapper} from "@/components/primitives";
import {FeaturesGrid} from "@/components/marketing/features-grid";
import landingContent from "@/content/landing";

View File

@ -9,7 +9,7 @@ async function getData() {
return {
sponsors,
};
} catch (error) {
} catch {
throw new Error("Failed to fetch data");
}
}

View File

@ -1,4 +1,3 @@
/* eslint-disable react/display-name */
import {clsx} from "@heroui/shared-utils";
import * as Components from "@heroui/react";
import {Language} from "prism-react-renderer";

View File

@ -1,4 +1,3 @@
/* eslint-disable no-undef */
import * as React from "react";
export function useScrollPosition(ref: React.MutableRefObject<HTMLElement | null>) {

View File

@ -1,4 +1,3 @@
/* eslint-disable no-undef */
import * as React from "react";
export function useScrollSpy(selectors: string[], options?: IntersectionObserverInit) {

View File

@ -16,7 +16,6 @@ export const useUpdateEffect: typeof useEffect = (effect, deps) => {
return effect();
}
effectCycleRef.current = true;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, deps);
useEffect(() => {

View File

@ -7,7 +7,7 @@ export interface GithubError extends Error {
function getErrorText(res: Response) {
try {
return res.text();
} catch (err) {
} catch {
return res.statusText;
}
}

View File

@ -20,7 +20,6 @@ const lineNumberify = function lineNumberify(ast, lineNum = 1) {
const lines = node.value.split("\n");
for (let i = 0; i < lines.length; i++) {
// eslint-disable-next-line no-plusplus
if (i !== 0) ++lineNumber;
if (i === lines.length - 1 && lines[i].length === 0) continue;
result.nodes.push({

View File

@ -48,7 +48,7 @@ async function build() {
// make sure the sponsors directory exists
try {
await fs.access(sponsorsDir);
} catch (error) {
} catch {
await fs.mkdir(sponsorsDir, { recursive: true });
}
await Promise.all([buildSponsors()])

View File

@ -35,7 +35,7 @@ async function getGithubInfo() {
};
// Format JSON with prettier
const formattedJson = prettier.format(JSON.stringify(githubInfo), {
const formattedJson = await prettier.format(JSON.stringify(githubInfo), {
parser: 'json',
printWidth: 80,
tabWidth: 2,

View File

@ -101,7 +101,7 @@ async function getSearchMeta(saveMode: "algolia" | "local" = "local") {
try {
result = await getMDXMeta(file);
json.push(...result);
} catch (error) {}
} catch {}
}
if (saveMode === "local") {

View File

@ -20,7 +20,7 @@ export const getSponsors = async () => {
);
return sponsors as Sponsor[];
} catch (error) {
} catch {
return __PROD__ ? [] : mockData;
}
};

160
eslint.config.mjs Normal file
View File

@ -0,0 +1,160 @@
import { defineConfig, globalIgnores } from "eslint/config";
import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
import react from "eslint-plugin-react";
import unusedImports from "eslint-plugin-unused-imports";
import _import from "eslint-plugin-import";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import jsxA11Y from "eslint-plugin-jsx-a11y";
import prettier from "eslint-plugin-prettier";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
export default defineConfig([globalIgnores([
".now/*",
".next/*",
"**/*.css",
"**/.changeset",
"**/dist",
"esm/*",
"public/*",
"tests/*",
"scripts/*",
"**/*.config.js",
"**/.DS_Store",
"**/node_modules",
"**/coverage",
"**/.next",
"**/build",
"!**/.storybook",
"**/.storybook/**/*",
"!**/.commitlintrc.cjs",
"!**/.lintstagedrc.cjs",
"!**/jest.config.js",
"!**/plopfile.js",
"!**/react-shim.js",
"!**/tsup.config.ts",
"apps/docs/preinstall.js",
"apps/docs/next-redirect.js",
"apps/docs/.contentlayer/**/*"
]), {
extends: fixupConfigRules(compat.extends(
"plugin:react/recommended",
"plugin:prettier/recommended",
"plugin:react-hooks/recommended",
"plugin:jsx-a11y/recommended",
)),
plugins: {
react: fixupPluginRules(react),
"unused-imports": unusedImports,
import: fixupPluginRules(_import),
"@typescript-eslint": typescriptEslint,
"jsx-a11y": fixupPluginRules(jsxA11Y),
prettier: fixupPluginRules(prettier),
},
languageOptions: {
globals: {
...Object.fromEntries(Object.entries(globals.browser).map(([key]) => [key, "off"])),
...globals.node,
},
parser: tsParser,
ecmaVersion: 12,
sourceType: "module",
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
settings: {
react: {
version: "detect",
},
},
files: [
"**/*.{ts,tsx,js,jsx}"
],
rules: {
"no-console": "warn",
"react/prop-types": "off",
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
"react-hooks/exhaustive-deps": "off",
"jsx-a11y/click-events-have-key-events": "warn",
"jsx-a11y/interactive-supports-focus": "warn",
"prettier/prettier": "warn",
"no-unused-vars": "off",
"unused-imports/no-unused-vars": "off",
"unused-imports/no-unused-imports": "warn",
"@typescript-eslint/no-unused-vars": ["warn", {
args: "after-used",
ignoreRestSiblings: false,
argsIgnorePattern: "^_.*?$",
}],
"import/order": ["warn", {
groups: [
"type",
"builtin",
"object",
"external",
"internal",
"parent",
"sibling",
"index",
],
pathGroups: [{
pattern: "~/**",
group: "external",
position: "after",
}],
"newlines-between": "always",
}],
"react/self-closing-comp": "warn",
"react/jsx-sort-props": ["warn", {
callbacksLast: true,
shorthandFirst: true,
noSortAlphabetically: false,
reservedFirst: true,
}],
"padding-line-between-statements": ["warn", {
blankLine: "always",
prev: "*",
next: "return",
}, {
blankLine: "always",
prev: ["const", "let", "var"],
next: "*",
}, {
blankLine: "any",
prev: ["const", "let", "var"],
next: ["const", "let", "var"],
}],
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
},
}]);

View File

@ -24,11 +24,8 @@
"test": "jest --verbose --config ./jest.config.js",
"test:strict": "cross-env STRICT_MODE=true pnpm test",
"typecheck": "turbo typecheck",
"lint": "pnpm lint:pkg && pnpm lint:docs",
"lint:pkg": "eslint -c .eslintrc.json ./packages/**/*.{ts,tsx}",
"lint:docs": "eslint -c .eslintrc.json ./apps/docs/**/*.{ts,tsx,js,jsx}",
"lint:fix": "eslint --fix -c .eslintrc.json ./packages/**/*.{ts,tsx}",
"lint:docs-fix": "eslint --fix -c .eslintrc.json ./apps/docs/**/*.{ts,tsx,js,jsx}",
"lint": "eslint --max-warnings=0",
"lint:fix": "eslint --fix",
"check:rap": "tsx scripts/check-rap-updates.ts",
"fix:rap": "tsx scripts/fix-rap.ts",
"format:check": "prettier --check packages/**/**/src --cache",
@ -66,6 +63,9 @@
"@changesets/types": "6.0.0",
"@commitlint/cli": "^17.2.0",
"@commitlint/config-conventional": "^17.2.0",
"@eslint/compat": "^1.2.9",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.26.0",
"@react-bootstrap/babel-preset": "^2.1.0",
"@react-types/link": "3.5.10",
"@react-types/shared": "3.27.0",
@ -81,33 +81,34 @@
"@types/react": "^18.0.1",
"@types/react-dom": "^18.0.0",
"@types/shelljs": "^0.8.9",
"@typescript-eslint/eslint-plugin": "^5.42.0",
"@typescript-eslint/parser": "^5.42.0",
"@typescript-eslint/eslint-plugin": "^8.31.1",
"@typescript-eslint/parser": "^8.31.1",
"chalk": "^4.1.2",
"commitlint-plugin-function-rules": "^1.7.1",
"concurrently": "^7.6.0",
"cross-env": "^7.0.3",
"eslint": "^7.29.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-airbnb-typescript": "^12.3.1",
"eslint-config-prettier": "^8.2.0",
"eslint-config-react-app": "^6.0.0",
"eslint": "^9.26.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-config-prettier": "^10.1.2",
"eslint-config-react-app": "^7.0.1",
"eslint-config-ts-lambdas": "^1.2.3",
"eslint-import-resolver-typescript": "^2.4.0",
"eslint-import-resolver-typescript": "^4.3.4",
"eslint-loader": "^4.0.2",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^24.7.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest": "^28.11.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react": "^7.23.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-unused-imports": "^2.0.0",
"eslint-plugin-prettier": "^5.2.6",
"eslint-plugin-promise": "^7.2.1",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-unused-imports": "^4.1.4",
"execa": "^5.1.1",
"find-up": "^6.3.0",
"fs-extra": "^10.0.0",
"glob": "^8.0.3",
"globals": "^16.0.0",
"graceful-fs": "^4.2.6",
"gray-matter": "^4.0.3",
"husky": "^8.0.1",
@ -121,9 +122,9 @@
"p-iteration": "^1.1.8",
"parcel": "^2.3.1",
"plop": "3.1.1",
"prettier": "^2.2.1",
"prettier-eslint": "^12.0.0",
"prettier-eslint-cli": "^5.0.1",
"prettier": "^3.5.3",
"prettier-eslint": "^16.4.1",
"prettier-eslint-cli": "^8.0.1",
"react": "18.3.0",
"rimraf": "^3.0.2",
"shelljs": "^0.8.4",

View File

@ -149,8 +149,8 @@ export function useAutocomplete<T extends object>(originalProps: UseAutocomplete
originalProps.disableClearable !== undefined
? !originalProps.disableClearable
: originalProps.isReadOnly
? false
: originalProps.isClearable;
? false
: originalProps.isClearable;
const {
ref,
@ -403,7 +403,7 @@ export function useAutocomplete<T extends object>(originalProps: UseAutocomplete
className: slots.selectorButton({
class: clsx(classNames?.selectorButton, slotsProps.selectorButtonProps?.className),
}),
} as ButtonProps);
}) as ButtonProps;
const getClearButtonProps = () =>
({
@ -426,7 +426,7 @@ export function useAutocomplete<T extends object>(originalProps: UseAutocomplete
className: slots.clearButton({
class: clsx(classNames?.clearButton, slotsProps.clearButtonProps?.className),
}),
} as ButtonProps);
}) as ButtonProps;
// prevent use-input's useFormValidation hook from overwriting use-autocomplete's useFormValidation hook when there are uncommitted validation errors
// see https://github.com/heroui-inc/heroui/pull/4452
@ -447,7 +447,7 @@ export function useAutocomplete<T extends object>(originalProps: UseAutocomplete
? errorMessage({isInvalid, validationErrors, validationDetails})
: errorMessage || validationErrors?.join(" "),
onClick: chain(slotsProps.inputProps.onClick, otherProps.onClick),
} as unknown as InputProps);
}) as unknown as InputProps;
const getListBoxProps = () => {
// Use isVirtualized prop if defined, otherwise fallback to default behavior

View File

@ -1,4 +1,3 @@
/* eslint-disable react/display-name */
import React from "react";
import {Meta} from "@storybook/react";

View File

@ -96,7 +96,6 @@ describe("Calendar", () => {
});
it("should focus the selected date if autoFocus is set", () => {
// eslint-disable-next-line jsx-a11y/no-autofocus
const wrapper = render(<Calendar autoFocus value={new CalendarDate(2024, 3, 31)} />);
const selectedDate = wrapper.getByLabelText("Selected", {exact: false});

View File

@ -329,7 +329,6 @@ const PrimaryActionTemplate = (args: CardProps) => {
return (
<div className="gap-2 grid grid-cols-2 sm:grid-cols-4">
{list.map((item, index) => (
// eslint-disable-next-line no-console
<Card {...args} key={index} isPressable onPress={() => handlePress(item)}>
<CardBody className="p-0">
<img
@ -352,12 +351,10 @@ const PressableTemplate = (args: CardProps) => {
// Both events should be fired when clicking on the card
const handlePress = () => {
// eslint-disable-next-line no-console
alert("card pressed");
};
const onClick = () => {
// eslint-disable-next-line no-console
alert("card clicked");
};

View File

@ -99,11 +99,11 @@ export function useCheckbox(props: UseCheckboxProps = {}) {
validationState,
isInvalid: isInvalidProp = validationState
? validationState === "invalid"
: groupContext?.isInvalid ?? false,
: (groupContext?.isInvalid ?? false),
isIndeterminate = false,
validationBehavior = isInGroup
? groupContext.validationBehavior
: formValidationBehavior ?? globalContext?.validationBehavior ?? "native",
: (formValidationBehavior ?? globalContext?.validationBehavior ?? "native"),
defaultSelected,
classNames,
className,
@ -330,7 +330,7 @@ export function useCheckbox(props: UseCheckboxProps = {}) {
isIndeterminate,
disableAnimation,
className: slots.icon({class: classNames?.icon}),
} as CheckboxIconProps),
}) as CheckboxIconProps,
[slots, classNames?.icon, isSelected, isIndeterminate, disableAnimation],
);

View File

@ -254,7 +254,7 @@ export const WithReactHookForm = {
export const CustomIconFunction = {
args: {
...defaultProps,
// eslint-disable-next-line react/display-name
icon: (props: CheckboxIconProps) => <CloseIcon {...props} />,
},
};

View File

@ -60,7 +60,6 @@ const ErrorMessageFunctionTemplate = (args) => {
});
const onSubmit = (data: any) => {
// eslint-disable-next-line no-console
alert("Submitted value: " + JSON.stringify(data));
};

View File

@ -1,4 +1,3 @@
/* eslint-disable jsx-a11y/anchor-is-valid */
/* eslint-disable jsx-a11y/no-autofocus */
import React from "react";
import {Meta} from "@storybook/react";

View File

@ -1,5 +1,3 @@
/* eslint-disable jsx-a11y/interactive-supports-focus */
/* eslint-disable jsx-a11y/click-events-have-key-events */
import type {ValidationResult} from "@react-types/shared";
import React from "react";

View File

@ -94,8 +94,8 @@ describe("Pagination", () => {
this.thresholds = Array.isArray(this.options?.threshold)
? this.options.threshold
: this.options?.threshold != null
? [this.options.threshold]
: [0];
? [this.options.threshold]
: [0];
this.disconnect = jest.fn();
this.observe = jest.fn();
this.unobserve = jest.fn();

View File

@ -123,8 +123,8 @@ const Pagination = forwardRef<"nav", PaginationProps>((props, ref) => {
? activePage - dotsJump
: 1
: activePage + dotsJump <= total
? activePage + dotsJump
: total;
? activePage + dotsJump
: total;
}
const itemChildren: Record<PaginationItemType, React.ReactNode> = {

View File

@ -104,7 +104,7 @@ export function useHiddenSelect<T>(
value:
selectionMode === "multiple"
? [...state.selectedKeys].map((k) => String(k))
: [...state.selectedKeys][0] ?? "",
: ([...state.selectedKeys][0] ?? ""),
multiple: selectionMode === "multiple",
onChange: (e: React.ChangeEvent<HTMLSelectElement>) => {
state.setSelectedKeys(e.target.value);

View File

@ -495,7 +495,7 @@ export function useSelect<T extends object>(originalProps: UseSelectProps<T>) {
form: originalProps?.form,
onChange,
...props,
} as HiddenSelectProps<T>),
}) as HiddenSelectProps<T>,
[
state,
selectionMode,

View File

@ -1,4 +1,3 @@
/* eslint-disable react/display-name */
import type {ValidationResult} from "@react-types/shared";
import React, {ChangeEvent} from "react";

View File

@ -252,8 +252,8 @@ export function useSlider(originalProps: UseSliderProps) {
state.values.length > 1
? state.getThumbPercent(0)
: fillOffset !== undefined
? state.getValuePercent(fillOffset)
: 0,
? state.getValuePercent(fillOffset)
: 0,
state.getThumbPercent(state.values.length - 1),
].sort();

View File

@ -1,4 +1,3 @@
/* eslint-disable jsx-a11y/label-has-associated-control */
import React from "react";
import {Meta} from "@storybook/react";
import {slider} from "@heroui/theme";

View File

@ -242,7 +242,7 @@ export function useSnippet(originalProps: UseSnippetProps) {
className: slots.copyButton({
class: clsx(classNames?.copyButton),
}),
} as ButtonProps),
}) as ButtonProps,
[
slots,
isFocusVisible,

View File

@ -1,4 +1,3 @@
/* eslint-disable react/display-name */
import React from "react";
import {Meta} from "@storybook/react";
import {toggle} from "@heroui/theme";

View File

@ -54,7 +54,7 @@ const Tooltip = forwardRef<"div", TooltipProps>((props, ref) => {
trigger = cloneElement(child, getTriggerProps(child.props, childRef));
}
} catch (error) {
} catch {
trigger = <span />;
warn("Tooltip must have only one child node. Please, check your code.");
}

View File

@ -27,11 +27,11 @@ type SuggestedVariants<CP, S> = {
[K in keyof CP]?: ValidateSubtype<CP[K], string> extends "true"
? {[K2 in CP[K]]?: GetSuggestedValues<S>}
: ValidateSubtype<CP[K], boolean> extends "true"
? {
true?: GetSuggestedValues<S>;
false?: GetSuggestedValues<S>;
}
: never;
? {
true?: GetSuggestedValues<S>;
false?: GetSuggestedValues<S>;
}
: never;
};
type ComposeVariants<CP, S> = SuggestedVariants<CP, S> | Variants<S>;

View File

@ -22,6 +22,5 @@ export function useCallbackRef<T extends (...args: any[]) => any>(
ref.current = fn;
});
// eslint-disable-next-line react-hooks/exhaustive-deps
return useCallback(((...args) => ref.current?.(...args)) as T, deps);
}

View File

@ -93,18 +93,7 @@ export function useIntersectionObserver({
return () => {
observer.disconnect();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
ref,
isEnabled,
// eslint-disable-next-line react-hooks/exhaustive-deps
JSON.stringify(threshold),
root,
rootMargin,
frozen,
freezeOnceVisible,
]);
}, [ref, isEnabled, JSON.stringify(threshold), root, rootMargin, frozen, freezeOnceVisible]);
// ensures that if the observed element changes, the intersection observer is reinitialized
const prevRef = useRef<Element | null>(null);

View File

@ -16,7 +16,6 @@ export const useUpdateEffect: typeof useEffect = (effect, deps) => {
return effect();
}
effectCycleRef.current = true;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, deps);
useEffect(() => {

View File

@ -8,8 +8,8 @@ export const getCSSStyleVal = (str: string, parentNum: number) => {
const strVal = str.includes("px")
? +str.split("px")[0]
: str.includes("%")
? +str.split("%")[0] * parentNum * 0.01
: str;
? +str.split("%")[0] * parentNum * 0.01
: str;
return Number.isNaN(+strVal) ? 0 : +strVal;
};

View File

@ -21,7 +21,7 @@ export function assignRef<T = any>(ref: ReactRef<T> | undefined, value: T) {
try {
(ref as MutableRefObject<T>).current = value;
} catch (error) {
} catch {
throw new Error(`Cannot assign value '${value}' to ref '${ref}'`);
}
}

View File

@ -4,7 +4,7 @@ const fs = require('fs')
function tryRequirePkg(pkg) {
try {
return require(pkg);
} catch (e) {
} catch {
return null;
}
}

View File

@ -1,5 +1,3 @@
/* eslint-disable no-shadow-restricted-names */
/* eslint-disable no-plusplus */
function toVal(mix: any) {
var k,
y,

View File

@ -153,7 +153,7 @@ export function objectToDeps(obj: Extractable) {
try {
return JSON.stringify(obj);
} catch (e) {
} catch {
return "";
}
}

View File

@ -15,7 +15,7 @@ export function isHTMLElement(el: any): el is HTMLElement {
}
export function getOwnerDocument(node?: Element | null): Document {
return isElement(node) ? node.ownerDocument ?? document : document;
return isElement(node) ? (node.ownerDocument ?? document) : document;
}
export function getActiveElement(node?: HTMLElement) {

View File

@ -75,8 +75,8 @@ export async function drag(
y: from.y + delta.y,
}
: inTo
? getCoords(inTo)
: null;
? getCoords(inTo)
: null;
if (to === null) throw new Error("You must provide either `delta` or `to`");

3571
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff