mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
tools: update ESLint to 6.7.1
Update ESLint to 6.7.1 PR-URL: https://github.com/nodejs/node/pull/30598 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
1 parent
1cfaccdc66
commit
bce08806c7
87 files changed
+3584
-1006
No files matched your search
+55
-10
@@ -78,6 +78,18 @@ function sortedMerge(tokens, comments) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if two nodes or tokens overlap.
|
||||
* @param {ASTNode|Token} first The first node or token to check.
|
||||
* @param {ASTNode|Token} second The second node or token to check.
|
||||
* @returns {boolean} True if the two nodes or tokens overlap.
|
||||
* @private
|
||||
*/
|
||||
function nodesOrTokensOverlap(first, second) {
|
||||
return (first.range[0] <= second.range[0] && first.range[1] >= second.range[0]) ||
|
||||
(second.range[0] <= first.range[0] && second.range[1] >= first.range[0]);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public Interface
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -411,19 +423,52 @@ class SourceCode extends TokenStore {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if two tokens have at least one whitespace character
|
||||
* between them. This completely disregards comments in making the
|
||||
* determination, so comments count as zero-length substrings.
|
||||
* @param {Token} first The token to check after.
|
||||
* @param {Token} second The token to check before.
|
||||
* @returns {boolean} True if there is only space between tokens, false
|
||||
* if there is anything other than whitespace between tokens.
|
||||
* Determines if two nodes or tokens have at least one whitespace character
|
||||
* between them. Order does not matter. Returns false if the given nodes or
|
||||
* tokens overlap.
|
||||
* @param {ASTNode|Token} first The first node or token to check between.
|
||||
* @param {ASTNode|Token} second The second node or token to check between.
|
||||
* @returns {boolean} True if there is a whitespace character between
|
||||
* any of the tokens found between the two given nodes or tokens.
|
||||
* @public
|
||||
*/
|
||||
isSpaceBetweenTokens(first, second) {
|
||||
const text = this.text.slice(first.range[1], second.range[0]);
|
||||
isSpaceBetween(first, second) {
|
||||
if (nodesOrTokensOverlap(first, second)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return /\s/u.test(text.replace(/\/\*.*?\*\//gus, ""));
|
||||
const [startingNodeOrToken, endingNodeOrToken] = first.range[1] <= second.range[0]
|
||||
? [first, second]
|
||||
: [second, first];
|
||||
const firstToken = this.getLastToken(startingNodeOrToken) || startingNodeOrToken;
|
||||
const finalToken = this.getFirstToken(endingNodeOrToken) || endingNodeOrToken;
|
||||
let currentToken = firstToken;
|
||||
|
||||
while (currentToken !== finalToken) {
|
||||
const nextToken = this.getTokenAfter(currentToken, { includeComments: true });
|
||||
|
||||
if (currentToken.range[1] !== nextToken.range[0]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
currentToken = nextToken;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if two nodes or tokens have at least one whitespace character
|
||||
* between them. Order does not matter. Returns false if the given nodes or
|
||||
* tokens overlap.
|
||||
* @param {...ASTNode|Token} args The nodes or tokens to check between.
|
||||
* @returns {boolean} True if there is a whitespace character between
|
||||
* any of the tokens found between the two given nodes or tokens.
|
||||
* @deprecated in favor of isSpaceBetween().
|
||||
* @public
|
||||
*/
|
||||
isSpaceBetweenTokens(...args) {
|
||||
return this.isSpaceBetween(...args);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user