This commit is contained in:
Alex
2023-07-30 20:43:14 -04:00
parent 08cf6729ae
commit 13f2f75acf
11 changed files with 378 additions and 127 deletions

7
README.md Normal file
View File

@ -0,0 +1,7 @@
# eslint-rules
## flat config support
- ❌ [import](https://github.com/import-js/eslint-plugin-import/issues/2556)
- ✅ [react](https://github.com/jsx-eslint/eslint-plugin-react/pull/3429)
- 🇵🇷 [a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/pull/891)

2
dist/basic.d.ts vendored
View File

@ -1,2 +1,2 @@
import type { ESLintConfig } from 'eslint-define-config'; import type { ESLintConfig } from 'eslint-define-config';
export declare function extendConfig({ plugins, settings, rules, ...config }: ESLintConfig): ESLintConfig; export declare function extendConfig({ plugins, settings, rules, extends: _extends, ...rest }: ESLintConfig): ESLintConfig;

2
dist/package.json vendored
View File

@ -1,6 +1,6 @@
{ {
"name": "@aet/eslint-rules", "name": "@aet/eslint-rules",
"version": "0.0.1-beta.17", "version": "0.0.1-beta.21",
"license": "UNLICENSED", "license": "UNLICENSED",
"peerDependencies": { "peerDependencies": {
"typescript": "^5.1.6" "typescript": "^5.1.6"

View File

@ -1,7 +1,7 @@
{ {
"name": "@aet/eslint-configs", "name": "@aet/eslint-configs",
"scripts": { "scripts": {
"build": "./esbuild.ts", "build": "./build.sh",
"check-import": "for js in dist/*.js; do cat $js | grep 'require('; done" "check-import": "for js in dist/*.js; do cat $js | grep 'require('; done"
}, },
"private": true, "private": true,
@ -27,6 +27,7 @@
"eslint-config-prettier": "8.8.0", "eslint-config-prettier": "8.8.0",
"eslint-define-config": "^1.21.0", "eslint-define-config": "^1.21.0",
"eslint-plugin-import": "^2.27.5", "eslint-plugin-import": "^2.27.5",
"eslint-plugin-unicorn": "^48.0.1",
"glob": "^10.3.3", "glob": "^10.3.3",
"json-schema-to-ts": "^2.9.1", "json-schema-to-ts": "^2.9.1",
"lodash": "^4.17.21", "lodash": "^4.17.21",

View File

@ -26,10 +26,10 @@ index 883c03b7..0111d616 100644
} }
diff --git a/.eslintrc b/.eslintrc diff --git a/.eslintrc b/.eslintrc
deleted file mode 100644 deleted file mode 100644
index 709a4744..00000000 index 932055e8..00000000
--- a/.eslintrc --- a/.eslintrc
+++ /dev/null +++ /dev/null
@@ -1,247 +0,0 @@ @@ -1,248 +0,0 @@
-{ -{
- "root": true, - "root": true,
- "plugins": [ - "plugins": [
@ -51,6 +51,7 @@ index 709a4744..00000000
- "ecmaVersion": 2020, - "ecmaVersion": 2020,
- }, - },
- "rules": { - "rules": {
- "array-bracket-spacing": [2, "never"],
- "arrow-body-style": [2, "as-needed"], - "arrow-body-style": [2, "as-needed"],
- "arrow-parens": [2, "always"], - "arrow-parens": [2, "always"],
- "arrow-spacing": [2, { "before": true, "after": true }], - "arrow-spacing": [2, { "before": true, "after": true }],
@ -607,3 +608,15 @@ index feafba90..9a464041 100644
+ ) + )
+} +}
\ No newline at end of file \ No newline at end of file
diff --git a/src/rules/imports-first.js b/src/rules/imports-first.js
index 966367e9..3881d383 100644
--- a/src/rules/imports-first.js
+++ b/src/rules/imports-first.js
@@ -1,6 +1,6 @@
import docsUrl from '../docsUrl';
-const first = require('./first');
+import first from './first';
const newMeta = {
...first.meta,

View File

@ -211,7 +211,7 @@ index a1bb4811..db051356 100644
const docsUrl = require('../util/docsUrl'); const docsUrl = require('../util/docsUrl');
const jsxUtil = require('../util/jsx'); const jsxUtil = require('../util/jsx');
diff --git a/lib/rules/jsx-sort-props.js b/lib/rules/jsx-sort-props.js diff --git a/lib/rules/jsx-sort-props.js b/lib/rules/jsx-sort-props.js
index 5de5bee1..8013a8de 100644 index 6d19f201..4b1849cc 100644
--- a/lib/rules/jsx-sort-props.js --- a/lib/rules/jsx-sort-props.js
+++ b/lib/rules/jsx-sort-props.js +++ b/lib/rules/jsx-sort-props.js
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
@ -284,7 +284,7 @@ index 55073bfe..efc07af1 100644
const astUtil = require('./ast'); const astUtil = require('./ast');
const isCreateElement = require('./isCreateElement'); const isCreateElement = require('./isCreateElement');
diff --git a/package.json b/package.json diff --git a/package.json b/package.json
index b1fa86fa..758b2177 100644 index e37bae08..5bfa4b9f 100644
--- a/package.json --- a/package.json
+++ b/package.json +++ b/package.json
@@ -25,21 +25,13 @@ @@ -25,21 +25,13 @@

View File

@ -71,12 +71,12 @@ index 0f1cd04..bfed363 100644
+export { hasProp } from './src'; +export { hasProp } from './src';
\ No newline at end of file \ No newline at end of file
diff --git a/package.json b/package.json diff --git a/package.json b/package.json
index 40f7947..4759eca 100644 index f77b766..3e6d321 100644
--- a/package.json --- a/package.json
+++ b/package.json +++ b/package.json
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
"name": "jsx-ast-utils", "name": "jsx-ast-utils",
"version": "3.3.4", "version": "3.3.5",
"description": "AST utility module for statically analyzing JSX", "description": "AST utility module for statically analyzing JSX",
- "main": "lib/index.js", - "main": "lib/index.js",
+ "main": "src/index.js", + "main": "src/index.js",

224
pnpm-lock.yaml generated
View File

@ -68,6 +68,9 @@ devDependencies:
eslint-plugin-import: eslint-plugin-import:
specifier: ^2.27.5 specifier: ^2.27.5
version: 2.27.5(eslint@8.45.0) version: 2.27.5(eslint@8.45.0)
eslint-plugin-unicorn:
specifier: ^48.0.1
version: 48.0.1(eslint@8.45.0)
glob: glob:
specifier: ^10.3.3 specifier: ^10.3.3
version: 10.3.3 version: 10.3.3
@ -1756,6 +1759,10 @@ packages:
resolution: {integrity: sha512-Dd0BYtWgnWJKwO1jkmTrzofjK2QXXcai0dmtzvIBhcA+RsG5h8R3xlyta0kGOZRNfL9GuRtb1knmPEhQrePCEw==} resolution: {integrity: sha512-Dd0BYtWgnWJKwO1jkmTrzofjK2QXXcai0dmtzvIBhcA+RsG5h8R3xlyta0kGOZRNfL9GuRtb1knmPEhQrePCEw==}
dev: true dev: true
/@types/normalize-package-data@2.4.1:
resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==}
dev: true
/@types/parse-json@4.0.0: /@types/parse-json@4.0.0:
resolution: {integrity: sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==} resolution: {integrity: sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==}
dev: true dev: true
@ -1941,6 +1948,11 @@ packages:
resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==}
dev: true dev: true
/builtin-modules@3.3.0:
resolution: {integrity: sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==}
engines: {node: '>=6'}
dev: true
/call-bind@1.0.2: /call-bind@1.0.2:
resolution: {integrity: sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==} resolution: {integrity: sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==}
dependencies: dependencies:
@ -1974,6 +1986,18 @@ packages:
supports-color: 7.2.0 supports-color: 7.2.0
dev: true dev: true
/ci-info@3.8.0:
resolution: {integrity: sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==}
engines: {node: '>=8'}
dev: true
/clean-regexp@1.0.0:
resolution: {integrity: sha512-GfisEZEJvzKrmGWkvfhgzcz/BllN1USeqD2V6tg14OAOgaCD2Z/PUEuxnAZ/nPvmaHRG7a8y77p1T/IRQ4D1Hw==}
engines: {node: '>=4'}
dependencies:
escape-string-regexp: 1.0.5
dev: true
/cliui@8.0.1: /cliui@8.0.1:
resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==}
engines: {node: '>=12'} engines: {node: '>=12'}
@ -2342,6 +2366,30 @@ packages:
- supports-color - supports-color
dev: true dev: true
/eslint-plugin-unicorn@48.0.1(eslint@8.45.0):
resolution: {integrity: sha512-FW+4r20myG/DqFcCSzoumaddKBicIPeFnTrifon2mWIzlfyvzwyqZjqVP7m4Cqr/ZYisS2aiLghkUWaPg6vtCw==}
engines: {node: '>=16'}
peerDependencies:
eslint: '>=8.44.0'
dependencies:
'@babel/helper-validator-identifier': 7.22.5
'@eslint-community/eslint-utils': 4.4.0(eslint@8.45.0)
ci-info: 3.8.0
clean-regexp: 1.0.0
eslint: 8.45.0
esquery: 1.5.0
indent-string: 4.0.0
is-builtin-module: 3.2.1
jsesc: 3.0.2
lodash: 4.17.21
pluralize: 8.0.0
read-pkg-up: 7.0.1
regexp-tree: 0.1.27
regjsparser: 0.10.0
semver: 7.5.4
strip-indent: 3.0.0
dev: true
/eslint-scope@7.2.0: /eslint-scope@7.2.0:
resolution: {integrity: sha512-DYj5deGlHBfMt15J7rdtyKNq/Nqlv5KfU4iodrQ019XESsRnwXH9KAE0y3cwtUHDo2ob7CypAnCqefh6vioWRw==} resolution: {integrity: sha512-DYj5deGlHBfMt15J7rdtyKNq/Nqlv5KfU4iodrQ019XESsRnwXH9KAE0y3cwtUHDo2ob7CypAnCqefh6vioWRw==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
@ -2459,6 +2507,14 @@ packages:
flat-cache: 3.0.4 flat-cache: 3.0.4
dev: true dev: true
/find-up@4.1.0:
resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==}
engines: {node: '>=8'}
dependencies:
locate-path: 5.0.0
path-exists: 4.0.0
dev: true
/find-up@5.0.0: /find-up@5.0.0:
resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==} resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==}
engines: {node: '>=10'} engines: {node: '>=10'}
@ -2645,6 +2701,10 @@ packages:
function-bind: 1.1.1 function-bind: 1.1.1
dev: true dev: true
/hosted-git-info@2.8.9:
resolution: {integrity: sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==}
dev: true
/ignore@5.2.4: /ignore@5.2.4:
resolution: {integrity: sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==} resolution: {integrity: sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==}
engines: {node: '>= 4'} engines: {node: '>= 4'}
@ -2663,6 +2723,11 @@ packages:
engines: {node: '>=0.8.19'} engines: {node: '>=0.8.19'}
dev: true dev: true
/indent-string@4.0.0:
resolution: {integrity: sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==}
engines: {node: '>=8'}
dev: true
/inflight@1.0.6: /inflight@1.0.6:
resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==}
dependencies: dependencies:
@ -2709,6 +2774,13 @@ packages:
has-tostringtag: 1.0.0 has-tostringtag: 1.0.0
dev: true dev: true
/is-builtin-module@3.2.1:
resolution: {integrity: sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==}
engines: {node: '>=6'}
dependencies:
builtin-modules: 3.3.0
dev: true
/is-callable@1.2.7: /is-callable@1.2.7:
resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==} resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==}
engines: {node: '>= 0.4'} engines: {node: '>= 0.4'}
@ -2846,6 +2918,12 @@ packages:
hasBin: true hasBin: true
dev: true dev: true
/jsesc@3.0.2:
resolution: {integrity: sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==}
engines: {node: '>=6'}
hasBin: true
dev: true
/json-parse-even-better-errors@2.3.1: /json-parse-even-better-errors@2.3.1:
resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==}
dev: true dev: true
@ -2892,6 +2970,13 @@ packages:
resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==}
dev: true dev: true
/locate-path@5.0.0:
resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==}
engines: {node: '>=8'}
dependencies:
p-locate: 4.1.0
dev: true
/locate-path@6.0.0: /locate-path@6.0.0:
resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==}
engines: {node: '>=10'} engines: {node: '>=10'}
@ -2917,11 +3002,23 @@ packages:
yallist: 3.1.1 yallist: 3.1.1
dev: true dev: true
/lru-cache@6.0.0:
resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==}
engines: {node: '>=10'}
dependencies:
yallist: 4.0.0
dev: true
/lru-cache@9.1.1: /lru-cache@9.1.1:
resolution: {integrity: sha512-65/Jky17UwSb0BuB9V+MyDpsOtXKmYwzhyl+cOa9XUiI4uV2Ouy/2voFP3+al0BjZbJgMBD8FojMpAf+Z+qn4A==} resolution: {integrity: sha512-65/Jky17UwSb0BuB9V+MyDpsOtXKmYwzhyl+cOa9XUiI4uV2Ouy/2voFP3+al0BjZbJgMBD8FojMpAf+Z+qn4A==}
engines: {node: 14 || >=16.14} engines: {node: 14 || >=16.14}
dev: true dev: true
/min-indent@1.0.1:
resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==}
engines: {node: '>=4'}
dev: true
/minimatch@3.1.2: /minimatch@3.1.2:
resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==}
dependencies: dependencies:
@ -2956,6 +3053,15 @@ packages:
resolution: {integrity: sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==} resolution: {integrity: sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==}
dev: true dev: true
/normalize-package-data@2.5.0:
resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==}
dependencies:
hosted-git-info: 2.8.9
resolve: 1.22.2
semver: 5.7.2
validate-npm-package-license: 3.0.4
dev: true
/object-inspect@1.12.3: /object-inspect@1.12.3:
resolution: {integrity: sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==} resolution: {integrity: sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==}
dev: true dev: true
@ -3002,6 +3108,13 @@ packages:
type-check: 0.4.0 type-check: 0.4.0
dev: true dev: true
/p-limit@2.3.0:
resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==}
engines: {node: '>=6'}
dependencies:
p-try: 2.2.0
dev: true
/p-limit@3.1.0: /p-limit@3.1.0:
resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==}
engines: {node: '>=10'} engines: {node: '>=10'}
@ -3009,6 +3122,13 @@ packages:
yocto-queue: 0.1.0 yocto-queue: 0.1.0
dev: true dev: true
/p-locate@4.1.0:
resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==}
engines: {node: '>=8'}
dependencies:
p-limit: 2.3.0
dev: true
/p-locate@5.0.0: /p-locate@5.0.0:
resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==} resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==}
engines: {node: '>=10'} engines: {node: '>=10'}
@ -3016,6 +3136,11 @@ packages:
p-limit: 3.1.0 p-limit: 3.1.0
dev: true dev: true
/p-try@2.2.0:
resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==}
engines: {node: '>=6'}
dev: true
/parent-module@1.0.1: /parent-module@1.0.1:
resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==}
engines: {node: '>=6'} engines: {node: '>=6'}
@ -3074,6 +3199,11 @@ packages:
engines: {node: '>= 6'} engines: {node: '>= 6'}
dev: true dev: true
/pluralize@8.0.0:
resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==}
engines: {node: '>=4'}
dev: true
/prelude-ls@1.2.1: /prelude-ls@1.2.1:
resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==}
engines: {node: '>= 0.8.0'} engines: {node: '>= 0.8.0'}
@ -3094,6 +3224,25 @@ packages:
resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
dev: true dev: true
/read-pkg-up@7.0.1:
resolution: {integrity: sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==}
engines: {node: '>=8'}
dependencies:
find-up: 4.1.0
read-pkg: 5.2.0
type-fest: 0.8.1
dev: true
/read-pkg@5.2.0:
resolution: {integrity: sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==}
engines: {node: '>=8'}
dependencies:
'@types/normalize-package-data': 2.4.1
normalize-package-data: 2.5.0
parse-json: 5.2.0
type-fest: 0.6.0
dev: true
/regenerate-unicode-properties@10.1.0: /regenerate-unicode-properties@10.1.0:
resolution: {integrity: sha512-d1VudCLoIGitcU/hEg2QqvyGZQmdC0Lf8BqdOMXGFSvJP4bNV1+XqbPQeHHLD51Jh4QJJ225dlIFvY4Ly6MXmQ==} resolution: {integrity: sha512-d1VudCLoIGitcU/hEg2QqvyGZQmdC0Lf8BqdOMXGFSvJP4bNV1+XqbPQeHHLD51Jh4QJJ225dlIFvY4Ly6MXmQ==}
engines: {node: '>=4'} engines: {node: '>=4'}
@ -3115,6 +3264,11 @@ packages:
'@babel/runtime': 7.21.5 '@babel/runtime': 7.21.5
dev: true dev: true
/regexp-tree@0.1.27:
resolution: {integrity: sha512-iETxpjK6YoRWJG5o6hXLwvjYAoW+FEZn9os0PD/b6AP6xQwsa/Y7lCVgIixBbUPMfhu+i2LtdeAqVTgGlQarfA==}
hasBin: true
dev: true
/regexp.prototype.flags@1.5.0: /regexp.prototype.flags@1.5.0:
resolution: {integrity: sha512-0SutC3pNudRKgquxGoRGIz946MZVHqbNfPjBdxeOhBrdgDKlRoXmYLQN9xRbrR09ZXWeGAdPuif7egofn6v5LA==} resolution: {integrity: sha512-0SutC3pNudRKgquxGoRGIz946MZVHqbNfPjBdxeOhBrdgDKlRoXmYLQN9xRbrR09ZXWeGAdPuif7egofn6v5LA==}
engines: {node: '>= 0.4'} engines: {node: '>= 0.4'}
@ -3136,6 +3290,13 @@ packages:
unicode-match-property-value-ecmascript: 2.1.0 unicode-match-property-value-ecmascript: 2.1.0
dev: true dev: true
/regjsparser@0.10.0:
resolution: {integrity: sha512-qx+xQGZVsy55CH0a1hiVwHmqjLryfh7wQyF5HO07XJ9f7dQMY/gPQHhlyDkIzJKC+x2fUCpCcUODUUUFrm7SHA==}
hasBin: true
dependencies:
jsesc: 0.5.0
dev: true
/regjsparser@0.9.1: /regjsparser@0.9.1:
resolution: {integrity: sha512-dQUtn90WanSNl+7mQKcXAgZxvUe7Z0SqXlgzv0za4LwiUhyzBC58yQO3liFoUgu8GiJVInAhJjkj1N0EtQ5nkQ==} resolution: {integrity: sha512-dQUtn90WanSNl+7mQKcXAgZxvUe7Z0SqXlgzv0za4LwiUhyzBC58yQO3liFoUgu8GiJVInAhJjkj1N0EtQ5nkQ==}
hasBin: true hasBin: true
@ -3188,11 +3349,24 @@ packages:
is-regex: 1.1.4 is-regex: 1.1.4
dev: true dev: true
/semver@5.7.2:
resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==}
hasBin: true
dev: true
/semver@6.3.1: /semver@6.3.1:
resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==}
hasBin: true hasBin: true
dev: true dev: true
/semver@7.5.4:
resolution: {integrity: sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==}
engines: {node: '>=10'}
hasBin: true
dependencies:
lru-cache: 6.0.0
dev: true
/shebang-command@2.0.0: /shebang-command@2.0.0:
resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==}
engines: {node: '>=8'} engines: {node: '>=8'}
@ -3235,6 +3409,28 @@ packages:
engines: {node: '>= 8'} engines: {node: '>= 8'}
dev: true dev: true
/spdx-correct@3.2.0:
resolution: {integrity: sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==}
dependencies:
spdx-expression-parse: 3.0.1
spdx-license-ids: 3.0.13
dev: true
/spdx-exceptions@2.3.0:
resolution: {integrity: sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==}
dev: true
/spdx-expression-parse@3.0.1:
resolution: {integrity: sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==}
dependencies:
spdx-exceptions: 2.3.0
spdx-license-ids: 3.0.13
dev: true
/spdx-license-ids@3.0.13:
resolution: {integrity: sha512-XkD+zwiqXHikFZm4AX/7JSCXA98U5Db4AFd5XUg/+9UNtnH75+Z9KxtpYiJZx36mUDVOwH83pl7yvCer6ewM3w==}
dev: true
/string-width@4.2.3: /string-width@4.2.3:
resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==}
engines: {node: '>=8'} engines: {node: '>=8'}
@ -3297,6 +3493,13 @@ packages:
engines: {node: '>=4'} engines: {node: '>=4'}
dev: true dev: true
/strip-indent@3.0.0:
resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==}
engines: {node: '>=8'}
dependencies:
min-indent: 1.0.1
dev: true
/strip-json-comments@3.1.1: /strip-json-comments@3.1.1:
resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==}
engines: {node: '>=8'} engines: {node: '>=8'}
@ -3364,6 +3567,16 @@ packages:
engines: {node: '>=10'} engines: {node: '>=10'}
dev: true dev: true
/type-fest@0.6.0:
resolution: {integrity: sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==}
engines: {node: '>=8'}
dev: true
/type-fest@0.8.1:
resolution: {integrity: sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==}
engines: {node: '>=8'}
dev: true
/typed-array-length@1.0.4: /typed-array-length@1.0.4:
resolution: {integrity: sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng==} resolution: {integrity: sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng==}
dependencies: dependencies:
@ -3427,6 +3640,13 @@ packages:
punycode: 2.3.0 punycode: 2.3.0
dev: true dev: true
/validate-npm-package-license@3.0.4:
resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==}
dependencies:
spdx-correct: 3.2.0
spdx-expression-parse: 3.0.1
dev: true
/which-boxed-primitive@1.0.2: /which-boxed-primitive@1.0.2:
resolution: {integrity: sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==} resolution: {integrity: sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==}
dependencies: dependencies:
@ -3488,6 +3708,10 @@ packages:
resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==}
dev: true dev: true
/yallist@4.0.0:
resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==}
dev: true
/yaml@1.10.2: /yaml@1.10.2:
resolution: {integrity: sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==} resolution: {integrity: sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==}
engines: {node: '>= 6'} engines: {node: '>= 6'}

