mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
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:
parent
8df9716dfa
commit
8c2613713a
@ -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
|
|
||||||
@ -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"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -16,7 +16,7 @@ module.exports = {
|
|||||||
"**/*.{js,ts,jsx,tsx}": async (files) => {
|
"**/*.{js,ts,jsx,tsx}": async (files) => {
|
||||||
const filesToLint = await removeIgnoredFiles(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) => {
|
"**/*.css": async (files) => {
|
||||||
const filesToLint = await removeIgnoredFiles(files);
|
const filesToLint = await removeIgnoredFiles(files);
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable no-console */
|
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable jsx-a11y/no-onchange */
|
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable jsx-a11y/no-onchange */
|
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|||||||
@ -91,7 +91,7 @@ export const CarbonAd: React.FC<unknown> = () => {
|
|||||||
setShowEthicalAds(true);
|
setShowEthicalAds(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch {
|
||||||
loadCarbonAds();
|
loadCarbonAds();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -47,7 +47,6 @@ export default {
|
|||||||
|
|
||||||
if (!document.hidden) {
|
if (!document.hidden) {
|
||||||
if (typeof _carbonads !== "undefined" && isElementInViewport("#carbonads")) {
|
if (typeof _carbonads !== "undefined" && isElementInViewport("#carbonads")) {
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
_carbonads.refresh();
|
_carbonads.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable jsx-a11y/media-has-caption */
|
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {useInView} from "framer-motion";
|
import {useInView} from "framer-motion";
|
||||||
|
|||||||
@ -210,7 +210,7 @@ export const Cmdk: FC<{}> = () => {
|
|||||||
[query],
|
[query],
|
||||||
);
|
);
|
||||||
|
|
||||||
const items = !isEmpty(results) ? results : recentSearches ?? [];
|
const items = !isEmpty(results) ? results : (recentSearches ?? []);
|
||||||
|
|
||||||
// Toggle the menu when ⌘K / CTRL K is pressed
|
// Toggle the menu when ⌘K / CTRL K is pressed
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@ -19,14 +19,14 @@ const DynamicReactLiveDemo = dynamic(
|
|||||||
() => import("./react-live-demo").then((m) => m.ReactLiveDemo),
|
() => import("./react-live-demo").then((m) => m.ReactLiveDemo),
|
||||||
{
|
{
|
||||||
ssr: false,
|
ssr: false,
|
||||||
// eslint-disable-next-line react/display-name
|
|
||||||
loading: () => <Skeleton className="w-full h-24 rounded-xl" />,
|
loading: () => <Skeleton className="w-full h-24 rounded-xl" />,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const DynamicSandpack = dynamic(() => import("../../../sandpack").then((m) => m.Sandpack), {
|
const DynamicSandpack = dynamic(() => import("../../../sandpack").then((m) => m.Sandpack), {
|
||||||
ssr: false,
|
ssr: false,
|
||||||
// eslint-disable-next-line react/display-name
|
|
||||||
loading: () => <Skeleton className="w-full h-32 rounded-xl" />,
|
loading: () => <Skeleton className="w-full h-32 rounded-xl" />,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
/* eslint-disable react/display-name */
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Image,
|
Image,
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
/* eslint-disable react/display-name */
|
|
||||||
import {useMemo, useState} from "react";
|
import {useMemo, useState} from "react";
|
||||||
import {Tabs, Tab, Card, CardBody, Image, Button, RadioGroup, Radio} from "@heroui/react";
|
import {Tabs, Tab, Card, CardBody, Image, Button, RadioGroup, Radio} from "@heroui/react";
|
||||||
import NextLink from "next/link";
|
import NextLink from "next/link";
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
/* eslint-disable react/display-name */
|
|
||||||
import {Button, Link} from "@heroui/react";
|
import {Button, Link} from "@heroui/react";
|
||||||
import NextLink from "next/link";
|
import NextLink from "next/link";
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
/* eslint-disable react/display-name */
|
|
||||||
import {Code, Button, Tooltip} from "@heroui/react";
|
import {Code, Button, Tooltip} from "@heroui/react";
|
||||||
import {useState} from "react";
|
import {useState} from "react";
|
||||||
import NextLink from "next/link";
|
import NextLink from "next/link";
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
/* eslint-disable react/display-name */
|
|
||||||
|
|
||||||
import {title, subtitle, titleWrapper, sectionWrapper} from "@/components/primitives";
|
import {title, subtitle, titleWrapper, sectionWrapper} from "@/components/primitives";
|
||||||
import {FeaturesGrid} from "@/components/marketing/features-grid";
|
import {FeaturesGrid} from "@/components/marketing/features-grid";
|
||||||
import landingContent from "@/content/landing";
|
import landingContent from "@/content/landing";
|
||||||
|
|||||||
@ -9,7 +9,7 @@ async function getData() {
|
|||||||
return {
|
return {
|
||||||
sponsors,
|
sponsors,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch {
|
||||||
throw new Error("Failed to fetch data");
|
throw new Error("Failed to fetch data");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable react/display-name */
|
|
||||||
import {clsx} from "@heroui/shared-utils";
|
import {clsx} from "@heroui/shared-utils";
|
||||||
import * as Components from "@heroui/react";
|
import * as Components from "@heroui/react";
|
||||||
import {Language} from "prism-react-renderer";
|
import {Language} from "prism-react-renderer";
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable no-undef */
|
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
|
|
||||||
export function useScrollPosition(ref: React.MutableRefObject<HTMLElement | null>) {
|
export function useScrollPosition(ref: React.MutableRefObject<HTMLElement | null>) {
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable no-undef */
|
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
|
|
||||||
export function useScrollSpy(selectors: string[], options?: IntersectionObserverInit) {
|
export function useScrollSpy(selectors: string[], options?: IntersectionObserverInit) {
|
||||||
|
|||||||
@ -16,7 +16,6 @@ export const useUpdateEffect: typeof useEffect = (effect, deps) => {
|
|||||||
return effect();
|
return effect();
|
||||||
}
|
}
|
||||||
effectCycleRef.current = true;
|
effectCycleRef.current = true;
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, deps);
|
}, deps);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@ -7,7 +7,7 @@ export interface GithubError extends Error {
|
|||||||
function getErrorText(res: Response) {
|
function getErrorText(res: Response) {
|
||||||
try {
|
try {
|
||||||
return res.text();
|
return res.text();
|
||||||
} catch (err) {
|
} catch {
|
||||||
return res.statusText;
|
return res.statusText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,6 @@ const lineNumberify = function lineNumberify(ast, lineNum = 1) {
|
|||||||
const lines = node.value.split("\n");
|
const lines = node.value.split("\n");
|
||||||
|
|
||||||
for (let i = 0; i < lines.length; i++) {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
// eslint-disable-next-line no-plusplus
|
|
||||||
if (i !== 0) ++lineNumber;
|
if (i !== 0) ++lineNumber;
|
||||||
if (i === lines.length - 1 && lines[i].length === 0) continue;
|
if (i === lines.length - 1 && lines[i].length === 0) continue;
|
||||||
result.nodes.push({
|
result.nodes.push({
|
||||||
|
|||||||
@ -48,7 +48,7 @@ async function build() {
|
|||||||
// make sure the sponsors directory exists
|
// make sure the sponsors directory exists
|
||||||
try {
|
try {
|
||||||
await fs.access(sponsorsDir);
|
await fs.access(sponsorsDir);
|
||||||
} catch (error) {
|
} catch {
|
||||||
await fs.mkdir(sponsorsDir, { recursive: true });
|
await fs.mkdir(sponsorsDir, { recursive: true });
|
||||||
}
|
}
|
||||||
await Promise.all([buildSponsors()])
|
await Promise.all([buildSponsors()])
|
||||||
|
|||||||
@ -35,7 +35,7 @@ async function getGithubInfo() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Format JSON with prettier
|
// Format JSON with prettier
|
||||||
const formattedJson = prettier.format(JSON.stringify(githubInfo), {
|
const formattedJson = await prettier.format(JSON.stringify(githubInfo), {
|
||||||
parser: 'json',
|
parser: 'json',
|
||||||
printWidth: 80,
|
printWidth: 80,
|
||||||
tabWidth: 2,
|
tabWidth: 2,
|
||||||
|
|||||||
@ -101,7 +101,7 @@ async function getSearchMeta(saveMode: "algolia" | "local" = "local") {
|
|||||||
try {
|
try {
|
||||||
result = await getMDXMeta(file);
|
result = await getMDXMeta(file);
|
||||||
json.push(...result);
|
json.push(...result);
|
||||||
} catch (error) {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (saveMode === "local") {
|
if (saveMode === "local") {
|
||||||
|
|||||||
@ -20,7 +20,7 @@ export const getSponsors = async () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return sponsors as Sponsor[];
|
return sponsors as Sponsor[];
|
||||||
} catch (error) {
|
} catch {
|
||||||
return __PROD__ ? [] : mockData;
|
return __PROD__ ? [] : mockData;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
160
eslint.config.mjs
Normal file
160
eslint.config.mjs
Normal 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"],
|
||||||
|
},
|
||||||
|
}]);
|
||||||
49
package.json
49
package.json
@ -24,11 +24,8 @@
|
|||||||
"test": "jest --verbose --config ./jest.config.js",
|
"test": "jest --verbose --config ./jest.config.js",
|
||||||
"test:strict": "cross-env STRICT_MODE=true pnpm test",
|
"test:strict": "cross-env STRICT_MODE=true pnpm test",
|
||||||
"typecheck": "turbo typecheck",
|
"typecheck": "turbo typecheck",
|
||||||
"lint": "pnpm lint:pkg && pnpm lint:docs",
|
"lint": "eslint --max-warnings=0",
|
||||||
"lint:pkg": "eslint -c .eslintrc.json ./packages/**/*.{ts,tsx}",
|
"lint:fix": "eslint --fix",
|
||||||
"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}",
|
|
||||||
"check:rap": "tsx scripts/check-rap-updates.ts",
|
"check:rap": "tsx scripts/check-rap-updates.ts",
|
||||||
"fix:rap": "tsx scripts/fix-rap.ts",
|
"fix:rap": "tsx scripts/fix-rap.ts",
|
||||||
"format:check": "prettier --check packages/**/**/src --cache",
|
"format:check": "prettier --check packages/**/**/src --cache",
|
||||||
@ -66,6 +63,9 @@
|
|||||||
"@changesets/types": "6.0.0",
|
"@changesets/types": "6.0.0",
|
||||||
"@commitlint/cli": "^17.2.0",
|
"@commitlint/cli": "^17.2.0",
|
||||||
"@commitlint/config-conventional": "^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-bootstrap/babel-preset": "^2.1.0",
|
||||||
"@react-types/link": "3.5.10",
|
"@react-types/link": "3.5.10",
|
||||||
"@react-types/shared": "3.27.0",
|
"@react-types/shared": "3.27.0",
|
||||||
@ -81,33 +81,34 @@
|
|||||||
"@types/react": "^18.0.1",
|
"@types/react": "^18.0.1",
|
||||||
"@types/react-dom": "^18.0.0",
|
"@types/react-dom": "^18.0.0",
|
||||||
"@types/shelljs": "^0.8.9",
|
"@types/shelljs": "^0.8.9",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.42.0",
|
"@typescript-eslint/eslint-plugin": "^8.31.1",
|
||||||
"@typescript-eslint/parser": "^5.42.0",
|
"@typescript-eslint/parser": "^8.31.1",
|
||||||
"chalk": "^4.1.2",
|
"chalk": "^4.1.2",
|
||||||
"commitlint-plugin-function-rules": "^1.7.1",
|
"commitlint-plugin-function-rules": "^1.7.1",
|
||||||
"concurrently": "^7.6.0",
|
"concurrently": "^7.6.0",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"eslint": "^7.29.0",
|
"eslint": "^9.26.0",
|
||||||
"eslint-config-airbnb": "^18.2.1",
|
"eslint-config-airbnb": "^19.0.4",
|
||||||
"eslint-config-airbnb-typescript": "^12.3.1",
|
"eslint-config-airbnb-typescript": "^18.0.0",
|
||||||
"eslint-config-prettier": "^8.2.0",
|
"eslint-config-prettier": "^10.1.2",
|
||||||
"eslint-config-react-app": "^6.0.0",
|
"eslint-config-react-app": "^7.0.1",
|
||||||
"eslint-config-ts-lambdas": "^1.2.3",
|
"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-loader": "^4.0.2",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.31.0",
|
||||||
"eslint-plugin-jest": "^24.7.0",
|
"eslint-plugin-jest": "^28.11.0",
|
||||||
"eslint-plugin-jsx-a11y": "^6.4.1",
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"eslint-plugin-prettier": "^4.0.0",
|
"eslint-plugin-prettier": "^5.2.6",
|
||||||
"eslint-plugin-promise": "^6.0.0",
|
"eslint-plugin-promise": "^7.2.1",
|
||||||
"eslint-plugin-react": "^7.23.2",
|
"eslint-plugin-react": "^7.37.5",
|
||||||
"eslint-plugin-react-hooks": "^4.6.0",
|
"eslint-plugin-react-hooks": "^5.2.0",
|
||||||
"eslint-plugin-unused-imports": "^2.0.0",
|
"eslint-plugin-unused-imports": "^4.1.4",
|
||||||
"execa": "^5.1.1",
|
"execa": "^5.1.1",
|
||||||
"find-up": "^6.3.0",
|
"find-up": "^6.3.0",
|
||||||
"fs-extra": "^10.0.0",
|
"fs-extra": "^10.0.0",
|
||||||
"glob": "^8.0.3",
|
"glob": "^8.0.3",
|
||||||
|
"globals": "^16.0.0",
|
||||||
"graceful-fs": "^4.2.6",
|
"graceful-fs": "^4.2.6",
|
||||||
"gray-matter": "^4.0.3",
|
"gray-matter": "^4.0.3",
|
||||||
"husky": "^8.0.1",
|
"husky": "^8.0.1",
|
||||||
@ -121,9 +122,9 @@
|
|||||||
"p-iteration": "^1.1.8",
|
"p-iteration": "^1.1.8",
|
||||||
"parcel": "^2.3.1",
|
"parcel": "^2.3.1",
|
||||||
"plop": "3.1.1",
|
"plop": "3.1.1",
|
||||||
"prettier": "^2.2.1",
|
"prettier": "^3.5.3",
|
||||||
"prettier-eslint": "^12.0.0",
|
"prettier-eslint": "^16.4.1",
|
||||||
"prettier-eslint-cli": "^5.0.1",
|
"prettier-eslint-cli": "^8.0.1",
|
||||||
"react": "18.3.0",
|
"react": "18.3.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"shelljs": "^0.8.4",
|
"shelljs": "^0.8.4",
|
||||||
|
|||||||
@ -149,8 +149,8 @@ export function useAutocomplete<T extends object>(originalProps: UseAutocomplete
|
|||||||
originalProps.disableClearable !== undefined
|
originalProps.disableClearable !== undefined
|
||||||
? !originalProps.disableClearable
|
? !originalProps.disableClearable
|
||||||
: originalProps.isReadOnly
|
: originalProps.isReadOnly
|
||||||
? false
|
? false
|
||||||
: originalProps.isClearable;
|
: originalProps.isClearable;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ref,
|
ref,
|
||||||
@ -403,7 +403,7 @@ export function useAutocomplete<T extends object>(originalProps: UseAutocomplete
|
|||||||
className: slots.selectorButton({
|
className: slots.selectorButton({
|
||||||
class: clsx(classNames?.selectorButton, slotsProps.selectorButtonProps?.className),
|
class: clsx(classNames?.selectorButton, slotsProps.selectorButtonProps?.className),
|
||||||
}),
|
}),
|
||||||
} as ButtonProps);
|
}) as ButtonProps;
|
||||||
|
|
||||||
const getClearButtonProps = () =>
|
const getClearButtonProps = () =>
|
||||||
({
|
({
|
||||||
@ -426,7 +426,7 @@ export function useAutocomplete<T extends object>(originalProps: UseAutocomplete
|
|||||||
className: slots.clearButton({
|
className: slots.clearButton({
|
||||||
class: clsx(classNames?.clearButton, slotsProps.clearButtonProps?.className),
|
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
|
// 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
|
// 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({isInvalid, validationErrors, validationDetails})
|
||||||
: errorMessage || validationErrors?.join(" "),
|
: errorMessage || validationErrors?.join(" "),
|
||||||
onClick: chain(slotsProps.inputProps.onClick, otherProps.onClick),
|
onClick: chain(slotsProps.inputProps.onClick, otherProps.onClick),
|
||||||
} as unknown as InputProps);
|
}) as unknown as InputProps;
|
||||||
|
|
||||||
const getListBoxProps = () => {
|
const getListBoxProps = () => {
|
||||||
// Use isVirtualized prop if defined, otherwise fallback to default behavior
|
// Use isVirtualized prop if defined, otherwise fallback to default behavior
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable react/display-name */
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {Meta} from "@storybook/react";
|
import {Meta} from "@storybook/react";
|
||||||
|
|
||||||
|
|||||||
@ -96,7 +96,6 @@ describe("Calendar", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should focus the selected date if autoFocus is set", () => {
|
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 wrapper = render(<Calendar autoFocus value={new CalendarDate(2024, 3, 31)} />);
|
||||||
|
|
||||||
const selectedDate = wrapper.getByLabelText("Selected", {exact: false});
|
const selectedDate = wrapper.getByLabelText("Selected", {exact: false});
|
||||||
|
|||||||
@ -329,7 +329,6 @@ const PrimaryActionTemplate = (args: CardProps) => {
|
|||||||
return (
|
return (
|
||||||
<div className="gap-2 grid grid-cols-2 sm:grid-cols-4">
|
<div className="gap-2 grid grid-cols-2 sm:grid-cols-4">
|
||||||
{list.map((item, index) => (
|
{list.map((item, index) => (
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
<Card {...args} key={index} isPressable onPress={() => handlePress(item)}>
|
<Card {...args} key={index} isPressable onPress={() => handlePress(item)}>
|
||||||
<CardBody className="p-0">
|
<CardBody className="p-0">
|
||||||
<img
|
<img
|
||||||
@ -352,12 +351,10 @@ const PressableTemplate = (args: CardProps) => {
|
|||||||
// Both events should be fired when clicking on the card
|
// Both events should be fired when clicking on the card
|
||||||
|
|
||||||
const handlePress = () => {
|
const handlePress = () => {
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
alert("card pressed");
|
alert("card pressed");
|
||||||
};
|
};
|
||||||
|
|
||||||
const onClick = () => {
|
const onClick = () => {
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
alert("card clicked");
|
alert("card clicked");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -99,11 +99,11 @@ export function useCheckbox(props: UseCheckboxProps = {}) {
|
|||||||
validationState,
|
validationState,
|
||||||
isInvalid: isInvalidProp = validationState
|
isInvalid: isInvalidProp = validationState
|
||||||
? validationState === "invalid"
|
? validationState === "invalid"
|
||||||
: groupContext?.isInvalid ?? false,
|
: (groupContext?.isInvalid ?? false),
|
||||||
isIndeterminate = false,
|
isIndeterminate = false,
|
||||||
validationBehavior = isInGroup
|
validationBehavior = isInGroup
|
||||||
? groupContext.validationBehavior
|
? groupContext.validationBehavior
|
||||||
: formValidationBehavior ?? globalContext?.validationBehavior ?? "native",
|
: (formValidationBehavior ?? globalContext?.validationBehavior ?? "native"),
|
||||||
defaultSelected,
|
defaultSelected,
|
||||||
classNames,
|
classNames,
|
||||||
className,
|
className,
|
||||||
@ -330,7 +330,7 @@ export function useCheckbox(props: UseCheckboxProps = {}) {
|
|||||||
isIndeterminate,
|
isIndeterminate,
|
||||||
disableAnimation,
|
disableAnimation,
|
||||||
className: slots.icon({class: classNames?.icon}),
|
className: slots.icon({class: classNames?.icon}),
|
||||||
} as CheckboxIconProps),
|
}) as CheckboxIconProps,
|
||||||
[slots, classNames?.icon, isSelected, isIndeterminate, disableAnimation],
|
[slots, classNames?.icon, isSelected, isIndeterminate, disableAnimation],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -254,7 +254,7 @@ export const WithReactHookForm = {
|
|||||||
export const CustomIconFunction = {
|
export const CustomIconFunction = {
|
||||||
args: {
|
args: {
|
||||||
...defaultProps,
|
...defaultProps,
|
||||||
// eslint-disable-next-line react/display-name
|
|
||||||
icon: (props: CheckboxIconProps) => <CloseIcon {...props} />,
|
icon: (props: CheckboxIconProps) => <CloseIcon {...props} />,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -60,7 +60,6 @@ const ErrorMessageFunctionTemplate = (args) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const onSubmit = (data: any) => {
|
const onSubmit = (data: any) => {
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
alert("Submitted value: " + JSON.stringify(data));
|
alert("Submitted value: " + JSON.stringify(data));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable jsx-a11y/anchor-is-valid */
|
|
||||||
/* eslint-disable jsx-a11y/no-autofocus */
|
/* eslint-disable jsx-a11y/no-autofocus */
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {Meta} from "@storybook/react";
|
import {Meta} from "@storybook/react";
|
||||||
|
|||||||
@ -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 type {ValidationResult} from "@react-types/shared";
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|||||||
@ -94,8 +94,8 @@ describe("Pagination", () => {
|
|||||||
this.thresholds = Array.isArray(this.options?.threshold)
|
this.thresholds = Array.isArray(this.options?.threshold)
|
||||||
? this.options.threshold
|
? this.options.threshold
|
||||||
: this.options?.threshold != null
|
: this.options?.threshold != null
|
||||||
? [this.options.threshold]
|
? [this.options.threshold]
|
||||||
: [0];
|
: [0];
|
||||||
this.disconnect = jest.fn();
|
this.disconnect = jest.fn();
|
||||||
this.observe = jest.fn();
|
this.observe = jest.fn();
|
||||||
this.unobserve = jest.fn();
|
this.unobserve = jest.fn();
|
||||||
|
|||||||
@ -123,8 +123,8 @@ const Pagination = forwardRef<"nav", PaginationProps>((props, ref) => {
|
|||||||
? activePage - dotsJump
|
? activePage - dotsJump
|
||||||
: 1
|
: 1
|
||||||
: activePage + dotsJump <= total
|
: activePage + dotsJump <= total
|
||||||
? activePage + dotsJump
|
? activePage + dotsJump
|
||||||
: total;
|
: total;
|
||||||
}
|
}
|
||||||
|
|
||||||
const itemChildren: Record<PaginationItemType, React.ReactNode> = {
|
const itemChildren: Record<PaginationItemType, React.ReactNode> = {
|
||||||
|
|||||||
@ -104,7 +104,7 @@ export function useHiddenSelect<T>(
|
|||||||
value:
|
value:
|
||||||
selectionMode === "multiple"
|
selectionMode === "multiple"
|
||||||
? [...state.selectedKeys].map((k) => String(k))
|
? [...state.selectedKeys].map((k) => String(k))
|
||||||
: [...state.selectedKeys][0] ?? "",
|
: ([...state.selectedKeys][0] ?? ""),
|
||||||
multiple: selectionMode === "multiple",
|
multiple: selectionMode === "multiple",
|
||||||
onChange: (e: React.ChangeEvent<HTMLSelectElement>) => {
|
onChange: (e: React.ChangeEvent<HTMLSelectElement>) => {
|
||||||
state.setSelectedKeys(e.target.value);
|
state.setSelectedKeys(e.target.value);
|
||||||
|
|||||||
@ -495,7 +495,7 @@ export function useSelect<T extends object>(originalProps: UseSelectProps<T>) {
|
|||||||
form: originalProps?.form,
|
form: originalProps?.form,
|
||||||
onChange,
|
onChange,
|
||||||
...props,
|
...props,
|
||||||
} as HiddenSelectProps<T>),
|
}) as HiddenSelectProps<T>,
|
||||||
[
|
[
|
||||||
state,
|
state,
|
||||||
selectionMode,
|
selectionMode,
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable react/display-name */
|
|
||||||
import type {ValidationResult} from "@react-types/shared";
|
import type {ValidationResult} from "@react-types/shared";
|
||||||
|
|
||||||
import React, {ChangeEvent} from "react";
|
import React, {ChangeEvent} from "react";
|
||||||
|
|||||||
@ -252,8 +252,8 @@ export function useSlider(originalProps: UseSliderProps) {
|
|||||||
state.values.length > 1
|
state.values.length > 1
|
||||||
? state.getThumbPercent(0)
|
? state.getThumbPercent(0)
|
||||||
: fillOffset !== undefined
|
: fillOffset !== undefined
|
||||||
? state.getValuePercent(fillOffset)
|
? state.getValuePercent(fillOffset)
|
||||||
: 0,
|
: 0,
|
||||||
state.getThumbPercent(state.values.length - 1),
|
state.getThumbPercent(state.values.length - 1),
|
||||||
].sort();
|
].sort();
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable jsx-a11y/label-has-associated-control */
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {Meta} from "@storybook/react";
|
import {Meta} from "@storybook/react";
|
||||||
import {slider} from "@heroui/theme";
|
import {slider} from "@heroui/theme";
|
||||||
|
|||||||
@ -242,7 +242,7 @@ export function useSnippet(originalProps: UseSnippetProps) {
|
|||||||
className: slots.copyButton({
|
className: slots.copyButton({
|
||||||
class: clsx(classNames?.copyButton),
|
class: clsx(classNames?.copyButton),
|
||||||
}),
|
}),
|
||||||
} as ButtonProps),
|
}) as ButtonProps,
|
||||||
[
|
[
|
||||||
slots,
|
slots,
|
||||||
isFocusVisible,
|
isFocusVisible,
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable react/display-name */
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {Meta} from "@storybook/react";
|
import {Meta} from "@storybook/react";
|
||||||
import {toggle} from "@heroui/theme";
|
import {toggle} from "@heroui/theme";
|
||||||
|
|||||||
@ -54,7 +54,7 @@ const Tooltip = forwardRef<"div", TooltipProps>((props, ref) => {
|
|||||||
|
|
||||||
trigger = cloneElement(child, getTriggerProps(child.props, childRef));
|
trigger = cloneElement(child, getTriggerProps(child.props, childRef));
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch {
|
||||||
trigger = <span />;
|
trigger = <span />;
|
||||||
warn("Tooltip must have only one child node. Please, check your code.");
|
warn("Tooltip must have only one child node. Please, check your code.");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,11 +27,11 @@ type SuggestedVariants<CP, S> = {
|
|||||||
[K in keyof CP]?: ValidateSubtype<CP[K], string> extends "true"
|
[K in keyof CP]?: ValidateSubtype<CP[K], string> extends "true"
|
||||||
? {[K2 in CP[K]]?: GetSuggestedValues<S>}
|
? {[K2 in CP[K]]?: GetSuggestedValues<S>}
|
||||||
: ValidateSubtype<CP[K], boolean> extends "true"
|
: ValidateSubtype<CP[K], boolean> extends "true"
|
||||||
? {
|
? {
|
||||||
true?: GetSuggestedValues<S>;
|
true?: GetSuggestedValues<S>;
|
||||||
false?: GetSuggestedValues<S>;
|
false?: GetSuggestedValues<S>;
|
||||||
}
|
}
|
||||||
: never;
|
: never;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ComposeVariants<CP, S> = SuggestedVariants<CP, S> | Variants<S>;
|
type ComposeVariants<CP, S> = SuggestedVariants<CP, S> | Variants<S>;
|
||||||
|
|||||||
@ -22,6 +22,5 @@ export function useCallbackRef<T extends (...args: any[]) => any>(
|
|||||||
ref.current = fn;
|
ref.current = fn;
|
||||||
});
|
});
|
||||||
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
return useCallback(((...args) => ref.current?.(...args)) as T, deps);
|
return useCallback(((...args) => ref.current?.(...args)) as T, deps);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -93,18 +93,7 @@ export function useIntersectionObserver({
|
|||||||
return () => {
|
return () => {
|
||||||
observer.disconnect();
|
observer.disconnect();
|
||||||
};
|
};
|
||||||
|
}, [ref, isEnabled, JSON.stringify(threshold), root, rootMargin, frozen, freezeOnceVisible]);
|
||||||
// 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,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// ensures that if the observed element changes, the intersection observer is reinitialized
|
// ensures that if the observed element changes, the intersection observer is reinitialized
|
||||||
const prevRef = useRef<Element | null>(null);
|
const prevRef = useRef<Element | null>(null);
|
||||||
|
|||||||
@ -16,7 +16,6 @@ export const useUpdateEffect: typeof useEffect = (effect, deps) => {
|
|||||||
return effect();
|
return effect();
|
||||||
}
|
}
|
||||||
effectCycleRef.current = true;
|
effectCycleRef.current = true;
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, deps);
|
}, deps);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@ -8,8 +8,8 @@ export const getCSSStyleVal = (str: string, parentNum: number) => {
|
|||||||
const strVal = str.includes("px")
|
const strVal = str.includes("px")
|
||||||
? +str.split("px")[0]
|
? +str.split("px")[0]
|
||||||
: str.includes("%")
|
: str.includes("%")
|
||||||
? +str.split("%")[0] * parentNum * 0.01
|
? +str.split("%")[0] * parentNum * 0.01
|
||||||
: str;
|
: str;
|
||||||
|
|
||||||
return Number.isNaN(+strVal) ? 0 : +strVal;
|
return Number.isNaN(+strVal) ? 0 : +strVal;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -21,7 +21,7 @@ export function assignRef<T = any>(ref: ReactRef<T> | undefined, value: T) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
(ref as MutableRefObject<T>).current = value;
|
(ref as MutableRefObject<T>).current = value;
|
||||||
} catch (error) {
|
} catch {
|
||||||
throw new Error(`Cannot assign value '${value}' to ref '${ref}'`);
|
throw new Error(`Cannot assign value '${value}' to ref '${ref}'`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ const fs = require('fs')
|
|||||||
function tryRequirePkg(pkg) {
|
function tryRequirePkg(pkg) {
|
||||||
try {
|
try {
|
||||||
return require(pkg);
|
return require(pkg);
|
||||||
} catch (e) {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
/* eslint-disable no-shadow-restricted-names */
|
|
||||||
/* eslint-disable no-plusplus */
|
|
||||||
function toVal(mix: any) {
|
function toVal(mix: any) {
|
||||||
var k,
|
var k,
|
||||||
y,
|
y,
|
||||||
|
|||||||
@ -153,7 +153,7 @@ export function objectToDeps(obj: Extractable) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return JSON.stringify(obj);
|
return JSON.stringify(obj);
|
||||||
} catch (e) {
|
} catch {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ export function isHTMLElement(el: any): el is HTMLElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getOwnerDocument(node?: Element | null): Document {
|
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) {
|
export function getActiveElement(node?: HTMLElement) {
|
||||||
|
|||||||
@ -75,8 +75,8 @@ export async function drag(
|
|||||||
y: from.y + delta.y,
|
y: from.y + delta.y,
|
||||||
}
|
}
|
||||||
: inTo
|
: inTo
|
||||||
? getCoords(inTo)
|
? getCoords(inTo)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
if (to === null) throw new Error("You must provide either `delta` or `to`");
|
if (to === null) throw new Error("You must provide either `delta` or `to`");
|
||||||
|
|
||||||
|
|||||||
3571
pnpm-lock.yaml
generated
3571
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user