Skip to content

Commit

Permalink
Replace eslint-plugin-node with eslint-plugin-n (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
BPScott authored Dec 13, 2024
1 parent 9931668 commit 75fe8da
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 102 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-beers-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/eslint-plugin': major
---

Replace `eslint-plugin-node` with `eslint-plugin-n`
85 changes: 46 additions & 39 deletions packages/eslint-plugin/lib/config/node.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const globals = require('globals');
const nodePlugin = require('eslint-plugin-node');
const nodePlugin = require('eslint-plugin-n');

module.exports = [
{
Expand All @@ -10,7 +10,8 @@ module.exports = [
},

plugins: {
node: nodePlugin,
// eslint-disable-next-line id-length
n: nodePlugin,
},

rules: {
Expand All @@ -27,79 +28,85 @@ module.exports = [
'no-restricted-modules': 'off',
'no-sync': 'off',
// Enforce return after a callback
'node/callback-return': ['error', ['callback', 'cb', 'next']],
'n/callback-return': ['error', ['callback', 'cb', 'next']],
// Enforce the style of file extensions in import declarations
'n/file-extension-in-import': 'off',
// Disallow require() outside of the top-level module scope
'node/global-require': 'off',
'n/global-require': 'off',
// Enforces error handling in callbacks
'node/handle-callback-err': ['error', '^.*(e|E)rr(or)?$'],
// Disallow use of the Buffer() constructor
'no-buffer-constructor': 'error',
'n/handle-callback-err': ['error', '^.*(e|E)rr(or)?$'],
// Require correct usage of hashbang
'n/hashbang': 'off',
// Disallow mixing regular variable and require declarations
'node/no-mixed-requires': 'off',
'n/no-mixed-requires': 'off',
// Disallow use of new operator with the require function
'node/no-new-require': 'error',
'n/no-new-require': 'error',
// Disallow string concatenation with __dirname and __filename
'node/no-path-concat': 'error',
'n/no-path-concat': 'error',
// Disallow process.exit()
'node/no-process-exit': 'off',
'n/no-process-exit': 'off',
// Restrict usage of specified node imports
'node/no-restricted-import': 'off',
'n/no-restricted-import': 'off',
// Restrict usage of specified node modules
'node/no-restricted-require': 'off',
'n/no-restricted-require': 'off',
// Disallow use of synchronous methods
'node/no-sync': 'off',
'n/no-sync': 'off',
// Disallow import declarations of extraneous packages
// defer to import/no-extraneous-dependencies
'node/no-extraneous-import': 'off',
'n/no-extraneous-import': 'off',
// Disallow require() expressions of extraneous packages
// defer to import/no-extraneous-dependencies
'node/no-extraneous-require': 'off',
'n/no-extraneous-require': 'off',
// Enforce either module.exports or exports.
'node/exports-style': ['error', 'module.exports'],
'n/exports-style': ['error', 'module.exports'],
// enforce either Buffer or require("buffer").Buffer
'node/prefer-global/buffer': 'error',
'n/prefer-global/buffer': 'error',
// enforce either console or require("console")
'node/prefer-global/console': 'error',
'n/prefer-global/console': 'error',
// enforce either process or require("process")
'node/prefer-global/process': 'error',
'n/prefer-global/process': 'error',
// enforce either TextDecoder or require("util").TextDecoder
'node/prefer-global/text-decoder': 'error',
'n/prefer-global/text-decoder': 'error',
// enforce either TextEncoder or require("util").TextEncoder
'node/prefer-global/text-encoder': 'error',
'n/prefer-global/text-encoder': 'error',
// enforce either URLSearchParams or require("url").URLSearchParams
'node/prefer-global/url-search-params': 'error',
'n/prefer-global/url-search-params': 'error',
// enforce either URL or require("url").URL
'node/prefer-global/url': 'error',
'n/prefer-global/url': 'error',
// Disallow deprecated API.
'node/no-deprecated-api': 'error',
'n/no-deprecated-api': 'error',
// Disallow import and export declarations for files that don't exist.
'node/no-missing-import': 'off',
'n/no-missing-import': 'off',
// Disallow require()s for files that don't exist.
'node/no-missing-require': 'off',
'n/no-missing-require': 'off',
// Disallow import and export declarations for files that are not published.
'node/no-unpublished-import': 'off',
'n/no-unpublished-import': 'off',
// Disallow bin files that npm ignores.
'node/no-unpublished-bin': 'error',
'n/no-unpublished-bin': 'error',
// Disallow require()s for files that are not published.
'node/no-unpublished-require': 'off',
'n/no-unpublished-require': 'off',
// disallow unsupported ECMAScript built-ins on the specified version
'node/no-unsupported-features/es-builtins': 'off',
'n/no-unsupported-features/es-builtins': 'off',
// disallow unsupported ECMAScript syntax on the specified version
'node/no-unsupported-features/es-syntax': 'off',
'n/no-unsupported-features/es-syntax': 'off',
// disallow unsupported Node.js built-in APIs on the specified version
'node/no-unsupported-features/node-builtins': 'error',
'n/no-unsupported-features/node-builtins': 'error',
// Disallow the use of process.env
'n/no-process-env': 'off',
// If you turn this rule on, ESLint comes to address process.exit() as throw in code path analysis.
'node/process-exit-as-throw': 'off',
'n/process-exit-as-throw': 'off',
// Suggest correct usage of shebang.
'node/shebang': 'error',
'n/shebang': 'error',
// enforce using the node: protocol when importing Node.js builtin modules.
'n/prefer-node-protocol': 'off',
// disallows callback API in favor of promise API for dns module
'node/prefer-promises/dns': 'error',
'n/prefer-promises/dns': 'error',
// disallows callback API in favor of promise API for fs module
'node/prefer-promises/fs': 'error',
'n/prefer-promises/fs': 'error',
// disallow the assignment to `exports`
'node/no-exports-assign': 'error',
'n/no-exports-assign': 'error',
// Ensures the Node.js error-first callback pattern is followed
'node/no-callback-literal': 'error',
'n/no-callback-literal': 'error',

'no-process-env': 'off',
'no-console': 'off',
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"eslint-plugin-jest": "^28.5.0",
"eslint-plugin-jest-formatting": "^3.1.0",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-n": "^17.5.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.34.1",
Expand Down
Loading

0 comments on commit 75fe8da

Please sign in to comment.