eslint-plugin-n 15.2.2 → 15.2.5
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/lib/rules/exports-style.js +11 -6
- package/lib/rules/no-callback-literal.js +4 -2
- package/lib/rules/no-deprecated-api.js +4 -2
- package/lib/rules/no-extraneous-import.js +2 -1
- package/lib/rules/no-extraneous-require.js +2 -1
- package/lib/rules/no-hide-core-modules.js +4 -2
- package/lib/rules/no-missing-import.js +2 -1
- package/lib/rules/no-missing-require.js +2 -1
- package/lib/rules/no-restricted-import.js +5 -6
- package/lib/rules/no-restricted-require.js +5 -6
- package/lib/rules/no-unpublished-bin.js +4 -2
- package/lib/rules/no-unpublished-import.js +2 -1
- package/lib/rules/no-unpublished-require.js +2 -1
- package/lib/rules/no-unsupported-features/es-builtins.js +5 -5
- package/lib/rules/no-unsupported-features/es-syntax.js +6 -5
- package/lib/rules/no-unsupported-features/node-builtins.js +5 -5
- package/lib/rules/no-unsupported-features.js +6 -4
- package/lib/rules/process-exit-as-throw.js +1 -0
- package/lib/rules/shebang.js +10 -6
- package/lib/util/check-existence.js +6 -2
- package/lib/util/check-extraneous.js +6 -2
- package/lib/util/check-publish.js +17 -7
- package/lib/util/check-restricted.js +6 -1
- package/lib/util/check-unsupported-builtins.js +9 -1
- package/lib/util/map-typescript-extension.js +1 -0
- package/package.json +8 -8
|
@@ -244,6 +244,14 @@ module.exports = {
|
|
|
244
244
|
additionalProperties: false,
|
|
245
245
|
},
|
|
246
246
|
],
|
|
247
|
+
messages: {
|
|
248
|
+
unexpectedExports:
|
|
249
|
+
"Unexpected access to 'exports'. Use 'module.exports' instead.",
|
|
250
|
+
unexpectedModuleExports:
|
|
251
|
+
"Unexpected access to 'module.exports'. Use 'exports' instead.",
|
|
252
|
+
unexpectedAssignment:
|
|
253
|
+
"Unexpected assignment to 'exports'. Don't modify 'exports' itself.",
|
|
254
|
+
},
|
|
247
255
|
},
|
|
248
256
|
|
|
249
257
|
create(context) {
|
|
@@ -299,8 +307,7 @@ module.exports = {
|
|
|
299
307
|
context.report({
|
|
300
308
|
node,
|
|
301
309
|
loc: getLocation(node),
|
|
302
|
-
|
|
303
|
-
"Unexpected access to 'exports'. Use 'module.exports' instead.",
|
|
310
|
+
messageId: "unexpectedExports",
|
|
304
311
|
})
|
|
305
312
|
}
|
|
306
313
|
}
|
|
@@ -335,8 +342,7 @@ module.exports = {
|
|
|
335
342
|
context.report({
|
|
336
343
|
node,
|
|
337
344
|
loc: getLocation(node),
|
|
338
|
-
|
|
339
|
-
"Unexpected access to 'module.exports'. Use 'exports' instead.",
|
|
345
|
+
messageId: "unexpectedModuleExports",
|
|
340
346
|
fix(fixer) {
|
|
341
347
|
return fixModuleExports(node, sourceCode, fixer)
|
|
342
348
|
},
|
|
@@ -359,8 +365,7 @@ module.exports = {
|
|
|
359
365
|
context.report({
|
|
360
366
|
node,
|
|
361
367
|
loc: getLocation(node),
|
|
362
|
-
|
|
363
|
-
"Unexpected assignment to 'exports'. Don't modify 'exports' itself.",
|
|
368
|
+
messageId: "unexpectedAssignment",
|
|
364
369
|
})
|
|
365
370
|
}
|
|
366
371
|
}
|
|
@@ -16,6 +16,9 @@ module.exports = {
|
|
|
16
16
|
type: "problem",
|
|
17
17
|
fixable: null,
|
|
18
18
|
schema: [],
|
|
19
|
+
messages: {
|
|
20
|
+
unexpectedLiteral: "Unexpected literal in error position of callback."
|
|
21
|
+
}
|
|
19
22
|
},
|
|
20
23
|
|
|
21
24
|
create(context) {
|
|
@@ -37,8 +40,7 @@ module.exports = {
|
|
|
37
40
|
) {
|
|
38
41
|
context.report({
|
|
39
42
|
node,
|
|
40
|
-
|
|
41
|
-
"Unexpected literal in error position of callback.",
|
|
43
|
+
messageId: "unexpectedLiteral",
|
|
42
44
|
})
|
|
43
45
|
}
|
|
44
46
|
},
|
|
@@ -719,6 +719,9 @@ module.exports = {
|
|
|
719
719
|
additionalProperties: false,
|
|
720
720
|
},
|
|
721
721
|
],
|
|
722
|
+
messages: {
|
|
723
|
+
"deprecated": "{{name}} was deprecated since v{{version}}{{replace}}."
|
|
724
|
+
}
|
|
722
725
|
},
|
|
723
726
|
create(context) {
|
|
724
727
|
const { ignoredModuleItems, ignoredGlobalItems, version } =
|
|
@@ -736,8 +739,7 @@ module.exports = {
|
|
|
736
739
|
context.report({
|
|
737
740
|
node,
|
|
738
741
|
loc: node.loc,
|
|
739
|
-
|
|
740
|
-
"{{name}} was deprecated since v{{version}}{{replace}}.",
|
|
742
|
+
messageId: "deprecated",
|
|
741
743
|
data: {
|
|
742
744
|
name,
|
|
743
745
|
version: info.since,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
"use strict"
|
|
6
6
|
|
|
7
|
-
const checkExtraneous = require("../util/check-extraneous")
|
|
7
|
+
const { checkExtraneous, messages } = require("../util/check-extraneous")
|
|
8
8
|
const getAllowModules = require("../util/get-allow-modules")
|
|
9
9
|
const getConvertPath = require("../util/get-convert-path")
|
|
10
10
|
const getResolvePaths = require("../util/get-resolve-paths")
|
|
@@ -32,6 +32,7 @@ module.exports = {
|
|
|
32
32
|
additionalProperties: false,
|
|
33
33
|
},
|
|
34
34
|
],
|
|
35
|
+
messages,
|
|
35
36
|
},
|
|
36
37
|
create(context) {
|
|
37
38
|
const filePath = context.getFilename()
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
"use strict"
|
|
6
6
|
|
|
7
|
-
const checkExtraneous = require("../util/check-extraneous")
|
|
7
|
+
const { checkExtraneous, messages } = require("../util/check-extraneous")
|
|
8
8
|
const getAllowModules = require("../util/get-allow-modules")
|
|
9
9
|
const getConvertPath = require("../util/get-convert-path")
|
|
10
10
|
const getResolvePaths = require("../util/get-resolve-paths")
|
|
@@ -34,6 +34,7 @@ module.exports = {
|
|
|
34
34
|
additionalProperties: false,
|
|
35
35
|
},
|
|
36
36
|
],
|
|
37
|
+
messages,
|
|
37
38
|
},
|
|
38
39
|
create(context) {
|
|
39
40
|
const filePath = context.getFilename()
|
|
@@ -80,6 +80,9 @@ module.exports = {
|
|
|
80
80
|
additionalProperties: false,
|
|
81
81
|
},
|
|
82
82
|
],
|
|
83
|
+
messages: {
|
|
84
|
+
"unexpectedImport": "Unexpected import of third-party module '{{name}}'.",
|
|
85
|
+
}
|
|
83
86
|
},
|
|
84
87
|
create(context) {
|
|
85
88
|
if (context.getFilename() === "<input>") {
|
|
@@ -149,8 +152,7 @@ module.exports = {
|
|
|
149
152
|
context.report({
|
|
150
153
|
node: target.node,
|
|
151
154
|
loc: target.node.loc,
|
|
152
|
-
|
|
153
|
-
"Unexpected import of third-party module '{{name}}'.",
|
|
155
|
+
messageId: "unexpectedImport",
|
|
154
156
|
data: {
|
|
155
157
|
name: path
|
|
156
158
|
.relative(dirPath, resolved)
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
"use strict"
|
|
6
6
|
|
|
7
|
-
const checkExistence = require("../util/check-existence")
|
|
7
|
+
const { checkExistence, messages } = require("../util/check-existence")
|
|
8
8
|
const getAllowModules = require("../util/get-allow-modules")
|
|
9
9
|
const getResolvePaths = require("../util/get-resolve-paths")
|
|
10
10
|
const visitImport = require("../util/visit-import")
|
|
@@ -30,6 +30,7 @@ module.exports = {
|
|
|
30
30
|
additionalProperties: false,
|
|
31
31
|
},
|
|
32
32
|
],
|
|
33
|
+
messages,
|
|
33
34
|
},
|
|
34
35
|
create(context) {
|
|
35
36
|
const filePath = context.getFilename()
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
"use strict"
|
|
6
6
|
|
|
7
|
-
const checkExistence = require("../util/check-existence")
|
|
7
|
+
const { checkExistence, messages } = require("../util/check-existence")
|
|
8
8
|
const getAllowModules = require("../util/get-allow-modules")
|
|
9
9
|
const getResolvePaths = require("../util/get-resolve-paths")
|
|
10
10
|
const getTryExtensions = require("../util/get-try-extensions")
|
|
@@ -32,6 +32,7 @@ module.exports = {
|
|
|
32
32
|
additionalProperties: false,
|
|
33
33
|
},
|
|
34
34
|
],
|
|
35
|
+
messages,
|
|
35
36
|
},
|
|
36
37
|
create(context) {
|
|
37
38
|
const filePath = context.getFilename()
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
"use strict"
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const { checkForRestriction, messages } = require("../util/check-restricted")
|
|
8
8
|
const visit = require("../util/visit-import")
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
@@ -47,14 +47,13 @@ module.exports = {
|
|
|
47
47
|
additionalItems: false,
|
|
48
48
|
},
|
|
49
49
|
],
|
|
50
|
-
messages
|
|
51
|
-
restricted:
|
|
52
|
-
"'{{name}}' module is restricted from being used.{{customMessage}}",
|
|
53
|
-
},
|
|
50
|
+
messages,
|
|
54
51
|
},
|
|
55
52
|
|
|
56
53
|
create(context) {
|
|
57
54
|
const opts = { includeCore: true }
|
|
58
|
-
return visit(context, opts, targets =>
|
|
55
|
+
return visit(context, opts, targets =>
|
|
56
|
+
checkForRestriction(context, targets)
|
|
57
|
+
)
|
|
59
58
|
},
|
|
60
59
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
"use strict"
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const { checkForRestriction, messages } = require("../util/check-restricted")
|
|
9
9
|
const visit = require("../util/visit-require")
|
|
10
10
|
|
|
11
11
|
module.exports = {
|
|
@@ -47,14 +47,13 @@ module.exports = {
|
|
|
47
47
|
additionalItems: false,
|
|
48
48
|
},
|
|
49
49
|
],
|
|
50
|
-
messages
|
|
51
|
-
restricted:
|
|
52
|
-
"'{{name}}' module is restricted from being used.{{customMessage}}",
|
|
53
|
-
},
|
|
50
|
+
messages,
|
|
54
51
|
},
|
|
55
52
|
|
|
56
53
|
create(context) {
|
|
57
54
|
const opts = { includeCore: true }
|
|
58
|
-
return visit(context, opts, targets =>
|
|
55
|
+
return visit(context, opts, targets =>
|
|
56
|
+
checkForRestriction(context, targets)
|
|
57
|
+
)
|
|
59
58
|
},
|
|
60
59
|
}
|
|
@@ -48,6 +48,9 @@ module.exports = {
|
|
|
48
48
|
},
|
|
49
49
|
},
|
|
50
50
|
],
|
|
51
|
+
messages: {
|
|
52
|
+
invalidIgnored: "npm ignores '{{name}}'. Check 'files' field of 'package.json' or '.npmignore'."
|
|
53
|
+
}
|
|
51
54
|
},
|
|
52
55
|
create(context) {
|
|
53
56
|
return {
|
|
@@ -86,8 +89,7 @@ module.exports = {
|
|
|
86
89
|
// Report.
|
|
87
90
|
context.report({
|
|
88
91
|
node,
|
|
89
|
-
|
|
90
|
-
"npm ignores '{{name}}'. Check 'files' field of 'package.json' or '.npmignore'.",
|
|
92
|
+
messageId: "invalidIgnored",
|
|
91
93
|
data: { name: relativePath },
|
|
92
94
|
})
|
|
93
95
|
},
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
"use strict"
|
|
6
6
|
|
|
7
|
-
const checkPublish = require("../util/check-publish")
|
|
7
|
+
const { checkPublish, messages } = require("../util/check-publish")
|
|
8
8
|
const getAllowModules = require("../util/get-allow-modules")
|
|
9
9
|
const getConvertPath = require("../util/get-convert-path")
|
|
10
10
|
const getResolvePaths = require("../util/get-resolve-paths")
|
|
@@ -32,6 +32,7 @@ module.exports = {
|
|
|
32
32
|
additionalProperties: false,
|
|
33
33
|
},
|
|
34
34
|
],
|
|
35
|
+
messages,
|
|
35
36
|
},
|
|
36
37
|
create(context) {
|
|
37
38
|
const filePath = context.getFilename()
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
"use strict"
|
|
6
6
|
|
|
7
|
-
const checkPublish = require("../util/check-publish")
|
|
7
|
+
const { checkPublish, messages } = require("../util/check-publish")
|
|
8
8
|
const getAllowModules = require("../util/get-allow-modules")
|
|
9
9
|
const getConvertPath = require("../util/get-convert-path")
|
|
10
10
|
const getResolvePaths = require("../util/get-resolve-paths")
|
|
@@ -34,6 +34,7 @@ module.exports = {
|
|
|
34
34
|
additionalProperties: false,
|
|
35
35
|
},
|
|
36
36
|
],
|
|
37
|
+
messages,
|
|
37
38
|
},
|
|
38
39
|
create(context) {
|
|
39
40
|
const filePath = context.getFilename()
|
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
"use strict"
|
|
6
6
|
|
|
7
7
|
const { READ } = require("eslint-utils")
|
|
8
|
-
const
|
|
8
|
+
const {
|
|
9
|
+
checkUnsupportedBuiltins,
|
|
10
|
+
messages,
|
|
11
|
+
} = require("../../util/check-unsupported-builtins")
|
|
9
12
|
const enumeratePropertyNames = require("../../util/enumerate-property-names")
|
|
10
13
|
|
|
11
14
|
const trackMap = {
|
|
@@ -165,10 +168,7 @@ module.exports = {
|
|
|
165
168
|
additionalProperties: false,
|
|
166
169
|
},
|
|
167
170
|
],
|
|
168
|
-
messages
|
|
169
|
-
unsupported:
|
|
170
|
-
"The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.",
|
|
171
|
-
},
|
|
171
|
+
messages,
|
|
172
172
|
},
|
|
173
173
|
create(context) {
|
|
174
174
|
return {
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
const { rules: esRules } = require("eslint-plugin-es")
|
|
8
8
|
const { getInnermostScope } = require("eslint-utils")
|
|
9
9
|
const { Range } = require("semver")
|
|
10
|
+
const rangeSubset = require("semver/ranges/subset")
|
|
10
11
|
const getConfiguredNodeVersion = require("../../util/get-configured-node-version")
|
|
11
12
|
const getSemverRange = require("../../util/get-semver-range")
|
|
12
13
|
const mergeVisitorsInPlace = require("../../util/merge-visitors-in-place")
|
|
@@ -457,11 +458,11 @@ function defineVisitor(context, options) {
|
|
|
457
458
|
return true
|
|
458
459
|
}
|
|
459
460
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
return options.version
|
|
461
|
+
const supported =
|
|
462
|
+
typeof aCase.supported === "string"
|
|
463
|
+
? getSemverRange(`>=${aCase.supported}`)
|
|
464
|
+
: aCase.supported
|
|
465
|
+
return !rangeSubset(options.version, supported)
|
|
465
466
|
}
|
|
466
467
|
|
|
467
468
|
/**
|
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
"use strict"
|
|
6
6
|
|
|
7
7
|
const { READ } = require("eslint-utils")
|
|
8
|
-
const
|
|
8
|
+
const {
|
|
9
|
+
checkUnsupportedBuiltins,
|
|
10
|
+
messages,
|
|
11
|
+
} = require("../../util/check-unsupported-builtins")
|
|
9
12
|
const enumeratePropertyNames = require("../../util/enumerate-property-names")
|
|
10
13
|
|
|
11
14
|
const trackMap = {
|
|
@@ -400,10 +403,7 @@ module.exports = {
|
|
|
400
403
|
additionalProperties: false,
|
|
401
404
|
},
|
|
402
405
|
],
|
|
403
|
-
messages
|
|
404
|
-
unsupported:
|
|
405
|
-
"The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.",
|
|
406
|
-
},
|
|
406
|
+
messages,
|
|
407
407
|
},
|
|
408
408
|
create(context) {
|
|
409
409
|
return {
|
|
@@ -1076,6 +1076,10 @@ module.exports = {
|
|
|
1076
1076
|
],
|
|
1077
1077
|
},
|
|
1078
1078
|
],
|
|
1079
|
+
messages: {
|
|
1080
|
+
unsupported:
|
|
1081
|
+
"{{feature}} {{be}} not supported yet on Node {{version}}.",
|
|
1082
|
+
},
|
|
1079
1083
|
},
|
|
1080
1084
|
create(context) {
|
|
1081
1085
|
const sourceCode = context.getSourceCode()
|
|
@@ -1161,8 +1165,7 @@ module.exports = {
|
|
|
1161
1165
|
if (!feature.supportedInStrict) {
|
|
1162
1166
|
context.report({
|
|
1163
1167
|
node,
|
|
1164
|
-
|
|
1165
|
-
"{{feature}} {{be}} not supported yet on Node {{version}}.",
|
|
1168
|
+
messageId: "unsupported",
|
|
1166
1169
|
data: {
|
|
1167
1170
|
feature: feature.name,
|
|
1168
1171
|
be: feature.singular ? "is" : "are",
|
|
@@ -1172,8 +1175,7 @@ module.exports = {
|
|
|
1172
1175
|
} else if (!normalizeScope(context.getScope(), node).isStrict) {
|
|
1173
1176
|
context.report({
|
|
1174
1177
|
node,
|
|
1175
|
-
|
|
1176
|
-
"{{feature}} {{be}} not supported yet on Node {{version}}.",
|
|
1178
|
+
messageId: "unsupported",
|
|
1177
1179
|
data: {
|
|
1178
1180
|
feature: `${feature.name} in non-strict mode`,
|
|
1179
1181
|
be: feature.singular ? "is" : "are",
|
package/lib/rules/shebang.js
CHANGED
|
@@ -86,6 +86,12 @@ module.exports = {
|
|
|
86
86
|
additionalProperties: false,
|
|
87
87
|
},
|
|
88
88
|
],
|
|
89
|
+
messages: {
|
|
90
|
+
unexpectedBOM: "This file must not have Unicode BOM.",
|
|
91
|
+
expectedLF: "This file must have Unix linebreaks (LF).",
|
|
92
|
+
expectedHashbangNode: 'This file needs shebang "#!/usr/bin/env node".',
|
|
93
|
+
expectedHashbang: "This file needs no shebang."
|
|
94
|
+
}
|
|
89
95
|
},
|
|
90
96
|
create(context) {
|
|
91
97
|
const sourceCode = context.getSourceCode()
|
|
@@ -123,7 +129,7 @@ module.exports = {
|
|
|
123
129
|
if (needsShebang && info.bom) {
|
|
124
130
|
context.report({
|
|
125
131
|
node,
|
|
126
|
-
|
|
132
|
+
messageId: "unexpectedBOM",
|
|
127
133
|
fix(fixer) {
|
|
128
134
|
return fixer.removeRange([-1, 0])
|
|
129
135
|
},
|
|
@@ -132,8 +138,7 @@ module.exports = {
|
|
|
132
138
|
if (needsShebang && info.cr) {
|
|
133
139
|
context.report({
|
|
134
140
|
node,
|
|
135
|
-
|
|
136
|
-
"This file must have Unix linebreaks (LF).",
|
|
141
|
+
messageId: "expectedLF",
|
|
137
142
|
fix(fixer) {
|
|
138
143
|
const index = sourceCode.text.indexOf("\r")
|
|
139
144
|
return fixer.removeRange([index, index + 1])
|
|
@@ -144,8 +149,7 @@ module.exports = {
|
|
|
144
149
|
// Shebang is lacking.
|
|
145
150
|
context.report({
|
|
146
151
|
node,
|
|
147
|
-
|
|
148
|
-
'This file needs shebang "#!/usr/bin/env node".',
|
|
152
|
+
messageId: "expectedHashbangNode",
|
|
149
153
|
fix(fixer) {
|
|
150
154
|
return fixer.replaceTextRange(
|
|
151
155
|
[-1, info.length],
|
|
@@ -157,7 +161,7 @@ module.exports = {
|
|
|
157
161
|
// Shebang is extra.
|
|
158
162
|
context.report({
|
|
159
163
|
node,
|
|
160
|
-
|
|
164
|
+
messageId: "expectedHashbang",
|
|
161
165
|
fix(fixer) {
|
|
162
166
|
return fixer.removeRange([0, info.length])
|
|
163
167
|
},
|
|
@@ -20,7 +20,7 @@ const mapTypescriptExtension = require("../util/map-typescript-extension")
|
|
|
20
20
|
* @param {ImportTarget[]} targets - A list of target information to check.
|
|
21
21
|
* @returns {void}
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
exports.checkExistence = function checkExistence(context, targets) {
|
|
24
24
|
const allowed = new Set(getAllowModules(context))
|
|
25
25
|
|
|
26
26
|
for (const target of targets) {
|
|
@@ -47,9 +47,13 @@ module.exports = function checkExistence(context, targets) {
|
|
|
47
47
|
context.report({
|
|
48
48
|
node: target.node,
|
|
49
49
|
loc: target.node.loc,
|
|
50
|
-
|
|
50
|
+
messageId: "notFound",
|
|
51
51
|
data: target,
|
|
52
52
|
})
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
+
|
|
57
|
+
exports.messages = {
|
|
58
|
+
notFound: '"{{name}}" is not found.',
|
|
59
|
+
}
|
|
@@ -17,7 +17,7 @@ const getPackageJson = require("./get-package-json")
|
|
|
17
17
|
* @param {ImportTarget[]} targets - A list of target information to check.
|
|
18
18
|
* @returns {void}
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
exports.checkExtraneous = function checkExtraneous(context, filePath, targets) {
|
|
21
21
|
const packageInfo = getPackageJson(filePath)
|
|
22
22
|
if (!packageInfo) {
|
|
23
23
|
return
|
|
@@ -44,9 +44,13 @@ module.exports = function checkForExtraneous(context, filePath, targets) {
|
|
|
44
44
|
context.report({
|
|
45
45
|
node: target.node,
|
|
46
46
|
loc: target.node.loc,
|
|
47
|
-
|
|
47
|
+
messageId: "extraneous",
|
|
48
48
|
data: target,
|
|
49
49
|
})
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
+
|
|
54
|
+
exports.messages = {
|
|
55
|
+
extraneous: '"{{moduleName}}" is extraneous.',
|
|
56
|
+
}
|
|
@@ -20,7 +20,7 @@ const getPackageJson = require("./get-package-json")
|
|
|
20
20
|
* @param {ImportTarget[]} targets - A list of target information to check.
|
|
21
21
|
* @returns {void}
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
exports.checkPublish = function checkPublish(context, filePath, targets) {
|
|
24
24
|
const packageInfo = getPackageJson(filePath)
|
|
25
25
|
if (!packageInfo) {
|
|
26
26
|
return
|
|
@@ -49,16 +49,22 @@ module.exports = function checkForPublish(context, filePath, targets) {
|
|
|
49
49
|
if (!npmignore.match(toRelative(filePath))) {
|
|
50
50
|
// This file is published, so this cannot import private files.
|
|
51
51
|
for (const target of targets) {
|
|
52
|
-
const isPrivateFile =
|
|
53
|
-
target.moduleName
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
const isPrivateFile = () => {
|
|
53
|
+
if (target.moduleName != null) {
|
|
54
|
+
return false
|
|
55
|
+
}
|
|
56
|
+
const relativeTargetPath = toRelative(target.filePath)
|
|
57
|
+
return (
|
|
58
|
+
relativeTargetPath !== "" &&
|
|
59
|
+
npmignore.match(relativeTargetPath)
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
const isDevPackage = () =>
|
|
56
63
|
target.moduleName != null &&
|
|
57
64
|
devDependencies.has(target.moduleName) &&
|
|
58
65
|
!dependencies.has(target.moduleName) &&
|
|
59
66
|
!allowed.has(target.moduleName)
|
|
60
|
-
|
|
61
|
-
if (isPrivateFile || isDevPackage) {
|
|
67
|
+
if (isPrivateFile() || isDevPackage()) {
|
|
62
68
|
context.report({
|
|
63
69
|
node: target.node,
|
|
64
70
|
loc: target.node.loc,
|
|
@@ -69,3 +75,7 @@ module.exports = function checkForPublish(context, filePath, targets) {
|
|
|
69
75
|
}
|
|
70
76
|
}
|
|
71
77
|
}
|
|
78
|
+
|
|
79
|
+
exports.messages = {
|
|
80
|
+
notPublished: '"{{name}}" is not published.',
|
|
81
|
+
}
|
|
@@ -90,7 +90,7 @@ function createRestrictions(defs) {
|
|
|
90
90
|
* @param {ImportTarget[]} targets - A list of target information to check.
|
|
91
91
|
* @returns {void}
|
|
92
92
|
*/
|
|
93
|
-
|
|
93
|
+
exports.checkForRestriction = function checkForRestriction(context, targets) {
|
|
94
94
|
const restrictions = createRestrictions(context.options[0])
|
|
95
95
|
|
|
96
96
|
for (const target of targets) {
|
|
@@ -107,3 +107,8 @@ module.exports = function checkForRestriction(context, targets) {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
+
|
|
111
|
+
exports.messages = {
|
|
112
|
+
restricted:
|
|
113
|
+
"'{{name}}' module is restricted from being used.{{customMessage}}",
|
|
114
|
+
}
|
|
@@ -80,7 +80,10 @@ function supportedVersionToString({ backported, supported }) {
|
|
|
80
80
|
* @param {{modules:object,globals:object}} trackMap The map for APIs to report.
|
|
81
81
|
* @returns {void}
|
|
82
82
|
*/
|
|
83
|
-
module.exports = function checkUnsupportedBuiltins(
|
|
83
|
+
module.exports.checkUnsupportedBuiltins = function checkUnsupportedBuiltins(
|
|
84
|
+
context,
|
|
85
|
+
trackMap
|
|
86
|
+
) {
|
|
84
87
|
const options = parseOptions(context)
|
|
85
88
|
const tracker = new ReferenceTracker(context.getScope(), { mode: "legacy" })
|
|
86
89
|
const references = [
|
|
@@ -106,3 +109,8 @@ module.exports = function checkUnsupportedBuiltins(context, trackMap) {
|
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
111
|
}
|
|
112
|
+
|
|
113
|
+
exports.messages = {
|
|
114
|
+
unsupported:
|
|
115
|
+
"The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.",
|
|
116
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-n",
|
|
3
|
-
"version": "15.2.
|
|
3
|
+
"version": "15.2.5",
|
|
4
4
|
"description": "Additional ESLint's rules for Node.js",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=12.22.0"
|
|
@@ -17,29 +17,29 @@
|
|
|
17
17
|
"eslint-plugin-es": "^4.1.0",
|
|
18
18
|
"eslint-utils": "^3.0.0",
|
|
19
19
|
"ignore": "^5.1.1",
|
|
20
|
-
"is-core-module": "^2.
|
|
20
|
+
"is-core-module": "^2.10.0",
|
|
21
21
|
"minimatch": "^3.1.2",
|
|
22
|
-
"resolve": "^1.
|
|
22
|
+
"resolve": "^1.22.1",
|
|
23
23
|
"semver": "^7.3.7"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"codecov": "^3.3.0",
|
|
27
27
|
"esbuild": "^0.14.39",
|
|
28
|
-
"eslint": "^8.
|
|
28
|
+
"eslint": "^8.21.0",
|
|
29
29
|
"eslint-config-prettier": "^8.5.0",
|
|
30
|
-
"eslint-plugin-eslint-plugin": "^
|
|
30
|
+
"eslint-plugin-eslint-plugin": "^5.0.2",
|
|
31
31
|
"eslint-plugin-n": "file:.",
|
|
32
32
|
"fast-glob": "^3.2.11",
|
|
33
|
-
"globals": "^13.
|
|
33
|
+
"globals": "^13.17.0",
|
|
34
34
|
"husky": "^8.0.1",
|
|
35
35
|
"import-meta-resolve": "^1.1.1",
|
|
36
36
|
"lint-staged": "^12.4.1",
|
|
37
37
|
"mocha": "^10.0.0",
|
|
38
38
|
"nyc": "^15.1.0",
|
|
39
39
|
"opener": "^1.5.1",
|
|
40
|
-
"prettier": "^2.
|
|
40
|
+
"prettier": "^2.7.1",
|
|
41
41
|
"punycode": "^2.1.1",
|
|
42
|
-
"release-it": "^15.
|
|
42
|
+
"release-it": "^15.2.0",
|
|
43
43
|
"rimraf": "^3.0.2"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|