From 55a46104da6af9da8a58d8e3f424de740afd9eac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20LUDWIG?= Date: Mon, 7 Oct 2024 17:42:09 +0200 Subject: [PATCH] feat!: add `eslint-plugin-import-x` rules BREAKING CHANGE: peerDependencies: `eslint-plugin-import-x@^4.3.1` Fixes #3 --- README.md | 2 + eslint.config.js | 13 +++++ package-lock.json | 125 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 + 4 files changed, 142 insertions(+) diff --git a/README.md b/README.md index d5f68a1..b8c4abc 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ npm install --save-dev \ eslint@^9.12.0 \ eslint-plugin-promise@^7.1.0 \ eslint-plugin-unicorn@^56.0.0 \ + eslint-plugin-import-x@^4.3.1 \ globals@^15.10.0 \ "typescript@~5.5.4" \ "typescript-eslint@^8.8.0" \ @@ -50,6 +51,7 @@ Dependencies are: - [ESLint Plugins](https://eslint.org/docs/user-guide/configuring/plugins) - [eslint-plugin-promise](https://github.com/xjamundx/eslint-plugin-promise) - [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) + - [eslint-plugin-import-x](https://github.com/un-ts/eslint-plugin-import-x) - [globals](https://github.com/sindresorhus/globals) - [TypeScript](https://github.com/Microsoft/TypeScript) - [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint): tooling which enables ESLint to support TypeScript. diff --git a/eslint.config.js b/eslint.config.js index e794b1b..9c37760 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,5 +1,6 @@ import promise from "eslint-plugin-promise" import unicorn from "eslint-plugin-unicorn" +import importX from "eslint-plugin-import-x" import globals from "globals" import typescriptESLint from "typescript-eslint" @@ -9,6 +10,7 @@ export default typescriptESLint.config( plugins: { promise, unicorn, + "import-x": importX, }, linterOptions: { reportUnusedDisableDirectives: "error", @@ -240,6 +242,17 @@ export default typescriptESLint.config( "unicorn/prefer-modern-math-apis": "error", "unicorn/prefer-structured-clone": "error", "unicorn/template-indent": "error", + + "import-x/no-absolute-path": "error", + "import-x/no-webpack-loader-syntax": "error", + "import-x/no-self-import": "error", + "import-x/no-useless-path-segments": "error", + "import-x/export": "error", + "import-x/no-duplicates": "error", + "import-x/no-named-default": "error", + "import-x/no-empty-named-blocks": "error", + "import-x/no-anonymous-default-export": "error", + "import-x/consistent-type-specifier-style": ["error", "prefer-top-level"], }, }, { diff --git a/package-lock.json b/package-lock.json index dbeb403..0bfc810 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "@types/node": "22.7.4", "editorconfig-checker": "6.0.0", "eslint": "9.12.0", + "eslint-plugin-import-x": "4.3.1", "eslint-plugin-promise": "7.1.0", "eslint-plugin-unicorn": "56.0.0", "globals": "15.10.0", @@ -26,6 +27,7 @@ }, "peerDependencies": { "eslint": "^9.12.0", + "eslint-plugin-import-x": "^4.3.1", "eslint-plugin-promise": "^7.1.0", "eslint-plugin-unicorn": "^56.0.0", "globals": "^15.10.0", @@ -1934,6 +1936,19 @@ "node": ">=8" } }, + "node_modules/doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/dot-prop": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz", @@ -2229,6 +2244,79 @@ } } }, + "node_modules/eslint-import-resolver-node": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", + "integrity": "sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^3.2.7", + "is-core-module": "^2.13.0", + "resolve": "^1.22.4" + } + }, + "node_modules/eslint-import-resolver-node/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-plugin-import-x": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-import-x/-/eslint-plugin-import-x-4.3.1.tgz", + "integrity": "sha512-5TriWkXulDl486XnYYRgsL+VQoS/7mhN/2ci02iLCuL7gdhbiWxnsuL/NTcaKY9fpMgsMFjWZBtIGW7pb+RX0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/utils": "^8.1.0", + "debug": "^4.3.4", + "doctrine": "^3.0.0", + "eslint-import-resolver-node": "^0.3.9", + "get-tsconfig": "^4.7.3", + "is-glob": "^4.0.3", + "minimatch": "^9.0.3", + "semver": "^7.6.3", + "stable-hash": "^0.0.4", + "tslib": "^2.6.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" + } + }, + "node_modules/eslint-plugin-import-x/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/eslint-plugin-import-x/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/eslint-plugin-promise": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-7.1.0.tgz", @@ -2660,6 +2748,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/get-tsconfig": { + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.8.1.tgz", + "integrity": "sha512-k9PN+cFBmaLWtVz29SkUoqU5O0slLuHJXt/2P+tMVFT+phsSGXGkp9t3rQIqdz0e+06EHNGs3oM6ZX1s2zHxRg==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, "node_modules/git-log-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/git-log-parser/-/git-log-parser-1.2.1.tgz", @@ -7657,6 +7758,16 @@ "node": ">=4" } }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, "node_modules/reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", @@ -8039,6 +8150,13 @@ "node": ">= 10.x" } }, + "node_modules/stable-hash": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/stable-hash/-/stable-hash-0.0.4.tgz", + "integrity": "sha512-LjdcbuBeLcdETCrPn9i8AYAZ1eCtu4ECAWtP7UleOiZ9LzVxRzzUZEoZ8zB24nhkQnDWyET0I+3sWokSDS3E7g==", + "dev": true, + "license": "MIT" + }, "node_modules/stream-combiner2": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", @@ -8368,6 +8486,13 @@ "typescript": ">=4.2.0" } }, + "node_modules/tslib": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==", + "dev": true, + "license": "0BSD" + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", diff --git a/package.json b/package.json index d3309fd..0b21b51 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "eslint": "^9.12.0", "eslint-plugin-promise": "^7.1.0", "eslint-plugin-unicorn": "^56.0.0", + "eslint-plugin-import-x": "^4.3.1", "globals": "^15.10.0", "typescript-eslint": "^8.8.0" }, @@ -59,6 +60,7 @@ "eslint": "9.12.0", "eslint-plugin-promise": "7.1.0", "eslint-plugin-unicorn": "56.0.0", + "eslint-plugin-import-x": "4.3.1", "typescript-eslint": "8.8.0", "prettier": "3.3.3", "semantic-release": "23.1.1",