Socket
Socket
Sign inDemoInstall

eslint-plugin-n

Package Overview
Dependencies
Maintainers
2
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-n - npm Package Compare versions

Comparing version 17.6.0 to 17.7.0

67

lib/rules/hashbang.js

@@ -15,8 +15,48 @@ /**

const NODE_SHEBANG = "#!/usr/bin/env node\n"
const ENV_SHEBANG = "#!/usr/bin/env"
const NODE_SHEBANG = `${ENV_SHEBANG} {{executableName}}\n`
const SHEBANG_PATTERN = /^(#!.+?)?(\r)?\n/u
const NODE_SHEBANG_PATTERN =
/^#!\/usr\/bin\/env(?: -\S+)*(?: [^\s=-]+=\S+)* node(?: [^\r\n]+?)?\n/u
// -i -S
// -u name
// --ignore-environment
// --block-signal=SIGINT
const ENV_FLAGS = /^\s*-(-.*?\b|[ivS]+|[Pu](\s+|=)\S+)(?=\s|$)/
// NAME="some variable"
// FOO=bar
const ENV_VARS = /^\s*\w+=(?:"(?:[^"\\]|\\.)*"|\w+)/
/**
* @param {string} shebang
* @param {string} executableName
* @returns {boolean}
*/
function isNodeShebang(shebang, executableName) {
if (shebang == null || shebang.length === 0) {
return false
}
shebang = shebang.slice(shebang.indexOf(ENV_SHEBANG) + ENV_SHEBANG.length)
while (ENV_FLAGS.test(shebang) || ENV_VARS.test(shebang)) {
shebang = shebang.replace(ENV_FLAGS, "").replace(ENV_VARS, "")
}
const [command] = shebang.trim().split(" ")
return command === executableName
}
/**
* @param {import('eslint').Rule.RuleContext} context The rule context.
* @returns {string}
*/
function getExpectedExecutableName(context) {
const extension = path.extname(context.filename)
/** @type {{ executableMap: Record<string, string> }} */
const { executableMap = {} } = context.options?.[0] ?? {}
return executableMap[extension] ?? "node"
}
/**
* Gets the shebang line (includes a line ending) from a given code.

@@ -60,2 +100,12 @@ *

},
executableMap: {
type: "object",
patternProperties: {
"^\\.\\w+$": {
type: "string",
pattern: "^[\\w-]+$",
},
},
additionalProperties: false,
},
},

@@ -69,3 +119,3 @@ additionalProperties: false,

expectedHashbangNode:
'This file needs shebang "#!/usr/bin/env node".',
'This file needs shebang "#!/usr/bin/env {{executableName}}".',
expectedHashbang: "This file needs no shebang.",

@@ -122,2 +172,3 @@ },

isBinFile(convertedAbsolutePath, packageJson?.bin, packageDirectory)
const executableName = getExpectedExecutableName(context)
const info = getShebangInfo(sourceCode)

@@ -137,3 +188,3 @@

needsShebang
? NODE_SHEBANG_PATTERN.test(info.shebang)
? isNodeShebang(info.shebang, executableName)
: !info.shebang

@@ -167,6 +218,10 @@ ) {

messageId: "expectedHashbangNode",
data: { executableName },
fix(fixer) {
return fixer.replaceTextRange(
[-1, info.length],
NODE_SHEBANG
NODE_SHEBANG.replaceAll(
"{{executableName}}",
executableName
)
)

@@ -173,0 +228,0 @@ },

14

lib/unsupported-features/node-builtins-modules/crypto.js
"use strict"
const { READ } = require("@eslint-community/eslint-utils")
const { CALL, CONSTRUCT, READ } = require("@eslint-community/eslint-utils")

@@ -109,4 +109,12 @@ /** @type {import('../types.js').SupportVersionTraceMap} */

},
Hash: { [READ]: { supported: ["0.1.92"] } },
Hmac: { [READ]: { supported: ["0.1.94"] } },
Hash: {
[READ]: { supported: ["0.1.92"] },
[CALL]: { deprecated: ["22.0.0", "20.13.0"] },
[CONSTRUCT]: { deprecated: ["22.0.0", "20.13.0"] },
},
Hmac: {
[READ]: { supported: ["0.1.94"] },
[CALL]: { deprecated: ["22.0.0", "20.13.0"] },
[CONSTRUCT]: { deprecated: ["22.0.0", "20.13.0"] },
},
KeyObject: {

@@ -113,0 +121,0 @@ [READ]: { supported: ["11.6.0"] },

@@ -39,3 +39,8 @@ "use strict"

},
CustomEvent: { [READ]: { experimental: ["18.7.0", "16.17.0"] } },
CustomEvent: {
[READ]: {
experimental: ["18.7.0", "16.17.0"],
supported: ["22.1.0", "20.13.0"],
},
},
NodeEventTarget: {

@@ -42,0 +47,0 @@ [READ]: {

"use strict"
const { READ } = require("@eslint-community/eslint-utils")
const { READ, CALL, CONSTRUCT } = require("@eslint-community/eslint-utils")
/** @type {import('../types.js').SupportVersionTraceMap} */
const promises_api = {
constants: { [READ]: { supported: ["18.4.0", "16.17.0"] } },
FileHandle: { [READ]: { supported: ["10.0.0"] } },
access: { [READ]: { supported: ["10.0.0"] } },

@@ -12,9 +12,11 @@ appendFile: { [READ]: { supported: ["10.0.0"] } },

chown: { [READ]: { supported: ["10.0.0"] } },
constants: { [READ]: { supported: ["18.4.0", "16.17.0"] } },
copyFile: { [READ]: { supported: ["10.0.0"] } },
cp: { [READ]: { experimental: ["16.7.0"] } },
glob: { [READ]: { experimental: ["22.0.0"] } },
lchmod: { [READ]: { supported: ["10.0.0"], deprecated: ["10.0.0"] } },
lchown: { [READ]: { supported: ["10.0.0"] } },
lutimes: { [READ]: { supported: ["14.5.0", "12.19.0"] } },
link: { [READ]: { supported: ["10.0.0"] } },
lstat: { [READ]: { supported: ["10.0.0"] } },
lutimes: { [READ]: { supported: ["14.5.0", "12.19.0"] } },
mkdir: { [READ]: { supported: ["10.0.0"] } },

@@ -24,9 +26,9 @@ mkdtemp: { [READ]: { supported: ["10.0.0"] } },

opendir: { [READ]: { supported: ["12.12.0"] } },
readFile: { [READ]: { supported: ["10.0.0"] } },
readdir: { [READ]: { supported: ["10.0.0"] } },
readFile: { [READ]: { supported: ["10.0.0"] } },
readlink: { [READ]: { supported: ["10.0.0"] } },
realpath: { [READ]: { supported: ["10.0.0"] } },
rename: { [READ]: { supported: ["10.0.0"] } },
rm: { [READ]: { supported: ["14.14.0"] } },
rmdir: { [READ]: { supported: ["10.0.0"] } },
rm: { [READ]: { supported: ["14.14.0"] } },
stat: { [READ]: { supported: ["10.0.0"] } },

@@ -40,3 +42,2 @@ statfs: { [READ]: { supported: ["19.6.0", "18.15.0"] } },

writeFile: { [READ]: { supported: ["10.0.0"] } },
FileHandle: { [READ]: { supported: ["10.0.0"] } },
}

@@ -63,9 +64,11 @@

futimes: { [READ]: { supported: ["0.4.2"] } },
glob: { [READ]: { experimental: ["22.0.0"] } },
lchmod: { [READ]: { supported: ["0.1.8"], deprecated: ["0.4.7"] } },
lchown: { [READ]: { supported: ["0.1.8"] } },
lutimes: { [READ]: { supported: ["14.5.0", "12.19.0"] } },
link: { [READ]: { supported: ["0.1.31"] } },
lstat: { [READ]: { supported: ["0.1.30"] } },
lutimes: { [READ]: { supported: ["14.5.0", "12.19.0"] } },
mkdir: { [READ]: { supported: ["0.1.8"] } },
mkdtemp: { [READ]: { supported: ["5.10.0"] } },
native: { [READ]: { supported: ["9.2.0"] } },
open: { [READ]: { supported: ["0.0.2"] } },

@@ -83,6 +86,5 @@ openAsBlob: { [READ]: { experimental: ["19.8.0"] } },

},
native: { [READ]: { supported: ["9.2.0"] } },
rename: { [READ]: { supported: ["0.0.2"] } },
rm: { [READ]: { supported: ["14.14.0"] } },
rmdir: { [READ]: { supported: ["0.0.2"] } },
rm: { [READ]: { supported: ["14.14.0"] } },
stat: { [READ]: { supported: ["0.0.2"] } },

@@ -119,9 +121,11 @@ statfs: { [READ]: { supported: ["19.6.0", "18.15.0"] } },

futimesSync: { [READ]: { supported: ["0.4.2"] } },
globSync: { [READ]: { experimental: ["22.0.0"] } },
lchmodSync: { [READ]: { supported: ["0.1.8"], deprecated: ["0.4.7"] } },
lchownSync: { [READ]: { supported: ["0.1.8"] } },
lutimesSync: { [READ]: { supported: ["14.5.0", "12.19.0"] } },
linkSync: { [READ]: { supported: ["0.1.31"] } },
lstatSync: { [READ]: { supported: ["0.1.30"] } },
lutimesSync: { [READ]: { supported: ["14.5.0", "12.19.0"] } },
mkdirSync: { [READ]: { supported: ["0.1.21"] } },
mkdtempSync: { [READ]: { supported: ["5.10.0"] } },
native: { [READ]: { supported: ["9.2.0"] } },
opendirSync: { [READ]: { supported: ["12.12.0"] } },

@@ -138,8 +142,7 @@ openSync: { [READ]: { supported: ["0.1.21"] } },

},
native: { [READ]: { supported: ["9.2.0"] } },
renameSync: { [READ]: { supported: ["0.1.21"] } },
rmdirSync: { [READ]: { supported: ["0.1.21"] } },
rmSync: { [READ]: { supported: ["14.14.0"] } },
statfsSync: { [READ]: { supported: ["19.6.0", "18.15.0"] } },
statSync: { [READ]: { supported: ["0.1.21"] } },
statfsSync: { [READ]: { supported: ["19.6.0", "18.15.0"] } },
symlinkSync: { [READ]: { supported: ["0.1.31"] } },

