Update checked-in dependencies
This commit is contained in:
parent
79817eb679
commit
9c3b394d7f
402 changed files with 12598 additions and 2912 deletions
9
node_modules/eslint/lib/cli.js
generated
vendored
9
node_modules/eslint/lib/cli.js
generated
vendored
|
|
@ -318,7 +318,14 @@ const cli = {
|
|||
options = CLIOptions.parse(args);
|
||||
} catch (error) {
|
||||
debug("Error parsing CLI options:", error.message);
|
||||
log.error(error.message);
|
||||
|
||||
let errorMessage = error.message;
|
||||
|
||||
if (usingFlatConfig) {
|
||||
errorMessage += "\nYou're using eslint.config.js, some command line flags are no longer available. Please see https://eslint.org/docs/latest/use/command-line-interface for details.";
|
||||
}
|
||||
|
||||
log.error(errorMessage);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
|
|
|||
89
node_modules/eslint/lib/config/flat-config-schema.js
generated
vendored
89
node_modules/eslint/lib/config/flat-config-schema.js
generated
vendored
|
|
@ -5,6 +5,16 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* Note: This can be removed in ESLint v9 because structuredClone is available globally
|
||||
* starting in Node.js v17.
|
||||
*/
|
||||
const structuredClone = require("@ungap/structured-clone").default;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Type Definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -119,7 +129,7 @@ function normalizeRuleOptions(ruleOptions) {
|
|||
: [ruleOptions];
|
||||
|
||||
finalOptions[0] = ruleSeverities.get(finalOptions[0]);
|
||||
return finalOptions;
|
||||
return structuredClone(finalOptions);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -378,48 +388,57 @@ const rulesSchema = {
|
|||
...second
|
||||
};
|
||||
|
||||
|
||||
for (const ruleId of Object.keys(result)) {
|
||||
|
||||
// avoid hairy edge case
|
||||
if (ruleId === "__proto__") {
|
||||
try {
|
||||
|
||||
/* eslint-disable-next-line no-proto -- Though deprecated, may still be present */
|
||||
delete result.__proto__;
|
||||
continue;
|
||||
// avoid hairy edge case
|
||||
if (ruleId === "__proto__") {
|
||||
|
||||
/* eslint-disable-next-line no-proto -- Though deprecated, may still be present */
|
||||
delete result.__proto__;
|
||||
continue;
|
||||
}
|
||||
|
||||
result[ruleId] = normalizeRuleOptions(result[ruleId]);
|
||||
|
||||
/*
|
||||
* If either rule config is missing, then the correct
|
||||
* config is already present and we just need to normalize
|
||||
* the severity.
|
||||
*/
|
||||
if (!(ruleId in first) || !(ruleId in second)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const firstRuleOptions = normalizeRuleOptions(first[ruleId]);
|
||||
const secondRuleOptions = normalizeRuleOptions(second[ruleId]);
|
||||
|
||||
/*
|
||||
* If the second rule config only has a severity (length of 1),
|
||||
* then use that severity and keep the rest of the options from
|
||||
* the first rule config.
|
||||
*/
|
||||
if (secondRuleOptions.length === 1) {
|
||||
result[ruleId] = [secondRuleOptions[0], ...firstRuleOptions.slice(1)];
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* In any other situation, then the second rule config takes
|
||||
* precedence. That means the value at `result[ruleId]` is
|
||||
* already correct and no further work is necessary.
|
||||
*/
|
||||
} catch (ex) {
|
||||
throw new Error(`Key "${ruleId}": ${ex.message}`, { cause: ex });
|
||||
}
|
||||
|
||||
result[ruleId] = normalizeRuleOptions(result[ruleId]);
|
||||
|
||||
/*
|
||||
* If either rule config is missing, then the correct
|
||||
* config is already present and we just need to normalize
|
||||
* the severity.
|
||||
*/
|
||||
if (!(ruleId in first) || !(ruleId in second)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const firstRuleOptions = normalizeRuleOptions(first[ruleId]);
|
||||
const secondRuleOptions = normalizeRuleOptions(second[ruleId]);
|
||||
|
||||
/*
|
||||
* If the second rule config only has a severity (length of 1),
|
||||
* then use that severity and keep the rest of the options from
|
||||
* the first rule config.
|
||||
*/
|
||||
if (secondRuleOptions.length === 1) {
|
||||
result[ruleId] = [secondRuleOptions[0], ...firstRuleOptions.slice(1)];
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* In any other situation, then the second rule config takes
|
||||
* precedence. That means the value at `result[ruleId]` is
|
||||
* already correct and no further work is necessary.
|
||||
*/
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
|
||||
},
|
||||
|
||||
validate(value) {
|
||||
|
|
|
|||
138
node_modules/eslint/lib/linter/apply-disable-directives.js
generated
vendored
138
node_modules/eslint/lib/linter/apply-disable-directives.js
generated
vendored
|
|
@ -30,7 +30,7 @@ function compareLocations(itemA, itemB) {
|
|||
|
||||
/**
|
||||
* Groups a set of directives into sub-arrays by their parent comment.
|
||||
* @param {Directive[]} directives Unused directives to be removed.
|
||||
* @param {Iterable<Directive>} directives Unused directives to be removed.
|
||||
* @returns {Directive[][]} Directives grouped by their parent comment.
|
||||
*/
|
||||
function groupByParentComment(directives) {
|
||||
|
|
@ -177,10 +177,10 @@ function createCommentRemoval(directives, commentToken) {
|
|||
|
||||
/**
|
||||
* Parses details from directives to create output Problems.
|
||||
* @param {Directive[]} allDirectives Unused directives to be removed.
|
||||
* @param {Iterable<Directive>} allDirectives Unused directives to be removed.
|
||||
* @returns {{ description, fix, unprocessedDirective }[]} Details for later creation of output Problems.
|
||||
*/
|
||||
function processUnusedDisableDirectives(allDirectives) {
|
||||
function processUnusedDirectives(allDirectives) {
|
||||
const directiveGroups = groupByParentComment(allDirectives);
|
||||
|
||||
return directiveGroups.flatMap(
|
||||
|
|
@ -199,6 +199,95 @@ function processUnusedDisableDirectives(allDirectives) {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect eslint-enable comments that are removing suppressions by eslint-disable comments.
|
||||
* @param {Directive[]} directives The directives to check.
|
||||
* @returns {Set<Directive>} The used eslint-enable comments
|
||||
*/
|
||||
function collectUsedEnableDirectives(directives) {
|
||||
|
||||
/**
|
||||
* A Map of `eslint-enable` keyed by ruleIds that may be marked as used.
|
||||
* If `eslint-enable` does not have a ruleId, the key will be `null`.
|
||||
* @type {Map<string|null, Directive>}
|
||||
*/
|
||||
const enabledRules = new Map();
|
||||
|
||||
/**
|
||||
* A Set of `eslint-enable` marked as used.
|
||||
* It is also the return value of `collectUsedEnableDirectives` function.
|
||||
* @type {Set<Directive>}
|
||||
*/
|
||||
const usedEnableDirectives = new Set();
|
||||
|
||||
/*
|
||||
* Checks the directives backwards to see if the encountered `eslint-enable` is used by the previous `eslint-disable`,
|
||||
* and if so, stores the `eslint-enable` in `usedEnableDirectives`.
|
||||
*/
|
||||
for (let index = directives.length - 1; index >= 0; index--) {
|
||||
const directive = directives[index];
|
||||
|
||||
if (directive.type === "disable") {
|
||||
if (enabledRules.size === 0) {
|
||||
continue;
|
||||
}
|
||||
if (directive.ruleId === null) {
|
||||
|
||||
// If encounter `eslint-disable` without ruleId,
|
||||
// mark all `eslint-enable` currently held in enabledRules as used.
|
||||
// e.g.
|
||||
// /* eslint-disable */ <- current directive
|
||||
// /* eslint-enable rule-id1 */ <- used
|
||||
// /* eslint-enable rule-id2 */ <- used
|
||||
// /* eslint-enable */ <- used
|
||||
for (const enableDirective of enabledRules.values()) {
|
||||
usedEnableDirectives.add(enableDirective);
|
||||
}
|
||||
enabledRules.clear();
|
||||
} else {
|
||||
const enableDirective = enabledRules.get(directive.ruleId);
|
||||
|
||||
if (enableDirective) {
|
||||
|
||||
// If encounter `eslint-disable` with ruleId, and there is an `eslint-enable` with the same ruleId in enabledRules,
|
||||
// mark `eslint-enable` with ruleId as used.
|
||||
// e.g.
|
||||
// /* eslint-disable rule-id */ <- current directive
|
||||
// /* eslint-enable rule-id */ <- used
|
||||
usedEnableDirectives.add(enableDirective);
|
||||
} else {
|
||||
const enabledDirectiveWithoutRuleId = enabledRules.get(null);
|
||||
|
||||
if (enabledDirectiveWithoutRuleId) {
|
||||
|
||||
// If encounter `eslint-disable` with ruleId, and there is no `eslint-enable` with the same ruleId in enabledRules,
|
||||
// mark `eslint-enable` without ruleId as used.
|
||||
// e.g.
|
||||
// /* eslint-disable rule-id */ <- current directive
|
||||
// /* eslint-enable */ <- used
|
||||
usedEnableDirectives.add(enabledDirectiveWithoutRuleId);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (directive.type === "enable") {
|
||||
if (directive.ruleId === null) {
|
||||
|
||||
// If encounter `eslint-enable` without ruleId, the `eslint-enable` that follows it are unused.
|
||||
// So clear enabledRules.
|
||||
// e.g.
|
||||
// /* eslint-enable */ <- current directive
|
||||
// /* eslint-enable rule-id *// <- unused
|
||||
// /* eslint-enable */ <- unused
|
||||
enabledRules.clear();
|
||||
enabledRules.set(null, directive);
|
||||
} else {
|
||||
enabledRules.set(directive.ruleId, directive);
|
||||
}
|
||||
}
|
||||
}
|
||||
return usedEnableDirectives;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the same as the exported function, except that it
|
||||
* doesn't handle disable-line and disable-next-line directives, and it always reports unused
|
||||
|
|
@ -206,7 +295,7 @@ function processUnusedDisableDirectives(allDirectives) {
|
|||
* @param {Object} options options for applying directives. This is the same as the options
|
||||
* for the exported function, except that `reportUnusedDisableDirectives` is not supported
|
||||
* (this function always reports unused disable directives).
|
||||
* @returns {{problems: LintMessage[], unusedDisableDirectives: LintMessage[]}} An object with a list
|
||||
* @returns {{problems: LintMessage[], unusedDirectives: LintMessage[]}} An object with a list
|
||||
* of problems (including suppressed ones) and unused eslint-disable directives
|
||||
*/
|
||||
function applyDirectives(options) {
|
||||
|
|
@ -258,17 +347,42 @@ function applyDirectives(options) {
|
|||
const unusedDisableDirectivesToReport = options.directives
|
||||
.filter(directive => directive.type === "disable" && !usedDisableDirectives.has(directive));
|
||||
|
||||
const processed = processUnusedDisableDirectives(unusedDisableDirectivesToReport);
|
||||
|
||||
const unusedDisableDirectives = processed
|
||||
const unusedEnableDirectivesToReport = new Set(
|
||||
options.directives.filter(directive => directive.unprocessedDirective.type === "enable")
|
||||
);
|
||||
|
||||
/*
|
||||
* If directives has the eslint-enable directive,
|
||||
* check whether the eslint-enable comment is used.
|
||||
*/
|
||||
if (unusedEnableDirectivesToReport.size > 0) {
|
||||
for (const directive of collectUsedEnableDirectives(options.directives)) {
|
||||
unusedEnableDirectivesToReport.delete(directive);
|
||||
}
|
||||
}
|
||||
|
||||
const processed = processUnusedDirectives(unusedDisableDirectivesToReport)
|
||||
.concat(processUnusedDirectives(unusedEnableDirectivesToReport));
|
||||
|
||||
const unusedDirectives = processed
|
||||
.map(({ description, fix, unprocessedDirective }) => {
|
||||
const { parentComment, type, line, column } = unprocessedDirective;
|
||||
|
||||
let message;
|
||||
|
||||
if (type === "enable") {
|
||||
message = description
|
||||
? `Unused eslint-enable directive (no matching eslint-disable directives were found for ${description}).`
|
||||
: "Unused eslint-enable directive (no matching eslint-disable directives were found).";
|
||||
} else {
|
||||
message = description
|
||||
? `Unused eslint-disable directive (no problems were reported from ${description}).`
|
||||
: "Unused eslint-disable directive (no problems were reported).";
|
||||
}
|
||||
return {
|
||||
ruleId: null,
|
||||
message: description
|
||||
? `Unused eslint-disable directive (no problems were reported from ${description}).`
|
||||
: "Unused eslint-disable directive (no problems were reported).",
|
||||
message,
|
||||
line: type === "disable-next-line" ? parentComment.commentToken.loc.start.line : line,
|
||||
column: type === "disable-next-line" ? parentComment.commentToken.loc.start.column + 1 : column,
|
||||
severity: options.reportUnusedDisableDirectives === "warn" ? 1 : 2,
|
||||
|
|
@ -277,7 +391,7 @@ function applyDirectives(options) {
|
|||
};
|
||||
});
|
||||
|
||||
return { problems, unusedDisableDirectives };
|
||||
return { problems, unusedDirectives };
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -344,8 +458,8 @@ module.exports = ({ directives, disableFixes, problems, reportUnusedDisableDirec
|
|||
|
||||
return reportUnusedDisableDirectives !== "off"
|
||||
? lineDirectivesResult.problems
|
||||
.concat(blockDirectivesResult.unusedDisableDirectives)
|
||||
.concat(lineDirectivesResult.unusedDisableDirectives)
|
||||
.concat(blockDirectivesResult.unusedDirectives)
|
||||
.concat(lineDirectivesResult.unusedDirectives)
|
||||
.sort(compareLocations)
|
||||
: lineDirectivesResult.problems;
|
||||
};
|
||||
|
|
|
|||
4
node_modules/eslint/lib/options.js
generated
vendored
4
node_modules/eslint/lib/options.js
generated
vendored
|
|
@ -47,7 +47,7 @@ const optionator = require("optionator");
|
|||
* @property {Object} [parserOptions] Specify parser options
|
||||
* @property {string[]} [plugin] Specify plugins
|
||||
* @property {string} [printConfig] Print the configuration for the given file
|
||||
* @property {boolean | undefined} reportUnusedDisableDirectives Adds reported errors for unused eslint-disable directives
|
||||
* @property {boolean | undefined} reportUnusedDisableDirectives Adds reported errors for unused eslint-disable and eslint-enable directives
|
||||
* @property {string} [resolvePluginsRelativeTo] A folder where plugins should be resolved from, CWD by default
|
||||
* @property {Object} [rule] Specify rules
|
||||
* @property {string[]} [rulesdir] Load additional rules from this directory. Deprecated: Use rules from plugins
|
||||
|
|
@ -304,7 +304,7 @@ module.exports = function(usingFlatConfig) {
|
|||
option: "report-unused-disable-directives",
|
||||
type: "Boolean",
|
||||
default: void 0,
|
||||
description: "Adds reported errors for unused eslint-disable directives"
|
||||
description: "Adds reported errors for unused eslint-disable and eslint-enable directives"
|
||||
},
|
||||
{
|
||||
heading: "Caching"
|
||||
|
|
|
|||
108
node_modules/eslint/lib/rules/no-object-constructor.js
generated
vendored
108
node_modules/eslint/lib/rules/no-object-constructor.js
generated
vendored
|
|
@ -9,12 +9,51 @@
|
|||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const { getVariableByName, isArrowToken } = require("./utils/ast-utils");
|
||||
const { getVariableByName, isArrowToken, isClosingBraceToken, isClosingParenToken } = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const BREAK_OR_CONTINUE = new Set(["BreakStatement", "ContinueStatement"]);
|
||||
|
||||
// Declaration types that must contain a string Literal node at the end.
|
||||
const DECLARATIONS = new Set(["ExportAllDeclaration", "ExportNamedDeclaration", "ImportDeclaration"]);
|
||||
|
||||
const IDENTIFIER_OR_KEYWORD = new Set(["Identifier", "Keyword"]);
|
||||
|
||||
// Keywords that can immediately precede an ExpressionStatement node, mapped to the their node types.
|
||||
const NODE_TYPES_BY_KEYWORD = {
|
||||
__proto__: null,
|
||||
break: "BreakStatement",
|
||||
continue: "ContinueStatement",
|
||||
debugger: "DebuggerStatement",
|
||||
do: "DoWhileStatement",
|
||||
else: "IfStatement",
|
||||
return: "ReturnStatement",
|
||||
yield: "YieldExpression"
|
||||
};
|
||||
|
||||
/*
|
||||
* Before an opening parenthesis, `>` (for JSX), and postfix `++` and `--` always trigger ASI;
|
||||
* the tokens `:`, `;`, `{` and `=>` don't expect a semicolon, as that would count as an empty statement.
|
||||
*/
|
||||
const PUNCTUATORS = new Set([":", ";", ">", "{", "=>", "++", "--"]);
|
||||
|
||||
/*
|
||||
* Statements that can contain an `ExpressionStatement` after a closing parenthesis.
|
||||
* DoWhileStatement is an exception in that it always triggers ASI after the closing parenthesis.
|
||||
*/
|
||||
const STATEMENTS = new Set([
|
||||
"DoWhileStatement",
|
||||
"ForInStatement",
|
||||
"ForOfStatement",
|
||||
"ForStatement",
|
||||
"IfStatement",
|
||||
"WhileStatement",
|
||||
"WithStatement"
|
||||
]);
|
||||
|
||||
/**
|
||||
* Tests if a node appears at the beginning of an ancestor ExpressionStatement node.
|
||||
* @param {ASTNode} node The node to check.
|
||||
|
|
@ -53,7 +92,8 @@ module.exports = {
|
|||
|
||||
messages: {
|
||||
preferLiteral: "The object literal notation {} is preferable.",
|
||||
useLiteral: "Replace with '{{replacement}}'."
|
||||
useLiteral: "Replace with '{{replacement}}'.",
|
||||
useLiteralAfterSemicolon: "Replace with '{{replacement}}', add preceding semicolon."
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -80,6 +120,50 @@ module.exports = {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a parenthesized object literal that replaces a specified node needs to be preceded by a semicolon.
|
||||
* @param {ASTNode} node The node to be replaced. This node should be at the start of an `ExpressionStatement` or at the start of the body of an `ArrowFunctionExpression`.
|
||||
* @returns {boolean} Whether a semicolon is required before the parenthesized object literal.
|
||||
*/
|
||||
function needsSemicolon(node) {
|
||||
const prevToken = sourceCode.getTokenBefore(node);
|
||||
|
||||
if (!prevToken || prevToken.type === "Punctuator" && PUNCTUATORS.has(prevToken.value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const prevNode = sourceCode.getNodeByRangeIndex(prevToken.range[0]);
|
||||
|
||||
if (isClosingParenToken(prevToken)) {
|
||||
return !STATEMENTS.has(prevNode.type);
|
||||
}
|
||||
|
||||
if (isClosingBraceToken(prevToken)) {
|
||||
return (
|
||||
prevNode.type === "BlockStatement" && prevNode.parent.type === "FunctionExpression" ||
|
||||
prevNode.type === "ClassBody" && prevNode.parent.type === "ClassExpression" ||
|
||||
prevNode.type === "ObjectExpression"
|
||||
);
|
||||
}
|
||||
|
||||
if (IDENTIFIER_OR_KEYWORD.has(prevToken.type)) {
|
||||
if (BREAK_OR_CONTINUE.has(prevNode.parent.type)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const keyword = prevToken.value;
|
||||
const nodeType = NODE_TYPES_BY_KEYWORD[keyword];
|
||||
|
||||
return prevNode.type !== nodeType;
|
||||
}
|
||||
|
||||
if (prevToken.type === "String") {
|
||||
return !DECLARATIONS.has(prevNode.parent.type);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports on nodes where the `Object` constructor is called without arguments.
|
||||
* @param {ASTNode} node The node to evaluate.
|
||||
|
|
@ -93,16 +177,30 @@ module.exports = {
|
|||
const variable = getVariableByName(sourceCode.getScope(node), "Object");
|
||||
|
||||
if (variable && variable.identifiers.length === 0) {
|
||||
const replacement = needsParentheses(node) ? "({})" : "{}";
|
||||
let replacement;
|
||||
let fixText;
|
||||
let messageId = "useLiteral";
|
||||
|
||||
if (needsParentheses(node)) {
|
||||
replacement = "({})";
|
||||
if (needsSemicolon(node)) {
|
||||
fixText = ";({})";
|
||||
messageId = "useLiteralAfterSemicolon";
|
||||
} else {
|
||||
fixText = "({})";
|
||||
}
|
||||
} else {
|
||||
replacement = fixText = "{}";
|
||||
}
|
||||
|
||||
context.report({
|
||||
node,
|
||||
messageId: "preferLiteral",
|
||||
suggest: [
|
||||
{
|
||||
messageId: "useLiteral",
|
||||
messageId,
|
||||
data: { replacement },
|
||||
fix: fixer => fixer.replaceText(node, replacement)
|
||||
fix: fixer => fixer.replaceText(node, fixText)
|
||||
}
|
||||
]
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue