Bump packages to fix linter
This commit is contained in:
parent
ed9506bbaf
commit
0a11e3fdd9
6063 changed files with 378752 additions and 306784 deletions
156
node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js
generated
vendored
156
node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js
generated
vendored
|
|
@ -29,6 +29,18 @@ function isCaseNode(node) {
|
|||
return Boolean(node.test);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a given node appears as the value of a PropertyDefinition node.
|
||||
* @param {ASTNode} node THe node to check.
|
||||
* @returns {boolean} `true` if the node is a PropertyDefinition value,
|
||||
* false if not.
|
||||
*/
|
||||
function isPropertyDefinitionValue(node) {
|
||||
const parent = node.parent;
|
||||
|
||||
return parent && parent.type === "PropertyDefinition" && parent.value === node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given logical operator is taken into account for the code
|
||||
* path analysis.
|
||||
|
|
@ -138,6 +150,7 @@ function isIdentifierReference(node) {
|
|||
return parent.id !== node;
|
||||
|
||||
case "Property":
|
||||
case "PropertyDefinition":
|
||||
case "MethodDefinition":
|
||||
return (
|
||||
parent.key !== node ||
|
||||
|
|
@ -388,29 +401,68 @@ function processCodePathToEnter(analyzer, node) {
|
|||
let state = codePath && CodePath.getState(codePath);
|
||||
const parent = node.parent;
|
||||
|
||||
/**
|
||||
* Creates a new code path and trigger the onCodePathStart event
|
||||
* based on the currently selected node.
|
||||
* @param {string} origin The reason the code path was started.
|
||||
* @returns {void}
|
||||
*/
|
||||
function startCodePath(origin) {
|
||||
if (codePath) {
|
||||
|
||||
// Emits onCodePathSegmentStart events if updated.
|
||||
forwardCurrentToHead(analyzer, node);
|
||||
debug.dumpState(node, state, false);
|
||||
}
|
||||
|
||||
// Create the code path of this scope.
|
||||
codePath = analyzer.codePath = new CodePath({
|
||||
id: analyzer.idGenerator.next(),
|
||||
origin,
|
||||
upper: codePath,
|
||||
onLooped: analyzer.onLooped
|
||||
});
|
||||
state = CodePath.getState(codePath);
|
||||
|
||||
// Emits onCodePathStart events.
|
||||
debug.dump(`onCodePathStart ${codePath.id}`);
|
||||
analyzer.emitter.emit("onCodePathStart", codePath, node);
|
||||
}
|
||||
|
||||
/*
|
||||
* Special case: The right side of class field initializer is considered
|
||||
* to be its own function, so we need to start a new code path in this
|
||||
* case.
|
||||
*/
|
||||
if (isPropertyDefinitionValue(node)) {
|
||||
startCodePath("class-field-initializer");
|
||||
|
||||
/*
|
||||
* Intentional fall through because `node` needs to also be
|
||||
* processed by the code below. For example, if we have:
|
||||
*
|
||||
* class Foo {
|
||||
* a = () => {}
|
||||
* }
|
||||
*
|
||||
* In this case, we also need start a second code path.
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
switch (node.type) {
|
||||
case "Program":
|
||||
startCodePath("program");
|
||||
break;
|
||||
|
||||
case "FunctionDeclaration":
|
||||
case "FunctionExpression":
|
||||
case "ArrowFunctionExpression":
|
||||
if (codePath) {
|
||||
startCodePath("function");
|
||||
break;
|
||||
|
||||
// Emits onCodePathSegmentStart events if updated.
|
||||
forwardCurrentToHead(analyzer, node);
|
||||
debug.dumpState(node, state, false);
|
||||
}
|
||||
|
||||
// Create the code path of this scope.
|
||||
codePath = analyzer.codePath = new CodePath(
|
||||
analyzer.idGenerator.next(),
|
||||
codePath,
|
||||
analyzer.onLooped
|
||||
);
|
||||
state = CodePath.getState(codePath);
|
||||
|
||||
// Emits onCodePathStart events.
|
||||
debug.dump(`onCodePathStart ${codePath.id}`);
|
||||
analyzer.emitter.emit("onCodePathStart", codePath, node);
|
||||
case "StaticBlock":
|
||||
startCodePath("class-static-block");
|
||||
break;
|
||||
|
||||
case "ChainExpression":
|
||||
|
|
@ -503,6 +555,7 @@ function processCodePathToEnter(analyzer, node) {
|
|||
* @returns {void}
|
||||
*/
|
||||
function processCodePathToExit(analyzer, node) {
|
||||
|
||||
const codePath = analyzer.codePath;
|
||||
const state = CodePath.getState(codePath);
|
||||
let dontForward = false;
|
||||
|
|
@ -627,28 +680,39 @@ function processCodePathToExit(analyzer, node) {
|
|||
* @returns {void}
|
||||
*/
|
||||
function postprocess(analyzer, node) {
|
||||
|
||||
/**
|
||||
* Ends the code path for the current node.
|
||||
* @returns {void}
|
||||
*/
|
||||
function endCodePath() {
|
||||
let codePath = analyzer.codePath;
|
||||
|
||||
// Mark the current path as the final node.
|
||||
CodePath.getState(codePath).makeFinal();
|
||||
|
||||
// Emits onCodePathSegmentEnd event of the current segments.
|
||||
leaveFromCurrentSegment(analyzer, node);
|
||||
|
||||
// Emits onCodePathEnd event of this code path.
|
||||
debug.dump(`onCodePathEnd ${codePath.id}`);
|
||||
analyzer.emitter.emit("onCodePathEnd", codePath, node);
|
||||
debug.dumpDot(codePath);
|
||||
|
||||
codePath = analyzer.codePath = analyzer.codePath.upper;
|
||||
if (codePath) {
|
||||
debug.dumpState(node, CodePath.getState(codePath), true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
switch (node.type) {
|
||||
case "Program":
|
||||
case "FunctionDeclaration":
|
||||
case "FunctionExpression":
|
||||
case "ArrowFunctionExpression": {
|
||||
let codePath = analyzer.codePath;
|
||||
|
||||
// Mark the current path as the final node.
|
||||
CodePath.getState(codePath).makeFinal();
|
||||
|
||||
// Emits onCodePathSegmentEnd event of the current segments.
|
||||
leaveFromCurrentSegment(analyzer, node);
|
||||
|
||||
// Emits onCodePathEnd event of this code path.
|
||||
debug.dump(`onCodePathEnd ${codePath.id}`);
|
||||
analyzer.emitter.emit("onCodePathEnd", codePath, node);
|
||||
debug.dumpDot(codePath);
|
||||
|
||||
codePath = analyzer.codePath = analyzer.codePath.upper;
|
||||
if (codePath) {
|
||||
debug.dumpState(node, CodePath.getState(codePath), true);
|
||||
}
|
||||
case "ArrowFunctionExpression":
|
||||
case "StaticBlock": {
|
||||
endCodePath();
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -662,6 +726,27 @@ function postprocess(analyzer, node) {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Special case: The right side of class field initializer is considered
|
||||
* to be its own function, so we need to end a code path in this
|
||||
* case.
|
||||
*
|
||||
* We need to check after the other checks in order to close the
|
||||
* code paths in the correct order for code like this:
|
||||
*
|
||||
*
|
||||
* class Foo {
|
||||
* a = () => {}
|
||||
* }
|
||||
*
|
||||
* In this case, The ArrowFunctionExpression code path is closed first
|
||||
* and then we need to close the code path for the PropertyDefinition
|
||||
* value.
|
||||
*/
|
||||
if (isPropertyDefinitionValue(node)) {
|
||||
endCodePath();
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
@ -674,7 +759,6 @@ function postprocess(analyzer, node) {
|
|||
*/
|
||||
class CodePathAnalyzer {
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
/**
|
||||
* @param {EventGenerator} eventGenerator An event generator to wrap.
|
||||
*/
|
||||
|
|
|
|||
7
node_modules/eslint/lib/linter/code-path-analysis/code-path-segment.js
generated
vendored
7
node_modules/eslint/lib/linter/code-path-analysis/code-path-segment.js
generated
vendored
|
|
@ -33,7 +33,6 @@ function isReachable(segment) {
|
|||
*/
|
||||
class CodePathSegment {
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
/**
|
||||
* @param {string} id An identifier.
|
||||
* @param {CodePathSegment[]} allPrevSegments An array of the previous segments.
|
||||
|
|
@ -89,10 +88,10 @@ class CodePathSegment {
|
|||
}
|
||||
});
|
||||
|
||||
/* istanbul ignore if */
|
||||
/* c8 ignore start */
|
||||
if (debug.enabled) {
|
||||
this.internal.nodes = [];
|
||||
}
|
||||
}/* c8 ignore stop */
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -101,7 +100,7 @@ class CodePathSegment {
|
|||
* @returns {boolean} `true` if the segment is coming from the end of a loop.
|
||||
*/
|
||||
isLoopedPrevSegment(segment) {
|
||||
return this.internal.loopedPrevSegments.indexOf(segment) !== -1;
|
||||
return this.internal.loopedPrevSegments.includes(segment);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
21
node_modules/eslint/lib/linter/code-path-analysis/code-path-state.js
generated
vendored
21
node_modules/eslint/lib/linter/code-path-analysis/code-path-state.js
generated
vendored
|
|
@ -33,7 +33,7 @@ function addToReturnedOrThrown(dest, others, all, segments) {
|
|||
const segment = segments[i];
|
||||
|
||||
dest.push(segment);
|
||||
if (others.indexOf(segment) === -1) {
|
||||
if (!others.includes(segment)) {
|
||||
all.push(segment);
|
||||
}
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ function getContinueContext(state, label) {
|
|||
context = context.upper;
|
||||
}
|
||||
|
||||
/* istanbul ignore next: foolproof (syntax error) */
|
||||
/* c8 ignore next */
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ function getBreakContext(state, label) {
|
|||
context = context.upper;
|
||||
}
|
||||
|
||||
/* istanbul ignore next: foolproof (syntax error) */
|
||||
/* c8 ignore next */
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -219,7 +219,6 @@ function finalizeTestSegmentsOfFor(context, choiceContext, head) {
|
|||
*/
|
||||
class CodePathState {
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
/**
|
||||
* @param {IdGenerator} idGenerator An id generator to generate id for code
|
||||
* path segments.
|
||||
|
|
@ -360,6 +359,7 @@ class CodePathState {
|
|||
|
||||
/**
|
||||
* Pops the last choice context and finalizes it.
|
||||
* @throws {Error} (Unreachable.)
|
||||
* @returns {ChoiceContext} The popped context.
|
||||
*/
|
||||
popChoiceContext() {
|
||||
|
|
@ -433,7 +433,7 @@ class CodePathState {
|
|||
*/
|
||||
return context;
|
||||
|
||||
/* istanbul ignore next */
|
||||
/* c8 ignore next */
|
||||
default:
|
||||
throw new Error("unreachable");
|
||||
}
|
||||
|
|
@ -450,6 +450,7 @@ class CodePathState {
|
|||
/**
|
||||
* Makes a code path segment of the right-hand operand of a logical
|
||||
* expression.
|
||||
* @throws {Error} (Unreachable.)
|
||||
* @returns {void}
|
||||
*/
|
||||
makeLogicalRight() {
|
||||
|
|
@ -965,6 +966,7 @@ class CodePathState {
|
|||
* `WhileStatement`, `DoWhileStatement`, `ForStatement`, `ForInStatement`,
|
||||
* and `ForStatement`.
|
||||
* @param {string|null} label A label of the node which was triggered.
|
||||
* @throws {Error} (Unreachable - unknown type.)
|
||||
* @returns {void}
|
||||
*/
|
||||
pushLoopContext(type, label) {
|
||||
|
|
@ -1028,7 +1030,7 @@ class CodePathState {
|
|||
};
|
||||
break;
|
||||
|
||||
/* istanbul ignore next */
|
||||
/* c8 ignore next */
|
||||
default:
|
||||
throw new Error(`unknown type: "${type}"`);
|
||||
}
|
||||
|
|
@ -1036,6 +1038,7 @@ class CodePathState {
|
|||
|
||||
/**
|
||||
* Pops the last context of a loop statement and finalizes it.
|
||||
* @throws {Error} (Unreachable - unknown type.)
|
||||
* @returns {void}
|
||||
*/
|
||||
popLoopContext() {
|
||||
|
|
@ -1092,7 +1095,7 @@ class CodePathState {
|
|||
);
|
||||
break;
|
||||
|
||||
/* istanbul ignore next */
|
||||
/* c8 ignore next */
|
||||
default:
|
||||
throw new Error("unreachable");
|
||||
}
|
||||
|
|
@ -1389,11 +1392,12 @@ class CodePathState {
|
|||
|
||||
const context = getBreakContext(this, label);
|
||||
|
||||
/* istanbul ignore else: foolproof (syntax error) */
|
||||
|
||||
if (context) {
|
||||
context.brokenForkContext.add(forkContext.head);
|
||||
}
|
||||
|
||||
/* c8 ignore next */
|
||||
forkContext.replaceHead(forkContext.makeUnreachable(-1, -1));
|
||||
}
|
||||
|
||||
|
|
@ -1414,7 +1418,6 @@ class CodePathState {
|
|||
|
||||
const context = getContinueContext(this, label);
|
||||
|
||||
/* istanbul ignore else: foolproof (syntax error) */
|
||||
if (context) {
|
||||
if (context.continueDestSegments) {
|
||||
makeLooped(this, forkContext.head, context.continueDestSegments);
|
||||
|
|
|
|||
21
node_modules/eslint/lib/linter/code-path-analysis/code-path.js
generated
vendored
21
node_modules/eslint/lib/linter/code-path-analysis/code-path.js
generated
vendored
|
|
@ -21,13 +21,15 @@ const IdGenerator = require("./id-generator");
|
|||
*/
|
||||
class CodePath {
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
/**
|
||||
* @param {string} id An identifier.
|
||||
* @param {CodePath|null} upper The code path of the upper function scope.
|
||||
* @param {Function} onLooped A callback function to notify looping.
|
||||
* Creates a new instance.
|
||||
* @param {Object} options Options for the function (see below).
|
||||
* @param {string} options.id An identifier.
|
||||
* @param {string} options.origin The type of code path origin.
|
||||
* @param {CodePath|null} options.upper The code path of the upper function scope.
|
||||
* @param {Function} options.onLooped A callback function to notify looping.
|
||||
*/
|
||||
constructor(id, upper, onLooped) {
|
||||
constructor({ id, origin, upper, onLooped }) {
|
||||
|
||||
/**
|
||||
* The identifier of this code path.
|
||||
|
|
@ -36,6 +38,13 @@ class CodePath {
|
|||
*/
|
||||
this.id = id;
|
||||
|
||||
/**
|
||||
* The reason that this code path was started. May be "program",
|
||||
* "function", "class-field-initializer", or "class-static-block".
|
||||
* @type {string}
|
||||
*/
|
||||
this.origin = origin;
|
||||
|
||||
/**
|
||||
* The code path of the upper function scope.
|
||||
* @type {CodePath|null}
|
||||
|
|
@ -203,7 +212,7 @@ class CodePath {
|
|||
}
|
||||
|
||||
// Reset the flag of skipping if all branches have been skipped.
|
||||
if (skippedSegment && segment.prevSegments.indexOf(skippedSegment) !== -1) {
|
||||
if (skippedSegment && segment.prevSegments.includes(skippedSegment)) {
|
||||
skippedSegment = null;
|
||||
}
|
||||
visited[segment.id] = true;
|
||||
|
|
|
|||
10
node_modules/eslint/lib/linter/code-path-analysis/debug-helpers.js
generated
vendored
10
node_modules/eslint/lib/linter/code-path-analysis/debug-helpers.js
generated
vendored
|
|
@ -20,8 +20,8 @@ const debug = require("debug")("eslint:code-path");
|
|||
* @param {CodePathSegment} segment A segment to get.
|
||||
* @returns {string} Id of the segment.
|
||||
*/
|
||||
/* istanbul ignore next */
|
||||
function getId(segment) { // eslint-disable-line jsdoc/require-jsdoc
|
||||
/* c8 ignore next */
|
||||
function getId(segment) { // eslint-disable-line jsdoc/require-jsdoc -- Ignoring
|
||||
return segment.id + (segment.reachable ? "" : "!");
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ module.exports = {
|
|||
* @param {boolean} leaving A flag whether or not it's leaving
|
||||
* @returns {void}
|
||||
*/
|
||||
dumpState: !debug.enabled ? debug : /* istanbul ignore next */ function(node, state, leaving) {
|
||||
dumpState: !debug.enabled ? debug : /* c8 ignore next */ function(node, state, leaving) {
|
||||
for (let i = 0; i < state.currentSegments.length; ++i) {
|
||||
const segInternal = state.currentSegments[i].internal;
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ module.exports = {
|
|||
* @see http://www.graphviz.org
|
||||
* @see http://www.webgraphviz.com
|
||||
*/
|
||||
dumpDot: !debug.enabled ? debug : /* istanbul ignore next */ function(codePath) {
|
||||
dumpDot: !debug.enabled ? debug : /* c8 ignore next */ function(codePath) {
|
||||
let text =
|
||||
"\n" +
|
||||
"digraph {\n" +
|
||||
|
|
@ -115,7 +115,7 @@ module.exports = {
|
|||
const traceMap = Object.create(null);
|
||||
const arrows = this.makeDotArrows(codePath, traceMap);
|
||||
|
||||
for (const id in traceMap) { // eslint-disable-line guard-for-in
|
||||
for (const id in traceMap) { // eslint-disable-line guard-for-in -- Want ability to traverse prototype
|
||||
const segment = traceMap[id];
|
||||
|
||||
text += `${id}[`;
|
||||
|
|
|
|||
1
node_modules/eslint/lib/linter/code-path-analysis/fork-context.js
generated
vendored
1
node_modules/eslint/lib/linter/code-path-analysis/fork-context.js
generated
vendored
|
|
@ -97,7 +97,6 @@ function mergeExtraSegments(context, segments) {
|
|||
*/
|
||||
class ForkContext {
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
/**
|
||||
* @param {IdGenerator} idGenerator An identifier generator for segments.
|
||||
* @param {ForkContext|null} upper An upper fork context.
|
||||
|
|
|
|||
5
node_modules/eslint/lib/linter/code-path-analysis/id-generator.js
generated
vendored
5
node_modules/eslint/lib/linter/code-path-analysis/id-generator.js
generated
vendored
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
class IdGenerator {
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
/**
|
||||
* @param {string} prefix Optional. A prefix of generated ids.
|
||||
*/
|
||||
|
|
@ -34,10 +33,10 @@ class IdGenerator {
|
|||
next() {
|
||||
this.n = 1 + this.n | 0;
|
||||
|
||||
/* istanbul ignore if */
|
||||
/* c8 ignore start */
|
||||
if (this.n < 0) {
|
||||
this.n = 1;
|
||||
}
|
||||
}/* c8 ignore stop */
|
||||
|
||||
return this.prefix + this.n;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue