eslint-plugin-n 16.1.0 → 16.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/lib/rules/callback-return.js +1 -2
- package/lib/rules/exports-style.js +1 -2
- package/lib/rules/file-extension-in-import.js +7 -11
- package/lib/rules/global-require.js +1 -2
- package/lib/rules/handle-callback-err.js +1 -2
- package/lib/rules/no-callback-literal.js +1 -2
- package/lib/rules/no-deprecated-api.js +1 -2
- package/lib/rules/no-exports-assign.js +1 -2
- package/lib/rules/no-extraneous-import.js +1 -2
- package/lib/rules/no-extraneous-require.js +1 -2
- package/lib/rules/no-hide-core-modules.js +4 -4
- package/lib/rules/no-missing-import.js +1 -2
- package/lib/rules/no-missing-require.js +1 -2
- package/lib/rules/no-mixed-requires.js +1 -2
- package/lib/rules/no-new-require.js +1 -2
- package/lib/rules/no-path-concat.js +1 -2
- package/lib/rules/no-process-env.js +1 -2
- package/lib/rules/no-process-exit.js +1 -2
- package/lib/rules/no-restricted-import.js +1 -2
- package/lib/rules/no-restricted-require.js +1 -2
- package/lib/rules/no-sync.js +24 -8
- package/lib/rules/no-unpublished-bin.js +4 -4
- package/lib/rules/no-unpublished-import.js +1 -2
- package/lib/rules/no-unpublished-require.js +1 -2
- package/lib/rules/no-unsupported-features/es-builtins.js +1 -2
- package/lib/rules/no-unsupported-features/es-syntax.js +1 -2
- package/lib/rules/no-unsupported-features/node-builtins.js +1 -2
- package/lib/rules/no-unsupported-features.js +1 -2
- package/lib/rules/prefer-global/buffer.js +1 -2
- package/lib/rules/prefer-global/console.js +1 -2
- package/lib/rules/prefer-global/process.js +1 -2
- package/lib/rules/prefer-global/text-decoder.js +1 -2
- package/lib/rules/prefer-global/text-encoder.js +1 -2
- package/lib/rules/prefer-global/url-search-params.js +1 -2
- package/lib/rules/prefer-global/url.js +1 -2
- package/lib/rules/prefer-promises/dns.js +1 -2
- package/lib/rules/prefer-promises/fs.js +1 -2
- package/lib/rules/process-exit-as-throw.js +1 -2
- package/lib/rules/shebang.js +1 -2
- package/lib/util/get-npmignore.js +4 -2
- package/lib/util/import-target.js +27 -0
- package/package.json +2 -5
package/README.md
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
> forked from [eslint-plugin-node](https://www.npmjs.com/package/eslint-plugin-node) v11.1.0. as the original repository seems [no longer maintained](https://github.com/mysticatea/eslint-plugin-node/issues/300).
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/eslint-plugin-n)
|
|
5
|
+
[](https://www.npmjs.com/package/eslint-plugin-n)
|
|
6
|
+
[](https://www.npmjs.com/package/eslint-plugin-n)
|
|
7
|
+
[](https://github.com/eslint-community/eslint-plugin-n/actions)
|
|
6
8
|
|
|
7
|
-
Additional ESLint
|
|
9
|
+
Additional ESLint rules for Node.js
|
|
8
10
|
|
|
9
11
|
## 💿 Install & Usage
|
|
10
12
|
|
|
@@ -207,7 +209,7 @@ Deprecated rules follow ESLint's [deprecation policy](https://eslint.org/docs/us
|
|
|
207
209
|
|
|
208
210
|
## 📰 Changelog
|
|
209
211
|
|
|
210
|
-
- [GitHub Releases](https://github.com/
|
|
212
|
+
- [GitHub Releases](https://github.com/eslint-community/eslint-plugin-n/releases)
|
|
211
213
|
|
|
212
214
|
## ❤️ Contributing
|
|
213
215
|
|
|
@@ -9,9 +9,8 @@ module.exports = {
|
|
|
9
9
|
type: "suggestion",
|
|
10
10
|
docs: {
|
|
11
11
|
description: "require `return` statements after callbacks",
|
|
12
|
-
category: "Stylistic Issues",
|
|
13
12
|
recommended: false,
|
|
14
|
-
url: "https://github.com/
|
|
13
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/callback-return.md",
|
|
15
14
|
},
|
|
16
15
|
schema: [
|
|
17
16
|
{
|
|
@@ -227,9 +227,8 @@ module.exports = {
|
|
|
227
227
|
meta: {
|
|
228
228
|
docs: {
|
|
229
229
|
description: "enforce either `module.exports` or `exports`",
|
|
230
|
-
category: "Stylistic Issues",
|
|
231
230
|
recommended: false,
|
|
232
|
-
url: "https://github.com/
|
|
231
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/exports-style.md",
|
|
233
232
|
},
|
|
234
233
|
type: "suggestion",
|
|
235
234
|
fixable: "code",
|
|
@@ -8,9 +8,6 @@ const path = require("path")
|
|
|
8
8
|
const fs = require("fs")
|
|
9
9
|
const mapTypescriptExtension = require("../util/map-typescript-extension")
|
|
10
10
|
const visitImport = require("../util/visit-import")
|
|
11
|
-
const packageNamePattern = /^(?:@[^/\\]+[/\\])?[^/\\]+$/u
|
|
12
|
-
const corePackageOverridePattern =
|
|
13
|
-
/^(?:assert|async_hooks|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|http2|https|inspector|module|net|os|path|perf_hooks|process|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|trace_events|tty|url|util|v8|vm|worker_threads|zlib)[/\\]$/u
|
|
14
11
|
|
|
15
12
|
/**
|
|
16
13
|
* Get all file extensions of the files which have the same basename.
|
|
@@ -37,9 +34,8 @@ module.exports = {
|
|
|
37
34
|
docs: {
|
|
38
35
|
description:
|
|
39
36
|
"enforce the style of file extensions in `import` declarations",
|
|
40
|
-
category: "Stylistic Issues",
|
|
41
37
|
recommended: false,
|
|
42
|
-
url: "https://github.com/
|
|
38
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/file-extension-in-import.md",
|
|
43
39
|
},
|
|
44
40
|
fixable: "code",
|
|
45
41
|
messages: {
|
|
@@ -67,13 +63,13 @@ module.exports = {
|
|
|
67
63
|
const defaultStyle = context.options[0] || "always"
|
|
68
64
|
const overrideStyle = context.options[1] || {}
|
|
69
65
|
|
|
70
|
-
|
|
66
|
+
/**
|
|
67
|
+
* @param {import("../util/import-target.js")} target
|
|
68
|
+
* @returns {void}
|
|
69
|
+
*/
|
|
70
|
+
function verify({ filePath, name, node, moduleType }) {
|
|
71
71
|
// Ignore if it's not resolved to a file or it's a bare module.
|
|
72
|
-
if (
|
|
73
|
-
!filePath ||
|
|
74
|
-
packageNamePattern.test(name) ||
|
|
75
|
-
corePackageOverridePattern.test(name)
|
|
76
|
-
) {
|
|
72
|
+
if (moduleType !== "relative" && moduleType !== "absolute") {
|
|
77
73
|
return
|
|
78
74
|
}
|
|
79
75
|
|
|
@@ -53,9 +53,8 @@ module.exports = {
|
|
|
53
53
|
docs: {
|
|
54
54
|
description:
|
|
55
55
|
"require `require()` calls to be placed at top-level module scope",
|
|
56
|
-
category: "Stylistic Issues",
|
|
57
56
|
recommended: false,
|
|
58
|
-
url: "https://github.com/
|
|
57
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/global-require.md",
|
|
59
58
|
},
|
|
60
59
|
fixable: null,
|
|
61
60
|
schema: [],
|
|
@@ -9,9 +9,8 @@ module.exports = {
|
|
|
9
9
|
type: "suggestion",
|
|
10
10
|
docs: {
|
|
11
11
|
description: "require error handling in callbacks",
|
|
12
|
-
category: "Possible Errors",
|
|
13
12
|
recommended: false,
|
|
14
|
-
url: "https://github.com/
|
|
13
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/handle-callback-err.md",
|
|
15
14
|
},
|
|
16
15
|
fixable: null,
|
|
17
16
|
schema: [
|
|
@@ -9,9 +9,8 @@ module.exports = {
|
|
|
9
9
|
docs: {
|
|
10
10
|
description:
|
|
11
11
|
"enforce Node.js-style error-first callback pattern is followed",
|
|
12
|
-
category: "Possible Errors",
|
|
13
12
|
recommended: false,
|
|
14
|
-
url: "https://github.com/
|
|
13
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-callback-literal.md",
|
|
15
14
|
},
|
|
16
15
|
type: "problem",
|
|
17
16
|
fixable: null,
|
|
@@ -691,9 +691,8 @@ module.exports = {
|
|
|
691
691
|
meta: {
|
|
692
692
|
docs: {
|
|
693
693
|
description: "disallow deprecated APIs",
|
|
694
|
-
category: "Best Practices",
|
|
695
694
|
recommended: true,
|
|
696
|
-
url: "https://github.com/
|
|
695
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-deprecated-api.md",
|
|
697
696
|
},
|
|
698
697
|
type: "problem",
|
|
699
698
|
fixable: null,
|
|
@@ -38,9 +38,8 @@ module.exports = {
|
|
|
38
38
|
meta: {
|
|
39
39
|
docs: {
|
|
40
40
|
description: "disallow the assignment to `exports`",
|
|
41
|
-
category: "Possible Errors",
|
|
42
41
|
recommended: true,
|
|
43
|
-
url: "https://github.com/
|
|
42
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-exports-assign.md",
|
|
44
43
|
},
|
|
45
44
|
fixable: null,
|
|
46
45
|
messages: {
|
|
@@ -15,9 +15,8 @@ module.exports = {
|
|
|
15
15
|
docs: {
|
|
16
16
|
description:
|
|
17
17
|
"disallow `import` declarations which import extraneous modules",
|
|
18
|
-
category: "Possible Errors",
|
|
19
18
|
recommended: true,
|
|
20
|
-
url: "https://github.com/
|
|
19
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-extraneous-import.md",
|
|
21
20
|
},
|
|
22
21
|
type: "problem",
|
|
23
22
|
fixable: null,
|
|
@@ -16,9 +16,8 @@ module.exports = {
|
|
|
16
16
|
docs: {
|
|
17
17
|
description:
|
|
18
18
|
"disallow `require()` expressions which import extraneous modules",
|
|
19
|
-
category: "Possible Errors",
|
|
20
19
|
recommended: true,
|
|
21
|
-
url: "https://github.com/
|
|
20
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-extraneous-require.md",
|
|
22
21
|
},
|
|
23
22
|
type: "problem",
|
|
24
23
|
fixable: null,
|
|
@@ -57,9 +57,8 @@ module.exports = {
|
|
|
57
57
|
docs: {
|
|
58
58
|
description:
|
|
59
59
|
"disallow third-party modules which are hiding core modules",
|
|
60
|
-
category: "Possible Errors",
|
|
61
60
|
recommended: false,
|
|
62
|
-
url: "https://github.com/
|
|
61
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-hide-core-modules.md",
|
|
63
62
|
},
|
|
64
63
|
type: "problem",
|
|
65
64
|
deprecated: true,
|
|
@@ -81,8 +80,9 @@ module.exports = {
|
|
|
81
80
|
},
|
|
82
81
|
],
|
|
83
82
|
messages: {
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
unexpectedImport:
|
|
84
|
+
"Unexpected import of third-party module '{{name}}'.",
|
|
85
|
+
},
|
|
86
86
|
},
|
|
87
87
|
create(context) {
|
|
88
88
|
if (context.getFilename() === "<input>") {
|
|
@@ -16,9 +16,8 @@ module.exports = {
|
|
|
16
16
|
docs: {
|
|
17
17
|
description:
|
|
18
18
|
"disallow `import` declarations which import non-existence modules",
|
|
19
|
-
category: "Possible Errors",
|
|
20
19
|
recommended: true,
|
|
21
|
-
url: "https://github.com/
|
|
20
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-missing-import.md",
|
|
22
21
|
},
|
|
23
22
|
type: "problem",
|
|
24
23
|
fixable: null,
|
|
@@ -17,9 +17,8 @@ module.exports = {
|
|
|
17
17
|
docs: {
|
|
18
18
|
description:
|
|
19
19
|
"disallow `require()` expressions which import non-existence modules",
|
|
20
|
-
category: "Possible Errors",
|
|
21
20
|
recommended: true,
|
|
22
|
-
url: "https://github.com/
|
|
21
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-missing-require.md",
|
|
23
22
|
},
|
|
24
23
|
type: "problem",
|
|
25
24
|
fixable: null,
|
|
@@ -71,9 +71,8 @@ module.exports = {
|
|
|
71
71
|
docs: {
|
|
72
72
|
description:
|
|
73
73
|
"disallow `require` calls to be mixed with regular variable declarations",
|
|
74
|
-
category: "Stylistic Issues",
|
|
75
74
|
recommended: false,
|
|
76
|
-
url: "https://github.com/
|
|
75
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-mixed-requires.md",
|
|
77
76
|
},
|
|
78
77
|
fixable: null,
|
|
79
78
|
schema: [
|
|
@@ -9,9 +9,8 @@ module.exports = {
|
|
|
9
9
|
type: "suggestion",
|
|
10
10
|
docs: {
|
|
11
11
|
description: "disallow `new` operators with calls to `require`",
|
|
12
|
-
category: "Possible Errors",
|
|
13
12
|
recommended: false,
|
|
14
|
-
url: "https://github.com/
|
|
13
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-new-require.md",
|
|
15
14
|
},
|
|
16
15
|
fixable: null,
|
|
17
16
|
schema: [],
|
|
@@ -166,9 +166,8 @@ module.exports = {
|
|
|
166
166
|
docs: {
|
|
167
167
|
description:
|
|
168
168
|
"disallow string concatenation with `__dirname` and `__filename`",
|
|
169
|
-
category: "Possible Errors",
|
|
170
169
|
recommended: false,
|
|
171
|
-
url: "https://github.com/
|
|
170
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-path-concat.md",
|
|
172
171
|
},
|
|
173
172
|
fixable: null,
|
|
174
173
|
schema: [],
|
|
@@ -13,9 +13,8 @@ module.exports = {
|
|
|
13
13
|
type: "suggestion",
|
|
14
14
|
docs: {
|
|
15
15
|
description: "disallow the use of `process.env`",
|
|
16
|
-
category: "Stylistic Issues",
|
|
17
16
|
recommended: false,
|
|
18
|
-
url: "https://github.com/
|
|
17
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-process-env.md",
|
|
19
18
|
},
|
|
20
19
|
fixable: null,
|
|
21
20
|
schema: [],
|
|
@@ -9,9 +9,8 @@ module.exports = {
|
|
|
9
9
|
type: "suggestion",
|
|
10
10
|
docs: {
|
|
11
11
|
description: "disallow the use of `process.exit()`",
|
|
12
|
-
category: "Possible Errors",
|
|
13
12
|
recommended: false,
|
|
14
|
-
url: "https://github.com/
|
|
13
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-process-exit.md",
|
|
15
14
|
},
|
|
16
15
|
fixable: null,
|
|
17
16
|
schema: [],
|
|
@@ -13,9 +13,8 @@ module.exports = {
|
|
|
13
13
|
docs: {
|
|
14
14
|
description:
|
|
15
15
|
"disallow specified modules when loaded by `import` declarations",
|
|
16
|
-
category: "Stylistic Issues",
|
|
17
16
|
recommended: false,
|
|
18
|
-
url: "https://github.com/
|
|
17
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-restricted-import.md",
|
|
19
18
|
},
|
|
20
19
|
fixable: null,
|
|
21
20
|
schema: [
|
|
@@ -13,9 +13,8 @@ module.exports = {
|
|
|
13
13
|
type: "suggestion",
|
|
14
14
|
docs: {
|
|
15
15
|
description: "disallow specified modules when loaded by `require`",
|
|
16
|
-
category: "Stylistic Issues",
|
|
17
16
|
recommended: false,
|
|
18
|
-
url: "https://github.com/
|
|
17
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-restricted-require.md",
|
|
19
18
|
},
|
|
20
19
|
fixable: null,
|
|
21
20
|
schema: [
|
package/lib/rules/no-sync.js
CHANGED
|
@@ -4,14 +4,31 @@
|
|
|
4
4
|
*/
|
|
5
5
|
"use strict"
|
|
6
6
|
|
|
7
|
+
const allowedAtRootLevelSelector = [
|
|
8
|
+
// fs.readFileSync()
|
|
9
|
+
":function MemberExpression > Identifier[name=/Sync$/]",
|
|
10
|
+
// readFileSync.call(null, 'path')
|
|
11
|
+
":function MemberExpression > Identifier[name=/Sync$/]",
|
|
12
|
+
// readFileSync()
|
|
13
|
+
":function :not(MemberExpression) > Identifier[name=/Sync$/]",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
const disallowedAtRootLevelSelector = [
|
|
17
|
+
// fs.readFileSync()
|
|
18
|
+
"MemberExpression > Identifier[name=/Sync$/]",
|
|
19
|
+
// readFileSync.call(null, 'path')
|
|
20
|
+
"MemberExpression > Identifier[name=/Sync$/]",
|
|
21
|
+
// readFileSync()
|
|
22
|
+
":not(MemberExpression) > Identifier[name=/Sync$/]",
|
|
23
|
+
]
|
|
24
|
+
|
|
7
25
|
module.exports = {
|
|
8
26
|
meta: {
|
|
9
27
|
type: "suggestion",
|
|
10
28
|
docs: {
|
|
11
29
|
description: "disallow synchronous methods",
|
|
12
|
-
category: "Stylistic Issues",
|
|
13
30
|
recommended: false,
|
|
14
|
-
url: "https://github.com/
|
|
31
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-sync.md",
|
|
15
32
|
},
|
|
16
33
|
fixable: null,
|
|
17
34
|
schema: [
|
|
@@ -32,18 +49,17 @@ module.exports = {
|
|
|
32
49
|
},
|
|
33
50
|
|
|
34
51
|
create(context) {
|
|
35
|
-
const selector =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
: "MemberExpression[property.name=/.*Sync$/]"
|
|
52
|
+
const selector = context.options[0]?.allowAtRootLevel
|
|
53
|
+
? allowedAtRootLevelSelector
|
|
54
|
+
: disallowedAtRootLevelSelector
|
|
39
55
|
|
|
40
56
|
return {
|
|
41
57
|
[selector](node) {
|
|
42
58
|
context.report({
|
|
43
|
-
node,
|
|
59
|
+
node: node.parent,
|
|
44
60
|
messageId: "noSync",
|
|
45
61
|
data: {
|
|
46
|
-
propertyName: node.
|
|
62
|
+
propertyName: node.name,
|
|
47
63
|
},
|
|
48
64
|
})
|
|
49
65
|
},
|
|
@@ -33,9 +33,8 @@ module.exports = {
|
|
|
33
33
|
meta: {
|
|
34
34
|
docs: {
|
|
35
35
|
description: "disallow `bin` files that npm ignores",
|
|
36
|
-
category: "Possible Errors",
|
|
37
36
|
recommended: true,
|
|
38
|
-
url: "https://github.com/
|
|
37
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-unpublished-bin.md",
|
|
39
38
|
},
|
|
40
39
|
type: "problem",
|
|
41
40
|
fixable: null,
|
|
@@ -49,8 +48,9 @@ module.exports = {
|
|
|
49
48
|
},
|
|
50
49
|
],
|
|
51
50
|
messages: {
|
|
52
|
-
invalidIgnored:
|
|
53
|
-
|
|
51
|
+
invalidIgnored:
|
|
52
|
+
"npm ignores '{{name}}'. Check 'files' field of 'package.json' or '.npmignore'.",
|
|
53
|
+
},
|
|
54
54
|
},
|
|
55
55
|
create(context) {
|
|
56
56
|
return {
|
|
@@ -15,9 +15,8 @@ module.exports = {
|
|
|
15
15
|
docs: {
|
|
16
16
|
description:
|
|
17
17
|
"disallow `import` declarations which import private modules",
|
|
18
|
-
category: "Possible Errors",
|
|
19
18
|
recommended: true,
|
|
20
|
-
url: "https://github.com/
|
|
19
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-unpublished-import.md",
|
|
21
20
|
},
|
|
22
21
|
type: "problem",
|
|
23
22
|
fixable: null,
|
|
@@ -16,9 +16,8 @@ module.exports = {
|
|
|
16
16
|
docs: {
|
|
17
17
|
description:
|
|
18
18
|
"disallow `require()` expressions which import private modules",
|
|
19
|
-
category: "Possible Errors",
|
|
20
19
|
recommended: true,
|
|
21
|
-
url: "https://github.com/
|
|
20
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-unpublished-require.md",
|
|
22
21
|
},
|
|
23
22
|
type: "problem",
|
|
24
23
|
fixable: null,
|
|
@@ -143,9 +143,8 @@ module.exports = {
|
|
|
143
143
|
docs: {
|
|
144
144
|
description:
|
|
145
145
|
"disallow unsupported ECMAScript built-ins on the specified version",
|
|
146
|
-
category: "Possible Errors",
|
|
147
146
|
recommended: true,
|
|
148
|
-
url: "https://github.com/
|
|
147
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-unsupported-features/es-builtins.md",
|
|
149
148
|
},
|
|
150
149
|
type: "problem",
|
|
151
150
|
fixable: null,
|
|
@@ -523,9 +523,8 @@ module.exports = {
|
|
|
523
523
|
docs: {
|
|
524
524
|
description:
|
|
525
525
|
"disallow unsupported ECMAScript syntax on the specified version",
|
|
526
|
-
category: "Possible Errors",
|
|
527
526
|
recommended: true,
|
|
528
|
-
url: "https://github.com/
|
|
527
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-unsupported-features/es-syntax.md",
|
|
529
528
|
},
|
|
530
529
|
type: "problem",
|
|
531
530
|
fixable: null,
|
|
@@ -379,9 +379,8 @@ module.exports = {
|
|
|
379
379
|
docs: {
|
|
380
380
|
description:
|
|
381
381
|
"disallow unsupported Node.js built-in APIs on the specified version",
|
|
382
|
-
category: "Possible Errors",
|
|
383
382
|
recommended: true,
|
|
384
|
-
url: "https://github.com/
|
|
383
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-unsupported-features/node-builtins.md",
|
|
385
384
|
},
|
|
386
385
|
type: "problem",
|
|
387
386
|
fixable: null,
|
|
@@ -1048,10 +1048,9 @@ module.exports = {
|
|
|
1048
1048
|
docs: {
|
|
1049
1049
|
description:
|
|
1050
1050
|
"disallow unsupported ECMAScript features on the specified version",
|
|
1051
|
-
category: "Possible Errors",
|
|
1052
1051
|
recommended: false,
|
|
1053
1052
|
|
|
1054
|
-
url: "https://github.com/
|
|
1053
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-unsupported-features.md",
|
|
1055
1054
|
},
|
|
1056
1055
|
type: "problem",
|
|
1057
1056
|
deprecated: true,
|
|
@@ -23,9 +23,8 @@ module.exports = {
|
|
|
23
23
|
docs: {
|
|
24
24
|
description:
|
|
25
25
|
'enforce either `Buffer` or `require("buffer").Buffer`',
|
|
26
|
-
category: "Stylistic Issues",
|
|
27
26
|
recommended: false,
|
|
28
|
-
url: "https://github.com/
|
|
27
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-global/buffer.md",
|
|
29
28
|
},
|
|
30
29
|
type: "suggestion",
|
|
31
30
|
fixable: null,
|
|
@@ -20,9 +20,8 @@ module.exports = {
|
|
|
20
20
|
meta: {
|
|
21
21
|
docs: {
|
|
22
22
|
description: 'enforce either `console` or `require("console")`',
|
|
23
|
-
category: "Stylistic Issues",
|
|
24
23
|
recommended: false,
|
|
25
|
-
url: "https://github.com/
|
|
24
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-global/console.md",
|
|
26
25
|
},
|
|
27
26
|
type: "suggestion",
|
|
28
27
|
fixable: null,
|
|
@@ -20,9 +20,8 @@ module.exports = {
|
|
|
20
20
|
meta: {
|
|
21
21
|
docs: {
|
|
22
22
|
description: 'enforce either `process` or `require("process")`',
|
|
23
|
-
category: "Stylistic Issues",
|
|
24
23
|
recommended: false,
|
|
25
|
-
url: "https://github.com/
|
|
24
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-global/process.md",
|
|
26
25
|
},
|
|
27
26
|
type: "suggestion",
|
|
28
27
|
fixable: null,
|
|
@@ -23,9 +23,8 @@ module.exports = {
|
|
|
23
23
|
docs: {
|
|
24
24
|
description:
|
|
25
25
|
'enforce either `TextDecoder` or `require("util").TextDecoder`',
|
|
26
|
-
category: "Stylistic Issues",
|
|
27
26
|
recommended: false,
|
|
28
|
-
url: "https://github.com/
|
|
27
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-global/text-decoder.md",
|
|
29
28
|
},
|
|
30
29
|
type: "suggestion",
|
|
31
30
|
fixable: null,
|
|
@@ -23,9 +23,8 @@ module.exports = {
|
|
|
23
23
|
docs: {
|
|
24
24
|
description:
|
|
25
25
|
'enforce either `TextEncoder` or `require("util").TextEncoder`',
|
|
26
|
-
category: "Stylistic Issues",
|
|
27
26
|
recommended: false,
|
|
28
|
-
url: "https://github.com/
|
|
27
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-global/text-encoder.md",
|
|
29
28
|
},
|
|
30
29
|
type: "suggestion",
|
|
31
30
|
fixable: null,
|
|
@@ -23,9 +23,8 @@ module.exports = {
|
|
|
23
23
|
docs: {
|
|
24
24
|
description:
|
|
25
25
|
'enforce either `URLSearchParams` or `require("url").URLSearchParams`',
|
|
26
|
-
category: "Stylistic Issues",
|
|
27
26
|
recommended: false,
|
|
28
|
-
url: "https://github.com/
|
|
27
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-global/url-search-params.md",
|
|
29
28
|
},
|
|
30
29
|
type: "suggestion",
|
|
31
30
|
fixable: null,
|
|
@@ -22,9 +22,8 @@ module.exports = {
|
|
|
22
22
|
meta: {
|
|
23
23
|
docs: {
|
|
24
24
|
description: 'enforce either `URL` or `require("url").URL`',
|
|
25
|
-
category: "Stylistic Issues",
|
|
26
25
|
recommended: false,
|
|
27
|
-
url: "https://github.com/
|
|
26
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-global/url.md",
|
|
28
27
|
},
|
|
29
28
|
type: "suggestion",
|
|
30
29
|
fixable: null,
|
|
@@ -38,9 +38,8 @@ module.exports = {
|
|
|
38
38
|
meta: {
|
|
39
39
|
docs: {
|
|
40
40
|
description: 'enforce `require("dns").promises`',
|
|
41
|
-
category: "Stylistic Issues",
|
|
42
41
|
recommended: false,
|
|
43
|
-
url: "https://github.com/
|
|
42
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-promises/dns.md",
|
|
44
43
|
},
|
|
45
44
|
fixable: null,
|
|
46
45
|
messages: {
|
|
@@ -40,9 +40,8 @@ module.exports = {
|
|
|
40
40
|
meta: {
|
|
41
41
|
docs: {
|
|
42
42
|
description: 'enforce `require("fs").promises`',
|
|
43
|
-
category: "Stylistic Issues",
|
|
44
43
|
recommended: false,
|
|
45
|
-
url: "https://github.com/
|
|
44
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-promises/fs.md",
|
|
46
45
|
},
|
|
47
46
|
fixable: null,
|
|
48
47
|
messages: {
|
|
@@ -149,9 +149,8 @@ module.exports = {
|
|
|
149
149
|
docs: {
|
|
150
150
|
description:
|
|
151
151
|
"require that `process.exit()` expressions use the same code path as `throw`",
|
|
152
|
-
category: "Possible Errors",
|
|
153
152
|
recommended: true,
|
|
154
|
-
url: "https://github.com/
|
|
153
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/process-exit-as-throw.md",
|
|
155
154
|
},
|
|
156
155
|
type: "problem",
|
|
157
156
|
fixable: null,
|
package/lib/rules/shebang.js
CHANGED
|
@@ -70,9 +70,8 @@ module.exports = {
|
|
|
70
70
|
meta: {
|
|
71
71
|
docs: {
|
|
72
72
|
description: "require correct usage of shebang",
|
|
73
|
-
category: "Possible Errors",
|
|
74
73
|
recommended: true,
|
|
75
|
-
url: "https://github.com/
|
|
74
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/shebang.md",
|
|
76
75
|
},
|
|
77
76
|
type: "problem",
|
|
78
77
|
fixable: "code",
|
|
@@ -12,7 +12,6 @@ const exists = require("./exists")
|
|
|
12
12
|
const getPackageJson = require("./get-package-json")
|
|
13
13
|
|
|
14
14
|
const cache = new Cache()
|
|
15
|
-
const SLASH_AT_BEGIN_AND_END = /^!?\/+|^!|\/+$/gu
|
|
16
15
|
const PARENT_RELATIVE_PATH = /^\.\./u
|
|
17
16
|
const NEVER_IGNORED =
|
|
18
17
|
/^(?:readme\.[^.]*|(?:licen[cs]e|changes|changelog|history)(?:\.[^.]*)?)$/iu
|
|
@@ -90,7 +89,10 @@ function parseWhiteList(files) {
|
|
|
90
89
|
|
|
91
90
|
for (const file of files) {
|
|
92
91
|
if (typeof file === "string" && file) {
|
|
93
|
-
const body =
|
|
92
|
+
const body = path.posix
|
|
93
|
+
.normalize(file.replace(/^!/u, ""))
|
|
94
|
+
.replace(/\/+$/u, "")
|
|
95
|
+
|
|
94
96
|
if (file.startsWith("!")) {
|
|
95
97
|
igN.add(`${body}`)
|
|
96
98
|
igN.add(`${body}/**`)
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
const path = require("path")
|
|
8
8
|
const { pathToFileURL, fileURLToPath } = require("url")
|
|
9
|
+
const { isBuiltin } = require("module")
|
|
9
10
|
const resolve = require("resolve")
|
|
10
11
|
const {
|
|
11
12
|
defaultResolve: importResolve,
|
|
@@ -72,6 +73,14 @@ function getFilePath(isModule, id, options, moduleType) {
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
|
|
76
|
+
function isNodeModule(name, options) {
|
|
77
|
+
try {
|
|
78
|
+
return require.resolve(name, options).startsWith(path.sep)
|
|
79
|
+
} catch {
|
|
80
|
+
return false
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
75
84
|
/**
|
|
76
85
|
* Gets the module name of a given path.
|
|
77
86
|
*
|
|
@@ -115,6 +124,24 @@ module.exports = class ImportTarget {
|
|
|
115
124
|
*/
|
|
116
125
|
this.name = name
|
|
117
126
|
|
|
127
|
+
/**
|
|
128
|
+
* What type of module is this
|
|
129
|
+
* @type {'unknown'|'relative'|'absolute'|'node'|'npm'|'http'|void}
|
|
130
|
+
*/
|
|
131
|
+
this.moduleType = "unknown"
|
|
132
|
+
|
|
133
|
+
if (name.startsWith("./") || name.startsWith(".\\")) {
|
|
134
|
+
this.moduleType = "relative"
|
|
135
|
+
} else if (name.startsWith("/") || name.startsWith("\\")) {
|
|
136
|
+
this.moduleType = "absolute"
|
|
137
|
+
} else if (isBuiltin(name)) {
|
|
138
|
+
this.moduleType = "node"
|
|
139
|
+
} else if (isNodeModule(name, options)) {
|
|
140
|
+
this.moduleType = "npm"
|
|
141
|
+
} else if (name.startsWith("http://") || name.startsWith("https://")) {
|
|
142
|
+
this.moduleType = "http"
|
|
143
|
+
}
|
|
144
|
+
|
|
118
145
|
/**
|
|
119
146
|
* The full path of this import target.
|
|
120
147
|
* If the target is a module and it does not exist then this is `null`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-n",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.3.0",
|
|
4
4
|
"description": "Additional ESLint's rules for Node.js",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.0.0"
|
|
@@ -25,11 +25,9 @@
|
|
|
25
25
|
"semver": "^7.5.3"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@eslint/eslintrc": "^2.0.3",
|
|
29
28
|
"@eslint/js": "^8.43.0",
|
|
30
29
|
"@types/eslint": "^8.44.2",
|
|
31
30
|
"@typescript-eslint/parser": "^5.60.0",
|
|
32
|
-
"codecov": "^3.8.2",
|
|
33
31
|
"esbuild": "^0.18.7",
|
|
34
32
|
"eslint": "^8.43.0",
|
|
35
33
|
"eslint-config-prettier": "^8.8.0",
|
|
@@ -43,7 +41,7 @@
|
|
|
43
41
|
"lint-staged": "^13.2.2",
|
|
44
42
|
"markdownlint-cli": "^0.35.0",
|
|
45
43
|
"mocha": "^10.2.0",
|
|
46
|
-
"npm-run-
|
|
44
|
+
"npm-run-all2": "^6.1.1",
|
|
47
45
|
"nyc": "^15.1.0",
|
|
48
46
|
"opener": "^1.5.2",
|
|
49
47
|
"prettier": "^2.8.8",
|
|
@@ -55,7 +53,6 @@
|
|
|
55
53
|
"scripts": {
|
|
56
54
|
"build": "node scripts/update",
|
|
57
55
|
"clean": "rimraf .nyc_output coverage",
|
|
58
|
-
"codecov": "nyc report --reporter text-lcov | codecov --pipe --disable=gcov -t $CODECOV_TOKEN",
|
|
59
56
|
"coverage": "opener ./coverage/lcov-report/index.html",
|
|
60
57
|
"format": "prettier --loglevel warn --write \"**/*.{js,css,md}\"",
|
|
61
58
|
"lint": "npm-run-all \"lint:*\"",
|