Bump packages to fix linter
This commit is contained in:
parent
ed9506bbaf
commit
0a11e3fdd9
6063 changed files with 378752 additions and 306784 deletions
180
node_modules/eslint/lib/rules/indent.js
generated
vendored
180
node_modules/eslint/lib/rules/indent.js
generated
vendored
|
|
@ -12,7 +12,7 @@
|
|||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const createTree = require("functional-red-black-tree");
|
||||
const { OrderedMap } = require("js-sdsl");
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
|
||||
|
|
@ -60,12 +60,15 @@ const KNOWN_NODES = new Set([
|
|||
"NewExpression",
|
||||
"ObjectExpression",
|
||||
"ObjectPattern",
|
||||
"PrivateIdentifier",
|
||||
"Program",
|
||||
"Property",
|
||||
"PropertyDefinition",
|
||||
"RestElement",
|
||||
"ReturnStatement",
|
||||
"SequenceExpression",
|
||||
"SpreadElement",
|
||||
"StaticBlock",
|
||||
"Super",
|
||||
"SwitchCase",
|
||||
"SwitchStatement",
|
||||
|
|
@ -132,23 +135,18 @@ class BinarySearchTree {
|
|||
* Creates an empty tree
|
||||
*/
|
||||
constructor() {
|
||||
this._rbTree = createTree();
|
||||
this._orderedMap = new OrderedMap();
|
||||
this._orderedMapEnd = this._orderedMap.end();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts an entry into the tree.
|
||||
* @param {number} key The entry's key
|
||||
* @param {*} value The entry's value
|
||||
* @param {any} value The entry's value
|
||||
* @returns {void}
|
||||
*/
|
||||
insert(key, value) {
|
||||
const iterator = this._rbTree.find(key);
|
||||
|
||||
if (iterator.valid) {
|
||||
this._rbTree = iterator.update(value);
|
||||
} else {
|
||||
this._rbTree = this._rbTree.insert(key, value);
|
||||
}
|
||||
this._orderedMap.setElement(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -157,9 +155,13 @@ class BinarySearchTree {
|
|||
* @returns {{key: number, value: *}|null} The found entry, or null if no such entry exists.
|
||||
*/
|
||||
findLe(key) {
|
||||
const iterator = this._rbTree.le(key);
|
||||
const iterator = this._orderedMap.reverseLowerBound(key);
|
||||
|
||||
return iterator && { key: iterator.key, value: iterator.value };
|
||||
if (iterator.equals(this._orderedMapEnd)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return { key: iterator.pointer[0], value: iterator.pointer[1] };
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -174,11 +176,20 @@ class BinarySearchTree {
|
|||
if (start === end) {
|
||||
return;
|
||||
}
|
||||
const iterator = this._rbTree.ge(start);
|
||||
const iterator = this._orderedMap.lowerBound(start);
|
||||
|
||||
while (iterator.valid && iterator.key < end) {
|
||||
this._rbTree = this._rbTree.remove(iterator.key);
|
||||
iterator.next();
|
||||
if (iterator.equals(this._orderedMapEnd)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (end > this._orderedMap.back()[0]) {
|
||||
while (!iterator.equals(this._orderedMapEnd)) {
|
||||
this._orderedMap.eraseElementByIterator(iterator);
|
||||
}
|
||||
} else {
|
||||
while (iterator.pointer[0] < end) {
|
||||
this._orderedMap.eraseElementByIterator(iterator);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -188,7 +199,6 @@ class BinarySearchTree {
|
|||
*/
|
||||
class TokenInfo {
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
/**
|
||||
* @param {SourceCode} sourceCode A SourceCode object
|
||||
*/
|
||||
|
|
@ -238,7 +248,6 @@ class TokenInfo {
|
|||
*/
|
||||
class OffsetStorage {
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
/**
|
||||
* @param {TokenInfo} tokenInfo a TokenInfo instance
|
||||
* @param {number} indentSize The desired size of each indentation level
|
||||
|
|
@ -263,7 +272,7 @@ class OffsetStorage {
|
|||
|
||||
/**
|
||||
* Sets the offset column of token B to match the offset column of token A.
|
||||
* **WARNING**: This matches a *column*, even if baseToken is not the first token on its line. In
|
||||
* - **WARNING**: This matches a *column*, even if baseToken is not the first token on its line. In
|
||||
* most cases, `setDesiredOffset` should be used instead.
|
||||
* @param {Token} baseToken The first token
|
||||
* @param {Token} offsetToken The second token, whose offset should be matched to the first token
|
||||
|
|
@ -352,11 +361,11 @@ class OffsetStorage {
|
|||
* Instead, the offset tree is represented as a collection of contiguous offset ranges in a file. For example, the following
|
||||
* list could represent the state of the offset tree at a given point:
|
||||
*
|
||||
* * Tokens starting in the interval [0, 15) are aligned with the beginning of the file
|
||||
* * Tokens starting in the interval [15, 30) are offset by 1 indent level from the `bar` token
|
||||
* * Tokens starting in the interval [30, 43) are offset by 1 indent level from the `foo` token
|
||||
* * Tokens starting in the interval [43, 820) are offset by 2 indent levels from the `bar` token
|
||||
* * Tokens starting in the interval [820, ∞) are offset by 1 indent level from the `baz` token
|
||||
* - Tokens starting in the interval [0, 15) are aligned with the beginning of the file
|
||||
* - Tokens starting in the interval [15, 30) are offset by 1 indent level from the `bar` token
|
||||
* - Tokens starting in the interval [30, 43) are offset by 1 indent level from the `foo` token
|
||||
* - Tokens starting in the interval [43, 820) are offset by 2 indent levels from the `bar` token
|
||||
* - Tokens starting in the interval [820, ∞) are offset by 1 indent level from the `baz` token
|
||||
*
|
||||
* The `setDesiredOffsets` methods inserts ranges like the ones above. The third line above would be inserted by using:
|
||||
* `setDesiredOffsets([30, 43], fooToken, 1);`
|
||||
|
|
@ -493,13 +502,13 @@ const ELEMENT_LIST_SCHEMA = {
|
|||
]
|
||||
};
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "layout",
|
||||
|
||||
docs: {
|
||||
description: "enforce consistent indentation",
|
||||
category: "Stylistic Issues",
|
||||
description: "Enforce consistent indentation",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/indent"
|
||||
},
|
||||
|
|
@ -584,6 +593,16 @@ module.exports = {
|
|||
},
|
||||
additionalProperties: false
|
||||
},
|
||||
StaticBlock: {
|
||||
type: "object",
|
||||
properties: {
|
||||
body: {
|
||||
type: "integer",
|
||||
minimum: 0
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
},
|
||||
CallExpression: {
|
||||
type: "object",
|
||||
properties: {
|
||||
|
|
@ -647,6 +666,9 @@ module.exports = {
|
|||
parameters: DEFAULT_PARAMETER_INDENT,
|
||||
body: DEFAULT_FUNCTION_BODY_INDENT
|
||||
},
|
||||
StaticBlock: {
|
||||
body: DEFAULT_FUNCTION_BODY_INDENT
|
||||
},
|
||||
CallExpression: {
|
||||
arguments: DEFAULT_PARAMETER_INDENT
|
||||
},
|
||||
|
|
@ -782,7 +804,7 @@ module.exports = {
|
|||
let statement = node.parent && node.parent.parent;
|
||||
|
||||
while (
|
||||
statement.type === "UnaryExpression" && ["!", "~", "+", "-"].indexOf(statement.operator) > -1 ||
|
||||
statement.type === "UnaryExpression" && ["!", "~", "+", "-"].includes(statement.operator) ||
|
||||
statement.type === "AssignmentExpression" ||
|
||||
statement.type === "LogicalExpression" ||
|
||||
statement.type === "SequenceExpression" ||
|
||||
|
|
@ -902,18 +924,6 @@ module.exports = {
|
|||
}
|
||||
|
||||
offsets.setDesiredOffsets([firstBodyToken.range[0], lastBodyToken.range[1]], lastParentToken, 1);
|
||||
|
||||
/*
|
||||
* For blockless nodes with semicolon-first style, don't indent the semicolon.
|
||||
* e.g.
|
||||
* if (foo) bar()
|
||||
* ; [1, 2, 3].map(foo)
|
||||
*/
|
||||
const lastToken = sourceCode.getLastToken(node);
|
||||
|
||||
if (node.type !== "EmptyStatement" && astUtils.isSemicolonToken(lastToken)) {
|
||||
offsets.setDesiredOffset(lastToken, lastParentToken, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1209,7 +1219,7 @@ module.exports = {
|
|||
}
|
||||
},
|
||||
|
||||
"DoWhileStatement, WhileStatement, ForInStatement, ForOfStatement": node => addBlocklessNodeIndent(node.body),
|
||||
"DoWhileStatement, WhileStatement, ForInStatement, ForOfStatement, WithStatement": node => addBlocklessNodeIndent(node.body),
|
||||
|
||||
ExportNamedDeclaration(node) {
|
||||
if (node.declaration === null) {
|
||||
|
|
@ -1257,6 +1267,50 @@ module.exports = {
|
|||
}
|
||||
},
|
||||
|
||||
/*
|
||||
* For blockless nodes with semicolon-first style, don't indent the semicolon.
|
||||
* e.g.
|
||||
* if (foo)
|
||||
* bar()
|
||||
* ; [1, 2, 3].map(foo)
|
||||
*
|
||||
* Traversal into the node sets indentation of the semicolon, so we need to override it on exit.
|
||||
*/
|
||||
":matches(DoWhileStatement, ForStatement, ForInStatement, ForOfStatement, IfStatement, WhileStatement, WithStatement):exit"(node) {
|
||||
let nodesToCheck;
|
||||
|
||||
if (node.type === "IfStatement") {
|
||||
nodesToCheck = [node.consequent];
|
||||
if (node.alternate) {
|
||||
nodesToCheck.push(node.alternate);
|
||||
}
|
||||
} else {
|
||||
nodesToCheck = [node.body];
|
||||
}
|
||||
|
||||
for (const nodeToCheck of nodesToCheck) {
|
||||
const lastToken = sourceCode.getLastToken(nodeToCheck);
|
||||
|
||||
if (astUtils.isSemicolonToken(lastToken)) {
|
||||
const tokenBeforeLast = sourceCode.getTokenBefore(lastToken);
|
||||
const tokenAfterLast = sourceCode.getTokenAfter(lastToken);
|
||||
|
||||
// override indentation of `;` only if its line looks like a semicolon-first style line
|
||||
if (
|
||||
!astUtils.isTokenOnSameLine(tokenBeforeLast, lastToken) &&
|
||||
tokenAfterLast &&
|
||||
astUtils.isTokenOnSameLine(lastToken, tokenAfterLast)
|
||||
) {
|
||||
offsets.setDesiredOffset(
|
||||
lastToken,
|
||||
sourceCode.getFirstToken(node),
|
||||
0
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
ImportDeclaration(node) {
|
||||
if (node.specifiers.some(specifier => specifier.type === "ImportSpecifier")) {
|
||||
const openingCurly = sourceCode.getFirstToken(node, astUtils.isOpeningBraceToken);
|
||||
|
|
@ -1359,6 +1413,52 @@ module.exports = {
|
|||
}
|
||||
},
|
||||
|
||||
PropertyDefinition(node) {
|
||||
const firstToken = sourceCode.getFirstToken(node);
|
||||
const maybeSemicolonToken = sourceCode.getLastToken(node);
|
||||
let keyLastToken = null;
|
||||
|
||||
// Indent key.
|
||||
if (node.computed) {
|
||||
const bracketTokenL = sourceCode.getTokenBefore(node.key, astUtils.isOpeningBracketToken);
|
||||
const bracketTokenR = keyLastToken = sourceCode.getTokenAfter(node.key, astUtils.isClosingBracketToken);
|
||||
const keyRange = [bracketTokenL.range[1], bracketTokenR.range[0]];
|
||||
|
||||
if (bracketTokenL !== firstToken) {
|
||||
offsets.setDesiredOffset(bracketTokenL, firstToken, 0);
|
||||
}
|
||||
offsets.setDesiredOffsets(keyRange, bracketTokenL, 1);
|
||||
offsets.setDesiredOffset(bracketTokenR, bracketTokenL, 0);
|
||||
} else {
|
||||
const idToken = keyLastToken = sourceCode.getFirstToken(node.key);
|
||||
|
||||
if (idToken !== firstToken) {
|
||||
offsets.setDesiredOffset(idToken, firstToken, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Indent initializer.
|
||||
if (node.value) {
|
||||
const eqToken = sourceCode.getTokenBefore(node.value, astUtils.isEqToken);
|
||||
const valueToken = sourceCode.getTokenAfter(eqToken);
|
||||
|
||||
offsets.setDesiredOffset(eqToken, keyLastToken, 1);
|
||||
offsets.setDesiredOffset(valueToken, eqToken, 1);
|
||||
if (astUtils.isSemicolonToken(maybeSemicolonToken)) {
|
||||
offsets.setDesiredOffset(maybeSemicolonToken, eqToken, 1);
|
||||
}
|
||||
} else if (astUtils.isSemicolonToken(maybeSemicolonToken)) {
|
||||
offsets.setDesiredOffset(maybeSemicolonToken, keyLastToken, 1);
|
||||
}
|
||||
},
|
||||
|
||||
StaticBlock(node) {
|
||||
const openingCurly = sourceCode.getFirstToken(node, { skip: 1 }); // skip the `static` token
|
||||
const closingCurly = sourceCode.getLastToken(node);
|
||||
|
||||
addElementListIndent(node.body, openingCurly, closingCurly, options.StaticBlock.body);
|
||||
},
|
||||
|
||||
SwitchStatement(node) {
|
||||
const openingCurly = sourceCode.getTokenAfter(node.discriminant, astUtils.isOpeningBraceToken);
|
||||
const closingCurly = sourceCode.getLastToken(node);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue