Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2021-07-27 16:54:26 +00:00
parent 6b0d45a5c6
commit cc1adb825a
4247 changed files with 144820 additions and 149530 deletions

View file

@ -12,8 +12,7 @@ const
{ isCommentToken } = require("eslint-utils"),
TokenStore = require("./token-store"),
astUtils = require("../shared/ast-utils"),
Traverser = require("../shared/traverser"),
lodash = require("lodash");
Traverser = require("../shared/traverser");
//------------------------------------------------------------------------------
// Private
@ -350,7 +349,7 @@ class SourceCode extends TokenStore {
let currentToken = this.getTokenBefore(node, { includeComments: true });
while (currentToken && isCommentToken(currentToken)) {
if (node.parent && (currentToken.start < node.parent.start)) {
if (node.parent && node.parent.type !== "Program" && (currentToken.start < node.parent.start)) {
break;
}
comments.leading.push(currentToken);
@ -362,7 +361,7 @@ class SourceCode extends TokenStore {
currentToken = this.getTokenAfter(node, { includeComments: true });
while (currentToken && isCommentToken(currentToken)) {
if (node.parent && (currentToken.end > node.parent.end)) {
if (node.parent && node.parent.type !== "Program" && (currentToken.end > node.parent.end)) {
break;
}
comments.trailing.push(currentToken);
@ -531,10 +530,12 @@ class SourceCode extends TokenStore {
}
/*
* To figure out which line rangeIndex is on, determine the last index at which rangeIndex could
* be inserted into lineIndices to keep the list sorted.
* To figure out which line index is on, determine the last place at which index could
* be inserted into lineStartIndices to keep the list sorted.
*/
const lineNumber = lodash.sortedLastIndex(this.lineStartIndices, index);
const lineNumber = index >= this.lineStartIndices[this.lineStartIndices.length - 1]
? this.lineStartIndices.length
: this.lineStartIndices.findIndex(el => index < el);
return { line: lineNumber, column: index - this.lineStartIndices[lineNumber - 1] };
}

View file

@ -4,12 +4,6 @@
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const lodash = require("lodash");
//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------
@ -29,18 +23,16 @@ function getStartLocation(token) {
//------------------------------------------------------------------------------
/**
* Binary-searches the index of the first token which is after the given location.
* Finds the index of the first token which is after the given location.
* If it was not found, this returns `tokens.length`.
* @param {(Token|Comment)[]} tokens It searches the token in this list.
* @param {number} location The location to search.
* @returns {number} The found index or `tokens.length`.
*/
exports.search = function search(tokens, location) {
return lodash.sortedIndexBy(
tokens,
{ range: [location] },
getStartLocation
);
const index = tokens.findIndex(el => location <= getStartLocation(el));
return index === -1 ? tokens.length : index;
};
/**