Socket
Socket
Sign inDemoInstall

eslint-plugin-node

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-node - npm Package Compare versions

Comparing version 5.2.1 to 6.0.0

lib/util/get-docs-url.js

2

lib/index.js

@@ -9,4 +9,4 @@ /**

module.exports = {
configs: {recommended: require("./recommended.json")},
configs: { recommended: require("./recommended.json") },
rules: require("./rules.js"),
}

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

//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const getDocsUrl = require("../util/get-docs-url")
//------------------------------------------------------------------------------
// Helpers

@@ -297,2 +303,3 @@ //------------------------------------------------------------------------------

recommended: false,
url: getDocsUrl("exports-style.md"),
},

@@ -306,3 +313,3 @@ fixable: false,

type: "object",
properties: {allowBatchAssign: {type: "boolean"}},
properties: { allowBatchAssign: { type: "boolean" } },
additionalProperties: false,

@@ -309,0 +316,0 @@ },

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

const deprecatedApis = require("../util/deprecated-apis")
const getDocsUrl = require("../util/get-docs-url")
const getValueIfString = require("../util/get-value-if-string")

@@ -468,3 +469,3 @@

path,
Object.assign({}, infoMap, {default: infoMap})
Object.assign({}, infoMap, { default: infoMap })
)

@@ -571,2 +572,3 @@ break

recommended: true,
url: getDocsUrl("no-deprecated-api.md"),
},

@@ -580,3 +582,3 @@ fixable: false,

type: "array",
items: {enum: MODULE_ITEMS},
items: { enum: MODULE_ITEMS },
additionalItems: false,

@@ -587,3 +589,3 @@ uniqueItems: true,

type: "array",
items: {enum: GLOBAL_ITEMS},
items: { enum: GLOBAL_ITEMS },
additionalItems: false,

@@ -594,3 +596,3 @@ uniqueItems: true,

// Deprecated since v4.2.0
ignoreIndirectDependencies: {type: "boolean"},
ignoreIndirectDependencies: { type: "boolean" },
},

@@ -597,0 +599,0 @@ additionalProperties: false,

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

const getConvertPath = require("../util/get-convert-path")
const getDocsUrl = require("../util/get-docs-url")
const getImportTargets = require("../util/get-import-export-targets")

@@ -57,2 +58,3 @@ const getResolvePaths = require("../util/get-resolve-paths")

recommended: false,
url: getDocsUrl("no-extraneous-import.md"),
},

@@ -59,0 +61,0 @@ fixable: false,

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

const getConvertPath = require("../util/get-convert-path")
const getDocsUrl = require("../util/get-docs-url")
const getRequireTargets = require("../util/get-require-targets")

@@ -57,2 +58,3 @@ const getResolvePaths = require("../util/get-resolve-paths")

recommended: true,
url: getDocsUrl("no-extraneous-require.md"),
},

@@ -59,0 +61,0 @@ fixable: false,

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

const resolve = require("resolve")
const getDocsUrl = require("../util/get-docs-url")
const getPackageJson = require("../util/get-package-json")

@@ -77,3 +78,3 @@ const getRequireTargets = require("../util/get-require-targets")

const resolved = resolve.sync(name, {basedir: dirPath})
const resolved = resolve.sync(name, { basedir: dirPath })
const isCore = resolved === name

@@ -111,2 +112,3 @@

recommended: false,
url: getDocsUrl("no-hide-core-modules.md"),
},

@@ -121,8 +123,8 @@ deprecated: true,

type: "array",
items: {enum: Array.from(CORE_MODULES)},
items: { enum: Array.from(CORE_MODULES) },
additionalItems: false,
uniqueItems: true,
},
ignoreDirectDependencies: {type: "boolean"},
ignoreIndirectDependencies: {type: "boolean"},
ignoreDirectDependencies: { type: "boolean" },
ignoreIndirectDependencies: { type: "boolean" },
},

@@ -129,0 +131,0 @@ additionalProperties: false,

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

const getAllowModules = require("../util/get-allow-modules")
const getDocsUrl = require("../util/get-docs-url")
const getImportExportTargets = require("../util/get-import-export-targets")

@@ -56,2 +57,3 @@ const getResolvePaths = require("../util/get-resolve-paths")

recommended: false,
url: getDocsUrl("no-missing-import.md"),
},

@@ -58,0 +60,0 @@ fixable: false,

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

const getAllowModules = require("../util/get-allow-modules")
const getDocsUrl = require("../util/get-docs-url")
const getRequireTargets = require("../util/get-require-targets")

@@ -56,2 +57,3 @@ const getResolvePaths = require("../util/get-resolve-paths")

recommended: true,
url: getDocsUrl("no-missing-require.md"),
},

@@ -58,0 +60,0 @@ fixable: false,

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

const getConvertPath = require("../util/get-convert-path")
const getDocsUrl = require("../util/get-docs-url")
const getNpmignore = require("../util/get-npmignore")

@@ -86,3 +87,3 @@ const getPackageJson = require("../util/get-package-json")

"Check 'files' field of 'package.json' or '.npmignore'.",
data: {name: relativePath},
data: { name: relativePath },
})

@@ -104,2 +105,3 @@ },

recommended: true,
url: getDocsUrl("no-unpublished-bin.md"),
},

@@ -106,0 +108,0 @@ fixable: false,

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

const getConvertPath = require("../util/get-convert-path")
const getDocsUrl = require("../util/get-docs-url")
const getImportExportTargets = require("../util/get-import-export-targets")

@@ -58,2 +59,3 @@ const getResolvePaths = require("../util/get-resolve-paths")

recommended: false,
url: getDocsUrl("no-unpublished-import.md"),
},

@@ -60,0 +62,0 @@ fixable: false,

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

const getConvertPath = require("../util/get-convert-path")
const getDocsUrl = require("../util/get-docs-url")
const getRequireTargets = require("../util/get-require-targets")

@@ -58,2 +59,3 @@ const getResolvePaths = require("../util/get-resolve-paths")

recommended: true,
url: getDocsUrl("no-unpublished-require.md"),
},

@@ -60,0 +62,0 @@ fixable: false,

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

const features = require("../util/features")
const getDocsUrl = require("../util/get-docs-url")
const getPackageJson = require("../util/get-package-json")

@@ -28,9 +29,13 @@ const getValueIfString = require("../util/get-value-if-string")

[6, "6.0.0"],
[6.5, "6.5.0"],
[7, "7.0.0"],
[7.6, "7.6.0"],
[8, "8.0.0"],
[8.3, "8.3.0"],
[9, "9.0.0"],
[10, "10.0.0"],
])
const VERSION_SCHEMA = {
anyOf: [
{enum: Array.from(VERSION_MAP.keys())},
{ enum: Array.from(VERSION_MAP.keys()) },
{

@@ -43,3 +48,2 @@ type: "string",

const DEFAULT_VERSION = "4.0.0"
const MINIMUM_VERSION = "0.0.0"
const OPTIONS = Object.keys(features)

@@ -89,36 +93,11 @@ const FUNC_TYPE = /^(?:Arrow)?Function(?:Declaration|Expression)$/

}
const REGEXP_NAMED_GROUP = /(\\*)\(\?<[_$\w]/
const REGEXP_LOOKBEHIND = /(\\*)\(\?<[=!]/
const REGEXP_UNICODE_PROPERTY = /(\\*)\\[pP]{.+?}/
/**
* Get the smaller value of the given 2 semvers.
* @param {string|null} a A semver to compare.
* @param {string} b Another semver to compare.
* @returns {string} The smaller value.
*/
function min(a, b) {
return (
a == null ? b :
semver.lt(a, b) ? a :
/* otherwise */ b
)
}
/**
* Get the larger value of the given 2 semvers.
* @param {string|null} a A semver to compare.
* @param {string} b Another semver to compare.
* @returns {string} The larger value.
*/
function max(a, b) {
return (
a == null ? b :
semver.gt(a, b) ? a :
/* otherwise */ b
)
}
/**
* Gets default version configuration of this rule.
*
* This finds and reads 'package.json' file, then parses 'engines.node' field.
* If it's nothing, this returns '4'.
* If it's nothing, this returns null.
*

@@ -132,34 +111,3 @@ * @param {string} filename - The file name of the current linting file.

try {
const range = new semver.Range(nodeVersion)
const comparators = Array.prototype.concat.apply([], range.set)
const ret = comparators.reduce(
(lu, comparator) => {
const op = comparator.operator
const v = comparator.semver
if (op === "" || op === ">=") {
lu.lower = min(lu.lower, `${v.major}.${v.minor}.${v.patch}`)
}
else if (op === ">") {
lu.lower = min(lu.lower, `${v.major}.${v.minor}.${v.patch + 1}`)
}
if (op === "" || op === "<=" || op === "<") {
lu.upper = max(lu.upper, `${v.major}.${v.minor}.${v.patch}`)
}
return lu
},
{lower: null, upper: null}
)
if (ret.lower == null && ret.upper != null) {
return MINIMUM_VERSION
}
return ret.lower || DEFAULT_VERSION
}
catch (_err) {
return DEFAULT_VERSION
}
return nodeVersion ? semver.validRange(nodeVersion) : null
}

@@ -207,3 +155,4 @@

function parseOptions(options, defaultVersion) {
let version = defaultVersion
let version = defaultVersion ? null : DEFAULT_VERSION
let range = null
let ignores = []

@@ -220,6 +169,12 @@

? VERSION_MAP.get(options.version)
: options.version || defaultVersion
: options.version
ignores = options.ignores || []
}
range = semver.validRange(version ? `>=${version}` : defaultVersion)
if (!version) {
version = defaultVersion
}
return Object.freeze({

@@ -243,4 +198,4 @@ version,

singular: Boolean(feature.singular),
supported: semver.gte(version, feature.node),
supportedInStrict: semver.gte(version, feature.node),
supported: !semver.intersects(range, `<${feature.node}`),
supportedInStrict: !semver.intersects(range, `<${feature.node}`),
})

@@ -255,7 +210,7 @@ }

feature.node.sloppy != null &&
semver.gte(version, feature.node.sloppy),
!semver.intersects(range, `<${feature.node.sloppy}`),
supportedInStrict:
feature.node != null &&
feature.node.strict != null &&
semver.gte(version, feature.node.strict),
!semver.intersects(range, `<${feature.node.strict}`),
})

@@ -317,2 +272,13 @@ }

/**
* Check a given string has a given pattern.
* @param {string} s A string to check.
* @param {RegExp} pattern A RegExp object to check.
* @returns {boolean} `true` if the string has the pattern.
*/
function hasPattern(s, pattern) {
const m = pattern.exec(s)
return m != null && ((m[1] || "").length % 2) === 0
}
/**
* The definition of this rule.

@@ -443,2 +409,56 @@ *

/**
* Validate RegExp syntax.
* @param {string} pattern A RegExp pattern to check.
* @param {string} flags A RegExp flags to check.
* @param {ASTNode} node A node to report.
* @returns {void}
*/
function validateRegExp(pattern, flags, node) {
if (typeof pattern === "string") {
if (hasPattern(pattern, REGEXP_NAMED_GROUP)) {
report(node, "regexpNamedCaptureGroups")
}
if (hasPattern(pattern, REGEXP_LOOKBEHIND)) {
report(node, "regexpLookbehind")
}
if (hasPattern(pattern, REGEXP_UNICODE_PROPERTY)) {
report(node, "regexpUnicodeProperties")
}
}
if (typeof flags === "string") {
if (flags.indexOf("y") !== -1) {
report(node, "regexpY")
}
if (flags.indexOf("u") !== -1) {
report(node, "regexpU")
}
if (flags.indexOf("s") !== -1) {
report(node, "regexpS")
}
}
}
/**
* Validate RegExp syntax in a RegExp literal.
* @param {ASTNode} node A Literal node to check.
* @returns {void}
*/
function validateRegExpLiteral(node) {
validateRegExp(node.regex.pattern, node.regex.flags, node)
}
/**
* Validate RegExp syntax in the first argument of `new RegExp()`.
* @param {ASTNode} node A NewExpression node to check.
* @returns {void}
*/
function validateRegExpString(node) {
const patternNode = node.arguments[0]
const flagsNode = node.arguments[1]
const pattern = (patternNode && patternNode.type === "Literal" && typeof patternNode.value === "string") ? patternNode.value : null
const flags = (flagsNode && flagsNode.type === "Literal" && typeof flagsNode.value === "string") ? flagsNode.value : null
validateRegExp(pattern, flags, node)
}
return {

@@ -533,2 +553,5 @@ //----------------------------------------------------------------------

}
if (node.async && node.generator) {
report(node, "asyncGenerators")
}
},

