diff --git a/benchmark/es/spread-assign.js b/benchmark/es/spread-assign.js index 970512aa6b93d4..c34bb93e762d12 100644 --- a/benchmark/es/spread-assign.js +++ b/benchmark/es/spread-assign.js @@ -15,7 +15,7 @@ function main({ n, context, count, rest, method }) { for (let n = 0; n < count; n++) src[`p${n}`] = n; - let obj; // eslint-disable-line no-unused-vars + let obj; switch (method) { case '_extend': @@ -33,7 +33,7 @@ function main({ n, context, count, rest, method }) { case 'spread': bench.start(); for (let i = 0; i < n; i++) - obj = { ...src }; + obj = { ...src }; // eslint-disable-line no-unused-vars bench.end(n); break; default: diff --git a/test/parallel/test-tls-transport-destroy-after-own-gc.js b/test/parallel/test-tls-transport-destroy-after-own-gc.js index 46f630982af643..9b9c8353077dfe 100644 --- a/test/parallel/test-tls-transport-destroy-after-own-gc.js +++ b/test/parallel/test-tls-transport-destroy-after-own-gc.js @@ -15,13 +15,12 @@ const makeDuplexPair = require('../common/duplexpair'); let { clientSide } = makeDuplexPair(); let clientTLS = new TLSSocket(clientSide, { isServer: false }); -// eslint-disable-next-line no-unused-vars let clientTLSHandle = clientTLS._handle; setImmediate(() => { clientTLS = null; global.gc(); - clientTLSHandle = null; + clientTLSHandle = null; // eslint-disable-line no-unused-vars global.gc(); setImmediate(() => { clientSide = null; diff --git a/tools/node_modules/eslint/README.md b/tools/node_modules/eslint/README.md index 1838496e238d0f..0cb3963b2c0b22 100644 --- a/tools/node_modules/eslint/README.md +++ b/tools/node_modules/eslint/README.md @@ -250,8 +250,8 @@ The following companies, organizations, and individuals support ESLint's ongoing

Gold Sponsors

Shopify Salesforce Airbnb

Silver Sponsors

-

AMP Project

Bronze Sponsors

-

Bruce EduBirdie CasinoTop.com Casino Topp Writers Per Hour Anagram Solver vpn netflix Kasinot.fi Pelisivut Nettikasinot.org BonusFinder Deutschland Bugsnag Stability Monitoring Mixpanel VPS Server Free Icons by Icons8 Discord ThemeIsle TekHattan Marfeel Fire Stick Tricks

+

Liftoff AMP Project

Bronze Sponsors

+

Bruce EduBirdie CasinoTop.com Casino Topp Writers Per Hour Anagram Solver vpn netflix Kasinot.fi Pelisivut Nettikasinot.org BonusFinder Deutschland Bugsnag Stability Monitoring Mixpanel VPS Server Free Icons by Icons8 Discord ThemeIsle TekHattan Marfeel Fire Stick Tricks

## Technology Sponsors diff --git a/tools/node_modules/eslint/lib/cli-engine/cli-engine.js b/tools/node_modules/eslint/lib/cli-engine/cli-engine.js index b6aa995beef933..802a405c04ac72 100644 --- a/tools/node_modules/eslint/lib/cli-engine/cli-engine.js +++ b/tools/node_modules/eslint/lib/cli-engine/cli-engine.js @@ -403,7 +403,7 @@ function getCacheFile(cacheFile, cwd) { try { fileStats = fs.lstatSync(resolvedCacheFile); - } catch (ex) { + } catch { fileStats = null; } @@ -991,7 +991,7 @@ class CLIEngine { const npmFormat = naming.normalizePackageName(normalizedFormatName, "eslint-formatter"); formatterPath = ModuleResolver.resolve(npmFormat, path.join(cwd, "__placeholder__.js")); - } catch (e) { + } catch { formatterPath = path.resolve(__dirname, "formatters", normalizedFormatName); } } diff --git a/tools/node_modules/eslint/lib/cli-engine/config-array-factory.js b/tools/node_modules/eslint/lib/cli-engine/config-array-factory.js index fa3fdb3bedd89b..7c0fba65c67d0a 100644 --- a/tools/node_modules/eslint/lib/cli-engine/config-array-factory.js +++ b/tools/node_modules/eslint/lib/cli-engine/config-array-factory.js @@ -517,7 +517,7 @@ class ConfigArrayFactory { try { loadPackageJSONConfigFile(filePath); return filePath; - } catch (error) { /* ignore */ } + } catch { /* ignore */ } } else { return filePath; } diff --git a/tools/node_modules/eslint/lib/init/config-initializer.js b/tools/node_modules/eslint/lib/init/config-initializer.js index 00f17678fc66c0..dce39946e6b876 100644 --- a/tools/node_modules/eslint/lib/init/config-initializer.js +++ b/tools/node_modules/eslint/lib/init/config-initializer.js @@ -265,11 +265,7 @@ function processAnswers(answers) { }; config.parserOptions.ecmaVersion = espree.latestEcmaVersion; - config.env.es6 = true; - config.globals = { - Atomics: "readonly", - SharedArrayBuffer: "readonly" - }; + config.env.es2020 = true; // set the module type if (answers.moduleType === "esm") { @@ -350,7 +346,7 @@ function getLocalESLintVersion() { const eslint = require(eslintPath); return eslint.linter.version || null; - } catch (_err) { + } catch { return null; } } diff --git a/tools/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js b/tools/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js index 8a623e33ea0681..b612cf43566b0c 100644 --- a/tools/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js +++ b/tools/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js @@ -33,10 +33,10 @@ function isCaseNode(node) { * Checks whether the given logical operator is taken into account for the code * path analysis. * @param {string} operator The operator found in the LogicalExpression node - * @returns {boolean} `true` if the operator is "&&" or "||" + * @returns {boolean} `true` if the operator is "&&" or "||" or "??" */ function isHandledLogicalOperator(operator) { - return operator === "&&" || operator === "||"; + return operator === "&&" || operator === "||" || operator === "??"; } /** diff --git a/tools/node_modules/eslint/lib/linter/code-path-analysis/code-path-state.js b/tools/node_modules/eslint/lib/linter/code-path-analysis/code-path-state.js index 75de1bc6ce4c4a..9e760601a0f744 100644 --- a/tools/node_modules/eslint/lib/linter/code-path-analysis/code-path-state.js +++ b/tools/node_modules/eslint/lib/linter/code-path-analysis/code-path-state.js @@ -201,6 +201,7 @@ function finalizeTestSegmentsOfFor(context, choiceContext, head) { if (!choiceContext.processed) { choiceContext.trueForkContext.add(head); choiceContext.falseForkContext.add(head); + choiceContext.qqForkContext.add(head); } if (context.test !== true) { @@ -351,6 +352,7 @@ class CodePathState { isForkingAsResult, trueForkContext: ForkContext.newEmpty(this.forkContext), falseForkContext: ForkContext.newEmpty(this.forkContext), + qqForkContext: ForkContext.newEmpty(this.forkContext), processed: false }; } @@ -370,6 +372,7 @@ class CodePathState { switch (context.kind) { case "&&": case "||": + case "??": /* * If any result were not transferred from child contexts, @@ -379,6 +382,7 @@ class CodePathState { if (!context.processed) { context.trueForkContext.add(headSegments); context.falseForkContext.add(headSegments); + context.qqForkContext.add(headSegments); } /* @@ -390,6 +394,7 @@ class CodePathState { parentContext.trueForkContext.addAll(context.trueForkContext); parentContext.falseForkContext.addAll(context.falseForkContext); + parentContext.qqForkContext.addAll(context.qqForkContext); parentContext.processed = true; return context; @@ -456,13 +461,24 @@ class CodePathState { * This got segments already from the child choice context. * Creates the next path from own true/false fork context. */ - const prevForkContext = - context.kind === "&&" ? context.trueForkContext - /* kind === "||" */ : context.falseForkContext; + let prevForkContext; + + switch (context.kind) { + case "&&": // if true then go to the right-hand side. + prevForkContext = context.trueForkContext; + break; + case "||": // if false then go to the right-hand side. + prevForkContext = context.falseForkContext; + break; + case "??": // Both true/false can short-circuit, so needs the third path to go to the right-hand side. That's qqForkContext. + prevForkContext = context.qqForkContext; + break; + default: + throw new Error("unreachable"); + } forkContext.replaceHead(prevForkContext.makeNext(0, -1)); prevForkContext.clear(); - context.processed = false; } else { @@ -471,14 +487,19 @@ class CodePathState { * So addresses the head segments. * The head segments are the path of the left-hand operand. */ - if (context.kind === "&&") { - - // The path does short-circuit if false. - context.falseForkContext.add(forkContext.head); - } else { - - // The path does short-circuit if true. - context.trueForkContext.add(forkContext.head); + switch (context.kind) { + case "&&": // the false path can short-circuit. + context.falseForkContext.add(forkContext.head); + break; + case "||": // the true path can short-circuit. + context.trueForkContext.add(forkContext.head); + break; + case "??": // both can short-circuit. + context.trueForkContext.add(forkContext.head); + context.falseForkContext.add(forkContext.head); + break; + default: + throw new Error("unreachable"); } forkContext.replaceHead(forkContext.makeNext(-1, -1)); @@ -501,6 +522,7 @@ class CodePathState { if (!context.processed) { context.trueForkContext.add(forkContext.head); context.falseForkContext.add(forkContext.head); + context.qqForkContext.add(forkContext.head); } context.processed = false; diff --git a/tools/node_modules/eslint/lib/linter/config-comment-parser.js b/tools/node_modules/eslint/lib/linter/config-comment-parser.js index 35862315d515f8..067d02480302cb 100644 --- a/tools/node_modules/eslint/lib/linter/config-comment-parser.js +++ b/tools/node_modules/eslint/lib/linter/config-comment-parser.js @@ -78,7 +78,7 @@ module.exports = class ConfigCommentParser { config: items }; } - } catch (ex) { + } catch { debug("Levn parsing failed; falling back to manual parsing."); diff --git a/tools/node_modules/eslint/lib/rules/func-call-spacing.js b/tools/node_modules/eslint/lib/rules/func-call-spacing.js index dccdd0a40c6d76..5ecb63ecfa7b60 100644 --- a/tools/node_modules/eslint/lib/rules/func-call-spacing.js +++ b/tools/node_modules/eslint/lib/rules/func-call-spacing.js @@ -116,7 +116,13 @@ module.exports = { if (never && hasWhitespace) { context.report({ node, - loc: leftToken.loc.start, + loc: { + start: leftToken.loc.end, + end: { + line: rightToken.loc.start.line, + column: rightToken.loc.start.column - 1 + } + }, messageId: "unexpectedWhitespace", fix(fixer) { @@ -134,7 +140,13 @@ module.exports = { } else if (!never && !hasWhitespace) { context.report({ node, - loc: leftToken.loc.start, + loc: { + start: { + line: leftToken.loc.end.line, + column: leftToken.loc.end.column - 1 + }, + end: rightToken.loc.start + }, messageId: "missing", fix(fixer) { return fixer.insertTextBefore(rightToken, " "); @@ -143,7 +155,10 @@ module.exports = { } else if (!never && !allowNewlines && hasNewline) { context.report({ node, - loc: leftToken.loc.start, + loc: { + start: leftToken.loc.end, + end: rightToken.loc.start + }, messageId: "unexpectedNewline", fix(fixer) { return fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], " "); diff --git a/tools/node_modules/eslint/lib/rules/keyword-spacing.js b/tools/node_modules/eslint/lib/rules/keyword-spacing.js index 2b3fef33bd7ac4..99979a32a5bbf7 100644 --- a/tools/node_modules/eslint/lib/rules/keyword-spacing.js +++ b/tools/node_modules/eslint/lib/rules/keyword-spacing.js @@ -152,7 +152,7 @@ module.exports = { sourceCode.isSpaceBetweenTokens(prevToken, token) ) { context.report({ - loc: token.loc.start, + loc: { start: prevToken.loc.end, end: token.loc.start }, messageId: "unexpectedBefore", data: token, fix(fixer) { @@ -203,8 +203,9 @@ module.exports = { astUtils.isTokenOnSameLine(token, nextToken) && sourceCode.isSpaceBetweenTokens(token, nextToken) ) { + context.report({ - loc: token.loc.start, + loc: { start: token.loc.end, end: nextToken.loc.start }, messageId: "unexpectedAfter", data: token, fix(fixer) { @@ -442,6 +443,12 @@ module.exports = { checkSpacingAround(sourceCode.getTokenAfter(firstToken)); } + if (node.type === "ExportAllDeclaration" && node.exported) { + const asToken = sourceCode.getTokenBefore(node.exported); + + checkSpacingBefore(asToken, PREV_TOKEN_M); + } + if (node.source) { const fromToken = sourceCode.getTokenBefore(node.source); diff --git a/tools/node_modules/eslint/lib/rules/multiline-ternary.js b/tools/node_modules/eslint/lib/rules/multiline-ternary.js index 1df90b6feb8321..6668bff4824842 100644 --- a/tools/node_modules/eslint/lib/rules/multiline-ternary.js +++ b/tools/node_modules/eslint/lib/rules/multiline-ternary.js @@ -39,25 +39,7 @@ module.exports = { const option = context.options[0]; const multiline = option !== "never"; const allowSingleLine = option === "always-multiline"; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Tests whether node is preceded by supplied tokens - * @param {ASTNode} node node to check - * @param {ASTNode} parentNode parent of node to report - * @param {boolean} expected whether newline was expected or not - * @returns {void} - * @private - */ - function reportError(node, parentNode, expected) { - context.report({ - node, - messageId: `${expected ? "expected" : "unexpected"}${node === parentNode.test ? "TestCons" : "ConsAlt"}` - }); - } + const sourceCode = context.getSourceCode(); //-------------------------------------------------------------------------- // Public @@ -65,16 +47,39 @@ module.exports = { return { ConditionalExpression(node) { - const areTestAndConsequentOnSameLine = astUtils.isTokenOnSameLine(node.test, node.consequent); - const areConsequentAndAlternateOnSameLine = astUtils.isTokenOnSameLine(node.consequent, node.alternate); + const questionToken = sourceCode.getTokenAfter(node.test, astUtils.isNotClosingParenToken); + const colonToken = sourceCode.getTokenAfter(node.consequent, astUtils.isNotClosingParenToken); + + const firstTokenOfTest = sourceCode.getFirstToken(node); + const lastTokenOfTest = sourceCode.getTokenBefore(questionToken); + const firstTokenOfConsequent = sourceCode.getTokenAfter(questionToken); + const lastTokenOfConsequent = sourceCode.getTokenBefore(colonToken); + const firstTokenOfAlternate = sourceCode.getTokenAfter(colonToken); + + const areTestAndConsequentOnSameLine = astUtils.isTokenOnSameLine(lastTokenOfTest, firstTokenOfConsequent); + const areConsequentAndAlternateOnSameLine = astUtils.isTokenOnSameLine(lastTokenOfConsequent, firstTokenOfAlternate); if (!multiline) { if (!areTestAndConsequentOnSameLine) { - reportError(node.test, node, false); + context.report({ + node: node.test, + loc: { + start: firstTokenOfTest.loc.start, + end: lastTokenOfTest.loc.end + }, + messageId: "unexpectedTestCons" + }); } if (!areConsequentAndAlternateOnSameLine) { - reportError(node.consequent, node, false); + context.report({ + node: node.consequent, + loc: { + start: firstTokenOfConsequent.loc.start, + end: lastTokenOfConsequent.loc.end + }, + messageId: "unexpectedConsAlt" + }); } } else { if (allowSingleLine && node.loc.start.line === node.loc.end.line) { @@ -82,11 +87,25 @@ module.exports = { } if (areTestAndConsequentOnSameLine) { - reportError(node.test, node, true); + context.report({ + node: node.test, + loc: { + start: firstTokenOfTest.loc.start, + end: lastTokenOfTest.loc.end + }, + messageId: "expectedTestCons" + }); } if (areConsequentAndAlternateOnSameLine) { - reportError(node.consequent, node, true); + context.report({ + node: node.consequent, + loc: { + start: firstTokenOfConsequent.loc.start, + end: lastTokenOfConsequent.loc.end + }, + messageId: "expectedConsAlt" + }); } } } diff --git a/tools/node_modules/eslint/lib/rules/no-control-regex.js b/tools/node_modules/eslint/lib/rules/no-control-regex.js index b39f731c3cdf29..146c4f22d01257 100644 --- a/tools/node_modules/eslint/lib/rules/no-control-regex.js +++ b/tools/node_modules/eslint/lib/rules/no-control-regex.js @@ -35,7 +35,7 @@ const collector = new (class { try { this._source = regexpStr; this._validator.validatePattern(regexpStr); // Call onCharacter hook - } catch (err) { + } catch { // Ignore syntax errors in RegExp. } diff --git a/tools/node_modules/eslint/lib/rules/no-extra-boolean-cast.js b/tools/node_modules/eslint/lib/rules/no-extra-boolean-cast.js index aba8e63e086a41..b90757b112658c 100644 --- a/tools/node_modules/eslint/lib/rules/no-extra-boolean-cast.js +++ b/tools/node_modules/eslint/lib/rules/no-extra-boolean-cast.js @@ -172,6 +172,9 @@ module.exports = { case "UnaryExpression": return precedence(node) < precedence(parent); case "LogicalExpression": + if (astUtils.isMixedLogicalAndCoalesceExpressions(node, parent)) { + return true; + } if (previousNode === parent.left) { return precedence(node) < precedence(parent); } diff --git a/tools/node_modules/eslint/lib/rules/no-extra-parens.js b/tools/node_modules/eslint/lib/rules/no-extra-parens.js index 7cbb7522ebedfa..bae1a498cf0cf1 100644 --- a/tools/node_modules/eslint/lib/rules/no-extra-parens.js +++ b/tools/node_modules/eslint/lib/rules/no-extra-parens.js @@ -51,7 +51,8 @@ module.exports = { ignoreJSX: { enum: ["none", "all", "single-line", "multi-line"] }, enforceForArrowConditionals: { type: "boolean" }, enforceForSequenceExpressions: { type: "boolean" }, - enforceForNewInMemberExpressions: { type: "boolean" } + enforceForNewInMemberExpressions: { type: "boolean" }, + enforceForFunctionPrototypeMethods: { type: "boolean" } }, additionalProperties: false } @@ -83,12 +84,28 @@ module.exports = { context.options[1].enforceForSequenceExpressions === false; const IGNORE_NEW_IN_MEMBER_EXPR = ALL_NODES && context.options[1] && context.options[1].enforceForNewInMemberExpressions === false; + const IGNORE_FUNCTION_PROTOTYPE_METHODS = ALL_NODES && context.options[1] && + context.options[1].enforceForFunctionPrototypeMethods === false; const PRECEDENCE_OF_ASSIGNMENT_EXPR = precedence({ type: "AssignmentExpression" }); const PRECEDENCE_OF_UPDATE_EXPR = precedence({ type: "UpdateExpression" }); let reportsBuffer; + /** + * Determines whether the given node is a `call` or `apply` method call, invoked directly on a `FunctionExpression` node. + * Example: function(){}.call() + * @param {ASTNode} node The node to be checked. + * @returns {boolean} True if the node is an immediate `call` or `apply` method call. + * @private + */ + function isImmediateFunctionPrototypeMethodCall(node) { + return node.type === "CallExpression" && + node.callee.type === "MemberExpression" && + node.callee.object.type === "FunctionExpression" && + ["call", "apply"].includes(astUtils.getStaticPropertyName(node.callee)); + } + /** * Determines if this rule should be enforced for a node given the current configuration. * @param {ASTNode} node The node to be checked. @@ -125,6 +142,10 @@ module.exports = { return false; } + if (isImmediateFunctionPrototypeMethodCall(node) && IGNORE_FUNCTION_PROTOTYPE_METHODS) { + return false; + } + return ALL_NODES || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression"; } @@ -478,6 +499,7 @@ module.exports = { if (!shouldSkipLeft && hasExcessParens(node.left)) { if ( !(node.left.type === "UnaryExpression" && isExponentiation) && + !astUtils.isMixedLogicalAndCoalesceExpressions(node.left, node) && (leftPrecedence > prec || (leftPrecedence === prec && !isExponentiation)) || isParenthesisedTwice(node.left) ) { @@ -487,6 +509,7 @@ module.exports = { if (!shouldSkipRight && hasExcessParens(node.right)) { if ( + !astUtils.isMixedLogicalAndCoalesceExpressions(node.right, node) && (rightPrecedence > prec || (rightPrecedence === prec && isExponentiation)) || isParenthesisedTwice(node.right) ) { @@ -927,7 +950,12 @@ module.exports = { LogicalExpression: checkBinaryLogical, MemberExpression(node) { - const nodeObjHasExcessParens = hasExcessParens(node.object); + const nodeObjHasExcessParens = hasExcessParens(node.object) && + !( + isImmediateFunctionPrototypeMethodCall(node.parent) && + node.parent.callee === node && + IGNORE_FUNCTION_PROTOTYPE_METHODS + ); if ( nodeObjHasExcessParens && diff --git a/tools/node_modules/eslint/lib/rules/no-invalid-regexp.js b/tools/node_modules/eslint/lib/rules/no-invalid-regexp.js index c09e36fd017697..48b7188d49f9c5 100644 --- a/tools/node_modules/eslint/lib/rules/no-invalid-regexp.js +++ b/tools/node_modules/eslint/lib/rules/no-invalid-regexp.js @@ -93,7 +93,7 @@ module.exports = { try { validator.validateFlags(flags); return null; - } catch (err) { + } catch { return `Invalid flags supplied to RegExp constructor '${flags}'`; } } diff --git a/tools/node_modules/eslint/lib/rules/no-misleading-character-class.js b/tools/node_modules/eslint/lib/rules/no-misleading-character-class.js index 9315ba64972f79..3d004615c3f070 100644 --- a/tools/node_modules/eslint/lib/rules/no-misleading-character-class.js +++ b/tools/node_modules/eslint/lib/rules/no-misleading-character-class.js @@ -147,7 +147,7 @@ module.exports = { pattern.length, flags.includes("u") ); - } catch (e) { + } catch { // Ignore regular expressions with syntax errors return; diff --git a/tools/node_modules/eslint/lib/rules/no-mixed-operators.js b/tools/node_modules/eslint/lib/rules/no-mixed-operators.js index 37e8906e827a4c..f0290e93ece8db 100644 --- a/tools/node_modules/eslint/lib/rules/no-mixed-operators.js +++ b/tools/node_modules/eslint/lib/rules/no-mixed-operators.js @@ -21,13 +21,15 @@ const COMPARISON_OPERATORS = ["==", "!=", "===", "!==", ">", ">=", "<", "<="]; const LOGICAL_OPERATORS = ["&&", "||"]; const RELATIONAL_OPERATORS = ["in", "instanceof"]; const TERNARY_OPERATOR = ["?:"]; +const COALESCE_OPERATOR = ["??"]; const ALL_OPERATORS = [].concat( ARITHMETIC_OPERATORS, BITWISE_OPERATORS, COMPARISON_OPERATORS, LOGICAL_OPERATORS, RELATIONAL_OPERATORS, - TERNARY_OPERATOR + TERNARY_OPERATOR, + COALESCE_OPERATOR ); const DEFAULT_GROUPS = [ ARITHMETIC_OPERATORS, @@ -236,7 +238,6 @@ module.exports = { return { BinaryExpression: check, LogicalExpression: check - }; } }; diff --git a/tools/node_modules/eslint/lib/rules/no-mixed-spaces-and-tabs.js b/tools/node_modules/eslint/lib/rules/no-mixed-spaces-and-tabs.js index 16c2bd4122e851..287cbda03daf5a 100644 --- a/tools/node_modules/eslint/lib/rules/no-mixed-spaces-and-tabs.js +++ b/tools/node_modules/eslint/lib/rules/no-mixed-spaces-and-tabs.js @@ -67,7 +67,7 @@ module.exports = { * or the reverse before non-tab/-space * characters begin. */ - let regex = /^(?=[\t ]*(\t | \t))/u; + let regex = /^(?=( +|\t+))\1(?:\t| )/u; if (smartTabs) { @@ -75,19 +75,27 @@ module.exports = { * At least one space followed by a tab * before non-tab/-space characters begin. */ - regex = /^(?=[\t ]* \t)/u; + regex = /^(?=(\t*))\1(?=( +))\2\t/u; } lines.forEach((line, i) => { const match = regex.exec(line); if (match) { - const lineNumber = i + 1, - column = match.index + 1, - loc = { line: lineNumber, column }; + const lineNumber = i + 1; + const loc = { + start: { + line: lineNumber, + column: match[0].length - 2 + }, + end: { + line: lineNumber, + column: match[0].length + } + }; if (!ignoredCommentLines.has(lineNumber)) { - const containingNode = sourceCode.getNodeByRangeIndex(sourceCode.getIndexFromLoc(loc)); + const containingNode = sourceCode.getNodeByRangeIndex(sourceCode.getIndexFromLoc(loc.start)); if (!(containingNode && ["Literal", "TemplateElement"].includes(containingNode.type))) { context.report({ diff --git a/tools/node_modules/eslint/lib/rules/no-regex-spaces.js b/tools/node_modules/eslint/lib/rules/no-regex-spaces.js index afb26d70259f1b..e6d4c9efba75fe 100644 --- a/tools/node_modules/eslint/lib/rules/no-regex-spaces.js +++ b/tools/node_modules/eslint/lib/rules/no-regex-spaces.js @@ -76,7 +76,7 @@ module.exports = { try { regExpAST = regExpParser.parsePattern(pattern, 0, pattern.length, flags.includes("u")); - } catch (e) { + } catch { // Ignore regular expressions with syntax errors return; diff --git a/tools/node_modules/eslint/lib/rules/no-restricted-exports.js b/tools/node_modules/eslint/lib/rules/no-restricted-exports.js index 5b5c7d9bffb99c..6031e26de2c7e8 100644 --- a/tools/node_modules/eslint/lib/rules/no-restricted-exports.js +++ b/tools/node_modules/eslint/lib/rules/no-restricted-exports.js @@ -61,6 +61,12 @@ module.exports = { } return { + ExportAllDeclaration(node) { + if (node.exported) { + checkExportedName(node.exported); + } + }, + ExportNamedDeclaration(node) { const declaration = node.declaration; diff --git a/tools/node_modules/eslint/lib/rules/no-unneeded-ternary.js b/tools/node_modules/eslint/lib/rules/no-unneeded-ternary.js index d4438e2fe08fbe..0fefc42b909820 100644 --- a/tools/node_modules/eslint/lib/rules/no-unneeded-ternary.js +++ b/tools/node_modules/eslint/lib/rules/no-unneeded-ternary.js @@ -147,10 +147,12 @@ module.exports = { loc: node.consequent.loc.start, messageId: "unnecessaryConditionalAssignment", fix: fixer => { - const shouldParenthesizeAlternate = ( - astUtils.getPrecedence(node.alternate) < OR_PRECEDENCE && - !astUtils.isParenthesised(sourceCode, node.alternate) - ); + const shouldParenthesizeAlternate = + ( + astUtils.getPrecedence(node.alternate) < OR_PRECEDENCE || + astUtils.isCoalesceExpression(node.alternate) + ) && + !astUtils.isParenthesised(sourceCode, node.alternate); const alternateText = shouldParenthesizeAlternate ? `(${sourceCode.getText(node.alternate)})` : astUtils.getParenthesisedText(sourceCode, node.alternate); diff --git a/tools/node_modules/eslint/lib/rules/no-unused-expressions.js b/tools/node_modules/eslint/lib/rules/no-unused-expressions.js index 26a25b7584bc80..8c049f556ff2d9 100644 --- a/tools/node_modules/eslint/lib/rules/no-unused-expressions.js +++ b/tools/node_modules/eslint/lib/rules/no-unused-expressions.js @@ -124,7 +124,7 @@ module.exports = { return true; } - return /^(?:Assignment|Call|New|Update|Yield|Await)Expression$/u.test(node.type) || + return /^(?:Assignment|Call|New|Update|Yield|Await|Import)Expression$/u.test(node.type) || (node.type === "UnaryExpression" && ["delete", "void"].indexOf(node.operator) >= 0); } diff --git a/tools/node_modules/eslint/lib/rules/no-unused-vars.js b/tools/node_modules/eslint/lib/rules/no-unused-vars.js index 18c48bf0d7810c..50dcab45fe2bb6 100644 --- a/tools/node_modules/eslint/lib/rules/no-unused-vars.js +++ b/tools/node_modules/eslint/lib/rules/no-unused-vars.js @@ -619,7 +619,9 @@ module.exports = { // Report the first declaration. if (unusedVar.defs.length > 0) { context.report({ - node: unusedVar.identifiers[0], + node: unusedVar.references.length ? unusedVar.references[ + unusedVar.references.length - 1 + ].identifier : unusedVar.identifiers[0], messageId: "unusedVar", data: unusedVar.references.some(ref => ref.isWrite()) ? getAssignedMessageData(unusedVar) diff --git a/tools/node_modules/eslint/lib/rules/no-useless-backreference.js b/tools/node_modules/eslint/lib/rules/no-useless-backreference.js index 8a6fbe14daafe6..958e3d5dd4e4d5 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-backreference.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-backreference.js @@ -95,7 +95,7 @@ module.exports = { try { regExpAST = parser.parsePattern(pattern, 0, pattern.length, flags.includes("u")); - } catch (e) { + } catch { // Ignore regular expressions with syntax errors return; diff --git a/tools/node_modules/eslint/lib/rules/prefer-named-capture-group.js b/tools/node_modules/eslint/lib/rules/prefer-named-capture-group.js index c8af043c1b5268..7d0aa3f9dc094d 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-named-capture-group.js +++ b/tools/node_modules/eslint/lib/rules/prefer-named-capture-group.js @@ -59,7 +59,7 @@ module.exports = { try { ast = parser.parsePattern(pattern, 0, pattern.length, uFlag); - } catch (_) { + } catch { // ignore regex syntax errors return; diff --git a/tools/node_modules/eslint/lib/rules/quote-props.js b/tools/node_modules/eslint/lib/rules/quote-props.js index a2a4e1d47923ff..fab7bdc9c1555b 100644 --- a/tools/node_modules/eslint/lib/rules/quote-props.js +++ b/tools/node_modules/eslint/lib/rules/quote-props.js @@ -154,7 +154,7 @@ module.exports = { try { tokens = espree.tokenize(key.value); - } catch (e) { + } catch { return; } @@ -239,7 +239,7 @@ module.exports = { try { tokens = espree.tokenize(key.value); - } catch (e) { + } catch { necessaryQuotes = true; return; } diff --git a/tools/node_modules/eslint/lib/rules/template-tag-spacing.js b/tools/node_modules/eslint/lib/rules/template-tag-spacing.js index 9eb6d86077da36..16f586255af567 100644 --- a/tools/node_modules/eslint/lib/rules/template-tag-spacing.js +++ b/tools/node_modules/eslint/lib/rules/template-tag-spacing.js @@ -49,7 +49,10 @@ module.exports = { if (never && hasWhitespace) { context.report({ node, - loc: tagToken.loc.start, + loc: { + start: tagToken.loc.end, + end: literalToken.loc.start + }, messageId: "unexpected", fix(fixer) { const comments = sourceCode.getCommentsBefore(node.quasi); @@ -68,7 +71,10 @@ module.exports = { } else if (!never && !hasWhitespace) { context.report({ node, - loc: tagToken.loc.start, + loc: { + start: node.loc.start, + end: literalToken.loc.start + }, messageId: "missing", fix(fixer) { return fixer.insertTextAfter(tagToken, " "); diff --git a/tools/node_modules/eslint/lib/rules/utils/ast-utils.js b/tools/node_modules/eslint/lib/rules/utils/ast-utils.js index 83ecf69434dafb..ecea6948da2360 100644 --- a/tools/node_modules/eslint/lib/rules/utils/ast-utils.js +++ b/tools/node_modules/eslint/lib/rules/utils/ast-utils.js @@ -416,6 +416,53 @@ function equalTokens(left, right, sourceCode) { return true; } +/** + * Check if the given node is a true logical expression or not. + * + * The three binary expressions logical-or (`||`), logical-and (`&&`), and + * coalesce (`??`) are known as `ShortCircuitExpression`. + * But ESTree represents those by `LogicalExpression` node. + * + * This function rejects coalesce expressions of `LogicalExpression` node. + * @param {ASTNode} node The node to check. + * @returns {boolean} `true` if the node is `&&` or `||`. + * @see https://tc39.es/ecma262/#prod-ShortCircuitExpression + */ +function isLogicalExpression(node) { + return ( + node.type === "LogicalExpression" && + (node.operator === "&&" || node.operator === "||") + ); +} + +/** + * Check if the given node is a nullish coalescing expression or not. + * + * The three binary expressions logical-or (`||`), logical-and (`&&`), and + * coalesce (`??`) are known as `ShortCircuitExpression`. + * But ESTree represents those by `LogicalExpression` node. + * + * This function finds only coalesce expressions of `LogicalExpression` node. + * @param {ASTNode} node The node to check. + * @returns {boolean} `true` if the node is `??`. + */ +function isCoalesceExpression(node) { + return node.type === "LogicalExpression" && node.operator === "??"; +} + +/** + * Check if given two nodes are the pair of a logical expression and a coalesce expression. + * @param {ASTNode} left A node to check. + * @param {ASTNode} right Another node to check. + * @returns {boolean} `true` if the two nodes are the pair of a logical expression and a coalesce expression. + */ +function isMixedLogicalAndCoalesceExpressions(left, right) { + return ( + (isLogicalExpression(left) && isCoalesceExpression(right)) || + (isCoalesceExpression(left) && isLogicalExpression(right)) + ); +} + //------------------------------------------------------------------------------ // Public Interface //------------------------------------------------------------------------------ @@ -779,6 +826,7 @@ module.exports = { case "LogicalExpression": switch (node.operator) { case "||": + case "??": return 4; case "&&": return 5; @@ -1415,7 +1463,7 @@ module.exports = { try { tokens = espree.tokenize(leftValue, espreeOptions); - } catch (e) { + } catch { return false; } @@ -1444,7 +1492,7 @@ module.exports = { try { tokens = espree.tokenize(rightValue, espreeOptions); - } catch (e) { + } catch { return false; } @@ -1538,5 +1586,9 @@ module.exports = { */ hasOctalEscapeSequence(rawString) { return OCTAL_ESCAPE_PATTERN.test(rawString); - } + }, + + isLogicalExpression, + isCoalesceExpression, + isMixedLogicalAndCoalesceExpressions }; diff --git a/tools/node_modules/eslint/node_modules/@babel/code-frame/lib/index.js b/tools/node_modules/eslint/node_modules/@babel/code-frame/lib/index.js index 62945f7782a774..2dd96e5758c777 100644 --- a/tools/node_modules/eslint/node_modules/@babel/code-frame/lib/index.js +++ b/tools/node_modules/eslint/node_modules/@babel/code-frame/lib/index.js @@ -29,7 +29,7 @@ function getMarkerLines(loc, source, opts) { column: 0, line: -1 }, loc.start); - const endLoc = Object.assign({}, startLoc, {}, loc.end); + const endLoc = Object.assign(Object.assign({}, startLoc), loc.end); const { linesAbove = 2, linesBelow = 3 diff --git a/tools/node_modules/eslint/node_modules/@babel/code-frame/package.json b/tools/node_modules/eslint/node_modules/@babel/code-frame/package.json index 7508b5b1402c94..05e388a3549712 100644 --- a/tools/node_modules/eslint/node_modules/@babel/code-frame/package.json +++ b/tools/node_modules/eslint/node_modules/@babel/code-frame/package.json @@ -3,9 +3,12 @@ "name": "Sebastian McKenzie", "email": "sebmck@gmail.com" }, + "bugs": { + "url": "https://github.com/babel/babel/issues" + }, "bundleDependencies": false, "dependencies": { - "@babel/highlight": "^7.8.3" + "@babel/highlight": "^7.10.1" }, "deprecated": false, "description": "Generate errors that contain a code frame that point to source locations.", @@ -13,7 +16,7 @@ "chalk": "^2.0.0", "strip-ansi": "^4.0.0" }, - "gitHead": "a7620bd266ae1345975767bbc7abf09034437017", + "gitHead": "88f57a7ea659d25232bf62de1efceb5d6299b8cf", "homepage": "https://babeljs.io/", "license": "MIT", "main": "lib/index.js", @@ -23,7 +26,8 @@ }, "repository": { "type": "git", - "url": "https://github.com/babel/babel/tree/master/packages/babel-code-frame" + "url": "git+https://github.com/babel/babel.git", + "directory": "packages/babel-code-frame" }, - "version": "7.8.3" + "version": "7.10.1" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/package.json b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/package.json index da8c4e12d40ff7..7ca0be602c99a6 100644 --- a/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/package.json +++ b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/package.json @@ -1,4 +1,7 @@ { + "bugs": { + "url": "https://github.com/babel/babel/issues" + }, "bundleDependencies": false, "deprecated": false, "description": "Validate identifier/keywords name", @@ -7,7 +10,8 @@ "unicode-13.0.0": "^0.8.0" }, "exports": "./lib/index.js", - "gitHead": "5b97e77e030cf3853a147fdff81844ea4026219d", + "gitHead": "88f57a7ea659d25232bf62de1efceb5d6299b8cf", + "homepage": "https://github.com/babel/babel#readme", "license": "MIT", "main": "./lib/index.js", "name": "@babel/helper-validator-identifier", @@ -16,7 +20,8 @@ }, "repository": { "type": "git", - "url": "https://github.com/babel/babel/tree/master/packages/babel-helper-validator-identifier" + "url": "git+https://github.com/babel/babel.git", + "directory": "packages/babel-helper-validator-identifier" }, - "version": "7.9.5" + "version": "7.10.1" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/@babel/highlight/package.json b/tools/node_modules/eslint/node_modules/@babel/highlight/package.json index f4ecd5f2a42a6c..1899d79a7f0fc2 100644 --- a/tools/node_modules/eslint/node_modules/@babel/highlight/package.json +++ b/tools/node_modules/eslint/node_modules/@babel/highlight/package.json @@ -3,9 +3,12 @@ "name": "suchipi", "email": "me@suchipi.com" }, + "bugs": { + "url": "https://github.com/babel/babel/issues" + }, "bundleDependencies": false, "dependencies": { - "@babel/helper-validator-identifier": "^7.9.0", + "@babel/helper-validator-identifier": "^7.10.1", "chalk": "^2.0.0", "js-tokens": "^4.0.0" }, @@ -14,7 +17,7 @@ "devDependencies": { "strip-ansi": "^4.0.0" }, - "gitHead": "8d5e422be27251cfaadf8dd2536b31b4a5024b02", + "gitHead": "88f57a7ea659d25232bf62de1efceb5d6299b8cf", "homepage": "https://babeljs.io/", "license": "MIT", "main": "lib/index.js", @@ -24,7 +27,8 @@ }, "repository": { "type": "git", - "url": "https://github.com/babel/babel/tree/master/packages/babel-highlight" + "url": "git+https://github.com/babel/babel.git", + "directory": "packages/babel-highlight" }, - "version": "7.9.0" + "version": "7.10.1" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/cross-spawn/lib/util/resolveCommand.js b/tools/node_modules/eslint/node_modules/cross-spawn/lib/util/resolveCommand.js index 6825a8bc5f05f9..7972455008e917 100644 --- a/tools/node_modules/eslint/node_modules/cross-spawn/lib/util/resolveCommand.js +++ b/tools/node_modules/eslint/node_modules/cross-spawn/lib/util/resolveCommand.js @@ -2,9 +2,10 @@ const path = require('path'); const which = require('which'); -const pathKey = require('path-key')(); +const getPathKey = require('path-key'); function resolveCommandAttempt(parsed, withoutPathExt) { + const env = parsed.options.env || process.env; const cwd = process.cwd(); const hasCustomCwd = parsed.options.cwd != null; // Worker threads do not have process.chdir() @@ -24,7 +25,7 @@ function resolveCommandAttempt(parsed, withoutPathExt) { try { resolved = which.sync(parsed.command, { - path: (parsed.options.env || process.env)[pathKey], + path: env[getPathKey({ env })], pathExt: withoutPathExt ? path.delimiter : undefined, }); } catch (e) { diff --git a/tools/node_modules/eslint/node_modules/cross-spawn/package.json b/tools/node_modules/eslint/node_modules/cross-spawn/package.json index cc4588cec1e990..5ed16e25e312a4 100644 --- a/tools/node_modules/eslint/node_modules/cross-spawn/package.json +++ b/tools/node_modules/eslint/node_modules/cross-spawn/package.json @@ -77,5 +77,5 @@ "release": "standard-version", "test": "jest --env node --coverage" }, - "version": "7.0.2" + "version": "7.0.3" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/eslint-scope/lib/referencer.js b/tools/node_modules/eslint/node_modules/eslint-scope/lib/referencer.js index 29f853293361d0..63d1935b3a957f 100644 --- a/tools/node_modules/eslint/node_modules/eslint-scope/lib/referencer.js +++ b/tools/node_modules/eslint/node_modules/eslint-scope/lib/referencer.js @@ -593,15 +593,26 @@ class Referencer extends esrecurse.Visitor { this.visitChildren(node); } + // TODO: ExportDeclaration doesn't exist. for bc? ExportDeclaration(node) { this.visitExportDeclaration(node); } + ExportAllDeclaration(node) { + this.visitExportDeclaration(node); + } + + ExportDefaultDeclaration(node) { + this.visitExportDeclaration(node); + } + ExportNamedDeclaration(node) { this.visitExportDeclaration(node); } ExportSpecifier(node) { + + // TODO: `node.id` doesn't exist. for bc? const local = (node.id || node.local); this.visit(local); diff --git a/tools/node_modules/eslint/node_modules/eslint-scope/package.json b/tools/node_modules/eslint/node_modules/eslint-scope/package.json index 1c7fa4450b0c9c..b39dbae1cc391c 100644 --- a/tools/node_modules/eslint/node_modules/eslint-scope/package.json +++ b/tools/node_modules/eslint/node_modules/eslint-scope/package.json @@ -16,7 +16,8 @@ "eslint-config-eslint": "^5.0.1", "eslint-plugin-node": "^9.1.0", "eslint-release": "^1.0.0", - "espree": "^6.0.0", + "eslint-visitor-keys": "^1.2.0", + "espree": "^7.1.0", "istanbul": "^0.4.5", "mocha": "^6.1.4", "npm-license": "^0.3.3", @@ -48,5 +49,5 @@ "publish-release": "eslint-publish-release", "test": "node Makefile.js test" }, - "version": "5.0.0" + "version": "5.1.0" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.json b/tools/node_modules/eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.json index d31b7b29439a13..e77fb9e4253be6 100644 --- a/tools/node_modules/eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.json +++ b/tools/node_modules/eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.json @@ -66,6 +66,7 @@ ], "EmptyStatement": [], "ExportAllDeclaration": [ + "exported", "source" ], "ExportDefaultDeclaration": [ diff --git a/tools/node_modules/eslint/node_modules/eslint-visitor-keys/package.json b/tools/node_modules/eslint/node_modules/eslint-visitor-keys/package.json index 68eec940691e0b..12384fc9a4cf8e 100644 --- a/tools/node_modules/eslint/node_modules/eslint-visitor-keys/package.json +++ b/tools/node_modules/eslint/node_modules/eslint-visitor-keys/package.json @@ -44,5 +44,5 @@ "publish-release": "eslint-publish-release", "test": "nyc mocha tests/lib" }, - "version": "1.1.0" + "version": "1.2.0" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/espree/package.json b/tools/node_modules/eslint/node_modules/espree/package.json index 5f7f545e8785a3..89b04e6f28707c 100644 --- a/tools/node_modules/eslint/node_modules/espree/package.json +++ b/tools/node_modules/eslint/node_modules/espree/package.json @@ -8,9 +8,9 @@ }, "bundleDependencies": false, "dependencies": { - "acorn": "^7.1.1", + "acorn": "^7.2.0", "acorn-jsx": "^5.2.0", - "eslint-visitor-keys": "^1.1.0" + "eslint-visitor-keys": "^1.2.0" }, "deprecated": false, "description": "An Esprima-compatible JavaScript parser built on Acorn", @@ -57,6 +57,7 @@ }, "scripts": { "browserify": "node Makefile.js browserify", + "fixlint": "node Makefile.js lint --fix", "generate-alpharelease": "eslint-generate-prerelease alpha", "generate-betarelease": "eslint-generate-prerelease beta", "generate-rcrelease": "eslint-generate-prerelease rc", @@ -67,5 +68,5 @@ "sync-docs": "node Makefile.js docs", "test": "npm run-script lint && node Makefile.js test" }, - "version": "7.0.0" + "version": "7.1.0" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/v8-compile-cache/package.json b/tools/node_modules/eslint/node_modules/v8-compile-cache/package.json index ee9b001b78754b..83d66522f04c29 100644 --- a/tools/node_modules/eslint/node_modules/v8-compile-cache/package.json +++ b/tools/node_modules/eslint/node_modules/v8-compile-cache/package.json @@ -38,5 +38,5 @@ "posttest": "npm run lint", "test": "tap test/*-test.js" }, - "version": "2.1.0" + "version": "2.1.1" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/v8-compile-cache/v8-compile-cache.js b/tools/node_modules/eslint/node_modules/v8-compile-cache/v8-compile-cache.js index bd755d657d9ac7..69f053667046ca 100644 --- a/tools/node_modules/eslint/node_modules/v8-compile-cache/v8-compile-cache.js +++ b/tools/node_modules/eslint/node_modules/v8-compile-cache/v8-compile-cache.js @@ -272,7 +272,7 @@ class NativeCompileCache { //------------------------------------------------------------------------------ function mkdirpSync(p_) { - _mkdirpSync(path.resolve(p_), parseInt('0777', 8) & ~process.umask()); + _mkdirpSync(path.resolve(p_), 0o777); } function _mkdirpSync(p, mode) { diff --git a/tools/node_modules/eslint/package.json b/tools/node_modules/eslint/package.json index f5d0ed08f0aa90..0422546fb1ecdc 100644 --- a/tools/node_modules/eslint/package.json +++ b/tools/node_modules/eslint/package.json @@ -18,10 +18,10 @@ "debug": "^4.0.1", "doctrine": "^3.0.0", "eslint-plugin-markdown": "^1.0.2", - "eslint-scope": "^5.0.0", + "eslint-scope": "^5.1.0", "eslint-utils": "^2.0.0", - "eslint-visitor-keys": "^1.1.0", - "espree": "^7.0.0", + "eslint-visitor-keys": "^1.2.0", + "espree": "^7.1.0", "esquery": "^1.2.0", "esutils": "^2.0.2", "file-entry-cache": "^5.0.1", @@ -54,7 +54,7 @@ "devDependencies": { "@babel/core": "^7.4.3", "@babel/preset-env": "^7.4.3", - "acorn": "^7.1.1", + "acorn": "^7.2.0", "babel-loader": "^8.0.5", "chai": "^4.0.1", "cheerio": "^0.22.0", @@ -153,5 +153,5 @@ "test:cli": "mocha", "webpack": "node Makefile.js webpack" }, - "version": "7.1.0" + "version": "7.2.0" } \ No newline at end of file