Skip to content

Commit

Permalink
BREAKING: Replace eslint-plugin-import with eslint-plugin-import-x (
Browse files Browse the repository at this point in the history
#356)

* Replace `eslint-plugin-import` with `eslint-plugin-import-x`

* Update READMEs

* Fix local ESLint config

* Update lockfile
  • Loading branch information
Mrtenz committed Jun 4, 2024
1 parent 95275db commit f009f13
Show file tree
Hide file tree
Showing 23 changed files with 181 additions and 722 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ module.exports = {
],

rules: {
'import/no-dynamic-require': 'off',
'import/no-nodejs-modules': 'off',
'import-x/no-dynamic-require': 'off',
'import-x/no-nodejs-modules': 'off',
'n/global-require': 'off',
'n/no-process-exit': 'off',
'n/no-sync': 'off',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@types/jest": "^29.5.12",
"eslint": "^8.57.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "~2.26.0",
"eslint-plugin-import-x": "^0.5.1",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-jsdoc": "^47.0.2",
"eslint-plugin-n": "^16.6.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ yarn add --dev \
@metamask/eslint-config@^12.2.0 \
eslint@^8.57.0 \
eslint-config-prettier@^8.5.0 \
eslint-plugin-import@~2.26.0 \
eslint-plugin-import-x@^0.5.1 \
eslint-plugin-jsdoc@^47.0.2 \
eslint-plugin-prettier@^4.2.1 \
eslint-plugin-promise@^6.1.1 \
Expand Down
4 changes: 2 additions & 2 deletions packages/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@metamask/auto-changelog": "^3.4.4",
"eslint": "^8.57.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "~2.26.0",
"eslint-plugin-import-x": "^0.5.1",
"eslint-plugin-jsdoc": "^47.0.2",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
Expand All @@ -34,7 +34,7 @@
"peerDependencies": {
"eslint": "^8.57.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "~2.26.0",
"eslint-plugin-import-x": "^0.5.1",
"eslint-plugin-jsdoc": ">=43.0.7 <48",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
Expand Down
50 changes: 25 additions & 25 deletions packages/base/rules-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,47 +99,47 @@
}
],
"implicit-arrow-linebreak": "off",
"import/default": "error",
"import/export": "error",
"import/extensions": [
"import-x/default": "error",
"import-x/export": "error",
"import-x/extensions": [
"error",
"never",
{
"json": "always"
}
],
"import/first": "error",
"import/named": "error",
"import/namespace": "error",
"import/newline-after-import": "error",
"import/no-absolute-path": "error",
"import/no-amd": "error",
"import/no-anonymous-default-export": "error",
"import/no-duplicates": "error",
"import/no-dynamic-require": "error",
"import/no-extraneous-dependencies": "error",
"import/no-mutable-exports": "error",
"import/no-named-as-default": "error",
"import/no-named-as-default-member": "error",
"import/no-named-default": "error",
"import/no-nodejs-modules": "error",
"import/no-self-import": "error",
"import/no-unassigned-import": "error",
"import/no-unresolved": [
"import-x/first": "error",
"import-x/named": "error",
"import-x/namespace": "error",
"import-x/newline-after-import": "error",
"import-x/no-absolute-path": "error",
"import-x/no-amd": "error",
"import-x/no-anonymous-default-export": "error",
"import-x/no-duplicates": "error",
"import-x/no-dynamic-require": "error",
"import-x/no-extraneous-dependencies": "error",
"import-x/no-mutable-exports": "error",
"import-x/no-named-as-default": "error",
"import-x/no-named-as-default-member": "error",
"import-x/no-named-default": "error",
"import-x/no-nodejs-modules": "error",
"import-x/no-self-import": "error",
"import-x/no-unassigned-import": "error",
"import-x/no-unresolved": [
"error",
{
"commonjs": true
}
],
"import/no-useless-path-segments": [
"import-x/no-useless-path-segments": [
"error",
{
"commonjs": true,
"noUselessIndex": true
}
],
"import/no-webpack-loader-syntax": "error",
"import/order": [
"import-x/no-webpack-loader-syntax": "error",
"import-x/order": [
"error",
{
"newlines-between": "always",
Expand All @@ -153,7 +153,7 @@
}
}
],
"import/unambiguous": "error",
"import-x/unambiguous": "error",
"indent": "off",
"indent-legacy": "off",
"jsdoc/check-access": "error",
Expand Down
44 changes: 22 additions & 22 deletions packages/base/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {
extends: [
'eslint:recommended',
'plugin:prettier/recommended',
'plugin:import/recommended',
'plugin:import-x/recommended',
],

rules: {
Expand Down Expand Up @@ -283,43 +283,43 @@ module.exports = {
yoda: ['error', 'never'],

/* import plugin rules */
'import/extensions': [
'import-x/extensions': [
'error',
'never',
{
json: 'always',
},
],
'import/first': 'error',
'import/newline-after-import': 'error',
'import/no-absolute-path': 'error',
'import/no-amd': 'error',
'import/no-anonymous-default-export': 'error',
'import/no-duplicates': 'error',
'import/no-dynamic-require': 'error',
'import/no-extraneous-dependencies': 'error',
'import/no-mutable-exports': 'error',
'import/no-named-as-default': 'error',
'import/no-named-as-default-member': 'error',
'import/no-named-default': 'error',
'import/no-nodejs-modules': 'error',
'import/no-self-import': 'error',
'import/no-unassigned-import': 'error',
'import/no-unresolved': [
'import-x/first': 'error',
'import-x/newline-after-import': 'error',
'import-x/no-absolute-path': 'error',
'import-x/no-amd': 'error',
'import-x/no-anonymous-default-export': 'error',
'import-x/no-duplicates': 'error',
'import-x/no-dynamic-require': 'error',
'import-x/no-extraneous-dependencies': 'error',
'import-x/no-mutable-exports': 'error',
'import-x/no-named-as-default': 'error',
'import-x/no-named-as-default-member': 'error',
'import-x/no-named-default': 'error',
'import-x/no-nodejs-modules': 'error',
'import-x/no-self-import': 'error',
'import-x/no-unassigned-import': 'error',
'import-x/no-unresolved': [
'error',
{
commonjs: true,
},
],
'import/no-useless-path-segments': [
'import-x/no-useless-path-segments': [
'error',
{
commonjs: true,
noUselessIndex: true,
},
],
'import/no-webpack-loader-syntax': 'error',
'import/order': [
'import-x/no-webpack-loader-syntax': 'error',
'import-x/order': [
'error',
{
// This means that there will always be a newline between the import
Expand All @@ -343,7 +343,7 @@ module.exports = {
},
},
],
'import/unambiguous': 'error',
'import-x/unambiguous': 'error',

/* jsdoc plugin rules */
'jsdoc/check-access': 'error',
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ yarn add --dev \
@metamask/eslint-config-browser@^12.1.0 \
eslint@^8.57.0 \
eslint-config-prettier@^8.5.0 \
eslint-plugin-import@~2.26.0 \
eslint-plugin-import-x@^0.5.1 \
eslint-plugin-jsdoc@^47.0.2 \
eslint-plugin-prettier@^4.2.1 \
eslint-plugin-promise@^6.1.1 \
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@metamask/auto-changelog": "^3.4.4",
"eslint": "^8.57.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "~2.26.0",
"eslint-plugin-import-x": "^0.5.1",
"eslint-plugin-jsdoc": "^47.0.2",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.7.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/commonjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ yarn add --dev \
@metamask/eslint-config-commonjs@^12.1.0 \
eslint@^8.57.0 \
eslint-config-prettier@^8.5.0 \
eslint-plugin-import@~2.26.0 \
eslint-plugin-import-x@^0.5.1 \
eslint-plugin-jsdoc@^47.0.2 \
eslint-plugin-prettier@^4.2.1 \
eslint-plugin-promise@^6.1.1 \
Expand Down
2 changes: 1 addition & 1 deletion packages/commonjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@metamask/auto-changelog": "^3.4.4",
"eslint": "^8.57.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "~2.26.0",
"eslint-plugin-import-x": "^0.5.1",
"eslint-plugin-jsdoc": "^47.0.2",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.7.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/jest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ yarn add --dev \
@metamask/eslint-config-jest@^12.1.0 \
eslint@^8.57.0 \
eslint-config-prettier@^8.5.0 \
eslint-plugin-import@~2.26.0 \
eslint-plugin-import-x@^0.5.1 \
eslint-plugin-jsdoc@^47.0.2 \
eslint-plugin-jest@^27.9.0 \
eslint-plugin-prettier@^4.2.1 \
Expand Down
2 changes: 1 addition & 1 deletion packages/jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@metamask/eslint-config": "^12.0.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "~2.26.0",
"eslint-plugin-import-x": "^0.5.1",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-jsdoc": "^47.0.2",
"eslint-plugin-prettier": "^4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/mocha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ yarn add --dev \
@metamask/eslint-config-mocha@^12.1.0 \
eslint@^8.57.0 \
eslint-config-prettier@^8.5.0 \
eslint-plugin-import@~2.26.0 \
eslint-plugin-import-x@^0.5.1 \
eslint-plugin-jsdoc@^47.0.2 \
eslint-plugin-mocha@^10.4.1 \
eslint-plugin-prettier@^4.2.1 \
Expand Down
2 changes: 1 addition & 1 deletion packages/mocha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@metamask/eslint-config": "^12.0.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "~2.26.0",
"eslint-plugin-import-x": "^0.5.1",
"eslint-plugin-jsdoc": "^47.0.2",
"eslint-plugin-mocha": "^10.4.1",
"eslint-plugin-prettier": "^4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ yarn add --dev \
@metamask/eslint-config-nodejs@^12.1.0 \
eslint@^8.57.0 \
eslint-config-prettier@^8.5.0 \
eslint-plugin-import@~2.26.0 \
eslint-plugin-import-x@^0.5.1 \
eslint-plugin-jsdoc@^47.0.2 \
eslint-plugin-n@^16.6.2 \
eslint-plugin-prettier@^4.2.1 \
Expand Down
2 changes: 1 addition & 1 deletion packages/nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@metamask/eslint-config": "^12.2.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "~2.26.0",
"eslint-plugin-import-x": "^0.5.1",
"eslint-plugin-jsdoc": "^47.0.2",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-prettier": "^4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/nodejs/rules-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"import/no-nodejs-modules": "off",
"import-x/no-nodejs-modules": "off",
"n/callback-return": "error",
"n/exports-style": "error",
"n/global-require": "error",
Expand Down
6 changes: 3 additions & 3 deletions packages/nodejs/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ module.exports = {
// Possible Errors
'n/handle-callback-err': ['error', '^(err|error)$'],
'n/no-callback-literal': 'error',
'n/no-missing-import': 'off', // Duplicates `import/no-unresolved`
'n/no-missing-require': 'off', // Duplicates `import/no-unresolved`
'n/no-missing-import': 'off', // Duplicates `import-x/no-unresolved`
'n/no-missing-require': 'off', // Duplicates `import-x/no-unresolved`
'n/no-new-require': 'error',
'n/no-path-concat': 'error',
'n/no-unsupported-features/es-syntax': 'off',
Expand All @@ -53,6 +53,6 @@ module.exports = {

// Enabled in the base config, but this should be allowed in Node.js
// projects.
'import/no-nodejs-modules': 'off',
'import-x/no-nodejs-modules': 'off',
},
};
2 changes: 1 addition & 1 deletion packages/typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ yarn add --dev \
@typescript-eslint/parser@^6.21.0 \
eslint@^8.57.0 \
eslint-config-prettier@^8.5.0 \
eslint-plugin-import@~2.26.0 \
eslint-plugin-import-x@^0.5.1 \
eslint-plugin-jsdoc@^47.0.2 \
eslint-plugin-prettier@^4.2.1 \
eslint-plugin-promise@^6.1.1 \
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@typescript-eslint/parser": "^6.21.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "~2.26.0",
"eslint-plugin-import-x": "^0.5.1",
"eslint-plugin-jsdoc": "^47.0.2",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.7.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/typescript/rules-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@
"constructor-super": "off",
"default-param-last": "off",
"getter-return": "off",
"import/named": "off",
"import/no-unresolved": "off",
"import-x/named": "off",
"import-x/no-unresolved": "off",
"jsdoc/check-indentation": "error",
"jsdoc/check-syntax": "error",
"jsdoc/no-types": "error",
Expand Down
4 changes: 2 additions & 2 deletions packages/typescript/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ module.exports = {
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-type-checked',
'plugin:import/typescript',
'plugin:import-x/typescript',
],

rules: {
// Handled by TypeScript
'import/no-unresolved': 'off',
'import-x/no-unresolved': 'off',

// Our rules
'@typescript-eslint/array-type': 'error',
Expand Down
Loading

0 comments on commit f009f13

Please sign in to comment.