Skip to content

Commit 75fe8da

Browse files
authored
Replace eslint-plugin-node with eslint-plugin-n (#444)
1 parent 9931668 commit 75fe8da

File tree

4 files changed

+127
-102
lines changed

4 files changed

+127
-102
lines changed

.changeset/cuddly-beers-wonder.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/eslint-plugin': major
3+
---
4+
5+
Replace `eslint-plugin-node` with `eslint-plugin-n`

packages/eslint-plugin/lib/config/node.js

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const globals = require('globals');
2-
const nodePlugin = require('eslint-plugin-node');
2+
const nodePlugin = require('eslint-plugin-n');
33

44
module.exports = [
55
{
@@ -10,7 +10,8 @@ module.exports = [
1010
},
1111

1212
plugins: {
13-
node: nodePlugin,
13+
// eslint-disable-next-line id-length
14+
n: nodePlugin,
1415
},
1516

1617
rules: {
@@ -27,79 +28,85 @@ module.exports = [
2728
'no-restricted-modules': 'off',
2829
'no-sync': 'off',
2930
// Enforce return after a callback
30-
'node/callback-return': ['error', ['callback', 'cb', 'next']],
31+
'n/callback-return': ['error', ['callback', 'cb', 'next']],
32+
// Enforce the style of file extensions in import declarations
33+
'n/file-extension-in-import': 'off',
3134
// Disallow require() outside of the top-level module scope
32-
'node/global-require': 'off',
35+
'n/global-require': 'off',
3336
// Enforces error handling in callbacks
34-
'node/handle-callback-err': ['error', '^.*(e|E)rr(or)?$'],
35-
// Disallow use of the Buffer() constructor
36-
'no-buffer-constructor': 'error',
37+
'n/handle-callback-err': ['error', '^.*(e|E)rr(or)?$'],
38+
// Require correct usage of hashbang
39+
'n/hashbang': 'off',
3740
// Disallow mixing regular variable and require declarations
38-
'node/no-mixed-requires': 'off',
41+
'n/no-mixed-requires': 'off',
3942
// Disallow use of new operator with the require function
40-
'node/no-new-require': 'error',
43+
'n/no-new-require': 'error',
4144
// Disallow string concatenation with __dirname and __filename
42-
'node/no-path-concat': 'error',
45+
'n/no-path-concat': 'error',
4346
// Disallow process.exit()
44-
'node/no-process-exit': 'off',
47+
'n/no-process-exit': 'off',
4548
// Restrict usage of specified node imports
46-
'node/no-restricted-import': 'off',
49+
'n/no-restricted-import': 'off',
4750
// Restrict usage of specified node modules
48-
'node/no-restricted-require': 'off',
51+
'n/no-restricted-require': 'off',
4952
// Disallow use of synchronous methods
50-
'node/no-sync': 'off',
53+
'n/no-sync': 'off',
5154
// Disallow import declarations of extraneous packages
5255
// defer to import/no-extraneous-dependencies
53-
'node/no-extraneous-import': 'off',
56+
'n/no-extraneous-import': 'off',
5457
// Disallow require() expressions of extraneous packages
5558
// defer to import/no-extraneous-dependencies
56-
'node/no-extraneous-require': 'off',
59+
'n/no-extraneous-require': 'off',
5760
// Enforce either module.exports or exports.
58-
'node/exports-style': ['error', 'module.exports'],
61+
'n/exports-style': ['error', 'module.exports'],
5962
// enforce either Buffer or require("buffer").Buffer
60-
'node/prefer-global/buffer': 'error',
63+
'n/prefer-global/buffer': 'error',
6164
// enforce either console or require("console")
62-
'node/prefer-global/console': 'error',
65+
'n/prefer-global/console': 'error',
6366
// enforce either process or require("process")
64-
'node/prefer-global/process': 'error',
67+
'n/prefer-global/process': 'error',
6568
// enforce either TextDecoder or require("util").TextDecoder
66-
'node/prefer-global/text-decoder': 'error',
69+
'n/prefer-global/text-decoder': 'error',
6770
// enforce either TextEncoder or require("util").TextEncoder
68-
'node/prefer-global/text-encoder': 'error',
71+
'n/prefer-global/text-encoder': 'error',
6972
// enforce either URLSearchParams or require("url").URLSearchParams
70-
'node/prefer-global/url-search-params': 'error',
73+
'n/prefer-global/url-search-params': 'error',
7174
// enforce either URL or require("url").URL
72-
'node/prefer-global/url': 'error',
75+
'n/prefer-global/url': 'error',
7376
// Disallow deprecated API.
74-
'node/no-deprecated-api': 'error',
77+
'n/no-deprecated-api': 'error',
7578
// Disallow import and export declarations for files that don't exist.
76-
'node/no-missing-import': 'off',
79+
'n/no-missing-import': 'off',
7780
// Disallow require()s for files that don't exist.
78-
'node/no-missing-require': 'off',
81+
'n/no-missing-require': 'off',
7982
// Disallow import and export declarations for files that are not published.
80-
'node/no-unpublished-import': 'off',
83+
'n/no-unpublished-import': 'off',
8184
// Disallow bin files that npm ignores.
82-
'node/no-unpublished-bin': 'error',
85+
'n/no-unpublished-bin': 'error',
8386
// Disallow require()s for files that are not published.
84-
'node/no-unpublished-require': 'off',
87+
'n/no-unpublished-require': 'off',
8588
// disallow unsupported ECMAScript built-ins on the specified version
86-
'node/no-unsupported-features/es-builtins': 'off',
89+
'n/no-unsupported-features/es-builtins': 'off',
8790
// disallow unsupported ECMAScript syntax on the specified version
88-
'node/no-unsupported-features/es-syntax': 'off',
91+
'n/no-unsupported-features/es-syntax': 'off',
8992
// disallow unsupported Node.js built-in APIs on the specified version
90-
'node/no-unsupported-features/node-builtins': 'error',
93+
'n/no-unsupported-features/node-builtins': 'error',
94+
// Disallow the use of process.env
95+
'n/no-process-env': 'off',
9196
// If you turn this rule on, ESLint comes to address process.exit() as throw in code path analysis.
92-
'node/process-exit-as-throw': 'off',
97+
'n/process-exit-as-throw': 'off',
9398
// Suggest correct usage of shebang.
94-
'node/shebang': 'error',
99+
'n/shebang': 'error',
100+
// enforce using the node: protocol when importing Node.js builtin modules.
101+
'n/prefer-node-protocol': 'off',
95102
// disallows callback API in favor of promise API for dns module
96-
'node/prefer-promises/dns': 'error',
103+
'n/prefer-promises/dns': 'error',
97104
// disallows callback API in favor of promise API for fs module
98-
'node/prefer-promises/fs': 'error',
105+
'n/prefer-promises/fs': 'error',
99106
// disallow the assignment to `exports`
100-
'node/no-exports-assign': 'error',
107+
'n/no-exports-assign': 'error',
101108
// Ensures the Node.js error-first callback pattern is followed
102-
'node/no-callback-literal': 'error',
109+
'n/no-callback-literal': 'error',
103110

104111
'no-process-env': 'off',
105112
'no-console': 'off',

packages/eslint-plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"eslint-plugin-jest": "^28.5.0",
4040
"eslint-plugin-jest-formatting": "^3.1.0",
4141
"eslint-plugin-jsx-a11y": "^6.8.0",
42-
"eslint-plugin-node": "^11.1.0",
42+
"eslint-plugin-n": "^17.5.0",
4343
"eslint-plugin-prettier": "^5.1.3",
4444
"eslint-plugin-promise": "^6.1.1",
4545
"eslint-plugin-react": "^7.34.1",

0 commit comments

Comments
 (0)