From e4ffa741201a19146b7d81b3cff0508286096edb Mon Sep 17 00:00:00 2001 From: "Node.js GitHub Bot" Date: Sun, 20 Nov 2022 00:30:47 +0000 Subject: [PATCH] tools: update eslint to 8.28.0 --- .../eslint/lib/eslint/eslint-helpers.js | 192 +++--------------- .../eslint/lib/rules/for-direction.js | 2 +- .../eslint/lib/rules/key-spacing.js | 32 +-- .../eslint/lib/rules/no-implicit-coercion.js | 21 +- .../eslint/lib/rules/no-magic-numbers.js | 19 +- .../eslint/lib/rules/no-obj-calls.js | 2 +- .../eslint/lib/rules/prefer-object-spread.js | 2 +- .../eslint/lib/shared/runtime-info.js | 2 +- .../generator/lib/generators/expressions.js | 3 - .../generator/lib/generators/methods.js | 23 +-- .../@babel/generator/lib/printer.js | 49 +++-- .../@babel/generator/package.json | 4 +- .../node_modules/@babel/parser/lib/index.js | 49 +---- .../node_modules/@babel/parser/package.json | 2 +- .../eslint/node_modules/globals/globals.json | 1 + .../eslint/node_modules/globals/package.json | 2 +- tools/node_modules/eslint/package.json | 2 +- 17 files changed, 123 insertions(+), 284 deletions(-) diff --git a/tools/node_modules/eslint/lib/eslint/eslint-helpers.js b/tools/node_modules/eslint/lib/eslint/eslint-helpers.js index 0b155ebad2310e..5c5ed299c68088 100644 --- a/tools/node_modules/eslint/lib/eslint/eslint-helpers.js +++ b/tools/node_modules/eslint/lib/eslint/eslint-helpers.js @@ -26,6 +26,7 @@ const isPathInside = require("is-path-inside"); const doFsWalk = util.promisify(fswalk.walk); const Minimatch = minimatch.Minimatch; +const MINIMATCH_OPTIONS = { dot: true }; //----------------------------------------------------------------------------- // Types @@ -76,7 +77,7 @@ class UnmatchedSearchPatternsError extends Error { constructor({ basePath, unmatchedPatterns, patterns, rawPatterns }) { super(`No files matching '${rawPatterns}' in '${basePath}' were found.`); this.basePath = basePath; - this.patternsToCheck = unmatchedPatterns; + this.unmatchedPatterns = unmatchedPatterns; this.patterns = patterns; this.rawPatterns = rawPatterns; } @@ -158,7 +159,7 @@ function globMatch({ basePath, pattern }) { ? normalizeToPosix(path.relative(basePath, pattern)) : pattern; - const matcher = new Minimatch(patternToUse); + const matcher = new Minimatch(patternToUse, MINIMATCH_OPTIONS); const fsWalkSettings = { @@ -257,7 +258,7 @@ async function globSearch({ relativeToPatterns.set(patternToUse, patterns[i]); - return new minimatch.Minimatch(patternToUse); + return new Minimatch(patternToUse, MINIMATCH_OPTIONS); }); /* @@ -337,49 +338,43 @@ async function globSearch({ } /** - * Checks to see if there are any ignored results for a given search. This - * happens either when there are unmatched patterns during a search or if - * a search returns no results. + * Throws an error for unmatched patterns. The error will only contain information about the first one. + * Checks to see if there are any ignored results for a given search. * @param {Object} options The options for this function. * @param {string} options.basePath The directory to search. * @param {Array} options.patterns An array of glob patterns * that were used in the original search. * @param {Array} options.rawPatterns An array of glob patterns * as the user inputted them. Used for errors. - * @param {Array} options.patternsToCheck An array of glob patterns - * to use for this check. - * @returns {void} - * @throws {NoFilesFoundError} If there is a pattern that doesn't match - * any files and `errorOnUnmatchedPattern` is true. - * @throws {AllFilesIgnoredError} If there is a pattern that matches files - * when there are no ignores. + * @param {Array} options.unmatchedPatterns A non-empty array of glob patterns + * that were unmatched in the original search. + * @returns {void} Always throws an error. + * @throws {NoFilesFoundError} If the first unmatched pattern + * doesn't match any files even when there are no ignores. + * @throws {AllFilesIgnoredError} If the first unmatched pattern + * matches some files when there are no ignores. */ -async function checkForIgnoredResults({ +async function throwErrorForUnmatchedPatterns({ basePath, patterns, rawPatterns, - patternsToCheck = patterns + unmatchedPatterns }) { - for (const pattern of patternsToCheck) { + const pattern = unmatchedPatterns[0]; + const rawPattern = rawPatterns[patterns.indexOf(pattern)]; - const patternHasMatch = await globMatch({ - basePath, - pattern - }); + const patternHasMatch = await globMatch({ + basePath, + pattern + }); - if (patternHasMatch) { - throw new AllFilesIgnoredError( - rawPatterns[patterns.indexOf(pattern)] - ); - } + if (patternHasMatch) { + throw new AllFilesIgnoredError(rawPattern); } // if we get here there are truly no matches - throw new NoFilesFoundError( - rawPatterns[patterns.indexOf(patternsToCheck[0])], - true - ); + throw new NoFilesFoundError(rawPattern, true); } /** @@ -446,9 +441,9 @@ async function globMultiSearch({ searches, configs, errorOnUnmatchedPattern }) { if (errorOnUnmatchedPattern) { - await checkForIgnoredResults({ + await throwErrorForUnmatchedPatterns({ ...currentSearch, - patternsToCheck: error.patternsToCheck + unmatchedPatterns: error.unmatchedPatterns }); } @@ -459,141 +454,6 @@ async function globMultiSearch({ searches, configs, errorOnUnmatchedPattern }) { } -/** - * Searches a directory looking for matching glob patterns. This uses - * the config array's logic to determine if a directory or file should - * be ignored, so it is consistent with how ignoring works throughout - * ESLint. - * @param {Object} options The options for this function. - * @param {string} options.basePath The directory to search. - * @param {Array} options.patterns An array of glob patterns - * to match. - * @param {FlatConfigArray} options.configs The config array to use for - * determining what to ignore. - * @returns {Promise>} An array of matching file paths - * or an empty array if there are no matches. - */ -async function globSearch({ basePath, patterns, configs }) { - - if (patterns.length === 0) { - return []; - } - - const matchers = patterns.map(pattern => { - const patternToUse = path.isAbsolute(pattern) - ? normalizeToPosix(path.relative(basePath, pattern)) - : pattern; - - return new minimatch.Minimatch(patternToUse); - }); - - return (await doFsWalk(basePath, { - - deepFilter(entry) { - const relativePath = normalizeToPosix(path.relative(basePath, entry.path)); - const matchesPattern = matchers.some(matcher => matcher.match(relativePath, true)); - - return matchesPattern && !configs.isDirectoryIgnored(entry.path); - }, - entryFilter(entry) { - const relativePath = normalizeToPosix(path.relative(basePath, entry.path)); - - // entries may be directories or files so filter out directories - if (entry.dirent.isDirectory()) { - return false; - } - - const matchesPattern = matchers.some(matcher => matcher.match(relativePath)); - - return matchesPattern && !configs.isFileIgnored(entry.path); - } - })).map(entry => entry.path); - -} - -/** - * Performs multiple glob searches in parallel. - * @param {Object} options The options for this function. - * @param {Array<{patterns:Array,rawPatterns:Array}>} options.searches - * An array of glob patterns to match. - * @param {FlatConfigArray} options.configs The config array to use for - * determining what to ignore. - * @returns {Promise>} An array of matching file paths - * or an empty array if there are no matches. - */ -async function globMultiSearch({ searches, configs }) { - - const results = await Promise.all( - [...searches].map( - ([basePath, { patterns }]) => globSearch({ basePath, patterns, configs }) - ) - ); - - return [...new Set(results.flat())]; -} - -/** - * Determines if a given glob pattern will return any results. - * Used primarily to help with useful error messages. - * @param {Object} options The options for the function. - * @param {string} options.basePath The directory to search. - * @param {string} options.pattern A glob pattern to match. - * @returns {Promise} True if there is a glob match, false if not. - */ -function globMatch({ basePath, pattern }) { - - let found = false; - const patternToUse = path.isAbsolute(pattern) - ? normalizeToPosix(path.relative(basePath, pattern)) - : pattern; - - const matcher = new Minimatch(patternToUse); - - const fsWalkSettings = { - - deepFilter(entry) { - const relativePath = normalizeToPosix(path.relative(basePath, entry.path)); - - return !found && matcher.match(relativePath, true); - }, - - entryFilter(entry) { - if (found || entry.dirent.isDirectory()) { - return false; - } - - const relativePath = normalizeToPosix(path.relative(basePath, entry.path)); - - if (matcher.match(relativePath)) { - found = true; - return true; - } - - return false; - } - }; - - return new Promise(resolve => { - - // using a stream so we can exit early because we just need one match - const globStream = fswalk.walkStream(basePath, fsWalkSettings); - - globStream.on("data", () => { - globStream.destroy(); - resolve(true); - }); - - // swallow errors as they're not important here - globStream.on("error", () => {}); - - globStream.on("end", () => { - resolve(false); - }); - globStream.read(); - }); - -} - /** * Finds all files matching the options specified. * @param {Object} args The arguments objects. diff --git a/tools/node_modules/eslint/lib/rules/for-direction.js b/tools/node_modules/eslint/lib/rules/for-direction.js index 7df3d7e4802819..5507a9a1f32c39 100644 --- a/tools/node_modules/eslint/lib/rules/for-direction.js +++ b/tools/node_modules/eslint/lib/rules/for-direction.js @@ -15,7 +15,7 @@ module.exports = { type: "problem", docs: { - description: "Enforce \"for\" loop update clause moving the counter in the right direction.", + description: "Enforce \"for\" loop update clause moving the counter in the right direction", recommended: true, url: "https://eslint.org/docs/rules/for-direction" }, diff --git a/tools/node_modules/eslint/lib/rules/key-spacing.js b/tools/node_modules/eslint/lib/rules/key-spacing.js index b764b7282ef831..083a7e62898bd3 100644 --- a/tools/node_modules/eslint/lib/rules/key-spacing.js +++ b/tools/node_modules/eslint/lib/rules/key-spacing.js @@ -334,6 +334,19 @@ module.exports = { const sourceCode = context.getSourceCode(); + /** + * Determines if the given property is key-value property. + * @param {ASTNode} property Property node to check. + * @returns {boolean} Whether the property is a key-value property. + */ + function isKeyValueProperty(property) { + return !( + (property.method || + property.shorthand || + property.kind !== "init" || property.type !== "Property") // Could be "ExperimentalSpreadProperty" or "SpreadElement" + ); + } + /** * Checks whether a property is a member of the property group it follows. * @param {ASTNode} lastMember The last Property known to be in the group. @@ -342,9 +355,9 @@ module.exports = { */ function continuesPropertyGroup(lastMember, candidate) { const groupEndLine = lastMember.loc.start.line, - candidateStartLine = candidate.loc.start.line; + candidateValueStartLine = (isKeyValueProperty(candidate) ? candidate.value : candidate).loc.start.line; - if (candidateStartLine - groupEndLine <= 1) { + if (candidateValueStartLine - groupEndLine <= 1) { return true; } @@ -358,7 +371,7 @@ module.exports = { if ( leadingComments.length && leadingComments[0].loc.start.line - groupEndLine <= 1 && - candidateStartLine - last(leadingComments).loc.end.line <= 1 + candidateValueStartLine - last(leadingComments).loc.end.line <= 1 ) { for (let i = 1; i < leadingComments.length; i++) { if (leadingComments[i].loc.start.line - leadingComments[i - 1].loc.end.line > 1) { @@ -371,19 +384,6 @@ module.exports = { return false; } - /** - * Determines if the given property is key-value property. - * @param {ASTNode} property Property node to check. - * @returns {boolean} Whether the property is a key-value property. - */ - function isKeyValueProperty(property) { - return !( - (property.method || - property.shorthand || - property.kind !== "init" || property.type !== "Property") // Could be "ExperimentalSpreadProperty" or "SpreadElement" - ); - } - /** * Starting from the given a node (a property.key node here) looks forward * until it finds the last token before a colon punctuator and returns it. diff --git a/tools/node_modules/eslint/lib/rules/no-implicit-coercion.js b/tools/node_modules/eslint/lib/rules/no-implicit-coercion.js index c2367715d9da7d..d4126112597b4e 100644 --- a/tools/node_modules/eslint/lib/rules/no-implicit-coercion.js +++ b/tools/node_modules/eslint/lib/rules/no-implicit-coercion.js @@ -71,6 +71,24 @@ function isMultiplyByOne(node) { ); } +/** + * Checks whether the given node logically represents multiplication by a fraction of `1`. + * For example, `a * 1` in `a * 1 / b` is technically multiplication by `1`, but the + * whole expression can be logically interpreted as `a * (1 / b)` rather than `(a * 1) / b`. + * @param {BinaryExpression} node A BinaryExpression node to check. + * @param {SourceCode} sourceCode The source code object. + * @returns {boolean} Whether or not the node is a multiplying by a fraction of `1`. + */ +function isMultiplyByFractionOfOne(node, sourceCode) { + return node.type === "BinaryExpression" && + node.operator === "*" && + (node.right.type === "Literal" && node.right.value === 1) && + node.parent.type === "BinaryExpression" && + node.parent.operator === "/" && + node.parent.left === node && + !astUtils.isParenthesised(sourceCode, node); +} + /** * Checks whether the result of a node is numeric or not * @param {ASTNode} node The node to test @@ -290,7 +308,8 @@ module.exports = { // 1 * foo operatorAllowed = options.allow.includes("*"); - const nonNumericOperand = !operatorAllowed && options.number && isMultiplyByOne(node) && getNonNumericOperand(node); + const nonNumericOperand = !operatorAllowed && options.number && isMultiplyByOne(node) && !isMultiplyByFractionOfOne(node, sourceCode) && + getNonNumericOperand(node); if (nonNumericOperand) { const recommendation = `Number(${sourceCode.getText(nonNumericOperand)})`; diff --git a/tools/node_modules/eslint/lib/rules/no-magic-numbers.js b/tools/node_modules/eslint/lib/rules/no-magic-numbers.js index 9b08588155652f..786e595220a046 100644 --- a/tools/node_modules/eslint/lib/rules/no-magic-numbers.js +++ b/tools/node_modules/eslint/lib/rules/no-magic-numbers.js @@ -65,6 +65,10 @@ module.exports = { ignoreDefaultValues: { type: "boolean", default: false + }, + ignoreClassFieldInitialValues: { + type: "boolean", + default: false } }, additionalProperties: false @@ -82,7 +86,8 @@ module.exports = { enforceConst = !!config.enforceConst, ignore = new Set((config.ignore || []).map(normalizeIgnoreValue)), ignoreArrayIndexes = !!config.ignoreArrayIndexes, - ignoreDefaultValues = !!config.ignoreDefaultValues; + ignoreDefaultValues = !!config.ignoreDefaultValues, + ignoreClassFieldInitialValues = !!config.ignoreClassFieldInitialValues; const okTypes = detectObjects ? [] : ["ObjectExpression", "Property", "AssignmentExpression"]; @@ -106,6 +111,17 @@ module.exports = { return parent.type === "AssignmentPattern" && parent.right === fullNumberNode; } + /** + * Returns whether the number is the initial value of a class field. + * @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node + * @returns {boolean} true if the number is the initial value of a class field. + */ + function isClassFieldInitialValue(fullNumberNode) { + const parent = fullNumberNode.parent; + + return parent.type === "PropertyDefinition" && parent.value === fullNumberNode; + } + /** * Returns whether the given node is used as a radix within parseInt() or Number.parseInt() * @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node @@ -194,6 +210,7 @@ module.exports = { if ( isIgnoredValue(value) || (ignoreDefaultValues && isDefaultValue(fullNumberNode)) || + (ignoreClassFieldInitialValues && isClassFieldInitialValue(fullNumberNode)) || isParseIntRadix(fullNumberNode) || isJSXNumber(fullNumberNode) || (ignoreArrayIndexes && isArrayIndex(fullNumberNode, value)) diff --git a/tools/node_modules/eslint/lib/rules/no-obj-calls.js b/tools/node_modules/eslint/lib/rules/no-obj-calls.js index 86355d85d36aad..d24d28589f3b5c 100644 --- a/tools/node_modules/eslint/lib/rules/no-obj-calls.js +++ b/tools/node_modules/eslint/lib/rules/no-obj-calls.js @@ -16,7 +16,7 @@ const getPropertyName = require("./utils/ast-utils").getStaticPropertyName; // Helpers //------------------------------------------------------------------------------ -const nonCallableGlobals = ["Atomics", "JSON", "Math", "Reflect"]; +const nonCallableGlobals = ["Atomics", "JSON", "Math", "Reflect", "Intl"]; /** * Returns the name of the node to report diff --git a/tools/node_modules/eslint/lib/rules/prefer-object-spread.js b/tools/node_modules/eslint/lib/rules/prefer-object-spread.js index 08192001a2b8d7..7d8f7857b3c3ac 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-object-spread.js +++ b/tools/node_modules/eslint/lib/rules/prefer-object-spread.js @@ -247,7 +247,7 @@ module.exports = { docs: { description: - "Disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead.", + "Disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead", recommended: false, url: "https://eslint.org/docs/rules/prefer-object-spread" }, diff --git a/tools/node_modules/eslint/lib/shared/runtime-info.js b/tools/node_modules/eslint/lib/shared/runtime-info.js index 56c0898be5475c..b99ad1038f3931 100644 --- a/tools/node_modules/eslint/lib/shared/runtime-info.js +++ b/tools/node_modules/eslint/lib/shared/runtime-info.js @@ -97,7 +97,7 @@ function environment() { */ function getNpmPackageVersion(pkg, { global = false } = {}) { const npmBinArgs = ["bin", "-g"]; - const npmLsArgs = ["ls", "--depth=0", "--json", "eslint"]; + const npmLsArgs = ["ls", "--depth=0", "--json", pkg]; if (global) { npmLsArgs.push("-g"); diff --git a/tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/expressions.js b/tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/expressions.js index 678d55b7d0cf17..f35a2891474aae 100644 --- a/tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/expressions.js +++ b/tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/expressions.js @@ -196,9 +196,6 @@ function AwaitExpression(node) { function YieldExpression(node) { this.word("yield", true); if (node.delegate) { - this.ensureNoLineTerminator(() => { - this.printInnerComments(node); - }); this.tokenChar(42); if (node.argument) { this.space(); diff --git a/tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/methods.js b/tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/methods.js index 238d64bcbd20a4..f0784729eb5d95 100644 --- a/tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/methods.js +++ b/tools/node_modules/eslint/node_modules/@babel/generator/lib/generators/methods.js @@ -20,8 +20,9 @@ function _params(node) { this.tokenChar(40); this._parameters(node.params, node); this.tokenChar(41); - this._noLineTerminator = true; - this.print(node.returnType, node, node.type === "ArrowFunctionExpression"); + const noLineTerminator = node.type === "ArrowFunctionExpression"; + this.print(node.returnType, node, noLineTerminator); + this._noLineTerminator = noLineTerminator; } function _parameters(parameters, parent) { const paramLength = parameters.length; @@ -32,10 +33,6 @@ function _parameters(parameters, parent) { this.space(); } } - - if (paramLength === 0) { - this.printInnerComments(parent); - } } function _param(parameter, parent) { this.printJoin(parameter.decorators, parameter); @@ -63,23 +60,15 @@ function _methodHead(node) { if (kind === "method" || kind === "init") { if (node.generator) { - if (node.async) { - this.printInnerComments(node); - } - this.tokenChar(42); - this._noLineTerminator = _noLineTerminator; } } if (node.computed) { this.tokenChar(91); - this._noLineTerminator = _noLineTerminator; this.print(key, node); this.tokenChar(93); - this.printInnerComments(node); } else { this.print(key, node); - this._noLineTerminator = _noLineTerminator; } if ( node.optional) { @@ -122,10 +111,6 @@ function FunctionExpression(node) { this.print(node.body, node); } function ArrowFunctionExpression(node) { - const { - _noLineTerminator - } = this; - if (node.async) { this.word("async", true); this.space(); @@ -135,8 +120,6 @@ function ArrowFunctionExpression(node) { if (!this.format.retainLines && node.params.length === 1 && isIdentifier(firstParam = node.params[0]) && !hasTypesOrComments(node, firstParam)) { this.print(firstParam, node, true); } else { - this._noLineTerminator = _noLineTerminator; - this._params(node); } this._predicate(node, true); diff --git a/tools/node_modules/eslint/node_modules/@babel/generator/lib/printer.js b/tools/node_modules/eslint/node_modules/@babel/generator/lib/printer.js index 8f0563af0ff86a..ac21d2c1d6f966 100644 --- a/tools/node_modules/eslint/node_modules/@babel/generator/lib/printer.js +++ b/tools/node_modules/eslint/node_modules/@babel/generator/lib/printer.js @@ -19,6 +19,7 @@ const ZERO_DECIMAL_INTEGER = /\.0+$/; const NON_DECIMAL_LITERAL = /^0[box]/; const PURE_ANNOTATION_RE = /^\s*[@#]__PURE__\s*$/; const HAS_NEWLINE = /[\n\r\u2028\u2029]/; +const HAS_BlOCK_COMMENT_END = /\*\//; const { needsParens } = n; @@ -435,9 +436,16 @@ class Printer { this.print(node, parent); } _printTrailingComments(node, parent, lineOffset) { - const comments = node.trailingComments; - if (!(comments != null && comments.length)) return; - this._printComments(2, comments, node, parent, lineOffset); + const { + innerComments, + trailingComments + } = node; + if (innerComments != null && innerComments.length) { + this._printComments(2, innerComments, node, parent, lineOffset); + } + if (trailingComments != null && trailingComments.length) { + this._printComments(2, trailingComments, node, parent, lineOffset); + } } _printLeadingComments(node, parent) { const comments = node.leadingComments; @@ -505,7 +513,8 @@ class Printer { _printComment(comment, skipNewLines) { if (comment.ignore) return false; if (this._printedComments.has(comment)) return false; - if (this._noLineTerminator && HAS_NEWLINE.test(comment.value)) { + const noLineTerminator = this._noLineTerminator; + if (noLineTerminator && (HAS_NEWLINE.test(comment.value) || HAS_BlOCK_COMMENT_END.test(comment.value))) { return true; } if (!this.format.shouldPrintComment(comment.value)) return false; @@ -536,7 +545,7 @@ class Printer { } val = val.replace(/\n(?!$)/g, `\n${" ".repeat(indentSize)}`); } - } else if (!this._noLineTerminator) { + } else if (!noLineTerminator) { val = `//${comment.value}`; } else { val = `/*${comment.value}*/`; @@ -545,7 +554,7 @@ class Printer { if (this.endsWith(47)) this._space(); this.source("start", comment.loc); this._append(val, isBlockComment); - if (!isBlockComment && !this._noLineTerminator) { + if (!isBlockComment && !noLineTerminator) { this.newline(1, true); } if (printNewLines && skipNewLines !== 3) { @@ -561,12 +570,11 @@ class Printer { const nodeEndLine = hasLoc ? nodeLoc.end.line : 0; let lastLine = 0; let leadingCommentNewline = 0; - const { - _noLineTerminator - } = this; + const maybeNewline = this._noLineTerminator ? function () {} : this.newline.bind(this); for (let i = 0; i < len; i++) { const comment = comments[i]; - if (hasLoc && comment.loc && !this._printedComments.has(comment)) { + const printed = this._printedComments.has(comment); + if (hasLoc && comment.loc && !printed) { const commentStartLine = comment.loc.start.line; const commentEndLine = comment.loc.end.line; if (type === 0) { @@ -579,31 +587,32 @@ class Printer { offset = commentStartLine - lastLine; } lastLine = commentEndLine; - if (!_noLineTerminator) this.newline(offset); + maybeNewline(offset); this._printComment(comment, 1); - if (!_noLineTerminator && i + 1 === len) { - this.newline(Math.max(nodeStartLine - lastLine, leadingCommentNewline)); + if (i + 1 === len) { + maybeNewline(Math.max(nodeStartLine - lastLine, leadingCommentNewline)); lastLine = nodeStartLine; } } else if (type === 1) { const offset = commentStartLine - (i === 0 ? nodeStartLine : lastLine); lastLine = commentEndLine; - if (!_noLineTerminator) this.newline(offset); + maybeNewline(offset); if (this._printComment(comment, 1)) break; - if (!_noLineTerminator && i + 1 === len) { - this.newline(Math.min(1, nodeEndLine - lastLine)); + if (i + 1 === len) { + maybeNewline(Math.min(1, nodeEndLine - lastLine)); lastLine = nodeEndLine; } } else { const offset = commentStartLine - (i === 0 ? nodeEndLine - lineOffset : lastLine); lastLine = commentEndLine; - if (!_noLineTerminator) this.newline(offset); + maybeNewline(offset); this._printComment(comment, 1); } } else { hasLoc = false; + if (printed) continue; if (len === 1) { - const singleLine = comment.loc ? comment.loc.start.line === comment.loc.end.line : !comment.value.includes("\n"); + const singleLine = comment.loc ? comment.loc.start.line === comment.loc.end.line : !HAS_NEWLINE.test(comment.value); const shouldSkipNewline = singleLine && !isStatement(node) && !isClassBody(parent) && !isTSInterfaceBody(parent); if (type === 0) { this._printComment(comment, shouldSkipNewline && node.type !== "ObjectExpression" || singleLine && isFunction(parent, { @@ -618,8 +627,8 @@ class Printer { } } else if (type === 1 && !(node.type === "ObjectExpression" && node.properties.length > 1) && node.type !== "ClassBody" && node.type !== "TSInterfaceBody") { - const skippedDueToNewlie = this._printComment(comment, i === 0 ? 2 : i === len - 1 ? 3 : 0); - if (skippedDueToNewlie) break; + const skippedDueToNewline = this._printComment(comment, i === 0 ? 2 : i === len - 1 ? 3 : 0); + if (skippedDueToNewline) break; } else { this._printComment(comment, 0); } diff --git a/tools/node_modules/eslint/node_modules/@babel/generator/package.json b/tools/node_modules/eslint/node_modules/@babel/generator/package.json index 7fd3ca39a32990..92eff1787bb6c9 100644 --- a/tools/node_modules/eslint/node_modules/@babel/generator/package.json +++ b/tools/node_modules/eslint/node_modules/@babel/generator/package.json @@ -1,6 +1,6 @@ { "name": "@babel/generator", - "version": "7.20.2", + "version": "7.20.4", "description": "Turns an AST into code.", "author": "The Babel Team (https://babel.dev/team)", "license": "MIT", @@ -25,7 +25,7 @@ }, "devDependencies": { "@babel/helper-fixtures": "^7.19.4", - "@babel/parser": "^7.20.2", + "@babel/parser": "^7.20.3", "@jridgewell/trace-mapping": "^0.3.8", "@types/jsesc": "^2.5.0", "charcodes": "^0.2.0" diff --git a/tools/node_modules/eslint/node_modules/@babel/parser/lib/index.js b/tools/node_modules/eslint/node_modules/@babel/parser/lib/index.js index ed02fddb0c32b8..a7eb4788ced826 100644 --- a/tools/node_modules/eslint/node_modules/@babel/parser/lib/index.js +++ b/tools/node_modules/eslint/node_modules/@babel/parser/lib/index.js @@ -9104,16 +9104,6 @@ var typescript = (superClass => class TypeScriptParserMixin extends superClass { } } - checkImportReflection(node) { - super.checkImportReflection(node); - - if (node.module && node.importKind !== "value") { - this.raise(TSErrors.ImportReflectionHasImportType, { - at: node.specifiers[0].loc.start - }); - } - } - checkDuplicateExports() {} parseImport(node) { node.importKind = "value"; @@ -12513,7 +12503,7 @@ class ExpressionParser extends LValParser { type } = this.state; return ( - type === 53 || type === 10 || type === 0 || tokenIsTemplate(type) || + type === 53 || type === 10 || type === 0 || tokenIsTemplate(type) || type === 101 && !this.state.containsEsc || type === 135 || type === 56 || this.hasPlugin("v8intrinsic") && type === 54 ); @@ -12926,13 +12916,6 @@ class StatementParser extends ExpressionParser { } return this.parseStatementContent(context, topLevel, decorators); } - parseStatementContent(context, topLevel, decorators) { - const starttype = this.state.type; - const node = this.startNode(); - - return this.parseStatementContent(context, topLevel, decorators); - } - parseStatementContent(context, topLevel, decorators) { const starttype = this.state.type; const node = this.startNode(); @@ -14470,36 +14453,6 @@ class StatementParser extends ExpressionParser { } } - parseMaybeImportReflection(node) { - let isImportReflection = false; - - if (this.isContextual(125)) { - const lookahead = this.lookahead(); - - if (tokenIsIdentifier(lookahead.type)) { - if (lookahead.type !== 97) { - isImportReflection = true; - } else { - const nextNextTokenFirstChar = this.input.charCodeAt(this.nextTokenStartSince(lookahead.end)); - - if (nextNextTokenFirstChar === 102) { - isImportReflection = true; - } - } - } else { - isImportReflection = true; - } - } - - if (isImportReflection) { - this.expectPlugin("importReflection"); - this.next(); - node.module = true; - } else if (this.hasPlugin("importReflection")) { - node.module = false; - } - } - parseImport(node) { node.specifiers = []; if (!this.match(131)) { diff --git a/tools/node_modules/eslint/node_modules/@babel/parser/package.json b/tools/node_modules/eslint/node_modules/@babel/parser/package.json index 0f4b38509b3fb5..e6a066820ff4f7 100644 --- a/tools/node_modules/eslint/node_modules/@babel/parser/package.json +++ b/tools/node_modules/eslint/node_modules/@babel/parser/package.json @@ -1,6 +1,6 @@ { "name": "@babel/parser", - "version": "7.20.2", + "version": "7.20.3", "description": "A JavaScript parser", "author": "The Babel Team (https://babel.dev/team)", "homepage": "https://babel.dev/docs/en/next/babel-parser", diff --git a/tools/node_modules/eslint/node_modules/globals/globals.json b/tools/node_modules/eslint/node_modules/globals/globals.json index c24ab96c4e9e36..852146428a84a6 100644 --- a/tools/node_modules/eslint/node_modules/globals/globals.json +++ b/tools/node_modules/eslint/node_modules/globals/globals.json @@ -419,6 +419,7 @@ "clearTimeout": false, "clientInformation": false, "ClipboardEvent": false, + "ClipboardItem": false, "close": false, "closed": false, "CloseEvent": false, diff --git a/tools/node_modules/eslint/node_modules/globals/package.json b/tools/node_modules/eslint/node_modules/globals/package.json index f38232e920e85a..9bf09ed00775d0 100644 --- a/tools/node_modules/eslint/node_modules/globals/package.json +++ b/tools/node_modules/eslint/node_modules/globals/package.json @@ -1,6 +1,6 @@ { "name": "globals", - "version": "13.17.0", + "version": "13.18.0", "description": "Global identifiers from different JavaScript environments", "license": "MIT", "repository": "sindresorhus/globals", diff --git a/tools/node_modules/eslint/package.json b/tools/node_modules/eslint/package.json index 7f4be8cf48aaac..9a6b1799dcd8cb 100644 --- a/tools/node_modules/eslint/package.json +++ b/tools/node_modules/eslint/package.json @@ -1,6 +1,6 @@ { "name": "eslint", - "version": "8.27.0", + "version": "8.28.0", "author": "Nicholas C. Zakas ", "description": "An AST-based pattern checker for JavaScript.", "bin": {