Skip to content

Commit

Permalink
node/peerDeps: replace eslint-plugin-node with eslint-plugin-n (#297)
Browse files Browse the repository at this point in the history
* node/peerDeps: replace eslint-plugin-node with eslint-plugin-n

eslint-plugin-node is unmaintained and suffers from issues addressed in the community-fork eslint-plugin-n.
  • Loading branch information
legobeat authored Jul 7, 2023
1 parent 5079543 commit 80a1565
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 382 deletions.
8 changes: 4 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ module.exports = {
rules: {
'import/no-dynamic-require': 'off',
'import/no-nodejs-modules': 'off',
'node/global-require': 'off',
'node/no-process-exit': 'off',
'node/no-sync': 'off',
'node/no-unpublished-require': 'off',
'n/global-require': 'off',
'n/no-process-exit': 'off',
'n/no-sync': 'off',
'n/no-unpublished-require': 'off',
},

ignorePatterns: ['!.eslintrc.js'],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.1.5",
"eslint-plugin-jsdoc": "^39.6.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-prettier": "^4.2.1",
"fast-deep-equal": "^3.1.3",
"globals": "^13.17.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ yarn add --dev \
eslint-config-prettier@^8.5.0 \
eslint-plugin-import@^2.26.0 \
eslint-plugin-jsdoc@^39.6.2 \
eslint-plugin-node@^11.1.0 \
eslint-plugin-n@^15.7.0 \
eslint-plugin-prettier@^4.2.1 \
eslint-plugin-promise@^6.1.1 \
prettier@^2.7.1
Expand Down
4 changes: 2 additions & 2 deletions packages/nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsdoc": "^39.6.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.7.1"
},
"peerDependencies": {
"@metamask/eslint-config": "^11.0.0",
"eslint": "^8.27.0",
"eslint-plugin-node": "^11.1.0"
"eslint-plugin-n": "^15.7.0"
},
"engines": {
"node": ">=14.0.0"
Expand Down
75 changes: 37 additions & 38 deletions packages/nodejs/rules-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
{
"import/no-nodejs-modules": "off",
"no-process-exit": "off",
"n/callback-return": "error",
"n/exports-style": "error",
"n/global-require": "error",
"n/handle-callback-err": ["error", "^(err|error)$"],
"n/no-callback-literal": "error",
"n/no-deprecated-api": "error",
"n/no-exports-assign": "error",
"n/no-extraneous-import": "error",
"n/no-extraneous-require": "error",
"n/no-missing-import": "off",
"n/no-missing-require": "off",
"n/no-mixed-requires": "error",
"n/no-new-require": "error",
"n/no-path-concat": "error",
"n/no-process-env": "error",
"n/no-process-exit": "error",
"n/no-restricted-import": "error",
"n/no-restricted-require": "error",
"n/no-sync": "error",
"n/no-unpublished-bin": "error",
"n/no-unpublished-import": "error",
"n/no-unpublished-require": "error",
"n/no-unsupported-features/es-builtins": "error",
"n/no-unsupported-features/es-syntax": "off",
"n/no-unsupported-features/node-builtins": "error",
"n/prefer-global/buffer": "error",
"n/prefer-global/console": "error",
"n/prefer-global/process": "error",
"n/prefer-global/text-decoder": "error",
"n/prefer-global/text-encoder": "error",
"n/prefer-global/url": "error",
"n/prefer-global/url-search-params": "error",
"n/prefer-promises/dns": "error",
"n/prefer-promises/fs": "error",
"n/process-exit-as-throw": "error",
"n/shebang": "error",
"no-restricted-globals": [
"error",
{
Expand Down Expand Up @@ -2799,41 +2834,5 @@
"name": "XSLTProcessor",
"message": "This global is not available in the Node.js environment."
}
],
"node/callback-return": "error",
"node/exports-style": "error",
"node/global-require": "error",
"node/handle-callback-err": ["error", "^(err|error)$"],
"node/no-callback-literal": "error",
"node/no-deprecated-api": "error",
"node/no-exports-assign": "error",
"node/no-extraneous-import": "error",
"node/no-extraneous-require": "error",
"node/no-missing-import": "off",
"node/no-missing-require": "off",
"node/no-mixed-requires": "error",
"node/no-new-require": "error",
"node/no-path-concat": "error",
"node/no-process-env": "error",
"node/no-process-exit": "error",
"node/no-restricted-import": "error",
"node/no-restricted-require": "error",
"node/no-sync": "error",
"node/no-unpublished-bin": "error",
"node/no-unpublished-import": "error",
"node/no-unpublished-require": "error",
"node/no-unsupported-features/es-builtins": "error",
"node/no-unsupported-features/es-syntax": "off",
"node/no-unsupported-features/node-builtins": "error",
"node/prefer-global/buffer": "error",
"node/prefer-global/console": "error",
"node/prefer-global/process": "error",
"node/prefer-global/text-decoder": "error",
"node/prefer-global/text-encoder": "error",
"node/prefer-global/url": "error",
"node/prefer-global/url-search-params": "error",
"node/prefer-promises/dns": "error",
"node/prefer-promises/fs": "error",
"node/process-exit-as-throw": "error",
"node/shebang": "error"
]
}
57 changes: 26 additions & 31 deletions packages/nodejs/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const environmentRules = require('./environment.json');

module.exports = {
plugins: ['node'],
plugins: ['n'],

env: {
// See comment under `parserOptions` below.
Expand All @@ -18,43 +18,38 @@ module.exports = {
ecmaVersion: 2017,
},

extends: ['plugin:node/recommended'],
extends: ['plugin:n/recommended'],

rules: {
...environmentRules,

// Possible Errors
'node/handle-callback-err': ['error', '^(err|error)$'],
'node/no-callback-literal': 'error',
'node/no-missing-import': 'off', // Duplicates `import/no-unresolved`
'node/no-missing-require': 'off', // Duplicates `import/no-unresolved`
'node/no-new-require': 'error',
'node/no-path-concat': 'error',
'node/no-process-exit': 'error',
'node/no-unsupported-features/es-syntax': 'off',
'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-new-require': 'error',
'n/no-path-concat': 'error',
'n/no-unsupported-features/es-syntax': 'off',

// Stylistic rules
'node/callback-return': 'error',
'node/exports-style': 'error',
'node/global-require': 'error',
'node/no-mixed-requires': 'error',
'node/no-process-env': 'error',
'node/no-restricted-import': 'error',
'node/no-restricted-require': 'error',
'node/no-sync': 'error',
'node/prefer-global/buffer': 'error',
'node/prefer-global/console': 'error',
'node/prefer-global/process': 'error',
'node/prefer-global/text-decoder': 'error',
'node/prefer-global/text-encoder': 'error',
'node/prefer-global/url-search-params': 'error',
'node/prefer-global/url': 'error',
'node/prefer-promises/dns': 'error',
'node/prefer-promises/fs': 'error',

// Deprecated eslint core rule, erroneously enabled by recommended Node rules
// https://eslint.org/docs/rules/no-process-exit
'no-process-exit': 'off',
'n/callback-return': 'error',
'n/exports-style': 'error',
'n/global-require': 'error',
'n/no-mixed-requires': 'error',
'n/no-process-env': 'error',
'n/no-restricted-import': 'error',
'n/no-restricted-require': 'error',
'n/no-sync': 'error',
'n/prefer-global/buffer': 'error',
'n/prefer-global/console': 'error',
'n/prefer-global/process': 'error',
'n/prefer-global/text-decoder': 'error',
'n/prefer-global/text-encoder': 'error',
'n/prefer-global/url-search-params': 'error',
'n/prefer-global/url': 'error',
'n/prefer-promises/dns': 'error',
'n/prefer-promises/fs': 'error',

// Enabled in the base config, but this should be allowed in Node.js
// projects.
Expand Down
Loading

0 comments on commit 80a1565

Please sign in to comment.