Skip to content

Commit

Permalink
feat!(deps): Replace import with import-x
Browse files Browse the repository at this point in the history
BREAKING CHANGE: there might be differences in a way this plugin works and this might require changes to project's own `eslint.config.js` files
  • Loading branch information
burtek committed Jun 11, 2024
1 parent a94e6d9 commit 994ee95
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 104 deletions.
42 changes: 20 additions & 22 deletions configs/base.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import stylisticPlugin from '@stylistic/eslint-plugin';
import * as importPlugin from 'eslint-plugin-import';
import * as importPlugin from 'eslint-plugin-import-x';
import promise from 'eslint-plugin-promise';
import tseslint from 'typescript-eslint';

Expand All @@ -23,15 +23,15 @@ export function prepareConfig() {
linterOptions: { reportUnusedDisableDirectives: true },
settings: {
...importPlugin.configs.typescript.settings,
'import/extensions': allImportExtensions,
'import/parsers': { '@typescript-eslint/parser': allImportExtensions },
'import/resolver': {
'import-x/extensions': allImportExtensions,
'import-x/parsers': { '@typescript-eslint/parser': allImportExtensions },
'import-x/resolver': {
node: { extensions: allImportExtensions },
typescript: true
}
},
plugins: {
import: importPlugin,
'import-x': importPlugin,
promise
},
rules: {
Expand Down Expand Up @@ -199,27 +199,25 @@ export function prepareConfig() {
'valid-typeof': ['error', { requireStringLiterals: true }],
'yoda': ['error', 'never', { exceptRange: true }],

'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
'import/default': 'error',
'import/export': 'error',
'import/first': 'error',
'import/namespace': 'error',
'import/newline-after-import': [
...importPlugin.configs.recommended.rules,
'import-x/no-unresolved': 'off',
'import-x/named': 'off',
'import-x/consistent-type-specifier-style': ['error', 'prefer-top-level'],
'import-x/first': 'error',
'import-x/newline-after-import': [
'error', {
considerComments: true,
count: 2
}
],
'import/no-anonymous-default-export': 'error',
'import/no-cycle': 'error',
'import/no-deprecated': 'warn',
'import/no-duplicates': 'error',
'import/no-empty-named-blocks': 'error',
'import/no-mutable-exports': 'error',
'import/no-named-as-default': 'warn',
'import/no-named-as-default-member': 'warn',
'import/no-self-import': 'error',
'import/order': [
'import-x/no-anonymous-default-export': 'error',
'import-x/no-cycle': 'error',
'import-x/no-deprecated': 'warn',
'import-x/no-duplicates': 'error',
'import-x/no-empty-named-blocks': 'error',
'import-x/no-mutable-exports': 'error',
'import-x/no-self-import': 'error',
'import-x/order': [
'error', {
'groups': [
'builtin',
Expand Down Expand Up @@ -435,7 +433,7 @@ export function prepareConfig() {
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/consistent-return': 'error',
'@typescript-eslint/no-implied-eval': 'error',
// import/consistent-type-specifier-style makes sure we don't inline `type` modifier
// import-x/consistent-type-specifier-style makes sure we don't inline `type` modifier
'@typescript-eslint/no-import-type-side-effects': 'off',
'@typescript-eslint/no-invalid-this': 'error',
'@typescript-eslint/no-invalid-void-type': 'error',
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default tseslint.config(
rules: {
'no-extra-parens': 'off',
'no-magic-numbers': 'off',
'import/no-named-as-default-member': 'off',
'import-x/no-named-as-default-member': 'off',
'@stylistic/quote-props': ['error', 'consistent-as-needed']
}
},
Expand Down
10 changes: 0 additions & 10 deletions import-types.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
declare module 'eslint-plugin-import' {
import type { TSESLint } from '@typescript-eslint/utils';
import type { Rule } from 'eslint';


export const configs: Record<'recommended' | 'error' | 'warnings' | 'react' | 'react-native' | 'electron' | 'typescript',
TSESLint.ClassicConfig.Config>;
export const rules: Record<string, Rule.RuleModule>;
}

declare module 'eslint-plugin-promise' {
import type { Rule } from 'eslint';

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@stylistic/eslint-plugin": "~2.1.0",
"eslint-import-resolver-typescript": "~3.6.1",
"eslint-plugin-cypress": "~3.3.0",
"eslint-plugin-import": "~2.29.1",
"eslint-plugin-import-x": "~0.5.1",
"eslint-plugin-jest": "~28.6.0",
"eslint-plugin-jest-dom": "~5.4.0",
"eslint-plugin-jest-formatting": "~3.1.0",
Expand Down
89 changes: 19 additions & 70 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -915,11 +915,6 @@
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841"
integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==

"@types/json5@^0.0.29":
version "0.0.29"
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==

"@types/mdast@^3.0.0":
version "3.0.15"
resolved "https://registry.yarnpkg.com/@types/mdast/-/mdast-3.0.15.tgz#49c524a263f30ffa28b71ae282f813ed000ab9f5"
Expand Down Expand Up @@ -1082,7 +1077,7 @@
semver "^7.6.0"
ts-api-utils "^1.3.0"

"@typescript-eslint/utils@7.13.0", "@typescript-eslint/utils@^6.0.0 || ^7.0.0", "@typescript-eslint/utils@^7.8.0":
"@typescript-eslint/utils@7.13.0", "@typescript-eslint/utils@^6.0.0 || ^7.0.0", "@typescript-eslint/utils@^7.4.0", "@typescript-eslint/utils@^7.8.0":
version "7.13.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-7.13.0.tgz#f84e7e8aeceae945a9a3f40d077fd95915308004"
integrity sha512-jceD8RgdKORVnB4Y6BqasfIkFhl4pajB1wVxrF4akxD2QPM8GNYjgGwEzYS+437ewlqqrg7Dw+6dhdpjMpeBFQ==
Expand Down Expand Up @@ -1292,19 +1287,7 @@ array.prototype.findlast@^1.2.5:
es-object-atoms "^1.0.0"
es-shim-unscopables "^1.0.2"

array.prototype.findlastindex@^1.2.3:
version "1.2.5"
resolved "https://registry.yarnpkg.com/array.prototype.findlastindex/-/array.prototype.findlastindex-1.2.5.tgz#8c35a755c72908719453f87145ca011e39334d0d"
integrity sha512-zfETvRFA8o7EiNn++N5f/kaCw221hrpGsDmcpndVupkPzEc1Wuf3VgC0qby1BbHs7f5DVYjgtEU2LLh5bqeGfQ==
dependencies:
call-bind "^1.0.7"
define-properties "^1.2.1"
es-abstract "^1.23.2"
es-errors "^1.3.0"
es-object-atoms "^1.0.0"
es-shim-unscopables "^1.0.2"

array.prototype.flat@^1.3.1, array.prototype.flat@^1.3.2:
array.prototype.flat@^1.3.1:
version "1.3.2"
resolved "https://registry.yarnpkg.com/array.prototype.flat/-/array.prototype.flat-1.3.2.tgz#1476217df8cff17d72ee8f3ba06738db5b387d18"
integrity sha512-djYB+Zx2vLewY8RWlNCUdHjDXs2XOgm602S9E7P/UpHgfeHL00cRiIF+IN/G/aUJ7kGPb6yO/ErDI5V2s8iycA==
Expand Down Expand Up @@ -2421,7 +2404,7 @@ eslint-mdx@^3.1.5:
uvu "^0.5.6"
vfile "^6.0.1"

eslint-module-utils@^2.7.4, eslint-module-utils@^2.8.0:
eslint-module-utils@^2.7.4:
version "2.8.1"
resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.8.1.tgz#52f2404300c3bd33deece9d7372fb337cc1d7c34"
integrity sha512-rXDXR3h7cs7dy9RNpUlQf80nX31XWJEyGq1tRMo+6GsO5VmTe4UTwtmonAD4ZkAsrfMVDA2wlGJ3790Ys+D49Q==
Expand All @@ -2444,28 +2427,20 @@ eslint-plugin-es-x@^7.5.0:
"@eslint-community/regexpp" "^4.6.0"
eslint-compat-utils "^0.5.0"

eslint-plugin-import@~2.29.1:
version "2.29.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.29.1.tgz#d45b37b5ef5901d639c15270d74d46d161150643"
integrity sha512-BbPC0cuExzhiMo4Ff1BTVwHpjjv28C5R+btTOGaCRC7UEz801up0JadwkeSk5Ued6TG34uaczuVuH6qyy5YUxw==
eslint-plugin-import-x@~0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-import-x/-/eslint-plugin-import-x-0.5.1.tgz#0781096ee737ccfc0f9a028d286839bfa53b1080"
integrity sha512-2JK8bbFOLes+gG6tgdnM8safCxMAj4u2wjX8X1BRFPfnY7Ct2hFYESoIcVwABX/DDcdpQFLGtKmzbNEWJZD9iQ==
dependencies:
array-includes "^3.1.7"
array.prototype.findlastindex "^1.2.3"
array.prototype.flat "^1.3.2"
array.prototype.flatmap "^1.3.2"
debug "^3.2.7"
doctrine "^2.1.0"
"@typescript-eslint/utils" "^7.4.0"
debug "^4.3.4"
doctrine "^3.0.0"
eslint-import-resolver-node "^0.3.9"
eslint-module-utils "^2.8.0"
hasown "^2.0.0"
is-core-module "^2.13.1"
get-tsconfig "^4.7.3"
is-glob "^4.0.3"
minimatch "^3.1.2"
object.fromentries "^2.0.7"
object.groupby "^1.0.1"
object.values "^1.1.7"
semver "^6.3.1"
tsconfig-paths "^3.15.0"
minimatch "^9.0.3"
semver "^7.6.0"
tslib "^2.6.2"

eslint-plugin-jest-dom@~5.4.0:
version "5.4.0"
Expand Down Expand Up @@ -2995,7 +2970,7 @@ get-symbol-description@^1.0.2:
es-errors "^1.3.0"
get-intrinsic "^1.2.4"

get-tsconfig@^4.5.0, get-tsconfig@^4.7.0:
get-tsconfig@^4.5.0, get-tsconfig@^4.7.0, get-tsconfig@^4.7.3:
version "4.7.5"
resolved "https://registry.yarnpkg.com/get-tsconfig/-/get-tsconfig-4.7.5.tgz#5e012498579e9a6947511ed0cd403272c7acbbaf"
integrity sha512-ZCuZCnlqNzjb4QprAzXKdpp/gh6KTxSJuw3IBsPnV/7fV4NxC9ckB+vPTt8w7fJA0TaSD7c55BR47JD6MEDyDw==
Expand Down Expand Up @@ -3393,7 +3368,7 @@ is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.2.7:
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055"
integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==

is-core-module@^2.11.0, is-core-module@^2.13.0, is-core-module@^2.13.1, is-core-module@^2.5.0:
is-core-module@^2.11.0, is-core-module@^2.13.0, is-core-module@^2.5.0:
version "2.13.1"
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.13.1.tgz#ad0d7532c6fea9da1ebdc82742d74525c6273384"
integrity sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==
Expand Down Expand Up @@ -4128,13 +4103,6 @@ json-stringify-safe@^5.0.1:
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==

json5@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.2.tgz#63d98d60f21b313b77c4d6da18bfa69d80e1d593"
integrity sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==
dependencies:
minimist "^1.2.0"

json5@^2.2.3:
version "2.2.3"
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
Expand Down Expand Up @@ -4832,7 +4800,7 @@ minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2:
dependencies:
brace-expansion "^1.1.7"

minimatch@^9.0.0, minimatch@^9.0.1, minimatch@^9.0.4:
minimatch@^9.0.0, minimatch@^9.0.1, minimatch@^9.0.3, minimatch@^9.0.4:
version "9.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.4.tgz#8e49c731d1749cbec05050ee5145147b32496a51"
integrity sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==
Expand All @@ -4848,7 +4816,7 @@ minimist-options@4.1.0:
is-plain-obj "^1.1.0"
kind-of "^6.0.3"

minimist@^1.2.0, minimist@^1.2.5, minimist@^1.2.6:
minimist@^1.2.5:
version "1.2.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c"
integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==
Expand Down Expand Up @@ -4981,15 +4949,6 @@ object.fromentries@^2.0.7, object.fromentries@^2.0.8:
es-abstract "^1.23.2"
es-object-atoms "^1.0.0"

object.groupby@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/object.groupby/-/object.groupby-1.0.3.tgz#9b125c36238129f6f7b61954a1e7176148d5002e"
integrity sha512-+Lhy3TQTuzXI5hevh8sBGqbmurHbbIjAi0Z4S63nthVLmLxfbj4T54a4CfZrXIrt9iP4mVAPYMo/v99taj3wjQ==
dependencies:
call-bind "^1.0.7"
define-properties "^1.2.1"
es-abstract "^1.23.2"

object.hasown@^1.1.4:
version "1.1.4"
resolved "https://registry.yarnpkg.com/object.hasown/-/object.hasown-1.1.4.tgz#e270ae377e4c120cdcb7656ce66884a6218283dc"
Expand All @@ -4999,7 +4958,7 @@ object.hasown@^1.1.4:
es-abstract "^1.23.2"
es-object-atoms "^1.0.0"

object.values@^1.1.6, object.values@^1.1.7, object.values@^1.2.0:
object.values@^1.1.6, object.values@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.2.0.tgz#65405a9d92cee68ac2d303002e0b8470a4d9ab1b"
integrity sha512-yBYjY9QX2hnRmZHAjG/f13MzmBzxzYgQhFrke06TTyKY5zSTEqkOeukBzIdVA3j3ulu8Qa3MbVFShV7T2RmGtQ==
Expand Down Expand Up @@ -6082,16 +6041,6 @@ ts-node@^10.9.2:
v8-compile-cache-lib "^3.0.1"
yn "3.1.1"

tsconfig-paths@^3.15.0:
version "3.15.0"
resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz#5299ec605e55b1abb23ec939ef15edaf483070d4"
integrity sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==
dependencies:
"@types/json5" "^0.0.29"
json5 "^1.0.2"
minimist "^1.2.6"
strip-bom "^3.0.0"

tslib@^1.8.1:
version "1.14.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
Expand Down

0 comments on commit 994ee95

Please sign in to comment.