mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
tools: update ESLint to 7.14.0
Update ESLint to 7.14.0 PR-URL: https://github.com/nodejs/node/pull/36217 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
1 parent
f4cb54d4a0
commit
abecf463ae
11 files changed
+205
-38
No files matched your search
+1
-1
@@ -250,7 +250,7 @@ The following companies, organizations, and individuals support ESLint's ongoing
|
||||
<!--sponsorsstart-->
|
||||
<h3>Platinum Sponsors</h3>
|
||||
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/photomatt/ff91f0b/logo.png" alt="Automattic" height="undefined"></a></p><h3>Gold Sponsors</h3>
|
||||
<p><a href="https://www.shopify.com"><img src="https://images.opencollective.com/shopify/e780cd4/logo.png" alt="Shopify" height="96"></a> <a href="https://www.salesforce.com"><img src="https://images.opencollective.com/salesforce/ca8f997/logo.png" alt="Salesforce" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="96"></a> <a href="https://aka.ms/microsoftfossfund"><img src="https://avatars1.githubusercontent.com/u/67931232?u=7fddc652a464d7151b97e8f108392af7d54fa3e8&v=4" alt="Microsoft FOSS Fund Sponsorships" height="96"></a></p><h3>Silver Sponsors</h3>
|
||||
<p><a href="https://google.com/chrome"><img src="https://images.opencollective.com/chrome/dc55bd4/logo.png" alt="Chrome's Web Framework & Tools Performance Fund" height="96"></a> <a href="https://www.shopify.com"><img src="https://images.opencollective.com/shopify/e780cd4/logo.png" alt="Shopify" height="96"></a> <a href="https://www.salesforce.com"><img src="https://images.opencollective.com/salesforce/ca8f997/logo.png" alt="Salesforce" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="96"></a> <a href="https://aka.ms/microsoftfossfund"><img src="https://avatars1.githubusercontent.com/u/67931232?u=7fddc652a464d7151b97e8f108392af7d54fa3e8&v=4" alt="Microsoft FOSS Fund Sponsorships" height="96"></a></p><h3>Silver Sponsors</h3>
|
||||
<p><a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://www.ampproject.org/"><img src="https://images.opencollective.com/amp/c8a3b25/logo.png" alt="AMP Project" height="64"></a></p><h3>Bronze Sponsors</h3>
|
||||
<p><a href="https://writersperhour.com"><img src="https://images.opencollective.com/writersperhour/5787d4b/logo.png" alt="Writers Per Hour" height="32"></a> <a href="https://www.betacalendars.com/printable-calendar"><img src="https://images.opencollective.com/betacalendars/9334b33/logo.png" alt="2021 calendar" height="32"></a> <a href="https://buy.fineproxy.org/eng/"><img src="https://images.opencollective.com/buy-fineproxy-org/b282e39/logo.png" alt="Buy.Fineproxy.Org" height="32"></a> <a href="https://www.veikkaajat.com"><img src="https://images.opencollective.com/veikkaajat/b92b427/logo.png" alt="Veikkaajat.com" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="null"><img src="https://images.opencollective.com/bugsnag-stability-monitoring/c2cef36/logo.png" alt="Bugsnag Stability Monitoring" height="32"></a> <a href="https://mixpanel.com"><img src="https://images.opencollective.com/mixpanel/cd682f7/logo.png" alt="Mixpanel" height="32"></a> <a href="https://www.vpsserver.com"><img src="https://images.opencollective.com/vpsservercom/logo.png" alt="VPS Server" height="32"></a> <a href="https://icons8.com"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8: free icons, photos, illustrations, and music" height="32"></a> <a href="https://discordapp.com"><img src="https://images.opencollective.com/discordapp/7e3d9a9/logo.png" alt="Discord" height="32"></a> <a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://www.firesticktricks.com"><img src="https://images.opencollective.com/fire-stick-tricks/b8fbe2c/logo.png" alt="Fire Stick Tricks" height="32"></a></p>
|
||||
<!--sponsorsend-->
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ require("v8-compile-cache");
|
||||
|
||||
// must do this initialization *before* other requires in order to work
|
||||
if (process.argv.includes("--debug")) {
|
||||
require("debug").enable("eslint:*,-eslint:code-path");
|
||||
require("debug").enable("eslint:*,-eslint:code-path,eslintrc:*");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
+1
@@ -169,6 +169,7 @@ module.exports = new LazyLoadingRuleMap(Object.entries({
|
||||
"no-new-require": () => require("./no-new-require"),
|
||||
"no-new-symbol": () => require("./no-new-symbol"),
|
||||
"no-new-wrappers": () => require("./no-new-wrappers"),
|
||||
"no-nonoctal-decimal-escape": () => require("./no-nonoctal-decimal-escape"),
|
||||
"no-obj-calls": () => require("./no-obj-calls"),
|
||||
"no-octal": () => require("./no-octal"),
|
||||
"no-octal-escape": () => require("./no-octal-escape"),
|
||||
|
||||
+7
-9
@@ -82,7 +82,7 @@ module.exports = {
|
||||
const commentNodes = sourceCode.getAllComments();
|
||||
|
||||
/**
|
||||
* Removes errors that occur inside a string node
|
||||
* Removes errors that occur inside the given node
|
||||
* @param {ASTNode} node to check for matching errors.
|
||||
* @returns {void}
|
||||
* @private
|
||||
@@ -91,14 +91,12 @@ module.exports = {
|
||||
const locStart = node.loc.start;
|
||||
const locEnd = node.loc.end;
|
||||
|
||||
errors = errors.filter(({ loc: { start: errorLoc } }) => {
|
||||
if (errorLoc.line >= locStart.line && errorLoc.line <= locEnd.line) {
|
||||
if (errorLoc.column >= locStart.column && (errorLoc.column <= locEnd.column || errorLoc.line < locEnd.line)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
errors = errors.filter(({ loc: { start: errorLocStart } }) => (
|
||||
errorLocStart.line < locStart.line ||
|
||||
errorLocStart.line === locStart.line && errorLocStart.column < locStart.column ||
|
||||
errorLocStart.line === locEnd.line && errorLocStart.column >= locEnd.column ||
|
||||
errorLocStart.line > locEnd.line
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
/**
|
||||
* @fileoverview Rule to disallow `\8` and `\9` escape sequences in string literals.
|
||||
* @author Milos Djermanovic
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const QUICK_TEST_REGEX = /\\[89]/u;
|
||||
|
||||
/**
|
||||
* Returns unicode escape sequence that represents the given character.
|
||||
* @param {string} character A single code unit.
|
||||
* @returns {string} "\uXXXX" sequence.
|
||||
*/
|
||||
function getUnicodeEscape(character) {
|
||||
return `\\u${character.charCodeAt(0).toString(16).padStart(4, "0")}`;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description: "disallow `\\8` and `\\9` escape sequences in string literals",
|
||||
category: "Best Practices",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/no-nonoctal-decimal-escape",
|
||||
suggestion: true
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
messages: {
|
||||
decimalEscape: "Don't use '{{decimalEscape}}' escape sequence.",
|
||||
|
||||
// suggestions
|
||||
refactor: "Replace '{{original}}' with '{{replacement}}'. This maintains the current functionality.",
|
||||
escapeBackslash: "Replace '{{original}}' with '{{replacement}}' to include the actual backslash character."
|
||||
}
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
|
||||
/**
|
||||
* Creates a new Suggestion object.
|
||||
* @param {string} messageId "refactor" or "escapeBackslash".
|
||||
* @param {int[]} range The range to replace.
|
||||
* @param {string} replacement New text for the range.
|
||||
* @returns {Object} Suggestion
|
||||
*/
|
||||
function createSuggestion(messageId, range, replacement) {
|
||||
return {
|
||||
messageId,
|
||||
data: {
|
||||
original: sourceCode.getText().slice(...range),
|
||||
replacement
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.replaceTextRange(range, replacement);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
Literal(node) {
|
||||
if (typeof node.value !== "string") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!QUICK_TEST_REGEX.test(node.raw)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const regex = /(?:[^\\]|(?<previousEscape>\\.))*?(?<decimalEscape>\\[89])/suy;
|
||||
let match;
|
||||
|
||||
while ((match = regex.exec(node.raw))) {
|
||||
const { previousEscape, decimalEscape } = match.groups;
|
||||
const decimalEscapeRangeEnd = node.range[0] + match.index + match[0].length;
|
||||
const decimalEscapeRangeStart = decimalEscapeRangeEnd - decimalEscape.length;
|
||||
const decimalEscapeRange = [decimalEscapeRangeStart, decimalEscapeRangeEnd];
|
||||
const suggest = [];
|
||||
|
||||
// When `regex` is matched, `previousEscape` can only capture characters adjacent to `decimalEscape`
|
||||
if (previousEscape === "\\0") {
|
||||
|
||||
/*
|
||||
* Now we have a NULL escape "\0" immediately followed by a decimal escape, e.g.: "\0\8".
|
||||
* Fixing this to "\08" would turn "\0" into a legacy octal escape. To avoid producing
|
||||
* an octal escape while fixing a decimal escape, we provide different suggestions.
|
||||
*/
|
||||
suggest.push(
|
||||
createSuggestion( // "\0\8" -> "\u00008"
|
||||
"refactor",
|
||||
[decimalEscapeRangeStart - previousEscape.length, decimalEscapeRangeEnd],
|
||||
`${getUnicodeEscape("\0")}${decimalEscape[1]}`
|
||||
),
|
||||
createSuggestion( // "\8" -> "\u0038"
|
||||
"refactor",
|
||||
decimalEscapeRange,
|
||||
getUnicodeEscape(decimalEscape[1])
|
||||
)
|
||||
);
|
||||
} else {
|
||||
suggest.push(
|
||||
createSuggestion( // "\8" -> "8"
|
||||
"refactor",
|
||||
decimalEscapeRange,
|
||||
decimalEscape[1]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
suggest.push(
|
||||
createSuggestion( // "\8" -> "\\8"
|
||||
"escapeBackslash",
|
||||
decimalEscapeRange,
|
||||
`\\${decimalEscape}`
|
||||
)
|
||||
);
|
||||
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: sourceCode.getLocFromIndex(decimalEscapeRangeStart),
|
||||
end: sourceCode.getLocFromIndex(decimalEscapeRangeEnd)
|
||||
},
|
||||
messageId: "decimalEscape",
|
||||
data: {
|
||||
decimalEscape
|
||||
},
|
||||
suggest
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
+8
@@ -162,6 +162,14 @@ module.exports = {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prevent crashing on parsers which do not require class constructor
|
||||
* to have a body, e.g. typescript and flow
|
||||
*/
|
||||
if (!node.value.body) {
|
||||
return;
|
||||
}
|
||||
|
||||
const body = node.value.body.body;
|
||||
const ctorParams = node.value.params;
|
||||
const superClass = node.parent.parent.superClass;
|
||||
|
||||
+1
-1
@@ -74,5 +74,5 @@
|
||||
"test:coverage": "cat ./coverage/lcov.info | coveralls",
|
||||
"test:node": "istanbul cover _mocha -- test.js"
|
||||
},
|
||||
"version": "4.2.0"
|
||||
"version": "4.3.1"
|
||||
}
|
||||
+10
@@ -9,6 +9,16 @@ exports.save = save;
|
||||
exports.load = load;
|
||||
exports.useColors = useColors;
|
||||
exports.storage = localstorage();
|
||||
exports.destroy = (() => {
|
||||
let warned = false;
|
||||
|
||||
return () => {
|
||||
if (!warned) {
|
||||
warned = true;
|
||||
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
/**
|
||||
* Colors.
|
||||
|
||||
+21
-24
@@ -12,16 +12,12 @@ function setup(env) {
|
||||
createDebug.enable = enable;
|
||||
createDebug.enabled = enabled;
|
||||
createDebug.humanize = require('ms');
|
||||
createDebug.destroy = destroy;
|
||||
|
||||
Object.keys(env).forEach(key => {
|
||||
createDebug[key] = env[key];
|
||||
});
|
||||
|
||||
/**
|
||||
* Active `debug` instances.
|
||||
*/
|
||||
createDebug.instances = [];
|
||||
|
||||
/**
|
||||
* The currently active debug mode names, and names to skip.
|
||||
*/
|
||||
@@ -63,6 +59,7 @@ function setup(env) {
|
||||
*/
|
||||
function createDebug(namespace) {
|
||||
let prevTime;
|
||||
let enableOverride = null;
|
||||
|
||||
function debug(...args) {
|
||||
// Disabled?
|
||||
@@ -92,7 +89,7 @@ function setup(env) {
|
||||
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
||||
// If we encounter an escaped % then don't increase the array index
|
||||
if (match === '%%') {
|
||||
return match;
|
||||
return '%';
|
||||
}
|
||||
index++;
|
||||
const formatter = createDebug.formatters[format];
|
||||
@@ -115,31 +112,28 @@ function setup(env) {
|
||||
}
|
||||
|
||||
debug.namespace = namespace;
|
||||
debug.enabled = createDebug.enabled(namespace);
|
||||
debug.useColors = createDebug.useColors();
|
||||
debug.color = createDebug.selectColor(namespace);
|
||||
debug.destroy = destroy;
|
||||
debug.extend = extend;
|
||||
debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
|
||||
|
||||
Object.defineProperty(debug, 'enabled', {
|
||||
enumerable: true,
|
||||
configurable: false,
|
||||
get: () => enableOverride === null ? createDebug.enabled(namespace) : enableOverride,
|
||||
set: v => {
|
||||
enableOverride = v;
|
||||
}
|
||||
});
|
||||
|
||||
// Env-specific initialization logic for debug instances
|
||||
if (typeof createDebug.init === 'function') {
|
||||
createDebug.init(debug);
|
||||
}
|
||||
|
||||
createDebug.instances.push(debug);
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
function destroy() {
|
||||
const index = createDebug.instances.indexOf(this);
|
||||
if (index !== -1) {
|
||||
createDebug.instances.splice(index, 1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function extend(namespace, delimiter) {
|
||||
const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
|
||||
newDebug.log = this.log;
|
||||
@@ -177,11 +171,6 @@ function setup(env) {
|
||||
createDebug.names.push(new RegExp('^' + namespaces + '$'));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < createDebug.instances.length; i++) {
|
||||
const instance = createDebug.instances[i];
|
||||
instance.enabled = createDebug.enabled(instance.namespace);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,6 +245,14 @@ function setup(env) {
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* XXX DO NOT USE. This is a temporary stub function.
|
||||
* XXX It WILL be removed in the next major release.
|
||||
*/
|
||||
function destroy() {
|
||||
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
||||
}
|
||||
|
||||
createDebug.enable(createDebug.load());
|
||||
|
||||
return createDebug;
|
||||
|
||||
+7
-1
@@ -15,6 +15,10 @@ exports.formatArgs = formatArgs;
|
||||
exports.save = save;
|
||||
exports.load = load;
|
||||
exports.useColors = useColors;
|
||||
exports.destroy = util.deprecate(
|
||||
() => {},
|
||||
'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
|
||||
);
|
||||
|
||||
/**
|
||||
* Colors.
|
||||
@@ -244,7 +248,9 @@ const {formatters} = module.exports;
|
||||
formatters.o = function (v) {
|
||||
this.inspectOpts.colors = this.useColors;
|
||||
return util.inspect(v, this.inspectOpts)
|
||||
.replace(/\s*\n\s*/g, ' ');
|
||||
.split('\n')
|
||||
.map(str => str.trim())
|
||||
.join(' ');
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -155,5 +155,5 @@
|
||||
"test:cli": "mocha",
|
||||
"webpack": "node Makefile.js webpack"
|
||||
},
|
||||
"version": "7.13.0"
|
||||
"version": "7.14.0"
|
||||
}
|
||||
Reference in new issue
Block a user