@@ -546,2 +569,5 @@

}
if (node.async && node.generator) {
report(node, "asyncGenerators")
}
},

@@ -557,8 +583,2 @@

"RestElement"(node) {
if (FUNC_TYPE.test(node.parent.type)) {
report(node, "restParameters")
}
},
//----------------------------------------------------------------------

@@ -590,2 +610,5 @@ // Classes

report(node, "forOf")
if (node.await) {
report(node, "forAwaitOf")
}
},

@@ -656,8 +679,3 @@

else if (node.regex) {
if (node.regex.flags.indexOf("y") !== -1) {
report(node, "regexpY")
}
if (node.regex.flags.indexOf("u") !== -1) {
report(node, "regexpU")
}
validateRegExpLiteral(node)
}

@@ -667,14 +685,4 @@ },

"NewExpression"(node) {
if (node.callee.type === "Identifier" &&
node.callee.name === "RegExp" &&
node.arguments.length === 2 &&
node.arguments[1].type === "Literal" &&
typeof node.arguments[1].value === "string"
) {
if (node.arguments[1].value.indexOf("y") !== -1) {
report(node, "regexpY")
}
if (node.arguments[1].value.indexOf("u") !== -1) {
report(node, "regexpU")
}
if (node.callee.type === "Identifier" && node.callee.name === "RegExp") {
validateRegExpString(node)
}

@@ -705,6 +713,26 @@ if (hasTrailingCommaForCall(node)) {

"RestElement"(node) {
if (FUNC_TYPE.test(node.parent.type)) {
report(node, "restParameters")
}
else if (node.parent.type === "ObjectPattern") {
report(node, "restProperties")
}
},
"SpreadElement"(node) {
report(node, "spreadOperators")
if (node.parent.type === "ObjectExpression") {
report(node, "spreadProperties")
}
else {
report(node, "spreadOperators")
}
},
"TemplateElement"(node) {
if (node.value.cooked == null) {
report(node, "templateLiteralRevision")
}
},
"TemplateLiteral"(node) {

@@ -715,2 +743,22 @@ report(node, "templateStrings")

//----------------------------------------------------------------------
// Legacy
//----------------------------------------------------------------------
"ExperimentalRestProperty"(node) {
report(node, "restProperties")
},
"ExperimentalSpreadProperty"(node) {
report(node, "spreadProperties")
},
"RestProperty"(node) {
report(node, "restProperties")
},
"SpreadProperty"(node) {
report(node, "spreadProperties")
},
//----------------------------------------------------------------------
// Modules

@@ -748,2 +796,3 @@ //----------------------------------------------------------------------

recommended: true,
url: getDocsUrl("no-unsupported-features.md"),
},

@@ -762,3 +811,3 @@ fixable: false,

type: "array",
items: {enum: getIgnoresEnum()},
items: { enum: getIgnoresEnum() },
uniqueItems: true,

@@ -765,0 +814,0 @@ },

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

const CodePathSegment = safeRequire("eslint/lib/code-path-analysis/code-path-segment")
const getDocsUrl = require("../util/get-docs-url")

@@ -66,3 +67,4 @@ //------------------------------------------------------------------------------

currentSegment,
node)
node
)
}

