chore: test new lintstaged rules (#1050)

This commit is contained in:
Tianen Pang 2023-02-18 09:38:14 +08:00 committed by GitHub
parent a6d8b976c8
commit de1556ef04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 87 additions and 56 deletions

View File

@ -11,7 +11,7 @@
"plugin:react-hooks/recommended", "plugin:react-hooks/recommended",
"plugin:jsx-a11y/recommended" "plugin:jsx-a11y/recommended"
], ],
"plugins": ["react", "prettier", "import", "@typescript-eslint", "jsx-a11y"], "plugins": ["react", "unused-imports", "import", "@typescript-eslint", "jsx-a11y", "prettier"],
"parser": "@typescript-eslint/parser", "parser": "@typescript-eslint/parser",
"parserOptions": { "parserOptions": {
"ecmaFeatures": { "ecmaFeatures": {
@ -34,6 +34,9 @@
"jsx-a11y/click-events-have-key-events": "warn", "jsx-a11y/click-events-have-key-events": "warn",
"jsx-a11y/interactive-supports-focus": "warn", "jsx-a11y/interactive-supports-focus": "warn",
"prettier/prettier": "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": [ "@typescript-eslint/no-unused-vars": [
"warn", "warn",
{ {

View File

@ -13,16 +13,14 @@ const removeIgnoredFiles = async (files) => {
}; };
module.exports = { module.exports = {
// *.!(js|ts|jsx|tsx|d.ts) "**/*.{cjs,mjs,js,ts,jsx,tsx}": async (files) => {
"./packages/**/**/*.{js,cjs,mjs,ts,jsx,tsx,json,md}": async (files) => { const filesToLint = await removeIgnoredFiles(files);
return [`eslint -c .eslintrc.json --max-warnings=0 --fix ${filesToLint}`];
},
"**/*.{css,json,md}": async (files) => {
const filesToLint = await removeIgnoredFiles(files); const filesToLint = await removeIgnoredFiles(files);
return [`prettier --config .prettierrc.json --ignore-path --write ${filesToLint}`]; return [`prettier --config .prettierrc.json --ignore-path --write ${filesToLint}`];
}, },
// TODO: fix linter rules
// "./packages/**/**/*.{js,cjs,mjs,ts,jsx,tsx}": async (files) => {
// const filesToLint = await removeIgnoredFiles(files);
// return [`eslint -c .eslintrc.json --max-warnings=0 --fix ${filesToLint}`];
// },
}; };

View File

@ -1,35 +1,31 @@
{ {
"extends": ["../../.eslintrc.json"], "extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"], "ignorePatterns": ["!**/*"],
"overrides": [ "overrides": [
{ {
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"parserOptions": { "parserOptions": {
"project": ["apps/docs/tsconfig(.*)?.json"], "project": ["apps/docs/tsconfig(.*)?.json"],
"ecmaFeatures": { "ecmaFeatures": {
"jsx": true "jsx": true
}
},
"rules": {
"react/no-unknown-property": [
2,
{
"ignore": [
"jsx",
"global"
]
}
]
} }
}, },
{ "rules": {
"files": ["*.ts", "*.tsx"], "react/no-unknown-property": [
"rules": {} 2,
}, {
{ "ignore": ["jsx", "global"]
"files": ["*.js", "*.jsx"], }
"rules": {} ]
} }
] },
} {
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}

View File

@ -97,6 +97,7 @@
"eslint-plugin-promise": "^6.0.0", "eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react": "^7.23.2", "eslint-plugin-react": "^7.23.2",
"eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-unused-imports": "^2.0.0",
"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",

View File

@ -2,8 +2,8 @@ import {forwardRef} from "@nextui-org/system";
import {__DEV__} from "@nextui-org/shared-utils"; import {__DEV__} from "@nextui-org/shared-utils";
import {useMemo} from "react"; import {useMemo} from "react";
import {useAvatar, UseAvatarProps} from "./use-avatar";
import {AvatarIcon} from "./avatar-icon"; import {AvatarIcon} from "./avatar-icon";
import {useAvatar, UseAvatarProps} from "./use-avatar";
export interface AvatarProps extends UseAvatarProps {} export interface AvatarProps extends UseAvatarProps {}

View File

@ -2,7 +2,7 @@ import * as React from "react";
import {render} from "@testing-library/react"; import {render} from "@testing-library/react";
import userEvent from "@testing-library/user-event"; import userEvent from "@testing-library/user-event";
import {Checkbox, CheckboxProps} from "../src"; import {Checkbox} from "../src";
describe("Checkbox", () => { describe("Checkbox", () => {
it("should render correctly", () => { it("should render correctly", () => {

61
pnpm-lock.yaml generated
View File

@ -62,6 +62,7 @@ importers:
eslint-plugin-promise: ^6.0.0 eslint-plugin-promise: ^6.0.0
eslint-plugin-react: ^7.23.2 eslint-plugin-react: ^7.23.2
eslint-plugin-react-hooks: ^4.6.0 eslint-plugin-react-hooks: ^4.6.0
eslint-plugin-unused-imports: ^2.0.0
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
@ -149,6 +150,7 @@ importers:
eslint-plugin-promise: 6.1.1_eslint@7.32.0 eslint-plugin-promise: 6.1.1_eslint@7.32.0
eslint-plugin-react: 7.32.2_eslint@7.32.0 eslint-plugin-react: 7.32.2_eslint@7.32.0
eslint-plugin-react-hooks: 4.6.0_eslint@7.32.0 eslint-plugin-react-hooks: 4.6.0_eslint@7.32.0
eslint-plugin-unused-imports: 2.0.0_ysufuzzt3cjmp72q35wizjhorm
execa: 5.1.1 execa: 5.1.1
find-up: 6.3.0 find-up: 6.3.0
fs-extra: 10.1.0 fs-extra: 10.1.0
@ -5279,7 +5281,7 @@ packages:
react-refresh: 0.11.0 react-refresh: 0.11.0
schema-utils: 3.1.1 schema-utils: 3.1.1
source-map: 0.7.4 source-map: 0.7.4
webpack: 5.75.0 webpack: 5.75.0_igc2o5duttbeim43y2d2sdpxx4
dev: true dev: true
/@polka/url/1.0.0-next.21: /@polka/url/1.0.0-next.21:
@ -10362,7 +10364,7 @@ packages:
loader-utils: 2.0.4 loader-utils: 2.0.4
make-dir: 3.1.0 make-dir: 3.1.0
schema-utils: 2.7.1 schema-utils: 2.7.1
webpack: 4.46.0 webpack: 4.46.0_webpack-cli@3.3.12
dev: true dev: true
/babel-plugin-add-module-exports/1.0.4: /babel-plugin-add-module-exports/1.0.4:
@ -10950,7 +10952,7 @@ packages:
mississippi: 3.0.0 mississippi: 3.0.0
mkdirp: 0.5.6 mkdirp: 0.5.6
move-concurrently: 1.0.1 move-concurrently: 1.0.1
promise-inflight: 1.0.1 promise-inflight: 1.0.1_bluebird@3.7.2
rimraf: 2.7.1 rimraf: 2.7.1
ssri: 6.0.2 ssri: 6.0.2
unique-filename: 1.1.1 unique-filename: 1.1.1
@ -11957,7 +11959,7 @@ packages:
postcss-value-parser: 4.2.0 postcss-value-parser: 4.2.0
schema-utils: 2.7.1 schema-utils: 2.7.1
semver: 6.3.0 semver: 6.3.0
webpack: 4.46.0 webpack: 4.46.0_webpack-cli@3.3.12
dev: true dev: true
/css-loader/5.2.7_webpack@5.75.0: /css-loader/5.2.7_webpack@5.75.0:
@ -13583,6 +13585,26 @@ packages:
string.prototype.matchall: 4.0.8 string.prototype.matchall: 4.0.8
dev: true dev: true
/eslint-plugin-unused-imports/2.0.0_ysufuzzt3cjmp72q35wizjhorm:
resolution: {integrity: sha512-3APeS/tQlTrFa167ThtP0Zm0vctjr4M44HMpeg1P4bK6wItarumq0Ma82xorMKdFsWpphQBlRPzw/pxiVELX1A==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
'@typescript-eslint/eslint-plugin': ^5.0.0
eslint: ^8.0.0
peerDependenciesMeta:
'@typescript-eslint/eslint-plugin':
optional: true
dependencies:
'@typescript-eslint/eslint-plugin': 5.51.0_r6r774cmu5uauzi735irvz3uwm
eslint: 7.32.0
eslint-rule-composer: 0.3.0
dev: true
/eslint-rule-composer/0.3.0:
resolution: {integrity: sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg==}
engines: {node: '>=4.0.0'}
dev: true
/eslint-scope/3.7.3: /eslint-scope/3.7.3:
resolution: {integrity: sha512-W+B0SvF4gamyCTmUc+uITPY0989iXVfKvhwtmJocTaYoc/3khEHmEmvfY/Gn9HA9VV75jrQECsHizkNw1b68FA==} resolution: {integrity: sha512-W+B0SvF4gamyCTmUc+uITPY0989iXVfKvhwtmJocTaYoc/3khEHmEmvfY/Gn9HA9VV75jrQECsHizkNw1b68FA==}
engines: {node: '>=4.0.0'} engines: {node: '>=4.0.0'}
@ -14160,7 +14182,7 @@ packages:
dependencies: dependencies:
loader-utils: 2.0.4 loader-utils: 2.0.4
schema-utils: 3.1.1 schema-utils: 3.1.1
webpack: 4.46.0 webpack: 4.46.0_webpack-cli@3.3.12
dev: true dev: true
/file-system-cache/1.1.0: /file-system-cache/1.1.0:
@ -15379,7 +15401,7 @@ packages:
pretty-error: 2.1.2 pretty-error: 2.1.2
tapable: 1.1.3 tapable: 1.1.3
util.promisify: 1.0.0 util.promisify: 1.0.0
webpack: 4.46.0 webpack: 4.46.0_webpack-cli@3.3.12
dev: true dev: true
/html-webpack-plugin/5.5.0_webpack@5.75.0: /html-webpack-plugin/5.5.0_webpack@5.75.0:
@ -19448,7 +19470,7 @@ packages:
postcss: 7.0.39 postcss: 7.0.39
schema-utils: 3.1.1 schema-utils: 3.1.1
semver: 7.3.8 semver: 7.3.8
webpack: 4.46.0 webpack: 4.46.0_webpack-cli@3.3.12
dev: true dev: true
/postcss-loader/4.3.0_postcss@7.0.39: /postcss-loader/4.3.0_postcss@7.0.39:
@ -19825,6 +19847,17 @@ packages:
optional: true optional: true
dev: true dev: true
/promise-inflight/1.0.1_bluebird@3.7.2:
resolution: {integrity: sha512-6zWPyEOFaQBJYcGMHBKTKJ3u6TBsnMFOIZSa6ce1e/ZrrsOlnHRHbabMjLiBYKp+n44X9eUI6VUPaukCXHuG4g==}
peerDependencies:
bluebird: '*'
peerDependenciesMeta:
bluebird:
optional: true
dependencies:
bluebird: 3.7.2
dev: true
/promise.allsettled/1.0.6: /promise.allsettled/1.0.6:
resolution: {integrity: sha512-22wJUOD3zswWFqgwjNHa1965LvqTX87WPu/lreY2KSd7SVcERfuZ4GfUaOnJNnvtoIv2yXT/W00YIGMetXtFXg==} resolution: {integrity: sha512-22wJUOD3zswWFqgwjNHa1965LvqTX87WPu/lreY2KSd7SVcERfuZ4GfUaOnJNnvtoIv2yXT/W00YIGMetXtFXg==}
engines: {node: '>= 0.4'} engines: {node: '>= 0.4'}
@ -20026,7 +20059,7 @@ packages:
dependencies: dependencies:
loader-utils: 2.0.4 loader-utils: 2.0.4
schema-utils: 3.1.1 schema-utils: 3.1.1
webpack: 4.46.0 webpack: 4.46.0_webpack-cli@3.3.12
dev: true dev: true
/react-autosuggest/10.1.0_react@17.0.2: /react-autosuggest/10.1.0_react@17.0.2:
@ -21887,7 +21920,7 @@ packages:
dependencies: dependencies:
loader-utils: 2.0.4 loader-utils: 2.0.4
schema-utils: 2.7.1 schema-utils: 2.7.1
webpack: 4.46.0 webpack: 4.46.0_webpack-cli@3.3.12
dev: true dev: true
/style-loader/2.0.0_webpack@5.75.0: /style-loader/2.0.0_webpack@5.75.0:
@ -22216,7 +22249,7 @@ packages:
serialize-javascript: 4.0.0 serialize-javascript: 4.0.0
source-map: 0.6.1 source-map: 0.6.1
terser: 4.8.1 terser: 4.8.1
webpack: 4.46.0 webpack: 4.46.0_webpack-cli@3.3.12
webpack-sources: 1.4.3 webpack-sources: 1.4.3
worker-farm: 1.7.0 worker-farm: 1.7.0
dev: true dev: true
@ -22235,7 +22268,7 @@ packages:
serialize-javascript: 5.0.1 serialize-javascript: 5.0.1
source-map: 0.6.1 source-map: 0.6.1
terser: 5.16.3 terser: 5.16.3
webpack: 4.46.0 webpack: 4.46.0_webpack-cli@3.3.12
webpack-sources: 1.4.3 webpack-sources: 1.4.3
transitivePeerDependencies: transitivePeerDependencies:
- bluebird - bluebird
@ -23063,7 +23096,7 @@ packages:
loader-utils: 2.0.4 loader-utils: 2.0.4
mime-types: 2.1.35 mime-types: 2.1.35
schema-utils: 3.1.1 schema-utils: 3.1.1
webpack: 4.46.0 webpack: 4.46.0_webpack-cli@3.3.12
dev: true dev: true
/url-parse/1.5.10: /url-parse/1.5.10:
@ -23409,7 +23442,7 @@ packages:
mime: 2.6.0 mime: 2.6.0
mkdirp: 0.5.6 mkdirp: 0.5.6
range-parser: 1.2.1 range-parser: 1.2.1
webpack: 4.46.0 webpack: 4.46.0_webpack-cli@3.3.12
webpack-log: 2.0.0 webpack-log: 2.0.0
dev: true dev: true
@ -23434,7 +23467,7 @@ packages:
peerDependencies: peerDependencies:
webpack: ^2.0.0 || ^3.0.0 || ^4.0.0 webpack: ^2.0.0 || ^3.0.0 || ^4.0.0
dependencies: dependencies:
webpack: 4.46.0 webpack: 4.46.0_webpack-cli@3.3.12
dev: true dev: true
/webpack-hot-middleware/2.25.3: /webpack-hot-middleware/2.25.3: