1
1
const globals = require ( 'globals' ) ;
2
- const nodePlugin = require ( 'eslint-plugin-node ' ) ;
2
+ const nodePlugin = require ( 'eslint-plugin-n ' ) ;
3
3
4
4
module . exports = [
5
5
{
@@ -10,7 +10,8 @@ module.exports = [
10
10
} ,
11
11
12
12
plugins : {
13
- node : nodePlugin ,
13
+ // eslint-disable-next-line id-length
14
+ n : nodePlugin ,
14
15
} ,
15
16
16
17
rules : {
@@ -27,79 +28,85 @@ module.exports = [
27
28
'no-restricted-modules' : 'off' ,
28
29
'no-sync' : 'off' ,
29
30
// 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' ,
31
34
// Disallow require() outside of the top-level module scope
32
- 'node /global-require' : 'off' ,
35
+ 'n /global-require' : 'off' ,
33
36
// 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 ' ,
37
40
// Disallow mixing regular variable and require declarations
38
- 'node /no-mixed-requires' : 'off' ,
41
+ 'n /no-mixed-requires' : 'off' ,
39
42
// Disallow use of new operator with the require function
40
- 'node /no-new-require' : 'error' ,
43
+ 'n /no-new-require' : 'error' ,
41
44
// Disallow string concatenation with __dirname and __filename
42
- 'node /no-path-concat' : 'error' ,
45
+ 'n /no-path-concat' : 'error' ,
43
46
// Disallow process.exit()
44
- 'node /no-process-exit' : 'off' ,
47
+ 'n /no-process-exit' : 'off' ,
45
48
// Restrict usage of specified node imports
46
- 'node /no-restricted-import' : 'off' ,
49
+ 'n /no-restricted-import' : 'off' ,
47
50
// Restrict usage of specified node modules
48
- 'node /no-restricted-require' : 'off' ,
51
+ 'n /no-restricted-require' : 'off' ,
49
52
// Disallow use of synchronous methods
50
- 'node /no-sync' : 'off' ,
53
+ 'n /no-sync' : 'off' ,
51
54
// Disallow import declarations of extraneous packages
52
55
// defer to import/no-extraneous-dependencies
53
- 'node /no-extraneous-import' : 'off' ,
56
+ 'n /no-extraneous-import' : 'off' ,
54
57
// Disallow require() expressions of extraneous packages
55
58
// defer to import/no-extraneous-dependencies
56
- 'node /no-extraneous-require' : 'off' ,
59
+ 'n /no-extraneous-require' : 'off' ,
57
60
// Enforce either module.exports or exports.
58
- 'node /exports-style' : [ 'error' , 'module.exports' ] ,
61
+ 'n /exports-style' : [ 'error' , 'module.exports' ] ,
59
62
// enforce either Buffer or require("buffer").Buffer
60
- 'node /prefer-global/buffer' : 'error' ,
63
+ 'n /prefer-global/buffer' : 'error' ,
61
64
// enforce either console or require("console")
62
- 'node /prefer-global/console' : 'error' ,
65
+ 'n /prefer-global/console' : 'error' ,
63
66
// enforce either process or require("process")
64
- 'node /prefer-global/process' : 'error' ,
67
+ 'n /prefer-global/process' : 'error' ,
65
68
// enforce either TextDecoder or require("util").TextDecoder
66
- 'node /prefer-global/text-decoder' : 'error' ,
69
+ 'n /prefer-global/text-decoder' : 'error' ,
67
70
// enforce either TextEncoder or require("util").TextEncoder
68
- 'node /prefer-global/text-encoder' : 'error' ,
71
+ 'n /prefer-global/text-encoder' : 'error' ,
69
72
// enforce either URLSearchParams or require("url").URLSearchParams
70
- 'node /prefer-global/url-search-params' : 'error' ,
73
+ 'n /prefer-global/url-search-params' : 'error' ,
71
74
// enforce either URL or require("url").URL
72
- 'node /prefer-global/url' : 'error' ,
75
+ 'n /prefer-global/url' : 'error' ,
73
76
// Disallow deprecated API.
74
- 'node /no-deprecated-api' : 'error' ,
77
+ 'n /no-deprecated-api' : 'error' ,
75
78
// Disallow import and export declarations for files that don't exist.
76
- 'node /no-missing-import' : 'off' ,
79
+ 'n /no-missing-import' : 'off' ,
77
80
// Disallow require()s for files that don't exist.
78
- 'node /no-missing-require' : 'off' ,
81
+ 'n /no-missing-require' : 'off' ,
79
82
// Disallow import and export declarations for files that are not published.
80
- 'node /no-unpublished-import' : 'off' ,
83
+ 'n /no-unpublished-import' : 'off' ,
81
84
// Disallow bin files that npm ignores.
82
- 'node /no-unpublished-bin' : 'error' ,
85
+ 'n /no-unpublished-bin' : 'error' ,
83
86
// Disallow require()s for files that are not published.
84
- 'node /no-unpublished-require' : 'off' ,
87
+ 'n /no-unpublished-require' : 'off' ,
85
88
// 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' ,
87
90
// disallow unsupported ECMAScript syntax on the specified version
88
- 'node /no-unsupported-features/es-syntax' : 'off' ,
91
+ 'n /no-unsupported-features/es-syntax' : 'off' ,
89
92
// 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' ,
91
96
// 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' ,
93
98
// 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' ,
95
102
// disallows callback API in favor of promise API for dns module
96
- 'node /prefer-promises/dns' : 'error' ,
103
+ 'n /prefer-promises/dns' : 'error' ,
97
104
// disallows callback API in favor of promise API for fs module
98
- 'node /prefer-promises/fs' : 'error' ,
105
+ 'n /prefer-promises/fs' : 'error' ,
99
106
// disallow the assignment to `exports`
100
- 'node /no-exports-assign' : 'error' ,
107
+ 'n /no-exports-assign' : 'error' ,
101
108
// Ensures the Node.js error-first callback pattern is followed
102
- 'node /no-callback-literal' : 'error' ,
109
+ 'n /no-callback-literal' : 'error' ,
103
110
104
111
'no-process-env' : 'off' ,
105
112
'no-console' : 'off' ,
0 commit comments