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.4.0 to 17.5.0

lib/unsupported-features/node-globals.js

197

lib/rules/no-unsupported-features/es-builtins.js

@@ -422,199 +422,2 @@ /**

},
// General APIs
AbortController: {
[READ]: { supported: ["15.0.0"] },
},
AbortSignal: {
[READ]: { supported: ["15.0.0"] },
abort: { [READ]: { supported: ["15.12.0"] } },
any: { [READ]: { supported: ["20.3.0"] } },
timeout: { [READ]: { supported: ["17.3.0"] } },
},
Blob: {
[READ]: { supported: ["18.0.0"] },
},
BroadcastChannel: {
[READ]: { supported: ["15.4.0"] },
},
ByteLengthQueuingStrategy: {
[READ]: { supported: ["18.0.0"] },
},
CompressionStream: {
[READ]: { supported: ["18.0.0"] },
},
CountQueuingStrategy: {
[READ]: { supported: ["18.0.0"] },
},
Crypto: {
[READ]: { supported: ["19.0.0"] },
},
CryptoKey: {
[READ]: { supported: ["15.0.0"] },
},
CustomEvent: {
[READ]: { supported: ["19.0.0"] },
},
DOMException: {
[READ]: { supported: ["17.0.0"] },
},
DecompressionStream: {
[READ]: { supported: ["18.0.0"] },
},
Event: {
[READ]: { supported: ["14.5.0"] },
},
EventTarget: {
[READ]: { supported: ["14.5.0"] },
},
FormData: {
[READ]: { supported: ["18.0.0"] },
},
Headers: {
[READ]: { supported: ["18.0.0"] },
},
MessageChannel: {
[READ]: { supported: ["15.0.0"] },
},
MessageEvent: {
[READ]: { supported: ["15.0.0"] },
},
MessagePort: {
[READ]: { supported: ["14.7.0"] },
},
Performance: {
[READ]: { supported: ["8.5.0"] },
},
PerformanceEntry: {
[READ]: { supported: ["8.5.0"] },
},
PerformanceMark: {
[READ]: { supported: ["8.5.0"] },
},
PerformanceMeasure: {
[READ]: { supported: ["8.5.0"] },
},
PerformanceObserver: {
[READ]: { supported: ["8.5.0"] },
supportedEntryTypes: { [READ]: { supported: ["8.5.0"] } },
},
PerformanceObserverEntryList: {
[READ]: { supported: ["8.5.0"] },
},
ReadableByteStreamController: {
[READ]: { supported: ["18.0.0"] },
},
ReadableStream: {
[READ]: { supported: ["18.0.0"] },
from: { [READ]: { supported: ["20.6.0"] } },
},
ReadableStreamBYOBReader: {
[READ]: { supported: ["18.0.0"] },
},
ReadableStreamBYOBRequest: {
[READ]: { supported: ["18.0.0"] },
},
ReadableStreamDefaultController: {
[READ]: { supported: ["18.0.0"] },
},
ReadableStreamDefaultReader: {
[READ]: { supported: ["18.0.0"] },
},
Request: {
[READ]: { supported: ["18.0.0"] },
},
Response: {
[READ]: { supported: ["18.0.0"] },
},
SubtleCrypto: {
[READ]: { supported: ["15.0.0"] },
},
TextDecoder: {
[READ]: { supported: ["11.0.0"] },
},
TextDecoderStream: {
[READ]: { supported: ["18.0.0"] },
},
TextEncoder: {
[READ]: { supported: ["11.0.0"] },
},
TextEncoderStream: {
[READ]: { supported: ["18.0.0"] },
},
TransformStream: {
[READ]: { supported: ["18.0.0"] },
},
TransformStreamDefaultController: {
[READ]: { supported: ["16.5.0"] },
},
URL: {
[READ]: { supported: ["10.0.0"] },
canParse: { [READ]: { supported: ["19.9.0"] } },
createObjectURL: { [READ]: { supported: ["16.7.0"] } },
revokeObjectURL: { [READ]: { supported: ["16.7.0"] } },
},
URLSearchParams: {
[READ]: { supported: ["10.0.0"] },
},
Worker: {
[READ]: { supported: ["12.17.0"] },
},
WritableStream: {
[READ]: { supported: ["18.0.0"] },
},
WritableStreamDefaultController: {
[READ]: { supported: ["18.0.0"] },
},
WritableStreamDefaultWriter: {
[READ]: { supported: ["18.0.0"] },
},
atob: {
[READ]: { supported: ["16.0.0"] },
},
btoa: {
[READ]: { supported: ["16.0.0"] },
},
clearInterval: {
[READ]: { supported: ["0.10.0"] },
},
clearTimeout: {
[READ]: { supported: ["0.10.0"] },
},
console: {
[READ]: { supported: ["0.10.0"] },
assert: { [READ]: { supported: ["10.0.0"] } },
clear: { [READ]: { supported: ["8.3.0"] } },
countReset: { [READ]: { supported: ["8.3.0"] } },
count: { [READ]: { supported: ["8.3.0"] } },
debug: { [READ]: { supported: ["8.0.0"] } },
dir: { [READ]: { supported: ["0.10.0"] } },
dirxml: { [READ]: { supported: ["9.3.0"] } },
error: { [READ]: { supported: ["0.10.0"] } },
groupCollapsed: { [READ]: { supported: ["8.5.0"] } },
groupEnd: { [READ]: { supported: ["8.5.0"] } },
group: { [READ]: { supported: ["8.5.0"] } },
info: { [READ]: { supported: ["0.10.0"] } },
log: { [READ]: { supported: ["0.10.0"] } },
table: { [READ]: { supported: ["10.0.0"] } },
timeEnd: { [READ]: { supported: ["0.10.0"] } },
timeLog: { [READ]: { supported: ["10.7.0"] } },
time: { [READ]: { supported: ["0.10.0"] } },
trace: { [READ]: { supported: ["0.10.0"] } },
warn: { [READ]: { supported: ["0.10.0"] } },
},
fetch: {
[READ]: { supported: ["18.0.0"] },
},
queueMicrotask: {
[READ]: { supported: ["11.0.0"] },
},
setInterval: {
[READ]: { supported: ["0.10.0"] },
},
setTimeout: {
[READ]: { supported: ["0.10.0"] },
},
structuredClone: {
[READ]: { supported: ["17.0.0"] },
},
},

@@ -621,0 +424,0 @@ modules: {},

39

lib/rules/no-unsupported-features/node-builtins.js

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

const { READ } = require("@eslint-community/eslint-utils")
const {

@@ -17,44 +16,10 @@ checkUnsupportedBuiltins,

const {
NodeBuiltinGlobals,
NodeBuiltinModules,
} = require("../../unsupported-features/node-builtins.js")
/**
* @typedef TraceMap
* @property {import('@eslint-community/eslint-utils').TraceMap<boolean>} globals
* @property {import('@eslint-community/eslint-utils').TraceMap<boolean>} modules
*/
const traceMap = {
globals: {
queueMicrotask: {
[READ]: { supported: ["12.0.0"], experimental: ["11.0.0"] },
},
require: {
resolve: {
paths: { [READ]: { supported: ["8.9.0"] } },
},
},
},
globals: NodeBuiltinGlobals,
modules: NodeBuiltinModules,
}
Object.assign(traceMap.globals, {
Buffer: traceMap.modules.buffer.Buffer,
TextDecoder: {
...traceMap.modules.util.TextDecoder,
[READ]: { supported: ["11.0.0"] },
},
TextEncoder: {
...traceMap.modules.util.TextEncoder,
[READ]: { supported: ["11.0.0"] },
},
URL: {
...traceMap.modules.url.URL,
[READ]: { supported: ["10.0.0"] },
},
URLSearchParams: {
...traceMap.modules.url.URLSearchParams,
[READ]: { supported: ["10.0.0"] },
},
console: traceMap.modules.console,
process: traceMap.modules.process,
})

@@ -61,0 +26,0 @@ /** @type {import('eslint').Rule.RuleModule} */

"use strict"
const { READ } = require("@eslint-community/eslint-utils")
const { CONSTRUCT, READ } = require("@eslint-community/eslint-utils")

@@ -26,2 +26,3 @@ /** @type {import('../types.js').SupportVersionTraceMap} */

[READ]: { supported: ["0.1.90"] },
[CONSTRUCT]: { deprecated: ["6.0.0"] },
alloc: { [READ]: { supported: ["5.10.0", "4.5.0"] } },

@@ -28,0 +29,0 @@ allocUnsafe: { [READ]: { supported: ["5.10.0", "4.5.0"] } },

@@ -62,3 +62,3 @@ "use strict"

/** @type {import('../types.js').SupportVersionTraceMap} */
const StreamWeb = {
const WebStream = {
ReadableStream: {

@@ -111,7 +111,7 @@ [READ]: { supported: ["16.5.0"] },

[READ]: { experimental: ["16.5.0"], supported: ["21.0.0"] },
...StreamWeb,
...WebStream,
},
"node:stream/web": {
[READ]: { experimental: ["16.5.0"], supported: ["21.0.0"] },
...StreamWeb,
...WebStream,
},

@@ -118,0 +118,0 @@

"use strict"
/** @type {import('./types.js').SupportVersionTraceMap} */
const NodeBuiltinGlobals = require("./node-globals.js")
/** @type {import('./types.js').SupportVersionTraceMap} */
const NodeBuiltinModules = {

@@ -48,2 +51,2 @@ ...require("./node-builtins-modules/assert.js"),

module.exports = { NodeBuiltinModules }
module.exports = { NodeBuiltinGlobals, NodeBuiltinModules }

@@ -7,7 +7,3 @@ /**

const path = require("path")
const exists = require("./exists")
const getAllowModules = require("./get-allow-modules")
const isTypescript = require("./is-typescript")
const { convertJsExtensionToTs } = require("../util/map-typescript-extension")

@@ -21,2 +17,5 @@ /**

function markMissing(context, target) {
// This should never happen... this is just a fallback for typescript
target.resolveError ??= `"${target.name}" is not found`
context.report({

@@ -28,3 +27,3 @@ node: target.node,

messageId: "notFound",
data: /** @type {Record<string, *>} */ (target),
data: { resolveError: target.resolveError },
})

@@ -44,45 +43,13 @@ }