@@ -86,3 +88,4 @@ }

headSegment,
node)
node
)
}

@@ -153,2 +156,3 @@ }

recommended: true,
url: getDocsUrl("process-exit-as-throw.md"),
},

@@ -155,0 +159,0 @@ fixable: false,

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

const getConvertPath = require("../util/get-convert-path")
const getDocsUrl = require("../util/get-docs-url")
const getPackageJson = require("../util/get-package-json")

@@ -150,2 +151,3 @@

recommended: true,
url: getDocsUrl("shebang.md"),
},

@@ -152,0 +154,0 @@ fixable: "code",

@@ -65,5 +65,5 @@ /**

else {
this.map.set(key, {value, expire})
this.map.set(key, { value, expire })
}
}
}

@@ -77,3 +77,3 @@ /**

message: "\"{{name}}\" is not published.",
data: {name: target.moduleName || target.name},
data: { name: target.moduleName || target.name },
})

@@ -80,0 +80,0 @@ }

@@ -19,2 +19,14 @@ /**

},
async_hooks: { //eslint-disable-line camelcase
currentId: {
$deprecated: true,
since: 8.2,
replacedBy: "'async_hooks.executionAsyncId()'",
},
triggerId: {
$deprecated: true,
since: 8.2,
replacedBy: "'async_hooks.triggerAsyncId()'",
},
},
buffer: {

@@ -126,2 +138,7 @@ Buffer: {

},
_debug: {
$deprecated: true,
since: 9,
replacedBy: null,
},
},

@@ -133,2 +150,7 @@ requireRepl: {

},
_debug: {
$deprecated: true,
since: 9,
replacedBy: null,
},
},

@@ -147,2 +169,9 @@ os: {

},
path: {
_makeLong: {
$deprecated: true,
since: 9,
replacedBy: "'path.toNamespacedPath()'",
},
},
punycode: {

@@ -201,2 +230,7 @@ $deprecated: true,

},
parseCertString: {
$deprecated: true,
since: 8.6,
replacedBy: "'querystring.parse()'",
},
},

@@ -203,0 +237,0 @@ tty: {

@@ -145,7 +145,52 @@ /**

"trailingCommasInFunctions": {
// trailingCommasInFunctionSyntax is for backward compatibility.
alias: ["syntax", "trailingCommasInFunctionSyntax"],
alias: ["syntax"],
name: "Trailing commas in functions",
node: "8.0.0",
},
//------------------------------------------
"templateLiteralRevision": {
alias: ["syntax"],
name: "Illegal escape sequences in taggled templates",
node: "9.0.0",
},
"regexpS": {
alias: ["syntax"],
name: "RegExp 's' flags",
node: "9.0.0",
},
"regexpNamedCaptureGroups": {
alias: ["syntax"],
name: "RegExp named capture groups",
node: "10.0.0",
},
"regexpLookbehind": {
alias: ["syntax"],
name: "RegExp lookbehind assertions",
node: "9.0.0",
},
"regexpUnicodeProperties": {
alias: ["syntax"],
name: "RegExp Unicode property escapes",
node: "10.0.0",
},
"restProperties": {
alias: ["syntax"],
name: "Rest properties",
node: "8.3.0",
},
"spreadProperties": {
alias: ["syntax"],
name: "Spread properties",
node: "8.3.0",
},
"asyncGenerators": {
alias: ["syntax"],
name: "Async generators",
node: "10.0.0",
},
"forAwaitOf": {
alias: ["syntax"],
name: "for-await-of loops",
node: "10.0.0",
},

@@ -268,3 +313,3 @@ //--------------------------------------------------------------------------

singular: true,
node: null,
node: "9.0.0",
},

@@ -275,3 +320,3 @@ "Atomics": {

singular: true,
node: null,
node: "9.0.0",
},

@@ -498,3 +543,3 @@

singular: true,
node: null,
node: "6.5.0",
},

@@ -517,3 +562,3 @@ "Symbol.isConcatSpreadablec": {

singular: true,
node: null,
node: "6.5.0",
},

@@ -567,3 +612,3 @@ "Symbol.replace": {

singular: true,
node: null,
node: "9.0.0",
},

@@ -574,3 +619,3 @@ "Atomics.and": {

singular: true,
node: null,
node: "9.0.0",
},

@@ -581,3 +626,3 @@ "Atomics.compareExchange": {

singular: true,
node: null,
node: "9.0.0",
},

@@ -588,3 +633,3 @@ "Atomics.exchange": {

singular: true,
node: null,
node: "9.0.0",
},

@@ -595,3 +640,3 @@ "Atomics.wait": {

singular: true,
node: null,
node: "9.0.0",
},

@@ -602,3 +647,3 @@ "Atomics.wake": {

singular: true,
node: null,
node: "9.0.0",
},

@@ -609,3 +654,3 @@ "Atomics.isLockFree": {

singular: true,
node: null,
node: "9.0.0",
},

@@ -616,3 +661,3 @@ "Atomics.load": {

singular: true,
node: null,
node: "9.0.0",
},

@@ -623,3 +668,3 @@ "Atomics.or": {

singular: true,
node: null,
node: "9.0.0",
},

@@ -630,3 +675,3 @@ "Atomics.store": {

singular: true,
node: null,
node: "9.0.0",
},

@@ -637,3 +682,3 @@ "Atomics.sub": {

singular: true,
node: null,
node: "9.0.0",
},

@@ -644,3 +689,3 @@ "Atomics.xor": {

singular: true,
node: null,
node: "9.0.0",
},

@@ -647,0 +692,0 @@

@@ -166,3 +166,3 @@ /**

type: "array",
items: {type: "string"},
items: { type: "string" },
minItems: 2,

@@ -181,3 +181,3 @@ maxItems: 2,

type: "array",
items: {type: "string"},
items: { type: "string" },
minItems: 1,

@@ -188,3 +188,3 @@ uniqueItems: true,

type: "array",
items: {type: "string"},
items: { type: "string" },
uniqueItems: true,

@@ -194,3 +194,3 @@ },

type: "array",
items: {type: "string"},
items: { type: "string" },
minItems: 2,

@@ -197,0 +197,0 @@ maxItems: 2,

@@ -44,3 +44,3 @@ /**

const extensions = getTryExtensions(context)
const options = {basedir, paths, extensions}
const options = { basedir, paths, extensions }

@@ -47,0 +47,0 @@ for (const statement of programNode.body) {

@@ -153,3 +153,3 @@ /**

module.exports = function getNpmignore(startPath) {
const retv = {match: notAncestorFiles}
const retv = { match: notAncestorFiles }

@@ -156,0 +156,0 @@ const p = getPackageJson(startPath)

@@ -68,3 +68,3 @@ /**

const extensions = getTryExtensions(context)
const options = {basedir, paths, extensions}
const options = { basedir, paths, extensions }

@@ -71,0 +71,0 @@ for (const reference of references) {

@@ -51,4 +51,4 @@ /**

type: "array",
items: {type: "string"},
items: { type: "string" },
uniqueItems: true,
}
{
"name": "eslint-plugin-node",
"version": "5.2.1",
"version": "6.0.0",
"description": "Additional ESLint's rules for Node.js",

@@ -32,13 +32,13 @@ "main": "lib/index.js",

"resolve": "^1.3.3",
"semver": "5.3.0"
"semver": "^5.4.1"
},
"devDependencies": {
"codecov": "^2.2.0",
"eslint": "^4.1.0",
"eslint-config-mysticatea": "^11.0.0",
"mocha": "^3.4.2",
"codecov": "^3.0.0",
"eslint": "^4.17.0",
"eslint-config-mysticatea": "^13.0.2",
"mocha": "^5.0.0",
"nyc": "^11.0.1",
"opener": "^1.4.3",
"rimraf": "^2.6.1",
"shelljs": "^0.7.7"
"shelljs": "^0.8.1"
},

@@ -45,0 +45,0 @@ "repository": {

@@ -29,3 +29,3 @@ # eslint-plugin-node

"rules": {
"node/exports-style": ["error", "module.exports"],
"node/exports-style": ["error", "module.exports"]
}

@@ -32,0 +32,0 @@ }

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