Update
This commit is contained in:
parent
1e6d679af3
commit
2853da4344
@ -4,8 +4,8 @@ Personal ESLint config. Guaranteed to have no useless polyfills.
|
|||||||
|
|
||||||
## flat config support
|
## flat config support
|
||||||
|
|
||||||
- ⏱️ [a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/pull/891)
|
- ⏱️ [a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/pull/993)
|
||||||
- ✅ [react](https://github.com/jsx-eslint/eslint-plugin-react/pull/3429)
|
- ✅ [react](https://github.com/jsx-eslint/eslint-plugin-react/pull/3429)
|
||||||
- ✅ [unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn/pull/1886)
|
- ✅ [unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn/pull/1886)
|
||||||
- ❌ [import](https://github.com/import-js/eslint-plugin-import/issues/2556)
|
- ❌ [import](https://github.com/un-ts/eslint-plugin-import-x/issues/29)
|
||||||
- ❌ [jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/issues/978)
|
- ❌ [jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/issues/978)
|
||||||
|
9
dist/index.d.ts
vendored
9
dist/index.d.ts
vendored
@ -48,11 +48,15 @@ export type InputConfig = Omit<ESLintConfig, "rules"> & {
|
|||||||
* this is statically analyzed.
|
* this is statically analyzed.
|
||||||
*/
|
*/
|
||||||
customRuleFiles?: string | string[];
|
customRuleFiles?: string | string[];
|
||||||
|
/**
|
||||||
|
* Automatically detect project types, dependencies and deduct the plugins.
|
||||||
|
*/
|
||||||
|
auto?: boolean;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Returns a ESLint config object.
|
* Returns a ESLint config object.
|
||||||
*
|
*
|
||||||
* By default, it includes `["@typescript-eslint", "import", "prettier"]` configs.
|
* By default, it includes `["@typescript-eslint", "import-x", "prettier", "unicorn"]` configs.
|
||||||
* Additional bundled plugins include:
|
* Additional bundled plugins include:
|
||||||
*
|
*
|
||||||
* 1. [`react`](https://github.com/jsx-eslint/eslint-plugin-react#list-of-supported-rules)
|
* 1. [`react`](https://github.com/jsx-eslint/eslint-plugin-react#list-of-supported-rules)
|
||||||
@ -61,7 +65,8 @@ export type InputConfig = Omit<ESLintConfig, "rules"> & {
|
|||||||
* 2. [`react-refresh`](https://github.com/ArnaudBarre/eslint-plugin-react-refresh)
|
* 2. [`react-refresh`](https://github.com/ArnaudBarre/eslint-plugin-react-refresh)
|
||||||
* 3. [`jsx-a11y`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#supported-rules)
|
* 3. [`jsx-a11y`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#supported-rules)
|
||||||
* 4. [`unicorn`](https://github.com/sindresorhus/eslint-plugin-unicorn#rules)
|
* 4. [`unicorn`](https://github.com/sindresorhus/eslint-plugin-unicorn#rules)
|
||||||
* 5. [`n`](https://github.com/eslint-community/eslint-plugin-n#-rules) (Node.js specific)
|
* 5. [`n`](https://github.com/eslint-community/eslint-plugin-n#-rules) (Node.js specific,
|
||||||
|
* requires `minimatch`)
|
||||||
* 6. [`jsdoc`](https://github.com/gajus/eslint-plugin-jsdoc#rules)
|
* 6. [`jsdoc`](https://github.com/gajus/eslint-plugin-jsdoc#rules)
|
||||||
*
|
*
|
||||||
* Non bundled:
|
* Non bundled:
|
||||||
|
44
dist/package.json
vendored
44
dist/package.json
vendored
@ -1,48 +1,50 @@
|
|||||||
{
|
{
|
||||||
"name": "@aet/eslint-rules",
|
"name": "@aet/eslint-rules",
|
||||||
"version": "0.0.32",
|
"version": "1.0.1-beta.10",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"typescript": "^5.4.4"
|
"typescript": "^5.4.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aet/eslint-define-config": "0.1.0-beta.1",
|
"@nolyfill/is-core-module": "^1.0.39",
|
||||||
|
"@aet/eslint-define-config": "0.1.0-beta.10",
|
||||||
"@eslint-community/eslint-utils": "^4.4.0",
|
"@eslint-community/eslint-utils": "^4.4.0",
|
||||||
"@types/eslint": "^8.56.10",
|
"@tanstack/eslint-plugin-query": "^5.51.15",
|
||||||
"@typescript-eslint/eslint-plugin": "^7.14.1",
|
"@types/eslint": "^8.56.11",
|
||||||
"@typescript-eslint/parser": "^7.14.1",
|
"@typescript-eslint/eslint-plugin": "^7.17.0",
|
||||||
"@typescript-eslint/type-utils": "^7.14.1",
|
"@typescript-eslint/parser": "^7.17.0",
|
||||||
"@typescript-eslint/utils": "^7.14.1",
|
"@typescript-eslint/type-utils": "^7.17.0",
|
||||||
|
"@typescript-eslint/utils": "^7.17.0",
|
||||||
|
"@eslint-react/eslint-plugin": "^1.6.0",
|
||||||
"aria-query": "^5.3.0",
|
"aria-query": "^5.3.0",
|
||||||
"axe-core": "^4.9.1",
|
"axe-core": "^4.9.1",
|
||||||
"axobject-query": "^4.0.0",
|
"axobject-query": "4.1.0",
|
||||||
"damerau-levenshtein": "1.0.8",
|
"damerau-levenshtein": "1.0.8",
|
||||||
"debug": "^4.3.5",
|
"debug": "^4.3.6",
|
||||||
"doctrine": "^3.0.0",
|
"doctrine": "^3.0.0",
|
||||||
"emoji-regex": "^10.3.0",
|
"emoji-regex": "^10.3.0",
|
||||||
"enhanced-resolve": "^5.17.0",
|
"enhanced-resolve": "^5.17.1",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-import-resolver-node": "^0.3.9",
|
"eslint-import-resolver-node": "^0.3.9",
|
||||||
"eslint-module-utils": "^2.8.1",
|
"eslint-module-utils": "^2.8.1",
|
||||||
"eslint-plugin-es-x": "^7.7.0",
|
"eslint-plugin-es-x": "^8.0.0",
|
||||||
"eslint-plugin-import-x": "^0.5.2",
|
"eslint-plugin-import-x": "^3.1.0",
|
||||||
"eslint-plugin-jsdoc": "^48.5.0",
|
"eslint-plugin-jsdoc": "^48.8.3",
|
||||||
"eslint-plugin-unicorn": "^54.0.0",
|
"eslint-plugin-react-refresh": "^0.4.9",
|
||||||
|
"eslint-plugin-unicorn": "^55.0.0",
|
||||||
"esprima": "^4.0.1",
|
"esprima": "^4.0.1",
|
||||||
"esquery": "^1.5.0",
|
"esquery": "^1.6.0",
|
||||||
"estraverse": "^5.3.0",
|
"estraverse": "^5.3.0",
|
||||||
"fast-glob": "^3.3.2",
|
"fast-glob": "^3.3.2",
|
||||||
"get-tsconfig": "^4.7.5",
|
"get-tsconfig": "^4.7.6",
|
||||||
|
"is-bun-module": "^1.0.2",
|
||||||
"ignore": "^5.3.1",
|
"ignore": "^5.3.1",
|
||||||
"is-builtin-module": "^4.0.0",
|
|
||||||
"is-glob": "^4.0.3",
|
"is-glob": "^4.0.3",
|
||||||
"language-tags": "^1.0.9",
|
"language-tags": "^1.0.9",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"minimatch": "^9.0.5",
|
|
||||||
"resolve": "^2.0.0-next.5",
|
"resolve": "^2.0.0-next.5",
|
||||||
"semver": "^7.6.2",
|
"semver": "^7.6.3"
|
||||||
"tsconfig-paths": "^4.2.0"
|
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"is-core-module": "file:./overrides/is-core-module",
|
"is-core-module": "file:./overrides/is-core-module",
|
||||||
@ -58,4 +60,4 @@
|
|||||||
"supports-preserve-symlinks-flag": "file:./overrides/supports-preserve-symlinks-flag"
|
"supports-preserve-symlinks-flag": "file:./overrides/supports-preserve-symlinks-flag"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1130
dist/yarn.lock
vendored
1130
dist/yarn.lock
vendored
File diff suppressed because it is too large
Load Diff
60
package.json
60
package.json
@ -2,48 +2,48 @@
|
|||||||
"name": "@aet/eslint-configs",
|
"name": "@aet/eslint-configs",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "./scripts/build.ts",
|
"build": "./scripts/build.ts",
|
||||||
"check-import": "./scripts/check-imports.ts"
|
"check-import": "./scripts/check-imports.ts",
|
||||||
|
"define": "/usr/local/bin/codium ./packages/eslint-define-config"
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@aet/eslint-define-config": "0.1.0-beta.1",
|
"@aet/eslint-define-config": "^0.1.0-beta.10",
|
||||||
"@babel/core": "^7.24.7",
|
"@babel/core": "^7.24.9",
|
||||||
"@babel/plugin-transform-flow-strip-types": "^7.24.7",
|
"@babel/plugin-transform-flow-strip-types": "^7.24.7",
|
||||||
"@babel/preset-env": "^7.24.7",
|
"@babel/preset-env": "^7.25.0",
|
||||||
"@types/babel-plugin-macros": "^3.1.3",
|
"@types/babel-plugin-macros": "^3.1.3",
|
||||||
"@types/babel__core": "^7.20.5",
|
"@types/babel__core": "^7.20.5",
|
||||||
"@types/eslint": "^8.56.10",
|
"@types/eslint": "^9.6.0",
|
||||||
"@types/esprima": "^4.0.6",
|
"@types/esprima": "^4.0.6",
|
||||||
"@types/esquery": "^1.5.4",
|
"@types/esquery": "^1.5.4",
|
||||||
"@types/estree": "^1.0.5",
|
"@types/estree": "^1.0.5",
|
||||||
"@types/estree-jsx": "^1.0.5",
|
"@types/estree-jsx": "^1.0.5",
|
||||||
"@types/lodash": "^4.17.5",
|
"@types/lodash": "^4.17.7",
|
||||||
"@types/node": "^20.14.9",
|
"@types/node": "^20.14.12",
|
||||||
"@typescript-eslint/eslint-plugin": "7.14.1",
|
"@typescript-eslint/eslint-plugin": "7.17.0",
|
||||||
"@typescript-eslint/type-utils": "^7.14.1",
|
"@typescript-eslint/type-utils": "^7.17.0",
|
||||||
"@typescript-eslint/types": "^7.14.1",
|
"@typescript-eslint/types": "^7.17.0",
|
||||||
"@typescript-eslint/typescript-estree": "^7.14.1",
|
"@typescript-eslint/typescript-estree": "^7.17.0",
|
||||||
"@typescript-eslint/utils": "^7.14.1",
|
"@typescript-eslint/utils": "^7.17.0",
|
||||||
"babel-plugin-macros": "^3.1.0",
|
"babel-plugin-macros": "^3.1.0",
|
||||||
"dts-bundle-generator": "9.4.0",
|
"dts-bundle-generator": "9.4.0",
|
||||||
"esbin": "0.0.4",
|
"esbuild": "0.23.0",
|
||||||
"esbuild": "0.21.5",
|
|
||||||
"esbuild-plugin-alias": "^0.2.1",
|
"esbuild-plugin-alias": "^0.2.1",
|
||||||
"eslint": "8.57.0",
|
"eslint": "8.57.0",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-plugin-import-x": "^0.5.2",
|
"eslint-plugin-import-x": "^3.1.0",
|
||||||
"esprima": "^4.0.1",
|
"esprima": "^4.0.1",
|
||||||
"esquery": "^1.5.0",
|
"esquery": "^1.6.0",
|
||||||
"fast-glob": "^3.3.2",
|
"fast-glob": "^3.3.2",
|
||||||
"find-cache-dir": "^5.0.0",
|
"find-cache-dir": "^5.0.0",
|
||||||
"json-schema-to-ts": "^3.1.0",
|
"json-schema-to-ts": "^3.1.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"minimatch": "^9.0.5",
|
"nolyfill": "^1.0.39",
|
||||||
"patch-package": "^8.0.0",
|
"patch-package": "^8.0.0",
|
||||||
"picocolors": "^1.0.1",
|
"picocolors": "^1.0.1",
|
||||||
"prettier": "^3.3.2",
|
"prettier": "^3.3.3",
|
||||||
"prop-types": "^15.8.1",
|
"prop-types": "^15.8.1",
|
||||||
"typescript": "^5.5.2"
|
"typescript": "^5.5.4"
|
||||||
},
|
},
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"arrowParens": "avoid",
|
"arrowParens": "avoid",
|
||||||
@ -55,15 +55,17 @@
|
|||||||
},
|
},
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"function-bind": "npm:@nolyfill/function-bind@latest",
|
"function-bind": "npm:@nolyfill/function-bind@^1",
|
||||||
"has-proto": "npm:@nolyfill/has-proto@latest",
|
"has-proto": "npm:@nolyfill/has-proto@^1",
|
||||||
"has-symbols": "npm:@nolyfill/has-symbols@latest",
|
"has-symbols": "npm:@nolyfill/has-symbols@^1",
|
||||||
"hasown": "npm:@nolyfill/hasown@latest",
|
"hasown": "npm:@nolyfill/hasown@^1",
|
||||||
"isarray": "npm:@nolyfill/isarray@latest",
|
"isarray": "npm:@nolyfill/isarray@^1",
|
||||||
"jsonify": "npm:@nolyfill/jsonify@latest",
|
"jsonify": "npm:@nolyfill/jsonify@^1",
|
||||||
"object-keys": "npm:@nolyfill/object-keys@latest",
|
"object-keys": "npm:@nolyfill/object-keys@^1",
|
||||||
"set-function-length": "npm:@nolyfill/set-function-length@latest",
|
"set-function-length": "npm:@nolyfill/set-function-length@^1",
|
||||||
"@babel/types": "7.24.0"
|
"@babel/types": "7.24.0",
|
||||||
|
"is-core-module": "npm:@nolyfill/is-core-module@^1",
|
||||||
|
"json-stable-stringify": "npm:@nolyfill/json-stable-stringify@^1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1 +1 @@
|
|||||||
Subproject commit 7a02ac08b5aaac8c217f0e87142f97eafcc38fbc
|
Subproject commit c9b5626ee69bd529c7e391e40928a4fb28dce179
|
@ -1 +0,0 @@
|
|||||||
Subproject commit f77ceb679d59ced5d9a633123385470a9eea10d9
|
|
@ -1 +1 @@
|
|||||||
Subproject commit 0d5321a5457c5f0da0ca216053cc5b4f571b53ae
|
Subproject commit cca288b73a39fa0932a57c02a7a88de68fc971fc
|
@ -1 +1 @@
|
|||||||
Subproject commit eb11b5b35a6a797dc7fba6df53b1c4dada3a2a55
|
Subproject commit 5aad5f1c419b3143ffb9356bd299fc50dc576ee5
|
@ -1 +0,0 @@
|
|||||||
Subproject commit 4467db503e38b9356517cf6926d11be544ccf4b1
|
|
@ -1,28 +1,10 @@
|
|||||||
diff --git a/package.json b/package.json
|
|
||||||
index 8de1a68..a99b6f0 100644
|
|
||||||
--- a/package.json
|
|
||||||
+++ b/package.json
|
|
||||||
@@ -62,8 +62,7 @@
|
|
||||||
"typecov": "type-coverage"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
- "eslint": "*",
|
|
||||||
- "eslint-plugin-import": "*"
|
|
||||||
+ "eslint": "*"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"debug": "^4.3.5",
|
|
||||||
diff --git a/tsconfig.json b/tsconfig.json
|
diff --git a/tsconfig.json b/tsconfig.json
|
||||||
deleted file mode 100644
|
index 39c6900..6fd8822 100644
|
||||||
index a303861..0000000
|
|
||||||
--- a/tsconfig.json
|
--- a/tsconfig.json
|
||||||
+++ /dev/null
|
+++ b/tsconfig.json
|
||||||
@@ -1,8 +0,0 @@
|
@@ -1,5 +1,4 @@
|
||||||
-{
|
{
|
||||||
- "extends": "@1stg/tsconfig/node16",
|
- "extends": "@1stg/tsconfig/node16",
|
||||||
- "compilerOptions": {
|
"compilerOptions": {
|
||||||
- "module": "Node16",
|
"module": "Node16",
|
||||||
- "outDir": "./lib"
|
"outDir": "./lib",
|
||||||
- },
|
|
||||||
- "include": ["./src", "./shim.d.ts"]
|
|
||||||
-}
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
diff --git a/src/index.js b/src/index.js
|
diff --git a/src/index.js b/src/index.js
|
||||||
index 2fa185f..627af9b 100644
|
index 2fa185f..29d65d0 100644
|
||||||
--- a/src/index.js
|
--- a/src/index.js
|
||||||
+++ b/src/index.js
|
+++ b/src/index.js
|
||||||
@@ -1,48 +1,90 @@
|
@@ -1,48 +1,90 @@
|
||||||
@ -135,68 +135,7 @@ index 2fa185f..627af9b 100644
|
|||||||
};
|
};
|
||||||
|
|
||||||
const recommendedRules = {
|
const recommendedRules = {
|
||||||
@@ -60,15 +102,7 @@ const recommendedRules = {
|
@@ -299,10 +341,10 @@ const jsxA11y = {
|
||||||
'jsx-a11y/control-has-associated-label': [
|
|
||||||
'off',
|
|
||||||
{
|
|
||||||
- ignoreElements: [
|
|
||||||
- 'audio',
|
|
||||||
- 'canvas',
|
|
||||||
- 'embed',
|
|
||||||
- 'input',
|
|
||||||
- 'textarea',
|
|
||||||
- 'tr',
|
|
||||||
- 'video',
|
|
||||||
- ],
|
|
||||||
+ ignoreElements: ['audio', 'canvas', 'embed', 'input', 'textarea', 'tr', 'video'],
|
|
||||||
ignoreRoles: [
|
|
||||||
'grid',
|
|
||||||
'listbox',
|
|
||||||
@@ -139,24 +173,8 @@ const recommendedRules = {
|
|
||||||
'jsx-a11y/no-noninteractive-element-to-interactive-role': [
|
|
||||||
'error',
|
|
||||||
{
|
|
||||||
- ul: [
|
|
||||||
- 'listbox',
|
|
||||||
- 'menu',
|
|
||||||
- 'menubar',
|
|
||||||
- 'radiogroup',
|
|
||||||
- 'tablist',
|
|
||||||
- 'tree',
|
|
||||||
- 'treegrid',
|
|
||||||
- ],
|
|
||||||
- ol: [
|
|
||||||
- 'listbox',
|
|
||||||
- 'menu',
|
|
||||||
- 'menubar',
|
|
||||||
- 'radiogroup',
|
|
||||||
- 'tablist',
|
|
||||||
- 'tree',
|
|
||||||
- 'treegrid',
|
|
||||||
- ],
|
|
||||||
+ ul: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'],
|
|
||||||
+ ol: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'],
|
|
||||||
li: [
|
|
||||||
'menuitem',
|
|
||||||
'menuitemradio',
|
|
||||||
@@ -214,15 +232,7 @@ const strictRules = {
|
|
||||||
'jsx-a11y/control-has-associated-label': [
|
|
||||||
'off',
|
|
||||||
{
|
|
||||||
- ignoreElements: [
|
|
||||||
- 'audio',
|
|
||||||
- 'canvas',
|
|
||||||
- 'embed',
|
|
||||||
- 'input',
|
|
||||||
- 'textarea',
|
|
||||||
- 'tr',
|
|
||||||
- 'video',
|
|
||||||
- ],
|
|
||||||
+ ignoreElements: ['audio', 'canvas', 'embed', 'input', 'textarea', 'tr', 'video'],
|
|
||||||
ignoreRoles: [
|
|
||||||
'grid',
|
|
||||||
'listbox',
|
|
||||||
@@ -299,22 +309,22 @@ const jsxA11y = {
|
|
||||||
const createConfig = (rules, flatConfigName) => ({
|
const createConfig = (rules, flatConfigName) => ({
|
||||||
...(flatConfigName
|
...(flatConfigName
|
||||||
? {
|
? {
|
||||||
@ -211,21 +150,6 @@ index 2fa185f..627af9b 100644
|
|||||||
: { ...legacyConfigBase, plugins: ['jsx-a11y'] }),
|
: { ...legacyConfigBase, plugins: ['jsx-a11y'] }),
|
||||||
rules: { ...rules },
|
rules: { ...rules },
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create configs for the plugin object
|
|
||||||
-const configs = {
|
|
||||||
+export const configs = {
|
|
||||||
recommended: createConfig(recommendedRules),
|
|
||||||
strict: createConfig(strictRules),
|
|
||||||
};
|
|
||||||
-const flatConfigs = {
|
|
||||||
+export const flatConfigs = {
|
|
||||||
recommended: createConfig(recommendedRules, 'recommended'),
|
|
||||||
strict: createConfig(strictRules, 'strict'),
|
|
||||||
};
|
|
||||||
|
|
||||||
-module.exports = { ...jsxA11y, configs, flatConfigs };
|
|
||||||
+export default { ...jsxA11y, configs, flatConfigs };
|
|
||||||
diff --git a/src/util/mayContainChildComponent.js b/src/util/mayContainChildComponent.js
|
diff --git a/src/util/mayContainChildComponent.js b/src/util/mayContainChildComponent.js
|
||||||
index 43a03ef..5e1035e 100644
|
index 43a03ef..5e1035e 100644
|
||||||
--- a/src/util/mayContainChildComponent.js
|
--- a/src/util/mayContainChildComponent.js
|
||||||
|
@ -27,3 +27,98 @@ index 49fd4c7..a0fdd81 100644
|
|||||||
},
|
},
|
||||||
rules: /** @type {Record<string, import('eslint').Rule.RuleModule>} */ ({
|
rules: /** @type {Record<string, import('eslint').Rule.RuleModule>} */ ({
|
||||||
"callback-return": require("./rules/callback-return"),
|
"callback-return": require("./rules/callback-return"),
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/dependencies/node_modules/@bbb/aaa.js b/tests/fixtures/no-extraneous/dependencies/node_modules/@bbb/aaa.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/dependencies/node_modules/aaa.js b/tests/fixtures/no-extraneous/dependencies/node_modules/aaa.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/dependencies/node_modules/bbb/index.js b/tests/fixtures/no-extraneous/dependencies/node_modules/bbb/index.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/dependencies/node_modules/bbb/package.json b/tests/fixtures/no-extraneous/dependencies/node_modules/bbb/package.json
|
||||||
|
deleted file mode 100644
|
||||||
|
index b7d25e2..0000000
|
||||||
|
--- a/tests/fixtures/no-extraneous/dependencies/node_modules/bbb/package.json
|
||||||
|
+++ /dev/null
|
||||||
|
@@ -1,4 +0,0 @@
|
||||||
|
-{
|
||||||
|
- "name": "bbb",
|
||||||
|
- "main": "index.js"
|
||||||
|
-}
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/devDependencies/node_modules/@bbb/aaa.js b/tests/fixtures/no-extraneous/devDependencies/node_modules/@bbb/aaa.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/devDependencies/node_modules/aaa.js b/tests/fixtures/no-extraneous/devDependencies/node_modules/aaa.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/devDependencies/node_modules/bbb/index.js b/tests/fixtures/no-extraneous/devDependencies/node_modules/bbb/index.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/devDependencies/node_modules/bbb/package.json b/tests/fixtures/no-extraneous/devDependencies/node_modules/bbb/package.json
|
||||||
|
deleted file mode 100644
|
||||||
|
index b7d25e2..0000000
|
||||||
|
--- a/tests/fixtures/no-extraneous/devDependencies/node_modules/bbb/package.json
|
||||||
|
+++ /dev/null
|
||||||
|
@@ -1,4 +0,0 @@
|
||||||
|
-{
|
||||||
|
- "name": "bbb",
|
||||||
|
- "main": "index.js"
|
||||||
|
-}
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/noDependencies/node_modules/@bbb/aaa.js b/tests/fixtures/no-extraneous/noDependencies/node_modules/@bbb/aaa.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/noDependencies/node_modules/aaa.js b/tests/fixtures/no-extraneous/noDependencies/node_modules/aaa.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/noDependencies/node_modules/bbb.js b/tests/fixtures/no-extraneous/noDependencies/node_modules/bbb.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/optionalDependencies/node_modules/@bbb/aaa.js b/tests/fixtures/no-extraneous/optionalDependencies/node_modules/@bbb/aaa.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/optionalDependencies/node_modules/aaa.js b/tests/fixtures/no-extraneous/optionalDependencies/node_modules/aaa.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/optionalDependencies/node_modules/bbb/index.js b/tests/fixtures/no-extraneous/optionalDependencies/node_modules/bbb/index.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/optionalDependencies/node_modules/bbb/package.json b/tests/fixtures/no-extraneous/optionalDependencies/node_modules/bbb/package.json
|
||||||
|
deleted file mode 100644
|
||||||
|
index b7d25e2..0000000
|
||||||
|
--- a/tests/fixtures/no-extraneous/optionalDependencies/node_modules/bbb/package.json
|
||||||
|
+++ /dev/null
|
||||||
|
@@ -1,4 +0,0 @@
|
||||||
|
-{
|
||||||
|
- "name": "bbb",
|
||||||
|
- "main": "index.js"
|
||||||
|
-}
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/peerDependencies/node_modules/@bbb/aaa.js b/tests/fixtures/no-extraneous/peerDependencies/node_modules/@bbb/aaa.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/peerDependencies/node_modules/aaa.js b/tests/fixtures/no-extraneous/peerDependencies/node_modules/aaa.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/peerDependencies/node_modules/bbb/index.js b/tests/fixtures/no-extraneous/peerDependencies/node_modules/bbb/index.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/peerDependencies/node_modules/bbb/package.json b/tests/fixtures/no-extraneous/peerDependencies/node_modules/bbb/package.json
|
||||||
|
deleted file mode 100644
|
||||||
|
index b7d25e2..0000000
|
||||||
|
--- a/tests/fixtures/no-extraneous/peerDependencies/node_modules/bbb/package.json
|
||||||
|
+++ /dev/null
|
||||||
|
@@ -1,4 +0,0 @@
|
||||||
|
-{
|
||||||
|
- "name": "bbb",
|
||||||
|
- "main": "index.js"
|
||||||
|
-}
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/tests/fixtures/no-hide-core-modules/indirect-thirdparty/node_modules/util/index.js b/tests/fixtures/no-hide-core-modules/indirect-thirdparty/node_modules/util/index.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-hide-core-modules/thirdparty/node_modules/util/index.js b/tests/fixtures/no-hide-core-modules/thirdparty/node_modules/util/index.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
@ -1,439 +0,0 @@
|
|||||||
diff --git a/.eslintrc b/.eslintrc
|
|
||||||
deleted file mode 100644
|
|
||||||
index d10247d2..00000000
|
|
||||||
--- a/.eslintrc
|
|
||||||
+++ /dev/null
|
|
||||||
@@ -1,82 +0,0 @@
|
|
||||||
-{
|
|
||||||
- "root": true,
|
|
||||||
- "extends": ["airbnb-base", "plugin:eslint-plugin/recommended"],
|
|
||||||
- "plugins": ["eslint-plugin"],
|
|
||||||
- "env": {
|
|
||||||
- "es6": true,
|
|
||||||
- "node": true
|
|
||||||
- },
|
|
||||||
- "parserOptions": {
|
|
||||||
- "ecmaVersion": 6,
|
|
||||||
- "ecmaFeatures": {
|
|
||||||
- "jsx": true
|
|
||||||
- },
|
|
||||||
- "sourceType": "script",
|
|
||||||
- },
|
|
||||||
- "ignorePatterns": [
|
|
||||||
- "coverage/",
|
|
||||||
- ".nyc_output/",
|
|
||||||
- ],
|
|
||||||
- "rules": {
|
|
||||||
- "comma-dangle": [2, "always-multiline"],
|
|
||||||
- "object-shorthand": [2, "always", {
|
|
||||||
- "ignoreConstructors": false,
|
|
||||||
- "avoidQuotes": false, // this is the override vs airbnb
|
|
||||||
- }],
|
|
||||||
- "max-len": [2, 120, {
|
|
||||||
- "ignoreStrings": true,
|
|
||||||
- "ignoreTemplateLiterals": true,
|
|
||||||
- "ignoreComments": true,
|
|
||||||
- }],
|
|
||||||
- "consistent-return": 0,
|
|
||||||
-
|
|
||||||
- "prefer-destructuring": [2, { "array": false, "object": false }, { "enforceForRenamedProperties": false }],
|
|
||||||
- "prefer-object-spread": 0, // until node 8 is required
|
|
||||||
- "prefer-rest-params": 0, // until node 6 is required
|
|
||||||
- "prefer-spread": 0, // until node 6 is required
|
|
||||||
- "function-call-argument-newline": 1, // TODO: enable
|
|
||||||
- "function-paren-newline": 0,
|
|
||||||
- "no-plusplus": [2, {"allowForLoopAfterthoughts": true}],
|
|
||||||
- "no-param-reassign": 1,
|
|
||||||
- "no-restricted-syntax": [2, {
|
|
||||||
- "selector": "ObjectPattern",
|
|
||||||
- "message": "Object destructuring is not compatible with Node v4"
|
|
||||||
- }],
|
|
||||||
- "strict": [2, "safe"],
|
|
||||||
- "valid-jsdoc": [2, {
|
|
||||||
- "requireReturn": false,
|
|
||||||
- "requireParamDescription": false,
|
|
||||||
- "requireReturnDescription": false,
|
|
||||||
- }],
|
|
||||||
-
|
|
||||||
- "eslint-plugin/consistent-output": 0,
|
|
||||||
- "eslint-plugin/require-meta-docs-description": [2, { "pattern": "^(Enforce|Require|Disallow)" }],
|
|
||||||
- "eslint-plugin/require-meta-schema": 0,
|
|
||||||
- "eslint-plugin/require-meta-type": 0
|
|
||||||
- },
|
|
||||||
- "overrides": [
|
|
||||||
- {
|
|
||||||
- "files": "tests/**",
|
|
||||||
- "rules": {
|
|
||||||
- "no-template-curly-in-string": 1,
|
|
||||||
- },
|
|
||||||
- },
|
|
||||||
- {
|
|
||||||
- "files": "markdown.config.js",
|
|
||||||
- "rules": {
|
|
||||||
- "no-console": 0,
|
|
||||||
- },
|
|
||||||
- },
|
|
||||||
- {
|
|
||||||
- "files": ".github/workflows/*.js",
|
|
||||||
- "parserOptions": {
|
|
||||||
- "ecmaVersion": 2019,
|
|
||||||
- },
|
|
||||||
- "rules": {
|
|
||||||
- "camelcase": 0,
|
|
||||||
- "no-console": 0,
|
|
||||||
- "no-restricted-syntax": 0,
|
|
||||||
- },
|
|
||||||
- },
|
|
||||||
- ],
|
|
||||||
- }
|
|
||||||
diff --git a/index.js b/index.js
|
|
||||||
index 4140c6c8..03e623af 100644
|
|
||||||
--- a/index.js
|
|
||||||
+++ b/index.js
|
|
||||||
@@ -1,31 +1,25 @@
|
|
||||||
-'use strict';
|
|
||||||
-
|
|
||||||
-const configAll = require('./configs/all');
|
|
||||||
-const configRecommended = require('./configs/recommended');
|
|
||||||
-const configRuntime = require('./configs/jsx-runtime');
|
|
||||||
-
|
|
||||||
-const allRules = require('./lib/rules');
|
|
||||||
+import configAll from './configs/all';
|
|
||||||
+import configRecommended from './configs/recommended';
|
|
||||||
+import configRuntime from './configs/jsx-runtime';
|
|
||||||
+import { name } from './package.json';
|
|
||||||
+export { default as rules } from './lib/rules';
|
|
||||||
|
|
||||||
// for legacy config system
|
|
||||||
-const plugins = [
|
|
||||||
- 'react',
|
|
||||||
-];
|
|
||||||
+const plugins = [name];
|
|
||||||
+
|
|
||||||
+export const deprecatedRules = configAll.plugins.react.deprecatedRules;
|
|
||||||
|
|
||||||
-module.exports = {
|
|
||||||
- deprecatedRules: configAll.plugins.react.deprecatedRules,
|
|
||||||
- rules: allRules,
|
|
||||||
- configs: {
|
|
||||||
- recommended: Object.assign({}, configRecommended, {
|
|
||||||
- parserOptions: configRecommended.languageOptions.parserOptions,
|
|
||||||
- plugins,
|
|
||||||
- }),
|
|
||||||
- all: Object.assign({}, configAll, {
|
|
||||||
- parserOptions: configAll.languageOptions.parserOptions,
|
|
||||||
- plugins,
|
|
||||||
- }),
|
|
||||||
- 'jsx-runtime': Object.assign({}, configRuntime, {
|
|
||||||
- parserOptions: configRuntime.languageOptions.parserOptions,
|
|
||||||
- plugins,
|
|
||||||
- }),
|
|
||||||
- },
|
|
||||||
+export const configs = {
|
|
||||||
+ recommended: Object.assign({}, configRecommended, {
|
|
||||||
+ parserOptions: configRecommended.languageOptions.parserOptions,
|
|
||||||
+ plugins,
|
|
||||||
+ }),
|
|
||||||
+ all: Object.assign({}, configAll, {
|
|
||||||
+ parserOptions: configAll.languageOptions.parserOptions,
|
|
||||||
+ plugins,
|
|
||||||
+ }),
|
|
||||||
+ 'jsx-runtime': Object.assign({}, configRuntime, {
|
|
||||||
+ parserOptions: configRuntime.languageOptions.parserOptions,
|
|
||||||
+ plugins,
|
|
||||||
+ }),
|
|
||||||
};
|
|
||||||
diff --git a/lib/rules/button-has-type.js b/lib/rules/button-has-type.js
|
|
||||||
index d4059606..982dd343 100644
|
|
||||||
--- a/lib/rules/button-has-type.js
|
|
||||||
+++ b/lib/rules/button-has-type.js
|
|
||||||
@@ -5,8 +5,7 @@
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
-const getProp = require('jsx-ast-utils/getProp');
|
|
||||||
-const getLiteralPropValue = require('jsx-ast-utils/getLiteralPropValue');
|
|
||||||
+const { getProp, getLiteralPropValue } = require('jsx-ast-utils');
|
|
||||||
const docsUrl = require('../util/docsUrl');
|
|
||||||
const isCreateElement = require('../util/isCreateElement');
|
|
||||||
const report = require('../util/report');
|
|
||||||
diff --git a/lib/rules/jsx-fragments.js b/lib/rules/jsx-fragments.js
|
|
||||||
index 4dadb076..de01ae32 100644
|
|
||||||
--- a/lib/rules/jsx-fragments.js
|
|
||||||
+++ b/lib/rules/jsx-fragments.js
|
|
||||||
@@ -5,7 +5,7 @@
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
-const elementType = require('jsx-ast-utils/elementType');
|
|
||||||
+import { elementType } from 'jsx-ast-utils';
|
|
||||||
const pragmaUtil = require('../util/pragma');
|
|
||||||
const variableUtil = require('../util/variable');
|
|
||||||
const testReactVersion = require('../util/version').testReactVersion;
|
|
||||||
diff --git a/lib/rules/jsx-key.js b/lib/rules/jsx-key.js
|
|
||||||
index 825d21f4..fb4459dd 100644
|
|
||||||
--- a/lib/rules/jsx-key.js
|
|
||||||
+++ b/lib/rules/jsx-key.js
|
|
||||||
@@ -5,8 +5,7 @@
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
-const hasProp = require('jsx-ast-utils/hasProp');
|
|
||||||
-const propName = require('jsx-ast-utils/propName');
|
|
||||||
+import { hasProp, propName } from 'jsx-ast-utils';
|
|
||||||
const values = require('object.values');
|
|
||||||
const docsUrl = require('../util/docsUrl');
|
|
||||||
const pragmaUtil = require('../util/pragma');
|
|
||||||
diff --git a/lib/rules/jsx-no-bind.js b/lib/rules/jsx-no-bind.js
|
|
||||||
index 4d6e349d..6cc8fbc3 100644
|
|
||||||
--- a/lib/rules/jsx-no-bind.js
|
|
||||||
+++ b/lib/rules/jsx-no-bind.js
|
|
||||||
@@ -7,7 +7,7 @@
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
-const propName = require('jsx-ast-utils/propName');
|
|
||||||
+import { propName } from 'jsx-ast-utils';
|
|
||||||
const docsUrl = require('../util/docsUrl');
|
|
||||||
const jsxUtil = require('../util/jsx');
|
|
||||||
const report = require('../util/report');
|
|
||||||
diff --git a/lib/rules/jsx-pascal-case.js b/lib/rules/jsx-pascal-case.js
|
|
||||||
index efeef403..33df4653 100644
|
|
||||||
--- a/lib/rules/jsx-pascal-case.js
|
|
||||||
+++ b/lib/rules/jsx-pascal-case.js
|
|
||||||
@@ -5,7 +5,7 @@
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
-const elementType = require('jsx-ast-utils/elementType');
|
|
||||||
+import { elementType } from 'jsx-ast-utils';
|
|
||||||
const minimatch = require('minimatch');
|
|
||||||
const docsUrl = require('../util/docsUrl');
|
|
||||||
const jsxUtil = require('../util/jsx');
|
|
||||||
diff --git a/lib/rules/jsx-sort-props.js b/lib/rules/jsx-sort-props.js
|
|
||||||
index f811e16c..ebbde786 100644
|
|
||||||
--- a/lib/rules/jsx-sort-props.js
|
|
||||||
+++ b/lib/rules/jsx-sort-props.js
|
|
||||||
@@ -5,7 +5,7 @@
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
-const propName = require('jsx-ast-utils/propName');
|
|
||||||
+import { propName } from 'jsx-ast-utils';
|
|
||||||
const includes = require('array-includes');
|
|
||||||
const toSorted = require('array.prototype.tosorted');
|
|
||||||
|
|
||||||
diff --git a/lib/rules/no-namespace.js b/lib/rules/no-namespace.js
|
|
||||||
index 20ca5d93..22eb516f 100644
|
|
||||||
--- a/lib/rules/no-namespace.js
|
|
||||||
+++ b/lib/rules/no-namespace.js
|
|
||||||
@@ -5,7 +5,7 @@
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
-const elementType = require('jsx-ast-utils/elementType');
|
|
||||||
+import { elementType } from 'jsx-ast-utils';
|
|
||||||
const docsUrl = require('../util/docsUrl');
|
|
||||||
const isCreateElement = require('../util/isCreateElement');
|
|
||||||
const report = require('../util/report');
|
|
||||||
diff --git a/lib/rules/no-unknown-property.js b/lib/rules/no-unknown-property.js
|
|
||||||
index 3e8c6de1..0b3224a3 100644
|
|
||||||
--- a/lib/rules/no-unknown-property.js
|
|
||||||
+++ b/lib/rules/no-unknown-property.js
|
|
||||||
@@ -544,7 +544,7 @@ module.exports = {
|
|
||||||
|
|
||||||
create(context) {
|
|
||||||
function getIgnoreConfig() {
|
|
||||||
- return (context.options[0] && context.options[0].ignore) || DEFAULTS.ignore;
|
|
||||||
+ return context.options[0]?.ignore || DEFAULTS.ignore;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getRequireDataLowercase() {
|
|
||||||
diff --git a/lib/util/annotations.js b/lib/util/annotations.js
|
|
||||||
index 24b18074..cc7e6faa 100644
|
|
||||||
--- a/lib/util/annotations.js
|
|
||||||
+++ b/lib/util/annotations.js
|
|
||||||
@@ -29,6 +29,6 @@ function isAnnotatedFunctionPropsDeclaration(node, context) {
|
|
||||||
return (isAnnotated && (isDestructuredProps || isProps));
|
|
||||||
}
|
|
||||||
|
|
||||||
-module.exports = {
|
|
||||||
+export {
|
|
||||||
isAnnotatedFunctionPropsDeclaration,
|
|
||||||
};
|
|
||||||
diff --git a/lib/util/ast.js b/lib/util/ast.js
|
|
||||||
index 5664dcb5..82f81709 100644
|
|
||||||
--- a/lib/util/ast.js
|
|
||||||
+++ b/lib/util/ast.js
|
|
||||||
@@ -4,12 +4,8 @@
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
-const estraverse = require('estraverse');
|
|
||||||
-const eslintUtil = require('./eslint');
|
|
||||||
-
|
|
||||||
-const getFirstTokens = eslintUtil.getFirstTokens;
|
|
||||||
-const getScope = eslintUtil.getScope;
|
|
||||||
-const getSourceCode = eslintUtil.getSourceCode;
|
|
||||||
+import estraverse from 'estraverse';
|
|
||||||
+import { getFirstTokens, getScope, getSourceCode } from './eslint.js';
|
|
||||||
// const pragmaUtil = require('./pragma');
|
|
||||||
|
|
||||||
/**
|
|
||||||
@@ -19,11 +15,15 @@ const getSourceCode = eslintUtil.getSourceCode;
|
|
||||||
* @param {Object} visitor Visitor Object for estraverse
|
|
||||||
*/
|
|
||||||
function traverse(ASTnode, visitor) {
|
|
||||||
- const opts = Object.assign({}, {
|
|
||||||
- fallback(node) {
|
|
||||||
- return Object.keys(node).filter((key) => key === 'children' || key === 'argument');
|
|
||||||
+ const opts = Object.assign(
|
|
||||||
+ {},
|
|
||||||
+ {
|
|
||||||
+ fallback(node) {
|
|
||||||
+ return Object.keys(node).filter(key => key === 'children' || key === 'argument');
|
|
||||||
+ },
|
|
||||||
},
|
|
||||||
- }, visitor);
|
|
||||||
+ visitor,
|
|
||||||
+ );
|
|
||||||
|
|
||||||
opts.keys = Object.assign({}, visitor.keys, {
|
|
||||||
JSXElement: ['children'],
|
|
||||||
@@ -56,8 +56,8 @@ function loopNodes(nodes) {
|
|
||||||
*/
|
|
||||||
function findReturnStatement(node) {
|
|
||||||
if (
|
|
||||||
- (!node.value || !node.value.body || !node.value.body.body)
|
|
||||||
- && (!node.body || !node.body.body)
|
|
||||||
+ (!node.value || !node.value.body || !node.value.body.body) &&
|
|
||||||
+ (!node.body || !node.body.body)
|
|
||||||
) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@@ -110,10 +110,10 @@ function traverseReturns(ASTNode, context, onReturn) {
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (
|
|
||||||
- nodeType !== 'FunctionExpression'
|
|
||||||
- && nodeType !== 'FunctionDeclaration'
|
|
||||||
- && nodeType !== 'ArrowFunctionExpression'
|
|
||||||
- && nodeType !== 'MethodDefinition'
|
|
||||||
+ nodeType !== 'FunctionExpression' &&
|
|
||||||
+ nodeType !== 'FunctionDeclaration' &&
|
|
||||||
+ nodeType !== 'ArrowFunctionExpression' &&
|
|
||||||
+ nodeType !== 'MethodDefinition'
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
@@ -196,13 +196,8 @@ function getFirstNodeInLine(context, node) {
|
|
||||||
let lines;
|
|
||||||
do {
|
|
||||||
token = sourceCode.getTokenBefore(token);
|
|
||||||
- lines = token.type === 'JSXText'
|
|
||||||
- ? token.value.split('\n')
|
|
||||||
- : null;
|
|
||||||
- } while (
|
|
||||||
- token.type === 'JSXText'
|
|
||||||
- && /^\s*$/.test(lines[lines.length - 1])
|
|
||||||
- );
|
|
||||||
+ lines = token.type === 'JSXText' ? token.value.split('\n') : null;
|
|
||||||
+ } while (token.type === 'JSXText' && /^\s*$/.test(lines[lines.length - 1]));
|
|
||||||
return token;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -291,10 +286,9 @@ function stripQuotes(string) {
|
|
||||||
function getKeyValue(context, node) {
|
|
||||||
if (node.type === 'ObjectTypeProperty') {
|
|
||||||
const tokens = getFirstTokens(context, node, 2);
|
|
||||||
- return (tokens[0].value === '+' || tokens[0].value === '-'
|
|
||||||
+ return tokens[0].value === '+' || tokens[0].value === '-'
|
|
||||||
? tokens[1].value
|
|
||||||
- : stripQuotes(tokens[0].value)
|
|
||||||
- );
|
|
||||||
+ : stripQuotes(tokens[0].value);
|
|
||||||
}
|
|
||||||
if (node.type === 'GenericTypeAnnotation') {
|
|
||||||
return node.id.name;
|
|
||||||
@@ -321,9 +315,14 @@ function isParenthesized(context, node) {
|
|
||||||
const previousToken = sourceCode.getTokenBefore(node);
|
|
||||||
const nextToken = sourceCode.getTokenAfter(node);
|
|
||||||
|
|
||||||
- return !!previousToken && !!nextToken
|
|
||||||
- && previousToken.value === '(' && previousToken.range[1] <= node.range[0]
|
|
||||||
- && nextToken.value === ')' && nextToken.range[0] >= node.range[1];
|
|
||||||
+ return (
|
|
||||||
+ !!previousToken &&
|
|
||||||
+ !!nextToken &&
|
|
||||||
+ previousToken.value === '(' &&
|
|
||||||
+ previousToken.range[1] <= node.range[0] &&
|
|
||||||
+ nextToken.value === ')' &&
|
|
||||||
+ nextToken.range[0] >= node.range[1]
|
|
||||||
+ );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@@ -333,9 +332,9 @@ function isParenthesized(context, node) {
|
|
||||||
*/
|
|
||||||
function isAssignmentLHS(node) {
|
|
||||||
return (
|
|
||||||
- node.parent
|
|
||||||
- && node.parent.type === 'AssignmentExpression'
|
|
||||||
- && node.parent.left === node
|
|
||||||
+ node.parent &&
|
|
||||||
+ node.parent.type === 'AssignmentExpression' &&
|
|
||||||
+ node.parent.left === node
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -434,7 +433,7 @@ function isTSTypeParameterInstantiation(node) {
|
|
||||||
return nodeType === 'TSTypeParameterInstantiation';
|
|
||||||
}
|
|
||||||
|
|
||||||
-module.exports = {
|
|
||||||
+export {
|
|
||||||
traverse,
|
|
||||||
findReturnStatement,
|
|
||||||
getFirstNodeInLine,
|
|
||||||
diff --git a/lib/util/jsx.js b/lib/util/jsx.js
|
|
||||||
index 07a09a80..0b9b139f 100644
|
|
||||||
--- a/lib/util/jsx.js
|
|
||||||
+++ b/lib/util/jsx.js
|
|
||||||
@@ -4,7 +4,7 @@
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
-const elementType = require('jsx-ast-utils/elementType');
|
|
||||||
+import { elementType } from 'jsx-ast-utils';
|
|
||||||
|
|
||||||
const astUtil = require('./ast');
|
|
||||||
const isCreateElement = require('./isCreateElement');
|
|
||||||
diff --git a/tsconfig.json b/tsconfig.json
|
|
||||||
deleted file mode 100644
|
|
||||||
index 39187b7f..00000000
|
|
||||||
--- a/tsconfig.json
|
|
||||||
+++ /dev/null
|
|
||||||
@@ -1,23 +0,0 @@
|
|
||||||
-{
|
|
||||||
- "compilerOptions": {
|
|
||||||
- "target": "ES2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
|
||||||
- "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
|
||||||
- // "lib": ["es2015"], /* Specify library files to be included in the compilation. */
|
|
||||||
- "allowJs": true, /* Allow javascript files to be compiled. */
|
|
||||||
- "checkJs": true, /* Report errors in .js files. */
|
|
||||||
- "noEmit": true, /* Do not emit outputs. */
|
|
||||||
- "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
||||||
-
|
|
||||||
- /* Strict Type-Checking Options */
|
|
||||||
- // "strict": true, /* Enable all strict type-checking options. */
|
|
||||||
- "noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
||||||
- // "strictNullChecks": true, /* Enable strict null checks. */
|
|
||||||
- // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
||||||
- "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
||||||
- "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
||||||
- "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
||||||
- "alwaysStrict": false, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
||||||
- "resolveJsonModule": true
|
|
||||||
- },
|
|
||||||
- "include": ["lib"],
|
|
||||||
-}
|
|
1870
pnpm-lock.yaml
generated
1870
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,7 @@ import type { Plugin } from 'esbuild';
|
|||||||
import { memoize } from 'lodash';
|
import { memoize } from 'lodash';
|
||||||
import { gray, green } from 'picocolors';
|
import { gray, green } from 'picocolors';
|
||||||
import { dependencies } from '../dist/package.json';
|
import { dependencies } from '../dist/package.json';
|
||||||
import { buildLocalRules } from '../src/build-local-rules';
|
import { buildLocalRules } from './build-local-rules';
|
||||||
import { dts } from './dts';
|
import { dts } from './dts';
|
||||||
import { babelPlugin } from './modifier';
|
import { babelPlugin } from './modifier';
|
||||||
|
|
||||||
@ -134,7 +134,6 @@ async function main() {
|
|||||||
|
|
||||||
console.log('Building packages...');
|
console.log('Building packages...');
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
bundle('./packages/eslint-plugin-react/index.js'),
|
|
||||||
bundle('./packages/eslint-plugin-jsx-a11y/src/index.js'),
|
bundle('./packages/eslint-plugin-jsx-a11y/src/index.js'),
|
||||||
bundle('./packages/eslint-plugin-react-hooks/index.ts'),
|
bundle('./packages/eslint-plugin-react-hooks/index.ts'),
|
||||||
bundle('./packages/eslint-plugin-n/lib/index.js', './dist/eslint-plugin-n/index.js'),
|
bundle('./packages/eslint-plugin-n/lib/index.js', './dist/eslint-plugin-n/index.js'),
|
||||||
|
@ -1,25 +1,15 @@
|
|||||||
#!/usr/bin/env tsx
|
#!/usr/bin/env tsx
|
||||||
import assert from 'node:assert';
|
import assert from 'node:assert';
|
||||||
import { readFileSync, promises as fs } from 'node:fs';
|
import { readFileSync } from 'node:fs';
|
||||||
import { resolve, extname, relative } from 'node:path';
|
import { resolve, extname } from 'node:path';
|
||||||
import { isBuiltin } from 'node:module';
|
|
||||||
import esbuild from 'esbuild';
|
|
||||||
import type { Loader, Plugin } from 'esbuild';
|
import type { Loader, Plugin } from 'esbuild';
|
||||||
import * as babel from '@babel/core';
|
import * as babel from '@babel/core';
|
||||||
import { memoize } from 'lodash';
|
|
||||||
import { gray, green } from 'picocolors';
|
|
||||||
import type { types as t, types } from '@babel/core';
|
import type { types as t, types } from '@babel/core';
|
||||||
import { dependencies } from '../dist/package.json';
|
|
||||||
import { createMacro, type MacroHandler } from 'babel-plugin-macros';
|
import { createMacro, type MacroHandler } from 'babel-plugin-macros';
|
||||||
import * as polyfill from '../src/polyfill';
|
import * as polyfill from '../src/polyfill';
|
||||||
import { buildLocalRules } from '../src/build-local-rules';
|
|
||||||
import { dts } from './dts';
|
|
||||||
|
|
||||||
const polyfills = Object.keys(polyfill);
|
const polyfills = Object.keys(polyfill);
|
||||||
|
|
||||||
const ENV = (process.env.NODE_ENV ??= 'production');
|
|
||||||
const PROD = ENV === 'production';
|
|
||||||
|
|
||||||
class HandlerMap {
|
class HandlerMap {
|
||||||
map = new Map<string, MacroHandler>();
|
map = new Map<string, MacroHandler>();
|
||||||
|
|
||||||
|
@ -6,5 +6,4 @@ sync() (
|
|||||||
sync eslint-import-resolver-typescript
|
sync eslint-import-resolver-typescript
|
||||||
sync eslint-plugin-jsx-a11y
|
sync eslint-plugin-jsx-a11y
|
||||||
sync eslint-plugin-n
|
sync eslint-plugin-n
|
||||||
sync eslint-plugin-react
|
|
||||||
sync jsx-ast-utils
|
sync jsx-ast-utils
|
||||||
|
@ -6,28 +6,28 @@
|
|||||||
"subject": "[meta] add `repository.directory` field"
|
"subject": "[meta] add `repository.directory` field"
|
||||||
},
|
},
|
||||||
"eslint-import-resolver-typescript": {
|
"eslint-import-resolver-typescript": {
|
||||||
"hash": "ca11f1c538714252ff058a8e1c680796ee5775d0",
|
"hash": "c9b5626ee69bd529c7e391e40928a4fb28dce179",
|
||||||
"date": "2024-06-01T03:27:29+00:00",
|
"date": "2024-07-23T20:40:14+08:00",
|
||||||
"committer": "GitHub",
|
"committer": "GitHub",
|
||||||
"subject": "chore(deps): update dependency eslint to ^8.57.0 (#287)"
|
"subject": "chore: release eslint-import-resolver-typescript (#302)"
|
||||||
},
|
},
|
||||||
"eslint-plugin-jsx-a11y": {
|
"eslint-plugin-jsx-a11y": {
|
||||||
"hash": "0be7ea95f560c6afc6817d381054d914ebd0b2ca",
|
"hash": "cca288b73a39fa0932a57c02a7a88de68fc971fc",
|
||||||
"date": "2024-06-23T23:41:48-04:00",
|
"date": "2024-07-22T02:39:43+01:00",
|
||||||
"committer": "Jordan Harband",
|
"committer": "Jordan Harband",
|
||||||
"subject": "[readme] remove deprecated travis ci badge; add github actions badge"
|
"subject": "[readme] fix typo in shareable config section in readme"
|
||||||
},
|
},
|
||||||
"eslint-plugin-n": {
|
"eslint-plugin-n": {
|
||||||
"hash": "67bbfdf3c6862dcbfe455a4afbd83fa60f9d1ea4",
|
"hash": "5aad5f1c419b3143ffb9356bd299fc50dc576ee5",
|
||||||
"date": "2024-06-14T09:43:13+08:00",
|
"date": "2024-07-26T10:04:35+08:00",
|
||||||
"committer": "GitHub",
|
"committer": "GitHub",
|
||||||
"subject": "chore(master): release 17.9.0 (#299)"
|
"subject": "chore(master): release 17.10.0 (#305)"
|
||||||
},
|
},
|
||||||
"eslint-plugin-react": {
|
"eslint-plugin-react": {
|
||||||
"hash": "3c1d5203438965b3999911520a930306f6e9c58f",
|
"hash": "983b88dd3cb5e07919517d3fde4085f60883ded7",
|
||||||
"date": "2024-06-23T23:00:32-07:00",
|
"date": "2024-07-24T15:26:33-07:00",
|
||||||
"committer": "Jordan Harband",
|
"committer": "Jordan Harband",
|
||||||
"subject": "[Dev Deps] downgrade `eslint-remote-tester-repositories`"
|
"subject": "[Tests] `no-array-index-key`: actually run valid tests"
|
||||||
},
|
},
|
||||||
"jsx-ast-utils": {
|
"jsx-ast-utils": {
|
||||||
"hash": "5943318eaf23764eec3ff397ebb969613d728a95",
|
"hash": "5943318eaf23764eec3ff397ebb969613d728a95",
|
||||||
|
46
src/env.ts
Normal file
46
src/env.ts
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import type { Extends, Plugin } from '@aet/eslint-define-config';
|
||||||
|
import * as fs from 'node:fs';
|
||||||
|
import { resolve } from 'node:path';
|
||||||
|
|
||||||
|
export function checkEnv() {
|
||||||
|
const rootDir = process.cwd();
|
||||||
|
const plugins: Plugin[] = [];
|
||||||
|
const extend: Extends[] = [];
|
||||||
|
|
||||||
|
const pkgJsonPath = resolve(rootDir, 'package.json');
|
||||||
|
const pkgJson = fs.existsSync(pkgJsonPath)
|
||||||
|
? JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8'))
|
||||||
|
: {};
|
||||||
|
|
||||||
|
const deps = Object.keys({
|
||||||
|
...pkgJson.dependencies,
|
||||||
|
...pkgJson.devDependencies,
|
||||||
|
...pkgJson.peerDependencies,
|
||||||
|
});
|
||||||
|
|
||||||
|
const hasReact = deps.includes('react');
|
||||||
|
if (hasReact) {
|
||||||
|
plugins.push('react-hooks');
|
||||||
|
}
|
||||||
|
if (deps.includes('@vitejs/plugin-react')) {
|
||||||
|
plugins.push('react-refresh');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deps.includes('tailwindcss') && deps.includes('eslint-plugin-tailwindcss')) {
|
||||||
|
plugins.push('tailwindcss');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deps.includes('storybook') && deps.includes('eslint-plugin-storybook')) {
|
||||||
|
extend.push('plugin:storybook/recommended');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deps.includes('@tanstack/react-query')) {
|
||||||
|
extend.push('plugin:@tanstack/eslint-plugin-query/recommended');
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
react: hasReact,
|
||||||
|
plugins,
|
||||||
|
extends: extend,
|
||||||
|
};
|
||||||
|
}
|
76
src/index.ts
76
src/index.ts
@ -1,9 +1,8 @@
|
|||||||
/// <reference path="./modules.d.ts" />
|
/// <reference path="./modules.d.ts" />
|
||||||
import './redirect';
|
import './redirect';
|
||||||
import fs from 'node:fs';
|
|
||||||
import type { Rule } from 'eslint';
|
import type { Rule } from 'eslint';
|
||||||
import type { ESLintUtils } from '@typescript-eslint/utils';
|
import type { ESLintUtils } from '@typescript-eslint/utils';
|
||||||
import type { ESLintConfig, Rules } from '@aet/eslint-define-config';
|
import type { ESLintConfig, Extends, Plugin, Rules } from '@aet/eslint-define-config';
|
||||||
// import findCacheDirectory from 'find-cache-dir';
|
// import findCacheDirectory from 'find-cache-dir';
|
||||||
import { typescriptRules } from './presets/typescript';
|
import { typescriptRules } from './presets/typescript';
|
||||||
import { unicornRules } from './presets/unicorn';
|
import { unicornRules } from './presets/unicorn';
|
||||||
@ -15,6 +14,7 @@ import { graphqlRules } from './presets/graphql';
|
|||||||
import { localRules } from './presets/local';
|
import { localRules } from './presets/local';
|
||||||
import { error, warn, off } from './constants';
|
import { error, warn, off } from './constants';
|
||||||
import { tailwindRules } from './presets/tailwind';
|
import { tailwindRules } from './presets/tailwind';
|
||||||
|
import { checkEnv } from './env';
|
||||||
|
|
||||||
export { error, warn, off };
|
export { error, warn, off };
|
||||||
|
|
||||||
@ -74,12 +74,17 @@ export type InputConfig = Omit<ESLintConfig, 'rules'> & {
|
|||||||
* this is statically analyzed.
|
* this is statically analyzed.
|
||||||
*/
|
*/
|
||||||
customRuleFiles?: string | string[];
|
customRuleFiles?: string | string[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Automatically detect project types, dependencies and deduct the plugins.
|
||||||
|
*/
|
||||||
|
auto?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a ESLint config object.
|
* Returns a ESLint config object.
|
||||||
*
|
*
|
||||||
* By default, it includes `["@typescript-eslint", "import", "prettier"]` configs.
|
* By default, it includes `["@typescript-eslint", "import-x", "prettier", "unicorn"]` configs.
|
||||||
* Additional bundled plugins include:
|
* Additional bundled plugins include:
|
||||||
*
|
*
|
||||||
* 1. [`react`](https://github.com/jsx-eslint/eslint-plugin-react#list-of-supported-rules)
|
* 1. [`react`](https://github.com/jsx-eslint/eslint-plugin-react#list-of-supported-rules)
|
||||||
@ -88,7 +93,8 @@ export type InputConfig = Omit<ESLintConfig, 'rules'> & {
|
|||||||
* 2. [`react-refresh`](https://github.com/ArnaudBarre/eslint-plugin-react-refresh)
|
* 2. [`react-refresh`](https://github.com/ArnaudBarre/eslint-plugin-react-refresh)
|
||||||
* 3. [`jsx-a11y`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#supported-rules)
|
* 3. [`jsx-a11y`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#supported-rules)
|
||||||
* 4. [`unicorn`](https://github.com/sindresorhus/eslint-plugin-unicorn#rules)
|
* 4. [`unicorn`](https://github.com/sindresorhus/eslint-plugin-unicorn#rules)
|
||||||
* 5. [`n`](https://github.com/eslint-community/eslint-plugin-n#-rules) (Node.js specific)
|
* 5. [`n`](https://github.com/eslint-community/eslint-plugin-n#-rules) (Node.js specific,
|
||||||
|
* requires `minimatch`)
|
||||||
* 6. [`jsdoc`](https://github.com/gajus/eslint-plugin-jsdoc#rules)
|
* 6. [`jsdoc`](https://github.com/gajus/eslint-plugin-jsdoc#rules)
|
||||||
*
|
*
|
||||||
* Non bundled:
|
* Non bundled:
|
||||||
@ -96,41 +102,49 @@ export type InputConfig = Omit<ESLintConfig, 'rules'> & {
|
|||||||
*/
|
*/
|
||||||
export function extendConfig(of: InputConfig = {}): ESLintConfig {
|
export function extendConfig(of: InputConfig = {}): ESLintConfig {
|
||||||
const {
|
const {
|
||||||
plugins = [],
|
auto,
|
||||||
|
plugins: _plugins = [],
|
||||||
settings,
|
settings,
|
||||||
rules,
|
rules,
|
||||||
extends: _extends,
|
extends: _extends,
|
||||||
overrides,
|
overrides,
|
||||||
customRuleFiles,
|
customRuleFiles,
|
||||||
|
parserOptions,
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
localRules: _,
|
localRules: _,
|
||||||
...rest
|
...rest
|
||||||
} = of;
|
} = of;
|
||||||
|
|
||||||
const hasReact = plugins.includes('react');
|
let hasReact = false;
|
||||||
const hasReactRefresh = plugins.includes('react-refresh');
|
let plugins: Plugin[] = _plugins;
|
||||||
const hasUnicorn = plugins.includes('unicorn');
|
let extend: Extends[] = ensureArray(_extends);
|
||||||
|
|
||||||
|
if (auto) {
|
||||||
|
const env = checkEnv();
|
||||||
|
hasReact = env.react;
|
||||||
|
plugins = [..._plugins, ...env.plugins];
|
||||||
|
extend = [...extend, ...env.extends];
|
||||||
|
}
|
||||||
|
|
||||||
const hasJsDoc = plugins.includes('jsdoc');
|
const hasJsDoc = plugins.includes('jsdoc');
|
||||||
const hasGraphQL = plugins.includes('@graphql-eslint');
|
const hasGraphQL = plugins.includes('@graphql-eslint');
|
||||||
const hasNext = ensureArray(_extends).some(name => name.includes(':@next/next'));
|
const hasTailwind = extend.some(name => name.includes('plugin:tailwindcss/'));
|
||||||
const hasTailwind = ensureArray(_extends).some(name =>
|
|
||||||
name.includes('plugin:tailwindcss/'),
|
|
||||||
);
|
|
||||||
|
|
||||||
const ruleDir = false; // ?? findCacheDirectory({ name: '_eslint-rules' });
|
// const ruleDir = false; // ?? findCacheDirectory({ name: '_eslint-rules' });
|
||||||
if (ruleDir) {
|
// if (ruleDir) {
|
||||||
fs.rmSync(ruleDir, { recursive: true, force: true });
|
// fs.rmSync(ruleDir, { recursive: true, force: true });
|
||||||
fs.mkdirSync(ruleDir, { recursive: true });
|
// fs.mkdirSync(ruleDir, { recursive: true });
|
||||||
}
|
// }
|
||||||
|
|
||||||
const result: InputConfig = {
|
const result: InputConfig = {
|
||||||
root: true,
|
root: true,
|
||||||
parser: '@typescript-eslint/parser',
|
parser: '@typescript-eslint/parser',
|
||||||
plugins: unique('@typescript-eslint', 'import-x', 'rules', plugins),
|
plugins: unique('@typescript-eslint', 'import-x', 'rules', 'unicorn', plugins),
|
||||||
env: { node: true, browser: true, es2023: true },
|
env: { node: true, browser: true, es2023: true },
|
||||||
reportUnusedDisableDirectives: true,
|
reportUnusedDisableDirectives: true,
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
project: true,
|
project: true,
|
||||||
|
...parserOptions,
|
||||||
},
|
},
|
||||||
extends: unique(
|
extends: unique(
|
||||||
'eslint:recommended',
|
'eslint:recommended',
|
||||||
@ -139,13 +153,14 @@ export function extendConfig(of: InputConfig = {}): ESLintConfig {
|
|||||||
'plugin:import-x/errors',
|
'plugin:import-x/errors',
|
||||||
'plugin:import-x/typescript',
|
'plugin:import-x/typescript',
|
||||||
hasReact && [
|
hasReact && [
|
||||||
'plugin:react/recommended',
|
'plugin:@eslint-react/recommended-legacy',
|
||||||
|
'plugin:@eslint-react/dom-legacy',
|
||||||
'plugin:react-hooks/recommended',
|
'plugin:react-hooks/recommended',
|
||||||
'plugin:jsx-a11y/recommended',
|
'plugin:jsx-a11y/recommended',
|
||||||
],
|
],
|
||||||
hasJsDoc && 'plugin:jsdoc/recommended-typescript',
|
hasJsDoc && 'plugin:jsdoc/recommended-typescript',
|
||||||
hasGraphQL && 'plugin:@graphql-eslint/recommended',
|
hasGraphQL && 'plugin:@graphql-eslint/recommended',
|
||||||
_extends,
|
extend as string[],
|
||||||
),
|
),
|
||||||
settings: {
|
settings: {
|
||||||
'import-x/parsers': {
|
'import-x/parsers': {
|
||||||
@ -156,9 +171,6 @@ export function extendConfig(of: InputConfig = {}): ESLintConfig {
|
|||||||
alwaysTryTypes: true,
|
alwaysTryTypes: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
react: {
|
|
||||||
version: 'detect',
|
|
||||||
},
|
|
||||||
...settings,
|
...settings,
|
||||||
},
|
},
|
||||||
overrides: [
|
overrides: [
|
||||||
@ -181,6 +193,12 @@ export function extendConfig(of: InputConfig = {}): ESLintConfig {
|
|||||||
'no-console': off,
|
'no-console': off,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
files: ['*.tsx'],
|
||||||
|
rules: {
|
||||||
|
'@eslint-react/no-leaked-conditional-rendering': error,
|
||||||
|
},
|
||||||
|
},
|
||||||
...(overrides ?? []),
|
...(overrides ?? []),
|
||||||
],
|
],
|
||||||
rules: {
|
rules: {
|
||||||
@ -188,17 +206,11 @@ export function extendConfig(of: InputConfig = {}): ESLintConfig {
|
|||||||
...typescriptRules,
|
...typescriptRules,
|
||||||
...importRules,
|
...importRules,
|
||||||
...localRules,
|
...localRules,
|
||||||
...(hasReact && {
|
...(hasReact && reactRules),
|
||||||
...reactRules,
|
...(plugins.includes('react-refresh') && {
|
||||||
'react/no-unknown-property': [
|
|
||||||
error,
|
|
||||||
{ ignore: hasNext ? ['css', 'next'] : ['css'] },
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
...(hasReactRefresh && {
|
|
||||||
'react-refresh/only-export-components': [warn, { allowConstantExport: true }],
|
'react-refresh/only-export-components': [warn, { allowConstantExport: true }],
|
||||||
}),
|
}),
|
||||||
...(hasUnicorn && unicornRules),
|
...unicornRules,
|
||||||
...(hasJsDoc && jsDocRules),
|
...(hasJsDoc && jsDocRules),
|
||||||
...(hasGraphQL && graphqlRules),
|
...(hasGraphQL && graphqlRules),
|
||||||
...(hasTailwind && tailwindRules),
|
...(hasTailwind && tailwindRules),
|
||||||
|
@ -8,7 +8,6 @@ import type { Node, Property } from 'estree';
|
|||||||
|
|
||||||
// https://github.com/gulpjs/interpret
|
// https://github.com/gulpjs/interpret
|
||||||
const transpilers = [
|
const transpilers = [
|
||||||
'esbin/register',
|
|
||||||
'esbuild-register',
|
'esbuild-register',
|
||||||
'ts-node/register/transpile-only',
|
'ts-node/register/transpile-only',
|
||||||
'@swc/register',
|
'@swc/register',
|
||||||
|
@ -4,7 +4,7 @@ import restrictedGlobals from './_restrictedGlobals.json';
|
|||||||
|
|
||||||
export const eslintRules: Partial<EslintRulesObject> = {
|
export const eslintRules: Partial<EslintRulesObject> = {
|
||||||
'arrow-body-style': [error, 'as-needed'],
|
'arrow-body-style': [error, 'as-needed'],
|
||||||
'class-methods-use-this': off,
|
'class-methods-use-this': warn,
|
||||||
'func-style': [error, 'declaration', { allowArrowFunctions: true }],
|
'func-style': [error, 'declaration', { allowArrowFunctions: true }],
|
||||||
'no-async-promise-executor': off,
|
'no-async-promise-executor': off,
|
||||||
'no-case-declarations': off,
|
'no-case-declarations': off,
|
||||||
@ -31,7 +31,7 @@ export const eslintRules: Partial<EslintRulesObject> = {
|
|||||||
'no-template-curly-in-string': error,
|
'no-template-curly-in-string': error,
|
||||||
'no-var': error,
|
'no-var': error,
|
||||||
'object-shorthand': [error, 'always', { ignoreConstructors: true }],
|
'object-shorthand': [error, 'always', { ignoreConstructors: true }],
|
||||||
'one-var': [error, { var: 'never', let: 'never' }],
|
'one-var': [error, { var: 'never', let: 'never', const: 'never' }],
|
||||||
'prefer-arrow-callback': error,
|
'prefer-arrow-callback': error,
|
||||||
'prefer-const': [error, { destructuring: 'all' }],
|
'prefer-const': [error, { destructuring: 'all' }],
|
||||||
'prefer-destructuring': [
|
'prefer-destructuring': [
|
||||||
|
@ -2,8 +2,6 @@ import { error, off } from '../constants';
|
|||||||
import { ReactRulesObject } from '@aet/eslint-define-config/src/rules/react';
|
import { ReactRulesObject } from '@aet/eslint-define-config/src/rules/react';
|
||||||
|
|
||||||
export const reactRules: Partial<ReactRulesObject> = {
|
export const reactRules: Partial<ReactRulesObject> = {
|
||||||
'react/display-name': off,
|
'@eslint-react/no-missing-component-display-name': off,
|
||||||
'react/no-children-prop': error,
|
'@eslint-react/no-children-prop': error,
|
||||||
'react/prop-types': off,
|
|
||||||
'react/react-in-jsx-scope': off,
|
|
||||||
};
|
};
|
||||||
|
@ -4,12 +4,10 @@ const { name } = [require][0]('./package.json');
|
|||||||
const _resolveFilename = Module._resolveFilename;
|
const _resolveFilename = Module._resolveFilename;
|
||||||
const alias = new Set([
|
const alias = new Set([
|
||||||
'eslint-import-resolver-typescript',
|
'eslint-import-resolver-typescript',
|
||||||
'eslint-plugin-import',
|
|
||||||
'eslint-plugin-jsx-a11y',
|
'eslint-plugin-jsx-a11y',
|
||||||
'eslint-plugin-local',
|
'eslint-plugin-local',
|
||||||
'eslint-plugin-n',
|
'eslint-plugin-n',
|
||||||
'eslint-plugin-react-hooks',
|
'eslint-plugin-react-hooks',
|
||||||
'eslint-plugin-react',
|
|
||||||
'eslint-plugin-rules',
|
'eslint-plugin-rules',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user