exports.checkExistence = function checkExistence(context, targets) {
/** @type {Set<string | undefined>} */
const allowed = new Set(getAllowModules(context))
target: for (const target of targets) {
if (
target.moduleName != null &&
!allowed.has(target.moduleName) &&
target.filePath == null
) {
markMissing(context, target)
for (const target of targets) {
if (allowed.has(target.moduleName)) {
continue
}
if (
target.moduleName != null ||
target.filePath == null ||
exists(target.filePath)
) {
continue
}
if (isTypescript(context) === false) {
if (target.resolveError != null) {
markMissing(context, target)
continue
}
const parsed = path.parse(target.filePath)
const pathWithoutExt = path.resolve(parsed.dir, parsed.name)
const reversedExtensions = convertJsExtensionToTs(
context,
target.filePath,
parsed.ext
)
for (const reversedExtension of reversedExtensions) {
const reversedPath = pathWithoutExt + reversedExtension
if (exists(reversedPath)) {
continue target
}
}
markMissing(context, target)
}

@@ -92,3 +59,3 @@ }

exports.messages = {
notFound: '"{{name}}" is not found.',
notFound: "{{resolveError}}",
}

@@ -135,2 +135,8 @@ /**

/**
* This is the full resolution failure reasons
* @type {string | null}
*/
this.resolveError = null
/**
* The full path of this import target.

@@ -244,2 +250,15 @@ * If the target is a module and it does not exist then this is `null`.

/**
* @param {string} baseDir
* @param {unknown} error
* @returns {void}
*/
handleResolutionError(baseDir, error) {
if (error instanceof Error === false) {
throw error
}
this.resolveError = error.message
}
/**
* Resolve the given id to file paths.

@@ -279,3 +298,4 @@ * @returns {string | null} The resolved path.

const requireResolve = resolver.create.sync({
/** @type {import('enhanced-resolve').ResolveOptionsOptionalFS} */
this.resolverConfig = {
conditionNames,

@@ -288,12 +308,15 @@ extensions,

alias,
})
}
const requireResolve = resolver.create.sync(this.resolverConfig)
const cwd = this.context.settings?.cwd ?? process.cwd()
for (const directory of this.getPaths()) {
const baseDir = resolve(cwd, directory)
try {
const baseDir = resolve(cwd, directory)
const resolved = requireResolve(baseDir, this.name)
if (typeof resolved === "string") return resolved
} catch {
continue
} catch (error) {
this.handleResolutionError(baseDir, error)
}

@@ -300,0 +323,0 @@ }

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

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

"lint-staged": "^15.2.0",
"markdownlint-cli": "^0.39.0",
"markdownlint-cli": "^0.40.0",
"mocha": "^10.2.0",

@@ -121,4 +121,4 @@ "npm-run-all2": "^6.1.1",

"imports": {
"#eslint-rule-tester": "./tests/eslint-rule-tester.js"
"#test-helpers": "./tests/test-helpers.js"
}
}
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