@@ -171,3 +174,7 @@ truncateSync: { [READ]: { supported: ["0.8.6"] } },

ReadStream: { [READ]: { supported: ["0.1.93"] } },
Stats: { [READ]: { supported: ["0.1.21"] } },
Stats: {
[READ]: { supported: ["0.1.21"] },
[CALL]: { deprecated: ["22.0.0", "20.13.0"] },
[CONSTRUCT]: { deprecated: ["22.0.0", "20.13.0"] },
},
StatFs: { [READ]: { supported: ["19.6.0", "18.15.0"] } },

@@ -174,0 +181,0 @@ WriteStream: { [READ]: { supported: ["0.1.93"] } },

@@ -8,2 +8,3 @@ "use strict"

allowedNodeEnvironmentFlags: { [READ]: { supported: ["10.10.0"] } },
availableMemory: { [READ]: { experimental: ["22.0.0", "20.13.0"] } },
arch: { [READ]: { supported: ["0.5.0"] } },

@@ -10,0 +11,0 @@ argv: { [READ]: { supported: ["0.1.27"] } },

@@ -23,2 +23,8 @@ "use strict"

},
suite: {
[READ]: { supported: ["22.0.0", "20.13.0"] },
skip: { [READ]: { supported: ["22.0.0", "20.13.0"] } },
todo: { [READ]: { supported: ["22.0.0", "20.13.0"] } },
only: { [READ]: { supported: ["22.0.0", "20.13.0"] } },
},
before: { [READ]: { supported: ["18.8.0", "16.18.0"] } },

@@ -25,0 +31,0 @@ after: { [READ]: { supported: ["18.8.0", "16.18.0"] } },

@@ -37,2 +37,3 @@ "use strict"

getHeapStatistics: { [READ]: { supported: ["1.0.0"] } },
queryObjects: { [READ]: { experimental: ["22.0.0", "20.13.0"] } },
setFlagsFromString: { [READ]: { supported: ["1.0.0"] } },

@@ -39,0 +40,0 @@ stopCoverage: { [READ]: { supported: ["15.1.0", "14.18.0", "12.22.0"] } },

@@ -116,3 +116,3 @@ /**

data: {
name: path.join("."),
name: name,
experimental: experimentalVersion,

@@ -136,3 +136,3 @@ version: options.version.raw,

data: {
name: path.join("."),
name: name,
supported: supportedVersion,

@@ -149,3 +149,3 @@ version: options.version.raw,

data: {
name: path.join("."),
name: name,
version: options.version.raw,

@@ -152,0 +152,0 @@ },

{
"name": "eslint-plugin-n",
"version": "17.6.0",
"version": "17.7.0",
"description": "Additional ESLint's rules for Node.js",

@@ -5,0 +5,0 @@ "engines": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc