From 12254ce242c30d403b523ad9adb60a0280080957 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 2 Dec 2019 05:26:39 -0800 Subject: [PATCH] tools: update ESLint to 6.7.2 PR-URL: https://github.com/nodejs/node/pull/30762 Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat --- tools/node_modules/eslint/README.md | 2 +- .../eslint/lib/cli-engine/file-enumerator.js | 18 +++- .../lib/rules/no-unexpected-multiline.js | 8 ++ .../eslint/lib/source-code/source-code.js | 82 +++++++++++++------ tools/node_modules/eslint/package.json | 2 +- 5 files changed, 81 insertions(+), 31 deletions(-) diff --git a/tools/node_modules/eslint/README.md b/tools/node_modules/eslint/README.md index b7cc385f0e35c7..0e574e5b2d2e18 100644 --- a/tools/node_modules/eslint/README.md +++ b/tools/node_modules/eslint/README.md @@ -265,7 +265,7 @@ The following companies, organizations, and individuals support ESLint's ongoing

Gold Sponsors

Shopify Salesforce Badoo Airbnb Facebook Open Source

Silver Sponsors

AMP Project

Bronze Sponsors

-

Bugsnag Stability Monitoring Crosswordsolver Codacy Mixpanel VPS Server Free Icons by Icons8 UI UX Design Agencies clay Discord ThemeIsle TekHattan Marfeel Fire Stick Tricks JSHeroes

+

UI UX Design Agencies EduBirdie Crosswordsolver Codacy Mixpanel VPS Server Free Icons by Icons8 Bugsnag Stability Monitoring clay Discord ThemeIsle TekHattan Marfeel Fire Stick Tricks JSHeroes

## Technology Sponsors diff --git a/tools/node_modules/eslint/lib/cli-engine/file-enumerator.js b/tools/node_modules/eslint/lib/cli-engine/file-enumerator.js index 700f8009cf88f2..b5a082b71a6bc8 100644 --- a/tools/node_modules/eslint/lib/cli-engine/file-enumerator.js +++ b/tools/node_modules/eslint/lib/cli-engine/file-enumerator.js @@ -375,9 +375,6 @@ class FileEnumerator { * @private */ *_iterateFilesRecursive(directoryPath, options) { - if (this._isIgnoredFile(directoryPath + path.sep, options)) { - return; - } debug(`Enter the directory: ${directoryPath}`); const { configArrayFactory, extensionRegExp } = internalSlotsMap.get(this); @@ -426,7 +423,20 @@ class FileEnumerator { // Dive into the sub directory. } else if (options.recursive && stat && stat.isDirectory()) { - yield* this._iterateFilesRecursive(filePath, options); + if (!config) { + config = configArrayFactory.getConfigArrayForFile( + filePath, + { ignoreNotFoundError: true } + ); + } + const ignored = this._isIgnoredFile( + filePath + path.sep, + { ...options, config } + ); + + if (!ignored) { + yield* this._iterateFilesRecursive(filePath, options); + } } } diff --git a/tools/node_modules/eslint/lib/rules/no-unexpected-multiline.js b/tools/node_modules/eslint/lib/rules/no-unexpected-multiline.js index 8026e1722236ff..eb72008a2947e7 100644 --- a/tools/node_modules/eslint/lib/rules/no-unexpected-multiline.js +++ b/tools/node_modules/eslint/lib/rules/no-unexpected-multiline.js @@ -74,6 +74,14 @@ module.exports = { if (node.tag.loc.end.line === node.quasi.loc.start.line) { return; } + + // handle generics type parameters on template tags + const tokenBefore = sourceCode.getTokenBefore(node.quasi); + + if (tokenBefore.loc.end.line === node.quasi.loc.start.line) { + return; + } + context.report({ node, loc: node.loc.start, messageId: "taggedTemplate" }); }, diff --git a/tools/node_modules/eslint/lib/source-code/source-code.js b/tools/node_modules/eslint/lib/source-code/source-code.js index 20b442f2367203..30b4e9ab5c26e3 100644 --- a/tools/node_modules/eslint/lib/source-code/source-code.js +++ b/tools/node_modules/eslint/lib/source-code/source-code.js @@ -90,6 +90,56 @@ function nodesOrTokensOverlap(first, second) { (second.range[0] <= first.range[0] && second.range[1] >= first.range[0]); } +/** + * 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 {SourceCode} sourceCode The source code object. + * @param {ASTNode|Token} first The first node or token to check between. + * @param {ASTNode|Token} second The second node or token to check between. + * @param {boolean} checkInsideOfJSXText If `true` is present, check inside of JSXText tokens for backward compatibility. + * @returns {boolean} True if there is a whitespace character between + * any of the tokens found between the two given nodes or tokens. + * @public + */ +function isSpaceBetween(sourceCode, first, second, checkInsideOfJSXText) { + if (nodesOrTokensOverlap(first, second)) { + return false; + } + + const [startingNodeOrToken, endingNodeOrToken] = first.range[1] <= second.range[0] + ? [first, second] + : [second, first]; + const firstToken = sourceCode.getLastToken(startingNodeOrToken) || startingNodeOrToken; + const finalToken = sourceCode.getFirstToken(endingNodeOrToken) || endingNodeOrToken; + let currentToken = firstToken; + + while (currentToken !== finalToken) { + const nextToken = sourceCode.getTokenAfter(currentToken, { includeComments: true }); + + if ( + currentToken.range[1] !== nextToken.range[0] || + + /* + * For backward compatibility, check speces in JSXText. + * https://github.com/eslint/eslint/issues/12614 + */ + ( + checkInsideOfJSXText && + nextToken !== finalToken && + nextToken.type === "JSXText" && + /\s/u.test(nextToken.value) + ) + ) { + return true; + } + + currentToken = nextToken; + } + + return false; +} + //------------------------------------------------------------------------------ // Public Interface //------------------------------------------------------------------------------ @@ -433,42 +483,24 @@ class SourceCode extends TokenStore { * @public */ isSpaceBetween(first, second) { - if (nodesOrTokensOverlap(first, second)) { - return false; - } - - 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; + return isSpaceBetween(this, first, second, 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. + * For backward compatibility, this method returns true if there are + * `JSXText` tokens that contain whitespaces between the two. + * @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. * @deprecated in favor of isSpaceBetween(). * @public */ - isSpaceBetweenTokens(...args) { - return this.isSpaceBetween(...args); + isSpaceBetweenTokens(first, second) { + return isSpaceBetween(this, first, second, true); } /** diff --git a/tools/node_modules/eslint/package.json b/tools/node_modules/eslint/package.json index 5fbc11817b879d..0abd303e051b44 100644 --- a/tools/node_modules/eslint/package.json +++ b/tools/node_modules/eslint/package.json @@ -153,5 +153,5 @@ "test:cli": "mocha", "webpack": "node Makefile.js webpack" }, - "version": "6.7.1" + "version": "6.7.2" } \ No newline at end of file