View File

@ -1,38 +1,56 @@
// @ts-check // @ts-check
import type { ESLintConfig } from 'eslint-define-config'; import type { ESLintConfig } from 'eslint-define-config';
function unique<T>(arr: T[]): T[] {
return [...new Set(arr)];
}
const error = 'error';
const warn = 'warn';
const off = 'off';
export function extendConfig({ export function extendConfig({
plugins, plugins,
settings, settings,
rules, rules,
...config extends: _extends,
...rest
}: ESLintConfig): ESLintConfig { }: ESLintConfig): ESLintConfig {
return { const hasReact = plugins?.includes('react');
const hasUnicorn = plugins?.includes('unicorn');
const result: ESLintConfig = {
root: true, root: true,
parser: '@typescript-eslint/parser', parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'import', ...(plugins ?? [])], plugins: unique(['@typescript-eslint', 'import', ...(plugins ?? [])]),
env: { node: true, browser: true }, env: { node: true, browser: true, es2023: true },
reportUnusedDisableDirectives: true, reportUnusedDisableDirectives: true,
parserOptions: { project: ['./tsconfig.json'] }, parserOptions: {
extends: [ project: ['./tsconfig.json'],
},
extends: unique([
'eslint:recommended', 'eslint:recommended',
'prettier', 'prettier',
'plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/recommended-type-checked',
'plugin:import/errors', 'plugin:import/errors',
'plugin:import/typescript', 'plugin:import/typescript',
...(hasReact
? [
'plugin:react/recommended', 'plugin:react/recommended',
'plugin:react-hooks/recommended', 'plugin:react-hooks/recommended',
'plugin:jsx-a11y/recommended', 'plugin:jsx-a11y/recommended',
], ]
: []),
...(hasUnicorn ? ['plugin:unicorn/recommended'] : []),
...(_extends ?? []),
]),
settings: { settings: {
'import/parsers': { 'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'], '@typescript-eslint/parser': ['.ts', '.tsx', '.mts', '.cts'],
}, },
'import/core-modules': ['node:test'],
'import/resolver': { 'import/resolver': {
typescript: { typescript: {
alwaysTryTypes: true, alwaysTryTypes: true,
project: './tsconfig.json',
}, },
}, },
react: { react: {
@ -41,9 +59,9 @@ export function extendConfig({
...settings, ...settings,
}, },
rules: { rules: {
'no-duplicate-imports': 'error', 'no-duplicate-imports': error,
'no-restricted-imports': [ 'no-restricted-imports': [
'error', error,
{ {
paths: [ paths: [
{ {
@ -54,78 +72,104 @@ export function extendConfig({
], ],
}, },
], ],
'no-restricted-globals': ['error', 'event', 'name'], 'no-restricted-globals': [error, 'event', 'name', 'length'],
'@typescript-eslint/ban-ts-comment': 'off', '@typescript-eslint/ban-ts-comment': [
error,
{
'ts-expect-error': 'allow-with-description',
'ts-check': false,
'ts-ignore': 'allow-with-description',
'ts-nocheck': 'allow-with-description',
},
],
'@typescript-eslint/consistent-type-imports': [ '@typescript-eslint/consistent-type-imports': [
'error', error,
{ disallowTypeAnnotations: false, fixStyle: 'inline-type-imports' }, { disallowTypeAnnotations: false, fixStyle: 'inline-type-imports' },
], ],
'@typescript-eslint/ban-types': [ '@typescript-eslint/ban-types': [error, { extendDefaults: true }],
'error', '@typescript-eslint/no-empty-interface': [error, { allowSingleExtends: true }],
{ '@typescript-eslint/no-explicit-any': off,
extendDefaults: false, '@typescript-eslint/no-extraneous-class': error,
types: { '@typescript-eslint/no-namespace': off,
String: { message: 'Use string instead', fixWith: 'string' }, '@typescript-eslint/no-unnecessary-type-assertion': error,
Number: { message: 'Use number instead', fixWith: 'number' }, '@typescript-eslint/no-unsafe-argument': off,
Boolean: { message: 'Use boolean instead', fixWith: 'boolean' }, '@typescript-eslint/no-unsafe-assignment': off,
Symbol: { message: 'Use symbol instead', fixWith: 'symbol' }, '@typescript-eslint/no-unsafe-member-access': off,
}, '@typescript-eslint/no-unsafe-call': off,
}, '@typescript-eslint/no-unsafe-return': off,
],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unused-vars': [ '@typescript-eslint/no-unused-vars': [
'error', error,
{ ignoreRestSiblings: true, varsIgnorePattern: '^_' }, { ignoreRestSiblings: true, varsIgnorePattern: '^_' },
], ],
'arrow-body-style': ['error', 'as-needed'], '@typescript-eslint/no-use-before-define': off,
'class-methods-use-this': 'off', '@typescript-eslint/no-var-requires': off,
complexity: ['warn', { max: 100 }], '@typescript-eslint/unbound-method': off,
curly: ['error', 'multi-line', 'consistent'], '@typescript-eslint/triple-slash-reference': off,
eqeqeq: ['error', 'smart'], 'arrow-body-style': [error, 'as-needed'],
'no-async-promise-executor': 'off', 'class-methods-use-this': off,
'no-case-declarations': 'off', complexity: [warn, { max: 100 }],
'no-console': 'warn', curly: [error, 'multi-line', 'consistent'],
'no-constant-condition': ['error', { checkLoops: false }], eqeqeq: [error, 'smart'],
'no-debugger': 'off', 'no-async-promise-executor': off,
'no-empty': ['error', { allowEmptyCatch: true }], 'no-case-declarations': off,
'no-inner-declarations': 'off', 'no-console': warn,
'no-lonely-if': 'error', 'no-constant-condition': [error, { checkLoops: false }],
'no-template-curly-in-string': 'error', 'no-debugger': warn,
'no-var': 'error', 'no-empty': [error, { allowEmptyCatch: true }],
'import/export': 'off', 'no-inner-declarations': off,
'import/order': ['error', { groups: ['builtin', 'external'] }], 'no-lonely-if': error,
'object-shorthand': ['error', 'always', { ignoreConstructors: true }], 'no-template-curly-in-string': error,
'one-var': ['error', { var: 'never', let: 'never' }], 'no-var': error,
'prefer-arrow-callback': 'error', 'import/export': off,
'prefer-const': ['error', { destructuring: 'all' }], 'import/order': [error, { groups: ['builtin', 'external'] }],
'object-shorthand': [error, 'always', { ignoreConstructors: true }],
'one-var': [error, { var: 'never', let: 'never' }],
'prefer-arrow-callback': error,
'prefer-const': [error, { destructuring: 'all' }],
'prefer-destructuring': [ 'prefer-destructuring': [
'warn', warn,
{ AssignmentExpression: { array: false, object: false } }, { AssignmentExpression: { array: false, object: false } },
], ],
'prefer-object-spread': 'error', 'prefer-object-spread': error,
'prefer-rest-params': 'warn', 'prefer-rest-params': warn,
'prefer-spread': 'warn', 'prefer-spread': warn,
'quote-props': ['error', 'as-needed'], 'quote-props': [error, 'as-needed'],
'spaced-comment': ['error', 'always', { markers: ['/'] }], 'spaced-comment': [error, 'always', { markers: ['/'] }],
'sort-imports': ['warn', { ignoreDeclarationSort: true }], 'sort-imports': [warn, { ignoreDeclarationSort: true }],
yoda: ['error', 'never', { exceptRange: true }], yoda: [error, 'never', { exceptRange: true }],
'react/display-name': 'off', ...(hasReact
'react/no-children-prop': 'error', ? {
'react/prop-types': 'off', 'react/display-name': off,
'react/react-in-jsx-scope': 'off', 'react/no-children-prop': error,
'react/no-unknown-property': ['error', { ignore: ['css'] }], 'react/prop-types': off,
'react/react-in-jsx-scope': off,
'react/no-unknown-property': [error, { ignore: ['css'] }],
}
: {}),
...(hasUnicorn
? {
'unicorn/no-abusive-eslint-disable': off,
'unicorn/no-array-callback-reference': off,
'unicorn/no-array-for-each': warn,
'unicorn/no-array-reduce': off,
'unicorn/no-await-expression-member': off,
'unicorn/no-empty-file': off,
'unicorn/no-negated-condition': warn,
'unicorn/no-new-array': off,
'unicorn/no-null': off,
'unicorn/no-process-exit': off,
'unicorn/no-this-assignment': off,
'unicorn/prefer-module': off,
'unicorn/prefer-string-replace-all': off,
'unicorn/prefer-top-level-await': off,
'unicorn/throw-new-error': off,
'unicorn/no-unnecessary-await': off,
}
: {}),
...rules, ...rules,
}, },
...config, ...rest,
}; };
return result;
} }

View File

@ -1,9 +1,7 @@
import type { Rule } from 'eslint'; import type { Rule } from 'eslint';
import noImportDot from "./no-import-dot"; import noImportDot from "./no-import-dot"
import requireNodePrefix from "./require-node-prefix"
export const rules: Record<string, Rule.RuleModule> = { export const rules: Record<string, Rule.RuleModule> = {
"no-import-dot": noImportDot, "no-import-dot": noImportDot
"require-node-prefix": requireNodePrefix
}; };

View File

@ -1,36 +0,0 @@
// @ts-check
import { builtinModules } from "node:module";
import type { Rule } from "eslint";
const rule: Rule.RuleModule = {
meta: {
type: "problem",
docs: {
description:
"Disallow imports of built-in Node.js modules without the `node:` prefix",
category: "Best Practices",
recommended: true,
},
fixable: "code",
schema: [],
},
create: context => ({
ImportDeclaration(node) {
const { source } = node;
if (source?.type === "Literal" && typeof source.value === "string") {
const moduleName = source.value;
if (builtinModules.includes(moduleName) && !moduleName.startsWith("node:")) {
context.report({
node: source,
message: `Import of built-in Node.js module "${moduleName}" must use the "node:" prefix.`,
fix: fixer => fixer.replaceText(source, `"node:${moduleName}"`),
});
}
}
},
}),
};
export default rule;