eslint-plugin-n
Advanced tools
Comparing version 16.2.0 to 16.3.0
@@ -12,3 +12,2 @@ /** | ||
description: "require `return` statements after callbacks", | ||
category: "Stylistic Issues", | ||
recommended: false, | ||
@@ -15,0 +14,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/callback-return.md", |
@@ -230,3 +230,2 @@ /** | ||
description: "enforce either `module.exports` or `exports`", | ||
category: "Stylistic Issues", | ||
recommended: false, | ||
@@ -233,0 +232,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/exports-style.md", |
@@ -11,5 +11,2 @@ /** | ||
const visitImport = require("../util/visit-import") | ||
const packageNamePattern = /^(?:@[^/\\]+[/\\])?[^/\\]+$/u | ||
const corePackageOverridePattern = | ||
/^(?: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 | ||
@@ -41,3 +38,2 @@ /** | ||
"enforce the style of file extensions in `import` declarations", | ||
category: "Stylistic Issues", | ||
recommended: false, | ||
@@ -72,9 +68,9 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/file-extension-in-import.md", | ||
function verify({ filePath, name, node }) { | ||
/** | ||
* @param {import("../util/import-target.js")} target | ||
* @returns {void} | ||
*/ | ||
function verify({ filePath, name, node, moduleType }) { | ||
// Ignore if it's not resolved to a file or it's a bare module. | ||
if ( | ||
!filePath || | ||
packageNamePattern.test(name) || | ||
corePackageOverridePattern.test(name) | ||
) { | ||
if (moduleType !== "relative" && moduleType !== "absolute") { | ||
return | ||
@@ -81,0 +77,0 @@ } |
@@ -56,3 +56,2 @@ /** | ||
"require `require()` calls to be placed at top-level module scope", | ||
category: "Stylistic Issues", | ||
recommended: false, | ||
@@ -59,0 +58,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/global-require.md", |
@@ -12,3 +12,2 @@ /** | ||
description: "require error handling in callbacks", | ||
category: "Possible Errors", | ||
recommended: false, | ||
@@ -15,0 +14,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/handle-callback-err.md", |
@@ -12,3 +12,2 @@ /** | ||
"enforce Node.js-style error-first callback pattern is followed", | ||
category: "Possible Errors", | ||
recommended: false, | ||
@@ -15,0 +14,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-callback-literal.md", |
@@ -694,3 +694,2 @@ /** | ||
description: "disallow deprecated APIs", | ||
category: "Best Practices", | ||
recommended: true, | ||
@@ -697,0 +696,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-deprecated-api.md", |
@@ -41,3 +41,2 @@ /** | ||
description: "disallow the assignment to `exports`", | ||
category: "Possible Errors", | ||
recommended: true, | ||
@@ -44,0 +43,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-exports-assign.md", |
@@ -18,3 +18,2 @@ /** | ||
"disallow `import` declarations which import extraneous modules", | ||
category: "Possible Errors", | ||
recommended: true, | ||
@@ -21,0 +20,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-extraneous-import.md", |
@@ -19,3 +19,2 @@ /** | ||
"disallow `require()` expressions which import extraneous modules", | ||
category: "Possible Errors", | ||
recommended: true, | ||
@@ -22,0 +21,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-extraneous-require.md", |
@@ -60,3 +60,2 @@ /** | ||
"disallow third-party modules which are hiding core modules", | ||
category: "Possible Errors", | ||
recommended: false, | ||
@@ -63,0 +62,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-hide-core-modules.md", |
@@ -19,3 +19,2 @@ /** | ||
"disallow `import` declarations which import non-existence modules", | ||
category: "Possible Errors", | ||
recommended: true, | ||
@@ -22,0 +21,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-missing-import.md", |
@@ -20,3 +20,2 @@ /** | ||
"disallow `require()` expressions which import non-existence modules", | ||
category: "Possible Errors", | ||
recommended: true, | ||
@@ -23,0 +22,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-missing-require.md", |
@@ -74,3 +74,2 @@ /** | ||
"disallow `require` calls to be mixed with regular variable declarations", | ||
category: "Stylistic Issues", | ||
recommended: false, | ||
@@ -77,0 +76,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-mixed-requires.md", |
@@ -12,3 +12,2 @@ /** | ||
description: "disallow `new` operators with calls to `require`", | ||
category: "Possible Errors", | ||
recommended: false, | ||
@@ -15,0 +14,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-new-require.md", |
@@ -169,3 +169,2 @@ /** | ||
"disallow string concatenation with `__dirname` and `__filename`", | ||
category: "Possible Errors", | ||
recommended: false, | ||
@@ -172,0 +171,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-path-concat.md", |
@@ -16,3 +16,2 @@ /** | ||
description: "disallow the use of `process.env`", | ||
category: "Stylistic Issues", | ||
recommended: false, | ||
@@ -19,0 +18,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-process-env.md", |
@@ -12,3 +12,2 @@ /** | ||
description: "disallow the use of `process.exit()`", | ||
category: "Possible Errors", | ||
recommended: false, | ||
@@ -15,0 +14,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-process-exit.md", |
@@ -16,3 +16,2 @@ /** | ||
"disallow specified modules when loaded by `import` declarations", | ||
category: "Stylistic Issues", | ||
recommended: false, | ||
@@ -19,0 +18,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-restricted-import.md", |
@@ -16,3 +16,2 @@ /** | ||
description: "disallow specified modules when loaded by `require`", | ||
category: "Stylistic Issues", | ||
recommended: false, | ||
@@ -19,0 +18,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-restricted-require.md", |
@@ -30,3 +30,2 @@ /** | ||
description: "disallow synchronous methods", | ||
category: "Stylistic Issues", | ||
recommended: false, | ||
@@ -33,0 +32,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-sync.md", |
@@ -36,3 +36,2 @@ /** | ||
description: "disallow `bin` files that npm ignores", | ||
category: "Possible Errors", | ||
recommended: true, | ||
@@ -39,0 +38,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-unpublished-bin.md", |
@@ -18,3 +18,2 @@ /** | ||
"disallow `import` declarations which import private modules", | ||
category: "Possible Errors", | ||
recommended: true, | ||
@@ -21,0 +20,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-unpublished-import.md", |
@@ -19,3 +19,2 @@ /** | ||
"disallow `require()` expressions which import private modules", | ||
category: "Possible Errors", | ||
recommended: true, | ||
@@ -22,0 +21,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-unpublished-require.md", |
@@ -1051,3 +1051,2 @@ /** | ||
"disallow unsupported ECMAScript features on the specified version", | ||
category: "Possible Errors", | ||
recommended: false, | ||
@@ -1054,0 +1053,0 @@ |
@@ -146,3 +146,2 @@ /** | ||
"disallow unsupported ECMAScript built-ins on the specified version", | ||
category: "Possible Errors", | ||
recommended: true, | ||
@@ -149,0 +148,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-unsupported-features/es-builtins.md", |
@@ -526,3 +526,2 @@ /** | ||
"disallow unsupported ECMAScript syntax on the specified version", | ||
category: "Possible Errors", | ||
recommended: true, | ||
@@ -529,0 +528,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-unsupported-features/es-syntax.md", |
@@ -382,3 +382,2 @@ /** | ||
"disallow unsupported Node.js built-in APIs on the specified version", | ||
category: "Possible Errors", | ||
recommended: true, | ||
@@ -385,0 +384,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-unsupported-features/node-builtins.md", |
@@ -26,3 +26,2 @@ /** | ||
'enforce either `Buffer` or `require("buffer").Buffer`', | ||
category: "Stylistic Issues", | ||
recommended: false, | ||
@@ -29,0 +28,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-global/buffer.md", |
@@ -23,3 +23,2 @@ /** | ||
description: 'enforce either `console` or `require("console")`', | ||
category: "Stylistic Issues", | ||
recommended: false, | ||
@@ -26,0 +25,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-global/console.md", |
@@ -23,3 +23,2 @@ /** | ||
description: 'enforce either `process` or `require("process")`', | ||
category: "Stylistic Issues", | ||
recommended: false, | ||
@@ -26,0 +25,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-global/process.md", |
@@ -26,3 +26,2 @@ /** | ||
'enforce either `TextDecoder` or `require("util").TextDecoder`', | ||
category: "Stylistic Issues", | ||
recommended: false, | ||
@@ -29,0 +28,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-global/text-decoder.md", |
@@ -26,3 +26,2 @@ /** | ||
'enforce either `TextEncoder` or `require("util").TextEncoder`', | ||
category: "Stylistic Issues", | ||
recommended: false, | ||
@@ -29,0 +28,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-global/text-encoder.md", |
@@ -26,3 +26,2 @@ /** | ||
'enforce either `URLSearchParams` or `require("url").URLSearchParams`', | ||
category: "Stylistic Issues", | ||
recommended: false, | ||
@@ -29,0 +28,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-global/url-search-params.md", |
@@ -25,3 +25,2 @@ /** | ||
description: 'enforce either `URL` or `require("url").URL`', | ||
category: "Stylistic Issues", | ||
recommended: false, | ||
@@ -28,0 +27,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-global/url.md", |
@@ -41,3 +41,2 @@ /** | ||
description: 'enforce `require("dns").promises`', | ||
category: "Stylistic Issues", | ||
recommended: false, | ||
@@ -44,0 +43,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-promises/dns.md", |
@@ -43,3 +43,2 @@ /** | ||
description: 'enforce `require("fs").promises`', | ||
category: "Stylistic Issues", | ||
recommended: false, | ||
@@ -46,0 +45,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-promises/fs.md", |
@@ -152,3 +152,2 @@ /* eslint-disable eslint-plugin/prefer-message-ids */ | ||
"require that `process.exit()` expressions use the same code path as `throw`", | ||
category: "Possible Errors", | ||
recommended: true, | ||
@@ -155,0 +154,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/process-exit-as-throw.md", |
@@ -73,3 +73,2 @@ /** | ||
description: "require correct usage of shebang", | ||
category: "Possible Errors", | ||
recommended: true, | ||
@@ -76,0 +75,0 @@ url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/shebang.md", |
@@ -9,2 +9,3 @@ /** | ||
const { pathToFileURL, fileURLToPath } = require("url") | ||
const { isBuiltin } = require("module") | ||
const resolve = require("resolve") | ||
@@ -76,2 +77,10 @@ const { | ||
function isNodeModule(name, options) { | ||
try { | ||
return require.resolve(name, options).startsWith(path.sep) | ||
} catch { | ||
return false | ||
} | ||
} | ||
/** | ||
@@ -121,2 +130,20 @@ * Gets the module name of a given path. | ||
/** | ||
* What type of module is this | ||
* @type {'unknown'|'relative'|'absolute'|'node'|'npm'|'http'|void} | ||
*/ | ||
this.moduleType = "unknown" | ||
if (name.startsWith("./") || name.startsWith(".\\")) { | ||
this.moduleType = "relative" | ||
} else if (name.startsWith("/") || name.startsWith("\\")) { | ||
this.moduleType = "absolute" | ||
} else if (isBuiltin(name)) { | ||
this.moduleType = "node" | ||
} else if (isNodeModule(name, options)) { | ||
this.moduleType = "npm" | ||
} else if (name.startsWith("http://") || name.startsWith("https://")) { | ||
this.moduleType = "http" | ||
} | ||
/** | ||
* The full path of this import target. | ||
@@ -123,0 +150,0 @@ * If the target is a module and it does not exist then this is `null`. |
{ | ||
"name": "eslint-plugin-n", | ||
"version": "16.2.0", | ||
"version": "16.3.0", | ||
"description": "Additional ESLint's rules for Node.js", | ||
@@ -5,0 +5,0 @@ "engines": { |
@@ -9,3 +9,3 @@ # eslint-plugin-n | ||
Additional ESLint's rules for Node.js | ||
Additional ESLint rules for Node.js | ||
@@ -12,0 +12,0 @@ ## πΏ Install & Usage |
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
342210
9650
7