Socket
Socket
Sign inDemoInstall

eslint-plugin-n

Package Overview
Dependencies
10
Maintainers
2
Versions
55
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 16.3.1 to 16.4.0

2

lib/rules/callback-return.js

@@ -29,3 +29,3 @@ /**

const callbacks = context.options[0] || ["callback", "cb", "next"]
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9

@@ -32,0 +32,0 @@ /**

@@ -261,3 +261,3 @@ /**

)
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9

@@ -290,4 +290,3 @@ /**

*/
function enforceModuleExports() {
const globalScope = context.getScope()
function enforceModuleExports(globalScope) {
const exportsNodes = getExportsNodes(globalScope)

@@ -322,4 +321,3 @@ const assignList = batchAssignAllowed

*/
function enforceExports() {
const globalScope = context.getScope()
function enforceExports(globalScope) {
const exportsNodes = getExportsNodes(globalScope)

@@ -376,9 +374,11 @@ const moduleExportsNodes = getModuleExportsNodes(globalScope)

return {
"Program:exit"() {
"Program:exit"(node) {
const scope = sourceCode.getScope?.(node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
switch (mode) {
case "module.exports":
enforceModuleExports()
enforceModuleExports(scope)
break
case "exports":
enforceExports()
enforceExports(scope)
break

@@ -385,0 +385,0 @@

@@ -60,3 +60,3 @@ /**

create(context) {
if (context.getFilename().startsWith("<")) {
if ((context.filename ?? context.getFilename()).startsWith("<")) {
return {}

@@ -63,0 +63,0 @@ }

@@ -67,5 +67,8 @@ /**

create(context) {
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
return {
CallExpression(node) {
const currentScope = context.getScope()
const currentScope =
sourceCode.getScope?.(node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9

@@ -76,4 +79,6 @@ if (

) {
const isGoodRequire = context
.getAncestors()
const isGoodRequire = (
sourceCode.getAncestors?.(node) ??
context.getAncestors()
) // TODO: remove context.getAncestors() when dropping support for ESLint < v9
.every(

@@ -80,0 +85,0 @@ parent =>

@@ -27,2 +27,3 @@ /**

create(context) {
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
const errorArgument = context.options[0] || "err"

@@ -73,3 +74,3 @@

function checkForError(node) {
const scope = context.getScope()
const scope = sourceCode.getScope?.(node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
const parameters = getParameters(scope)

@@ -76,0 +77,0 @@ const firstParameter = parameters[0]

@@ -759,5 +759,8 @@ /**

const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope(), {
"Program:exit"(node) {
const scope = sourceCode.getScope?.(node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
const tracker = new ReferenceTracker(scope, {
mode: "legacy",

@@ -764,0 +767,0 @@ })

@@ -53,5 +53,8 @@ /**

create(context) {
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
return {
AssignmentExpression(node) {
const scope = context.getScope()
const scope = sourceCode.getScope?.(node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
if (

@@ -58,0 +61,0 @@ !isExports(node.left, scope) ||

@@ -37,3 +37,3 @@ /**

create(context) {
const filePath = context.getFilename()
const filePath = context.filename ?? context.getFilename()
if (filePath === "<input>") {

@@ -40,0 +40,0 @@ return {}

@@ -39,3 +39,3 @@ /**

create(context) {
const filePath = context.getFilename()
const filePath = context.filename ?? context.getFilename()
if (filePath === "<input>") {

@@ -42,0 +42,0 @@ return {}

@@ -88,6 +88,7 @@ /**

create(context) {
if (context.getFilename() === "<input>") {
const filename = context.filename ?? context.getFilename()
if (filename === "<input>") {
return {}
}
const filePath = path.resolve(context.getFilename())
const filePath = path.resolve(filename)
const dirPath = path.dirname(filePath)

@@ -94,0 +95,0 @@ const packageJson = getPackageJson(filePath)

@@ -39,3 +39,3 @@ /**

create(context) {
const filePath = context.getFilename()
const filePath = context.filename ?? context.getFilename()
if (filePath === "<input>") {

@@ -42,0 +42,0 @@ return {}

@@ -41,3 +41,3 @@ /**

create(context) {
const filePath = context.getFilename()
const filePath = context.filename ?? context.getFilename()
if (filePath === "<input>") {

@@ -44,0 +44,0 @@ return {}

@@ -182,4 +182,6 @@ /**

return {
"Program:exit"() {
const globalScope = context.getScope()
"Program:exit"(node) {
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
const globalScope =
sourceCode.getScope?.(node) ?? context.getScope()
const tracker = new ReferenceTracker(globalScope)

@@ -186,0 +188,0 @@ const sepNodes = new Set()

@@ -59,3 +59,3 @@ /**

// Check file path.
let rawFilePath = context.getFilename()
let rawFilePath = context.filename ?? context.getFilename()
if (rawFilePath === "<input>") {

@@ -62,0 +62,0 @@ return

@@ -38,3 +38,3 @@ /**

create(context) {
const filePath = context.getFilename()
const filePath = context.filename ?? context.getFilename()
const options = context.options[0] || {}

@@ -41,0 +41,0 @@ const ignoreTypeImport =

@@ -39,3 +39,3 @@ /**

create(context) {
const filePath = context.getFilename()
const filePath = context.filename ?? context.getFilename()
if (filePath === "<input>") {

@@ -42,0 +42,0 @@ return {}

@@ -1088,6 +1088,6 @@ /**

create(context) {
const sourceCode = context.getSourceCode()
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
const supportInfo = parseOptions(
context.options[0],
getDefaultVersion(context.getFilename())
getDefaultVersion(context.filename ?? context.getFilename())
)

@@ -1102,3 +1102,4 @@

function* getReferences(names) {
const globalScope = context.getScope()
const globalScope =
sourceCode.getScope?.(sourceCode.ast) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9

@@ -1164,2 +1165,4 @@ for (const name of names) {

function report(node, key) {
const globalScope =
sourceCode.getScope?.(node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
const version = supportInfo.version

@@ -1181,3 +1184,3 @@ const feature = supportInfo.features[key]

})
} else if (!normalizeScope(context.getScope(), node).isStrict) {
} else if (!normalizeScope(globalScope, node).isStrict) {
context.report({

@@ -1338,3 +1341,5 @@ node,

FunctionDeclaration(node) {
const scope = context.getScope().upper
const scope = (
sourceCode.getScope?.(node) ?? context.getScope()
).upper //TODO: remove context.getScope() when dropping support for ESLint < v9
if (!TOPLEVEL_SCOPE_TYPE.test(scope.type)) {

@@ -1341,0 +1346,0 @@ report(node, "blockScopedFunctions")

@@ -446,3 +446,5 @@ /**

get isStrict() {
return normalizeScope(context.getScope(), this.node).isStrict
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
const scope = sourceCode.getScope?.(this.node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
return normalizeScope(scope, this.node).isStrict
},

@@ -449,0 +451,0 @@ }

@@ -375,3 +375,3 @@ /**

/*eslint-enable camelcase */

@@ -378,0 +378,0 @@ module.exports = {

@@ -55,4 +55,5 @@ /**

return {
"Program:exit"() {
const scope = context.getScope()
"Program:exit"(node) {
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
const scope = sourceCode.getScope?.(node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
const tracker = new ReferenceTracker(scope, { mode: "legacy" })

@@ -59,0 +60,0 @@ const references = [

@@ -56,4 +56,5 @@ /**

return {
"Program:exit"() {
const scope = context.getScope()
"Program:exit"(node) {
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
const scope = sourceCode.getScope?.(node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
const tracker = new ReferenceTracker(scope, { mode: "legacy" })

@@ -60,0 +61,0 @@ const references = [

@@ -97,4 +97,4 @@ /**

create(context) {
const sourceCode = context.getSourceCode()
let filePath = context.getFilename()
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
let filePath = context.filename ?? context.getFilename()
if (filePath === "<input>") {

@@ -101,0 +101,0 @@ return {}

@@ -34,3 +34,6 @@ /**

const { context, trackMap } = this
const tracker = new ReferenceTracker(context.getScope(), {
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
const scope =
sourceCode.getScope?.(sourceCode.ast) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
const tracker = new ReferenceTracker(scope, {
mode: "legacy",

@@ -55,3 +58,6 @@ })

const { context, trackMap } = this
const tracker = new ReferenceTracker(context.getScope())
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
const scope =
sourceCode.getScope?.(sourceCode.ast) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
const tracker = new ReferenceTracker(scope)

@@ -58,0 +64,0 @@ for (const { node } of tracker.iterateGlobalReferences(

@@ -88,3 +88,5 @@ /**

const options = parseOptions(context)
const tracker = new ReferenceTracker(context.getScope(), { mode: "legacy" })
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
const scope = sourceCode.getScope?.(sourceCode.ast) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
const tracker = new ReferenceTracker(scope, { mode: "legacy" })
const references = [

@@ -91,0 +93,0 @@ ...tracker.iterateCjsReferences(trackMap.modules || {}),

@@ -50,3 +50,3 @@ /**

get(context.settings && (context.settings.n || context.settings.node))
const filePath = context.getFilename()
const filePath = context.filename ?? context.getFilename()

@@ -53,0 +53,0 @@ return (

@@ -115,15 +115,11 @@ "use strict"

module.exports = function getTypescriptExtensionMap(context) {
const filename =
context.physicalFilename ??
context.getPhysicalFilename?.() ??
context.filename ??
context.getFilename?.() // TODO: remove context.get(PhysicalFilename|Filename) when dropping eslint < v10
return (
get(context.options?.[0]) ||
get(context.settings?.n ?? context.settings?.node) ||
getFromTSConfigFromFile(
// eslint ^8
context.physicalFilename ??
// eslint ^7.28 (deprecated ^8)
context.getPhysicalFilename?.() ??
// eslint ^8 (if physicalFilename undefined)
context.filename ??
// eslint ^7 (deprecated ^8)
context.getFilename?.()
) ||
getFromTSConfigFromFile(filename) ||
PRESERVE_MAPPING

@@ -130,0 +126,0 @@ )

@@ -14,4 +14,6 @@ "use strict"

module.exports = function isTypescript(context) {
const sourceFileExt = path.extname(context.getPhysicalFilename())
const sourceFileExt = path.extname(
context.physicalFilename ?? context.getPhysicalFilename()
)
return typescriptExtensions.includes(sourceFileExt)
}

@@ -33,3 +33,5 @@ /**

const targets = []
const basedir = path.dirname(path.resolve(context.getFilename()))
const basedir = path.dirname(
path.resolve(context.filename ?? context.getFilename())
)
const paths = getResolvePaths(context, optionIndex)

@@ -36,0 +38,0 @@ const extensions = getTryExtensions(context, optionIndex)

@@ -36,3 +36,5 @@ /**

const targets = []
const basedir = path.dirname(path.resolve(context.getFilename()))
const basedir = path.dirname(
path.resolve(context.filename ?? context.getFilename())
)
const paths = getResolvePaths(context)

@@ -43,4 +45,7 @@ const extensions = getTryExtensions(context)

return {
"Program:exit"() {
const tracker = new ReferenceTracker(context.getScope())
"Program:exit"(node) {
const sourceCode = context.sourceCode ?? context.getSourceCode() // TODO: just use context.sourceCode when dropping eslint < v9
const tracker = new ReferenceTracker(
sourceCode.getScope?.(node) ?? context.getScope() //TODO: remove context.getScope() when dropping support for ESLint < v9
)
const references = tracker.iterateGlobalReferences({

@@ -47,0 +52,0 @@ require: {

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

@@ -19,3 +19,3 @@ "engines": {

"builtins": "^5.0.1",
"eslint-plugin-es-x": "^7.1.0",
"eslint-plugin-es-x": "^7.5.0",
"get-tsconfig": "^4.7.0",

@@ -31,6 +31,6 @@ "ignore": "^5.2.4",

"@eslint/js": "^8.43.0",
"@types/eslint": "^8.44.2",
"@types/eslint": "^8.44.6",
"@typescript-eslint/parser": "^5.60.0",
"esbuild": "^0.18.7",
"eslint": "^8.43.0",
"eslint": "^8.53.0",
"eslint-config-prettier": "^8.8.0",

@@ -37,0 +37,0 @@ "eslint-doc-generator": "^1.4.3",

@@ -11,2 +11,6 @@ # eslint-plugin-n

## 🎨 Playground
[online-playground](https://eslint-online-playground.netlify.app/#eNp1jzEOwjAMRa9SeWFpYS8rOwtiIQxRalWBxIniFIFQ747bCASV2BK/Lz//J3AyG7xrHx2uLwwtWB9DytXKW2ZLfVP+q60iqGGN7CzlZCQbSNJPRVWlAO8ZqWMFbXWS3xxqE5rgvcyxU1BLKrqht9TS5oec67Kj0PcO+gI6MaZ9zDYUPEtnrfH6iIkFTHMFTmfkLLZ3gsOQDB4eEUvAh25w8p74qGiUTlGbq+6n9t+NOrztME4nkrG40M79/hgLbEqbZnHXRzu+APYwfks=)
## πŸ’Ώ Install & Usage

@@ -13,0 +17,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc