From cac1d01cad4259b9af53d92c012e6b770f4fedd5 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 28 Feb 2020 17:07:33 -0500 Subject: [PATCH] tools: update ESLint to 7.0.0-alpha.1 Update ESLint to 7.0.0-alpha.1 PR-URL: https://github.com/nodejs/node/pull/31400 Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat Reviewed-By: Rich Trott --- tools/node_modules/eslint/README.md | 46 +++---- .../node_modules/eslint/conf/environments.js | 2 +- .../eslint/lib/cli-engine/cli-engine.js | 3 - .../cli-engine/config-array/config-array.js | 2 +- .../cli-engine/config-array/ignore-pattern.js | 4 +- .../eslint/lib/cli-engine/file-enumerator.js | 4 +- .../node_modules/eslint/lib/init/npm-utils.js | 2 +- .../code-path-analysis/code-path-analyzer.js | 1 + .../code-path-analysis/debug-helpers.js | 4 +- .../linter/code-path-analysis/fork-context.js | 2 +- .../node_modules/eslint/lib/linter/linter.js | 2 +- .../eslint/lib/rules/array-callback-return.js | 119 ++++++++++++------ .../eslint/lib/rules/complexity.js | 2 +- .../eslint/lib/rules/consistent-this.js | 2 +- .../eslint/lib/rules/id-blacklist.js | 82 +++++++----- .../eslint/lib/rules/linebreak-style.js | 2 +- .../node_modules/eslint/lib/rules/max-len.js | 2 +- .../lib/rules/multiline-comment-style.js | 4 + .../eslint/lib/rules/no-confusing-arrow.js | 4 +- .../eslint/lib/rules/no-constant-condition.js | 16 ++- .../eslint/lib/rules/no-control-regex.js | 2 +- .../eslint/lib/rules/no-dupe-class-members.js | 5 +- .../eslint/lib/rules/no-extra-parens.js | 3 +- .../eslint/lib/rules/no-invalid-regexp.js | 8 +- .../lib/rules/no-irregular-whitespace.js | 2 +- .../eslint/lib/rules/no-iterator.js | 10 +- .../eslint/lib/rules/no-lonely-if.js | 2 +- .../eslint/lib/rules/no-magic-numbers.js | 11 +- .../eslint/lib/rules/no-native-reassign.js | 8 +- .../eslint/lib/rules/no-negated-in-lhs.js | 8 +- .../eslint/lib/rules/no-obj-calls.js | 4 +- .../eslint/lib/rules/no-process-env.js | 8 +- .../eslint/lib/rules/no-process-exit.js | 8 +- .../node_modules/eslint/lib/rules/no-proto.js | 19 ++- .../eslint/lib/rules/no-prototype-builtins.js | 8 +- .../eslint/lib/rules/no-regex-spaces.js | 10 +- .../eslint/lib/rules/no-restricted-modules.js | 38 +++--- .../lib/rules/no-restricted-properties.js | 13 +- .../eslint/lib/rules/no-restricted-syntax.js | 11 +- .../eslint/lib/rules/no-return-assign.js | 11 +- .../eslint/lib/rules/no-return-await.js | 10 +- .../eslint/lib/rules/no-script-url.js | 8 +- .../eslint/lib/rules/no-self-assign.js | 8 +- .../eslint/lib/rules/no-self-compare.js | 8 +- .../eslint/lib/rules/no-sequences.js | 8 +- .../lib/rules/no-shadow-restricted-names.js | 10 +- .../eslint/lib/rules/no-spaced-func.js | 8 +- .../eslint/lib/rules/no-sparse-arrays.js | 8 +- .../node_modules/eslint/lib/rules/no-sync.js | 8 +- .../node_modules/eslint/lib/rules/no-tabs.js | 8 +- .../lib/rules/no-template-curly-in-string.js | 8 +- .../eslint/lib/rules/no-ternary.js | 8 +- .../eslint/lib/rules/no-this-before-super.js | 8 +- .../eslint/lib/rules/no-trailing-spaces.js | 8 +- .../eslint/lib/rules/no-undef-init.js | 8 +- .../eslint/lib/rules/no-undefined.js | 8 +- .../eslint/lib/rules/no-underscore-dangle.js | 14 ++- .../lib/rules/no-unmodified-loop-condition.js | 8 +- .../eslint/lib/rules/no-unneeded-ternary.js | 11 +- .../eslint/lib/rules/no-unreachable.js | 8 +- .../eslint/lib/rules/no-unsafe-finally.js | 8 +- .../eslint/lib/rules/no-unused-expressions.js | 8 +- .../eslint/lib/rules/no-unused-vars.js | 73 +++++++---- .../eslint/lib/rules/no-useless-call.js | 8 +- .../eslint/lib/rules/no-useless-catch.js | 11 +- .../lib/rules/no-useless-computed-key.js | 10 +- .../eslint/lib/rules/no-useless-concat.js | 10 +- .../lib/rules/no-useless-constructor.js | 2 +- .../eslint/lib/rules/no-useless-rename.js | 8 +- .../eslint/lib/rules/no-useless-return.js | 10 +- tools/node_modules/eslint/lib/rules/no-var.js | 8 +- .../eslint/lib/rules/no-warning-comments.js | 8 +- .../rules/no-whitespace-before-property.js | 8 +- .../node_modules/eslint/lib/rules/no-with.js | 8 +- .../rules/nonblock-statement-body-position.js | 11 +- .../eslint/lib/rules/object-curly-newline.js | 17 ++- .../eslint/lib/rules/object-curly-spacing.js | 17 ++- .../lib/rules/object-property-newline.js | 15 ++- .../eslint/lib/rules/object-shorthand.js | 26 ++-- .../lib/rules/one-var-declaration-per-line.js | 9 +- .../node_modules/eslint/lib/rules/one-var.js | 32 +++-- .../eslint/lib/rules/operator-assignment.js | 6 +- .../eslint/lib/rules/operator-linebreak.js | 17 ++- .../eslint/lib/rules/padded-blocks.js | 22 ++-- .../rules/padding-line-between-statements.js | 9 +- .../eslint/lib/rules/prefer-arrow-callback.js | 10 +- .../eslint/lib/rules/prefer-destructuring.js | 8 +- .../eslint/lib/rules/prefer-object-spread.js | 2 +- .../lib/rules/prefer-promise-reject-errors.js | 8 +- .../eslint/lib/rules/prefer-reflect.js | 14 ++- .../eslint/lib/rules/prefer-rest-params.js | 8 +- .../eslint/lib/rules/prefer-spread.js | 8 +- .../eslint/lib/rules/prefer-template.js | 8 +- .../eslint/lib/rules/quote-props.js | 29 +++-- tools/node_modules/eslint/lib/rules/radix.js | 27 ++-- .../lib/rules/require-atomic-updates.js | 2 +- .../eslint/lib/rules/require-jsdoc.js | 8 +- .../eslint/lib/rules/require-yield.js | 8 +- .../eslint/lib/rules/rest-spread-spacing.js | 11 +- .../eslint/lib/rules/semi-spacing.js | 17 ++- .../eslint/lib/rules/semi-style.js | 8 +- tools/node_modules/eslint/lib/rules/semi.js | 2 +- .../eslint/lib/rules/sort-imports.js | 14 ++- .../eslint/lib/rules/sort-keys.js | 16 ++- .../eslint/lib/rules/sort-vars.js | 8 +- .../eslint/lib/rules/space-before-blocks.js | 11 +- .../lib/rules/space-before-function-paren.js | 11 +- .../eslint/lib/rules/space-in-parens.js | 4 +- .../eslint/lib/rules/space-infix-ops.js | 14 ++- .../eslint/lib/rules/spaced-comment.js | 35 ++++-- .../eslint/lib/rules/use-isnan.js | 4 +- tools/node_modules/eslint/lib/rules/yoda.js | 37 +++++- .../eslint/lib/shared/config-validator.js | 2 +- .../node_modules/eslint/lib/shared/naming.js | 2 +- tools/node_modules/eslint/lib/shared/types.js | 2 +- .../eslint/lib/source-code/source-code.js | 2 +- .../lib/source-code/token-store/utils.js | 2 +- tools/node_modules/eslint/package.json | 4 +- 118 files changed, 922 insertions(+), 452 deletions(-) diff --git a/tools/node_modules/eslint/README.md b/tools/node_modules/eslint/README.md index 65c57271956185..5f5be9c730927b 100644 --- a/tools/node_modules/eslint/README.md +++ b/tools/node_modules/eslint/README.md @@ -1,9 +1,12 @@ -[![NPM version][npm-image]][npm-url] +[![NPM version](https://img.shields.io/npm/v/eslint.svg)](https://www.npmjs.com/package/eslint) +[![Downloads](https://img.shields.io/npm/dm/eslint.svg)](https://www.npmjs.com/package/eslint) [![Build Status](https://github.com/eslint/eslint/workflows/CI/badge.svg)](https://github.com/eslint/eslint/actions) -[![Downloads][downloads-image]][downloads-url] -[![Bountysource](https://www.bountysource.com/badge/tracker?tracker_id=282608)](https://www.bountysource.com/trackers/282608-eslint?utm_source=282608&utm_medium=shield&utm_campaign=TRACKER_BADGE) -[![Join the chat at https://gitter.im/eslint/eslint](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/eslint/eslint?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Feslint%2Feslint.svg?type=shield)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Feslint%2Feslint?ref=badge_shield) +
+[![Open Collective Backers](https://img.shields.io/opencollective/backers/eslint)](https://opencollective.com/eslint) +[![Open Collective Sponsors](https://img.shields.io/opencollective/sponsors/eslint)](https://opencollective.com/eslint) +[![Join the chat at https://gitter.im/eslint/eslint](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/eslint/eslint?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Follow us on Twitter](https://img.shields.io/twitter/follow/geteslint?label=Follow&style=social)](https://twitter.com/intent/user?screen_name=geteslint) # ESLint @@ -185,16 +188,6 @@ The people who manage releases, review feature requests, and meet regularly to e Nicholas C. Zakas - -
-Kevin Partington -
- - -
-Ilya Volodin -
-
Brandon Mills @@ -209,11 +202,6 @@ Toru Nagashima
Kai Cataldo
- - -
-Teddy Katz -
@@ -236,16 +224,16 @@ The people who review and implement new features. The people who review and fix bugs and help triage issues.
- -
-Gyandeep Singh -
-

Pig Fang
+ +
+YeonJuan +
+

Milos Djermanovic @@ -262,17 +250,11 @@ The following companies, organizations, and individuals support ESLint's ongoing

Gold Sponsors

-

Shopify Salesforce Badoo Airbnb Facebook Open Source

Silver Sponsors

+

Shopify Salesforce MagicLab Airbnb Facebook Open Source

Silver Sponsors

AMP Project

Bronze Sponsors

-

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

+

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

## Technology Sponsors * Site search ([eslint.org](https://eslint.org)) is sponsored by [Algolia](https://www.algolia.com) - - -[npm-image]: https://img.shields.io/npm/v/eslint.svg?style=flat-square -[npm-url]: https://www.npmjs.com/package/eslint -[downloads-image]: https://img.shields.io/npm/dm/eslint.svg?style=flat-square -[downloads-url]: https://www.npmjs.com/package/eslint diff --git a/tools/node_modules/eslint/conf/environments.js b/tools/node_modules/eslint/conf/environments.js index 10e6fdaa70fca5..ee5ee1b4e5b2ab 100644 --- a/tools/node_modules/eslint/conf/environments.js +++ b/tools/node_modules/eslint/conf/environments.js @@ -15,7 +15,7 @@ const globals = require("globals"); //------------------------------------------------------------------------------ /** - * Get the object that has differentce. + * Get the object that has difference. * @param {Record} current The newer object. * @param {Record} prev The older object. * @returns {Record} The difference object. 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 6a0352399b7738..9d2ef8cbcdef04 100644 --- a/tools/node_modules/eslint/lib/cli-engine/cli-engine.js +++ b/tools/node_modules/eslint/lib/cli-engine/cli-engine.js @@ -278,14 +278,11 @@ function createIgnoreResult(filePath, baseDir) { let message; const isHidden = /^\./u.test(path.basename(filePath)); const isInNodeModules = baseDir && path.relative(baseDir, filePath).startsWith("node_modules"); - const isInBowerComponents = baseDir && path.relative(baseDir, filePath).startsWith("bower_components"); if (isHidden) { message = "File ignored by default. Use a negated ignore pattern (like \"--ignore-pattern '!'\") to override."; } else if (isInNodeModules) { message = "File ignored by default. Use \"--ignore-pattern '!node_modules/*'\" to override."; - } else if (isInBowerComponents) { - message = "File ignored by default. Use \"--ignore-pattern '!bower_components/*'\" to override."; } else { message = "File ignored because of a matching ignore pattern. Use \"--no-ignore\" to override."; } diff --git a/tools/node_modules/eslint/lib/cli-engine/config-array/config-array.js b/tools/node_modules/eslint/lib/cli-engine/config-array/config-array.js index 02f73b43e65438..b3f7c1e7350033 100644 --- a/tools/node_modules/eslint/lib/cli-engine/config-array/config-array.js +++ b/tools/node_modules/eslint/lib/cli-engine/config-array/config-array.js @@ -5,7 +5,7 @@ * config file, base config files that were extended, loaded parsers, and loaded * plugins. * - * `ConfigArray` class provies three properties and two methods. + * `ConfigArray` class provides three properties and two methods. * * - `pluginEnvironments` * - `pluginProcessors` diff --git a/tools/node_modules/eslint/lib/cli-engine/config-array/ignore-pattern.js b/tools/node_modules/eslint/lib/cli-engine/config-array/ignore-pattern.js index 6140194433e861..92690b9f8ae342 100644 --- a/tools/node_modules/eslint/lib/cli-engine/config-array/ignore-pattern.js +++ b/tools/node_modules/eslint/lib/cli-engine/config-array/ignore-pattern.js @@ -103,8 +103,8 @@ function dirSuffix(filePath) { return isDir ? "/" : ""; } -const DefaultPatterns = Object.freeze(["/node_modules/*", "/bower_components/*"]); -const DotPatterns = Object.freeze([".*", "!../"]); +const DefaultPatterns = Object.freeze(["/**/node_modules/*"]); +const DotPatterns = Object.freeze([".*", "!.eslintrc.*", "!../"]); //------------------------------------------------------------------------------ // Public 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 16e5182ad8a450..7c433d32f44b1c 100644 --- a/tools/node_modules/eslint/lib/cli-engine/file-enumerator.js +++ b/tools/node_modules/eslint/lib/cli-engine/file-enumerator.js @@ -6,7 +6,7 @@ * 1. Find target files by processing glob patterns. * 2. Tie each target file and appropriate configuration. * - * It provies a method: + * It provides a method: * * - `iterateFiles(patterns)` * Iterate files which are matched by given patterns together with the @@ -283,7 +283,7 @@ class FileEnumerator { continue; } - // Iterate files of this pttern. + // Iterate files of this pattern. for (const { config, filePath, flag } of this._iterateFiles(pattern)) { foundRegardlessOfIgnored = true; if (flag === IGNORED_SILENTLY) { diff --git a/tools/node_modules/eslint/lib/init/npm-utils.js b/tools/node_modules/eslint/lib/init/npm-utils.js index 28c198fc8ada67..555ea2b2b28cb2 100644 --- a/tools/node_modules/eslint/lib/init/npm-utils.js +++ b/tools/node_modules/eslint/lib/init/npm-utils.js @@ -135,7 +135,7 @@ function check(packages, opt) { * * Convenience wrapper around check(). * @param {string[]} packages Array of node modules to check. - * @param {string} rootDir The directory contianing a package.json + * @param {string} rootDir The directory containing a package.json * @returns {Object} An object whose keys are the module names * and values are booleans indicating installation. */ 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 6822ae2be0a6cd..8a623e33ea0681 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 @@ -518,6 +518,7 @@ function processCodePathToExit(analyzer, node) { case "ImportExpression": case "MemberExpression": case "NewExpression": + case "YieldExpression": state.makeFirstThrowablePathInTryBlock(); break; diff --git a/tools/node_modules/eslint/lib/linter/code-path-analysis/debug-helpers.js b/tools/node_modules/eslint/lib/linter/code-path-analysis/debug-helpers.js index 35a4cb2dacb1ca..bde4e0a38ad24b 100644 --- a/tools/node_modules/eslint/lib/linter/code-path-analysis/debug-helpers.js +++ b/tools/node_modules/eslint/lib/linter/code-path-analysis/debug-helpers.js @@ -70,7 +70,7 @@ module.exports = { /** * Dumps a DOT code of a given code path. - * The DOT code can be visialized with Graphvis. + * The DOT code can be visualized with Graphvis. * @param {CodePath} codePath A code path to dump. * @returns {void} * @see http://www.graphviz.org @@ -135,7 +135,7 @@ module.exports = { /** * Makes a DOT code of a given code path. - * The DOT code can be visialized with Graphvis. + * The DOT code can be visualized with Graphvis. * @param {CodePath} codePath A code path to make DOT. * @param {Object} traceMap Optional. A map to check whether or not segments had been done. * @returns {string} A DOT code of the code path. diff --git a/tools/node_modules/eslint/lib/linter/code-path-analysis/fork-context.js b/tools/node_modules/eslint/lib/linter/code-path-analysis/fork-context.js index eb1d2de5a7db5b..2e872b5c0dbf5a 100644 --- a/tools/node_modules/eslint/lib/linter/code-path-analysis/fork-context.js +++ b/tools/node_modules/eslint/lib/linter/code-path-analysis/fork-context.js @@ -211,7 +211,7 @@ class ForkContext { } /** - * Clears all secments in this context. + * Clears all segments in this context. * @returns {void} */ clear() { diff --git a/tools/node_modules/eslint/lib/linter/linter.js b/tools/node_modules/eslint/lib/linter/linter.js index 76d35b49eefb55..1d021d1e82e7fb 100644 --- a/tools/node_modules/eslint/lib/linter/linter.js +++ b/tools/node_modules/eslint/lib/linter/linter.js @@ -1272,7 +1272,7 @@ class Linter { * @param {string|SourceCode} textOrSourceCode The source code. * @param {ConfigData|ExtractedConfig} config The config array. * @param {VerifyOptions&ProcessorOptions} options The options. - * @param {ConfigArray} [configForRecursive] The `CofnigArray` object to apply multiple processors recursively. + * @param {ConfigArray} [configForRecursive] The `ConfigArray` object to apply multiple processors recursively. * @returns {LintMessage[]} The found problems. */ _verifyWithProcessor(textOrSourceCode, config, options, configForRecursive) { diff --git a/tools/node_modules/eslint/lib/rules/array-callback-return.js b/tools/node_modules/eslint/lib/rules/array-callback-return.js index 6e425dcdcb89da..eb38965024f05d 100644 --- a/tools/node_modules/eslint/lib/rules/array-callback-return.js +++ b/tools/node_modules/eslint/lib/rules/array-callback-return.js @@ -18,7 +18,7 @@ const astUtils = require("./utils/ast-utils"); //------------------------------------------------------------------------------ const TARGET_NODE_TYPE = /^(?:Arrow)?FunctionExpression$/u; -const TARGET_METHODS = /^(?:every|filter|find(?:Index)?|flatMap|map|reduce(?:Right)?|some|sort)$/u; +const TARGET_METHODS = /^(?:every|filter|find(?:Index)?|flatMap|forEach|map|reduce(?:Right)?|some|sort)$/u; /** * Checks a given code path segment is reachable. @@ -61,12 +61,13 @@ function isTargetMethod(node) { /** * Checks whether or not a given node is a function expression which is the - * callback of an array method. + * callback of an array method, returning the method name. * @param {ASTNode} node A node to check. This is one of * FunctionExpression or ArrowFunctionExpression. - * @returns {boolean} `true` if the node is the callback of an array method. + * @returns {string} The method name if the node is a callback method, + * null otherwise. */ -function isCallbackOfArrayMethod(node) { +function getArrayMethodName(node) { let currentNode = node; while (currentNode) { @@ -95,7 +96,7 @@ function isCallbackOfArrayMethod(node) { const func = astUtils.getUpperFunction(parent); if (func === null || !astUtils.isCallee(func)) { - return false; + return null; } currentNode = func.parent; break; @@ -108,27 +109,31 @@ function isCallbackOfArrayMethod(node) { */ case "CallExpression": if (astUtils.isArrayFromMethod(parent.callee)) { - return ( + if ( parent.arguments.length >= 2 && parent.arguments[1] === currentNode - ); + ) { + return "from"; + } } if (isTargetMethod(parent.callee)) { - return ( + if ( parent.arguments.length >= 1 && parent.arguments[0] === currentNode - ); + ) { + return astUtils.getStaticPropertyName(parent.callee); + } } - return false; + return null; // Otherwise this node is not target. default: - return false; + return null; } } /* istanbul ignore next: unreachable */ - return false; + return null; } //------------------------------------------------------------------------------ @@ -153,6 +158,10 @@ module.exports = { allowImplicit: { type: "boolean", default: false + }, + checkForEach: { + type: "boolean", + default: false } }, additionalProperties: false @@ -162,15 +171,17 @@ module.exports = { messages: { expectedAtEnd: "Expected to return a value at the end of {{name}}.", expectedInside: "Expected to return a value in {{name}}.", - expectedReturnValue: "{{name}} expected a return value." + expectedReturnValue: "{{name}} expected a return value.", + expectedNoReturnValue: "{{name}} did not expect a return value." } }, create(context) { - const options = context.options[0] || { allowImplicit: false }; + const options = context.options[0] || { allowImplicit: false, checkForEach: false }; let funcInfo = { + arrayMethodName: null, upper: null, codePath: null, hasReturn: false, @@ -188,18 +199,32 @@ module.exports = { * @returns {void} */ function checkLastSegment(node) { - if (funcInfo.shouldCheck && - funcInfo.codePath.currentSegments.some(isReachable) - ) { + + if (!funcInfo.shouldCheck) { + return; + } + + let messageId = null; + + if (funcInfo.arrayMethodName === "forEach") { + if (options.checkForEach && node.type === "ArrowFunctionExpression" && node.expression) { + messageId = "expectedNoReturnValue"; + } + } else { + if (node.body.type === "BlockStatement" && funcInfo.codePath.currentSegments.some(isReachable)) { + messageId = funcInfo.hasReturn ? "expectedAtEnd" : "expectedInside"; + } + } + + if (messageId) { + let name = astUtils.getFunctionNameWithKind(funcInfo.node); + + name = messageId === "expectedNoReturnValue" ? lodash.upperFirst(name) : name; context.report({ node, loc: getLocation(node, context.getSourceCode()).loc.start, - messageId: funcInfo.hasReturn - ? "expectedAtEnd" - : "expectedInside", - data: { - name: astUtils.getFunctionNameWithKind(funcInfo.node) - } + messageId, + data: { name } }); } } @@ -208,14 +233,20 @@ module.exports = { // Stacks this function's information. onCodePathStart(codePath, node) { + + let methodName = null; + + if (TARGET_NODE_TYPE.test(node.type)) { + methodName = getArrayMethodName(node); + } + funcInfo = { + arrayMethodName: methodName, upper: funcInfo, codePath, hasReturn: false, shouldCheck: - TARGET_NODE_TYPE.test(node.type) && - node.body.type === "BlockStatement" && - isCallbackOfArrayMethod(node) && + methodName && !node.async && !node.generator, node @@ -229,20 +260,38 @@ module.exports = { // Checks the return statement is valid. ReturnStatement(node) { - if (funcInfo.shouldCheck) { - funcInfo.hasReturn = true; + + if (!funcInfo.shouldCheck) { + return; + } + + funcInfo.hasReturn = true; + + let messageId = null; + + if (funcInfo.arrayMethodName === "forEach") { + + // if checkForEach: true, returning a value at any path inside a forEach is not allowed + if (options.checkForEach && node.argument) { + messageId = "expectedNoReturnValue"; + } + } else { // if allowImplicit: false, should also check node.argument if (!options.allowImplicit && !node.argument) { - context.report({ - node, - messageId: "expectedReturnValue", - data: { - name: lodash.upperFirst(astUtils.getFunctionNameWithKind(funcInfo.node)) - } - }); + messageId = "expectedReturnValue"; } } + + if (messageId) { + context.report({ + node, + messageId, + data: { + name: lodash.upperFirst(astUtils.getFunctionNameWithKind(funcInfo.node)) + } + }); + } }, // Reports a given function if the last path is reachable. diff --git a/tools/node_modules/eslint/lib/rules/complexity.js b/tools/node_modules/eslint/lib/rules/complexity.js index 91180e989540ce..7fc8bf9bc2ea8c 100644 --- a/tools/node_modules/eslint/lib/rules/complexity.js +++ b/tools/node_modules/eslint/lib/rules/complexity.js @@ -1,6 +1,6 @@ /** * @fileoverview Counts the cyclomatic complexity of each function of the script. See http://en.wikipedia.org/wiki/Cyclomatic_complexity. - * Counts the number of if, conditional, for, whilte, try, switch/case, + * Counts the number of if, conditional, for, while, try, switch/case, * @author Patrick Brosset */ diff --git a/tools/node_modules/eslint/lib/rules/consistent-this.js b/tools/node_modules/eslint/lib/rules/consistent-this.js index 16f53b5374cd24..e5bc9678daef3c 100644 --- a/tools/node_modules/eslint/lib/rules/consistent-this.js +++ b/tools/node_modules/eslint/lib/rules/consistent-this.js @@ -114,7 +114,7 @@ module.exports = { } /** - * Check each alias to ensure that is was assinged to the correct value. + * Check each alias to ensure that is was assigned to the correct value. * @returns {void} */ function ensureWasAssigned() { diff --git a/tools/node_modules/eslint/lib/rules/id-blacklist.js b/tools/node_modules/eslint/lib/rules/id-blacklist.js index e5dcdc63091568..cb6e5e215f6c60 100644 --- a/tools/node_modules/eslint/lib/rules/id-blacklist.js +++ b/tools/node_modules/eslint/lib/rules/id-blacklist.js @@ -41,6 +41,7 @@ module.exports = { //-------------------------------------------------------------------------- const blacklist = context.options; + const reportedNodes = new Set(); /** @@ -54,18 +55,46 @@ module.exports = { } /** - * Verifies if we should report an error or not based on the effective - * parent node and the identifier name. - * @param {ASTNode} effectiveParent The effective parent node of the node to be reported - * @param {string} name The identifier name of the identifier node + * Checks whether the given node represents an imported name that is renamed in the same import/export specifier. + * + * Examples: + * import { a as b } from 'mod'; // node `a` is renamed import + * export { a as b } from 'mod'; // node `a` is renamed import + * @param {ASTNode} node `Identifier` node to check. + * @returns {boolean} `true` if the node is a renamed import. + */ + function isRenamedImport(node) { + const parent = node.parent; + + return ( + ( + parent.type === "ImportSpecifier" && + parent.imported !== parent.local && + parent.imported === node + ) || + ( + parent.type === "ExportSpecifier" && + parent.parent.source && // re-export + parent.local !== parent.exported && + parent.local === node + ) + ); + } + + /** + * Verifies if we should report an error or not. + * @param {ASTNode} node The node to check * @returns {boolean} whether an error should be reported or not */ - function shouldReport(effectiveParent, name) { + function shouldReport(node) { + const parent = node.parent; + return ( - effectiveParent.type !== "CallExpression" && - effectiveParent.type !== "NewExpression" && - effectiveParent.parent.type !== "ObjectPattern" && - isInvalid(name) + parent.type !== "CallExpression" && + parent.type !== "NewExpression" && + parent.parent.type !== "ObjectPattern" && + !isRenamedImport(node) && + isInvalid(node.name) ); } @@ -76,27 +105,30 @@ module.exports = { * @private */ function report(node) { - context.report({ - node, - messageId: "blacklisted", - data: { - name: node.name - } - }); + if (!reportedNodes.has(node)) { + context.report({ + node, + messageId: "blacklisted", + data: { + name: node.name + } + }); + reportedNodes.add(node); + } } return { Identifier(node) { - const name = node.name, - effectiveParent = (node.parent.type === "MemberExpression") ? node.parent.parent : node.parent; // MemberExpressions get special rules if (node.parent.type === "MemberExpression") { + const name = node.name, + effectiveParent = node.parent.parent; // Always check object names if (node.parent.object.type === "Identifier" && - node.parent.object.name === node.name) { + node.parent.object.name === name) { if (isInvalid(name)) { report(node); } @@ -105,21 +137,13 @@ module.exports = { } else if (effectiveParent.type === "AssignmentExpression" && (effectiveParent.right.type !== "MemberExpression" || effectiveParent.left.type === "MemberExpression" && - effectiveParent.left.property.name === node.name)) { + effectiveParent.left.property.name === name)) { if (isInvalid(name)) { report(node); } } - // Properties have their own rules - } else if (node.parent.type === "Property") { - - if (shouldReport(effectiveParent, name)) { - report(node); - } - - // Report anything that is a match and not a CallExpression - } else if (shouldReport(effectiveParent, name)) { + } else if (shouldReport(node)) { report(node); } } diff --git a/tools/node_modules/eslint/lib/rules/linebreak-style.js b/tools/node_modules/eslint/lib/rules/linebreak-style.js index 97d552ea07c966..078eaf2cd268d2 100644 --- a/tools/node_modules/eslint/lib/rules/linebreak-style.js +++ b/tools/node_modules/eslint/lib/rules/linebreak-style.js @@ -64,7 +64,7 @@ module.exports = { //-------------------------------------------------------------------------- return { - Program: function checkForlinebreakStyle(node) { + Program: function checkForLinebreakStyle(node) { const linebreakStyle = context.options[0] || "unix", expectedLF = linebreakStyle === "unix", expectedLFChars = expectedLF ? "\n" : "\r\n", diff --git a/tools/node_modules/eslint/lib/rules/max-len.js b/tools/node_modules/eslint/lib/rules/max-len.js index 82229c3be4894a..995e0c52026385 100644 --- a/tools/node_modules/eslint/lib/rules/max-len.js +++ b/tools/node_modules/eslint/lib/rules/max-len.js @@ -203,7 +203,7 @@ module.exports = { * stripped. * @param {string} line The source line with a trailing comment * @param {ASTNode} comment The comment to remove - * @returns {string} Line without comment and trailing whitepace + * @returns {string} Line without comment and trailing whitespace */ function stripTrailingComment(line, comment) { diff --git a/tools/node_modules/eslint/lib/rules/multiline-comment-style.js b/tools/node_modules/eslint/lib/rules/multiline-comment-style.js index fb50e1522ea11d..9524818b8bd74d 100644 --- a/tools/node_modules/eslint/lib/rules/multiline-comment-style.js +++ b/tools/node_modules/eslint/lib/rules/multiline-comment-style.js @@ -316,6 +316,10 @@ module.exports = { const [, prefix = "", initialOffset = ""] = lineTextToAlignWith.match(/^(\s*(?:\/?\*)?(\s*))/u) || []; offset = `${commentTextPrefix.slice(prefix.length)}${initialOffset}`; + + if (/^\s*\//u.test(lineText) && offset.length === 0) { + offset += " "; + } break; } diff --git a/tools/node_modules/eslint/lib/rules/no-confusing-arrow.js b/tools/node_modules/eslint/lib/rules/no-confusing-arrow.js index b9a0e6ed0a70b5..9009b64fa1559a 100644 --- a/tools/node_modules/eslint/lib/rules/no-confusing-arrow.js +++ b/tools/node_modules/eslint/lib/rules/no-confusing-arrow.js @@ -1,6 +1,6 @@ /** * @fileoverview A rule to warn against using arrow functions when they could be - * confused with comparisions + * confused with comparisons * @author Jxck */ @@ -71,7 +71,7 @@ module.exports = { messageId: "confusing", fix(fixer) { - // if `allowParens` is not set to true dont bother wrapping in parens + // if `allowParens` is not set to true don't bother wrapping in parens return allowParens && fixer.replaceText(node.body, `(${sourceCode.getText(node.body)})`); } }); diff --git a/tools/node_modules/eslint/lib/rules/no-constant-condition.js b/tools/node_modules/eslint/lib/rules/no-constant-condition.js index d6d04174298cff..5e5838641028fe 100644 --- a/tools/node_modules/eslint/lib/rules/no-constant-condition.js +++ b/tools/node_modules/eslint/lib/rules/no-constant-condition.js @@ -90,13 +90,27 @@ module.exports = { * @private */ function isConstant(node, inBooleanPosition) { + + // node.elements can return null values in the case of sparse arrays ex. [,] + if (!node) { + return true; + } switch (node.type) { case "Literal": case "ArrowFunctionExpression": case "FunctionExpression": case "ObjectExpression": - case "ArrayExpression": return true; + case "TemplateLiteral": + return (inBooleanPosition && node.quasis.some(quasi => quasi.value.cooked.length)) || + node.expressions.every(exp => isConstant(exp, inBooleanPosition)); + + case "ArrayExpression": { + if (node.parent.type === "BinaryExpression" && node.parent.operator === "+") { + return node.elements.every(element => isConstant(element, false)); + } + return true; + } case "UnaryExpression": if (node.operator === "void") { 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 24e6b197be0b44..b39f731c3cdf29 100644 --- a/tools/node_modules/eslint/lib/rules/no-control-regex.js +++ b/tools/node_modules/eslint/lib/rules/no-control-regex.js @@ -1,5 +1,5 @@ /** - * @fileoverview Rule to forbid control charactes from regular expressions. + * @fileoverview Rule to forbid control characters from regular expressions. * @author Nicholas C. Zakas */ diff --git a/tools/node_modules/eslint/lib/rules/no-dupe-class-members.js b/tools/node_modules/eslint/lib/rules/no-dupe-class-members.js index 55639746b27590..b12939d57bc884 100644 --- a/tools/node_modules/eslint/lib/rules/no-dupe-class-members.js +++ b/tools/node_modules/eslint/lib/rules/no-dupe-class-members.js @@ -74,11 +74,12 @@ module.exports = { // Reports the node if its name has been declared already. MethodDefinition(node) { - if (node.computed) { + const name = astUtils.getStaticPropertyName(node); + + if (name === null || node.kind === "constructor") { return; } - const name = astUtils.getStaticPropertyName(node) || ""; const state = getState(name, node.static); let isDuplicate = false; 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 e70353576bb950..a5488c3c1c6aa4 100644 --- a/tools/node_modules/eslint/lib/rules/no-extra-parens.js +++ b/tools/node_modules/eslint/lib/rules/no-extra-parens.js @@ -702,8 +702,7 @@ module.exports = { } if (node.body.type === "ConditionalExpression" && - IGNORE_ARROW_CONDITIONALS && - !isParenthesisedTwice(node.body) + IGNORE_ARROW_CONDITIONALS ) { return; } 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 4ede995891bbca..c09e36fd017697 100644 --- a/tools/node_modules/eslint/lib/rules/no-invalid-regexp.js +++ b/tools/node_modules/eslint/lib/rules/no-invalid-regexp.js @@ -39,9 +39,11 @@ module.exports = { } }, additionalProperties: false - }] + }], - // no messages, because the error text comes directly from the regexpp module + messages: { + regexMessage: "{{message}}." + } }, create(context) { @@ -118,7 +120,7 @@ module.exports = { if (message) { context.report({ node, - message: "{{message}}.", + messageId: "regexMessage", data: { message } }); } diff --git a/tools/node_modules/eslint/lib/rules/no-irregular-whitespace.js b/tools/node_modules/eslint/lib/rules/no-irregular-whitespace.js index fa72c3ee72fcdc..21842331f21ff0 100644 --- a/tools/node_modules/eslint/lib/rules/no-irregular-whitespace.js +++ b/tools/node_modules/eslint/lib/rules/no-irregular-whitespace.js @@ -1,5 +1,5 @@ /** - * @fileoverview Rule to disalow whitespace that is not a tab or space, whitespace inside strings and comments are allowed + * @fileoverview Rule to disallow whitespace that is not a tab or space, whitespace inside strings and comments are allowed * @author Jonathan Kingston * @author Christophe Porteneuve */ diff --git a/tools/node_modules/eslint/lib/rules/no-iterator.js b/tools/node_modules/eslint/lib/rules/no-iterator.js index 0b01d3533d9db1..9ba1e7aefdbc3b 100644 --- a/tools/node_modules/eslint/lib/rules/no-iterator.js +++ b/tools/node_modules/eslint/lib/rules/no-iterator.js @@ -5,6 +5,12 @@ "use strict"; +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const { getStaticPropertyName } = require("./utils/ast-utils"); + //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -33,9 +39,7 @@ module.exports = { MemberExpression(node) { - if (node.property && - (node.property.type === "Identifier" && node.property.name === "__iterator__" && !node.computed) || - (node.property.type === "Literal" && node.property.value === "__iterator__")) { + if (getStaticPropertyName(node) === "__iterator__") { context.report({ node, messageId: "noIterator" diff --git a/tools/node_modules/eslint/lib/rules/no-lonely-if.js b/tools/node_modules/eslint/lib/rules/no-lonely-if.js index 53f9445f835ec5..6552adc5752852 100644 --- a/tools/node_modules/eslint/lib/rules/no-lonely-if.js +++ b/tools/node_modules/eslint/lib/rules/no-lonely-if.js @@ -1,5 +1,5 @@ /** - * @fileoverview Rule to disallow if as the only statmenet in an else block + * @fileoverview Rule to disallow if as the only statement in an else block * @author Brandon Mills */ "use strict"; 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 4bf24996cb8f20..5dd6feaab0dbff 100644 --- a/tools/node_modules/eslint/lib/rules/no-magic-numbers.js +++ b/tools/node_modules/eslint/lib/rules/no-magic-numbers.js @@ -110,11 +110,14 @@ module.exports = { /** * Returns whether the number should be ignored when used as an array index with enabled 'ignoreArrayIndexes' option. - * @param {ASTNode} parent the non-"UnaryExpression" parent. + * @param {ASTNode} node Node to check * @returns {boolean} true if the number should be ignored */ - function shouldIgnoreArrayIndexes(parent) { - return parent.type === "MemberExpression" && ignoreArrayIndexes; + function shouldIgnoreArrayIndexes(node) { + const parent = node.parent; + + return ignoreArrayIndexes && + parent.type === "MemberExpression" && parent.property === node; } return { @@ -145,7 +148,7 @@ module.exports = { if (shouldIgnoreNumber(value) || shouldIgnoreParseInt(parent, fullNumberNode) || - shouldIgnoreArrayIndexes(parent) || + shouldIgnoreArrayIndexes(fullNumberNode) || shouldIgnoreJSXNumbers(parent)) { return; } diff --git a/tools/node_modules/eslint/lib/rules/no-native-reassign.js b/tools/node_modules/eslint/lib/rules/no-native-reassign.js index eb233c80b1cca0..833e3b7ce409b3 100644 --- a/tools/node_modules/eslint/lib/rules/no-native-reassign.js +++ b/tools/node_modules/eslint/lib/rules/no-native-reassign.js @@ -37,7 +37,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + nativeReassign: "Read-only global '{{name}}' should not be modified." + } }, create(context) { @@ -65,7 +69,7 @@ module.exports = { ) { context.report({ node: identifier, - message: "Read-only global '{{name}}' should not be modified.", + messageId: "nativeReassign", data: identifier }); } diff --git a/tools/node_modules/eslint/lib/rules/no-negated-in-lhs.js b/tools/node_modules/eslint/lib/rules/no-negated-in-lhs.js index 0084ad1570bb00..1229cedd1190dc 100644 --- a/tools/node_modules/eslint/lib/rules/no-negated-in-lhs.js +++ b/tools/node_modules/eslint/lib/rules/no-negated-in-lhs.js @@ -24,7 +24,11 @@ module.exports = { replacedBy: ["no-unsafe-negation"], deprecated: true, - schema: [] + schema: [], + + messages: { + negatedLHS: "The 'in' expression's left operand is negated." + } }, create(context) { @@ -33,7 +37,7 @@ module.exports = { BinaryExpression(node) { if (node.operator === "in" && node.left.type === "UnaryExpression" && node.left.operator === "!") { - context.report({ node, message: "The 'in' expression's left operand is negated." }); + context.report({ node, messageId: "negatedLHS" }); } } }; 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 5102d5594949ba..9ff666b03281ca 100644 --- a/tools/node_modules/eslint/lib/rules/no-obj-calls.js +++ b/tools/node_modules/eslint/lib/rules/no-obj-calls.js @@ -47,8 +47,8 @@ module.exports = { const tracker = new ReferenceTracker(scope); const traceMap = {}; - for (const global of nonCallableGlobals) { - traceMap[global] = { + for (const g of nonCallableGlobals) { + traceMap[g] = { [CALL]: true }; } diff --git a/tools/node_modules/eslint/lib/rules/no-process-env.js b/tools/node_modules/eslint/lib/rules/no-process-env.js index a66d9709b09b4f..0f8d7f8a339d0e 100644 --- a/tools/node_modules/eslint/lib/rules/no-process-env.js +++ b/tools/node_modules/eslint/lib/rules/no-process-env.js @@ -19,7 +19,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-process-env" }, - schema: [] + schema: [], + + messages: { + unexpectedProcessEnv: "Unexpected use of process.env." + } }, create(context) { @@ -31,7 +35,7 @@ module.exports = { propertyName = node.property.name; if (objectName === "process" && !node.computed && propertyName && propertyName === "env") { - context.report({ node, message: "Unexpected use of process.env." }); + context.report({ node, messageId: "unexpectedProcessEnv" }); } } diff --git a/tools/node_modules/eslint/lib/rules/no-process-exit.js b/tools/node_modules/eslint/lib/rules/no-process-exit.js index fcfc6b2af59d0e..29871660cc6ee1 100644 --- a/tools/node_modules/eslint/lib/rules/no-process-exit.js +++ b/tools/node_modules/eslint/lib/rules/no-process-exit.js @@ -19,7 +19,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-process-exit" }, - schema: [] + schema: [], + + messages: { + noProcessExit: "Don't use process.exit(); throw an error instead." + } }, create(context) { @@ -30,7 +34,7 @@ module.exports = { return { "CallExpression > MemberExpression.callee[object.name = 'process'][property.name = 'exit']"(node) { - context.report({ node: node.parent, message: "Don't use process.exit(); throw an error instead." }); + context.report({ node: node.parent, messageId: "noProcessExit" }); } }; diff --git a/tools/node_modules/eslint/lib/rules/no-proto.js b/tools/node_modules/eslint/lib/rules/no-proto.js index 80b9650941696d..82ce02fa4e3b9e 100644 --- a/tools/node_modules/eslint/lib/rules/no-proto.js +++ b/tools/node_modules/eslint/lib/rules/no-proto.js @@ -5,6 +5,12 @@ "use strict"; +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const { getStaticPropertyName } = require("./utils/ast-utils"); + //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -20,7 +26,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-proto" }, - schema: [] + schema: [], + + messages: { + unexpectedProto: "The '__proto__' property is deprecated." + } }, create(context) { @@ -28,11 +38,8 @@ module.exports = { return { MemberExpression(node) { - - if (node.property && - (node.property.type === "Identifier" && node.property.name === "__proto__" && !node.computed) || - (node.property.type === "Literal" && node.property.value === "__proto__")) { - context.report({ node, message: "The '__proto__' property is deprecated." }); + if (getStaticPropertyName(node) === "__proto__") { + context.report({ node, messageId: "unexpectedProto" }); } } }; diff --git a/tools/node_modules/eslint/lib/rules/no-prototype-builtins.js b/tools/node_modules/eslint/lib/rules/no-prototype-builtins.js index 87a760156e3693..5bed2539a6486b 100644 --- a/tools/node_modules/eslint/lib/rules/no-prototype-builtins.js +++ b/tools/node_modules/eslint/lib/rules/no-prototype-builtins.js @@ -19,7 +19,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-prototype-builtins" }, - schema: [] + schema: [], + + messages: { + prototypeBuildIn: "Do not access Object.prototype method '{{prop}}' from target object." + } }, create(context) { @@ -42,7 +46,7 @@ module.exports = { if (DISALLOWED_PROPS.indexOf(propName) > -1) { context.report({ - message: "Do not access Object.prototype method '{{prop}}' from target object.", + messageId: "prototypeBuildIn", loc: node.callee.property.loc.start, data: { prop: propName }, node 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 7581e9271fdf14..afb26d70259f1b 100644 --- a/tools/node_modules/eslint/lib/rules/no-regex-spaces.js +++ b/tools/node_modules/eslint/lib/rules/no-regex-spaces.js @@ -45,7 +45,11 @@ module.exports = { }, schema: [], - fixable: "code" + fixable: "code", + + messages: { + multipleSpaces: "Spaces are hard to count. Use {{{length}}}." + } }, create(context) { @@ -96,7 +100,7 @@ module.exports = { ) { context.report({ node: nodeToReport, - message: "Spaces are hard to count. Use {{{length}}}.", + messageId: "multipleSpaces", data: { length }, fix(fixer) { if (pattern !== rawPattern) { @@ -109,7 +113,7 @@ module.exports = { } }); - // Report only the first occurence of consecutive spaces + // Report only the first occurrence of consecutive spaces return; } } diff --git a/tools/node_modules/eslint/lib/rules/no-restricted-modules.js b/tools/node_modules/eslint/lib/rules/no-restricted-modules.js index ef8748a7d04baf..abbc30a05fb53d 100644 --- a/tools/node_modules/eslint/lib/rules/no-restricted-modules.js +++ b/tools/node_modules/eslint/lib/rules/no-restricted-modules.js @@ -4,13 +4,6 @@ */ "use strict"; -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const DEFAULT_MESSAGE_TEMPLATE = "'{{moduleName}}' module is restricted from being used."; -const CUSTOM_MESSAGE_TEMPLATE = "'{{moduleName}}' module is restricted from being used. {{customMessage}}"; - //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -72,6 +65,13 @@ module.exports = { additionalItems: false } ] + }, + + messages: { + defaultMessage: "'{{name}}' module is restricted from being used.", + // eslint-disable-next-line eslint-plugin/report-message-format + customMessage: "'{{name}}' module is restricted from being used. {{customMessage}}", + patternMessage: "'{{name}}' module is restricted from being used by a pattern." } }, @@ -126,17 +126,17 @@ module.exports = { * @private */ function reportPath(node) { - const moduleName = node.arguments[0].value.trim(); - const customMessage = restrictedPathMessages[moduleName]; - const message = customMessage - ? CUSTOM_MESSAGE_TEMPLATE - : DEFAULT_MESSAGE_TEMPLATE; + const name = node.arguments[0].value.trim(); + const customMessage = restrictedPathMessages[name]; + const messageId = customMessage + ? "customMessage" + : "defaultMessage"; context.report({ node, - message, + messageId, data: { - moduleName, + name, customMessage } }); @@ -158,18 +158,18 @@ module.exports = { // node has arguments and first argument is string if (node.arguments.length && isString(node.arguments[0])) { - const moduleName = node.arguments[0].value.trim(); + const name = node.arguments[0].value.trim(); // check if argument value is in restricted modules array - if (isRestrictedPath(moduleName)) { + if (isRestrictedPath(name)) { reportPath(node); } - if (restrictedPatterns.length > 0 && ig.ignores(moduleName)) { + if (restrictedPatterns.length > 0 && ig.ignores(name)) { context.report({ node, - message: "'{{moduleName}}' module is restricted from being used by a pattern.", - data: { moduleName } + messageId: "patternMessage", + data: { name } }); } } diff --git a/tools/node_modules/eslint/lib/rules/no-restricted-properties.js b/tools/node_modules/eslint/lib/rules/no-restricted-properties.js index bdab22b19c4edc..7ab83995a3ebbf 100644 --- a/tools/node_modules/eslint/lib/rules/no-restricted-properties.js +++ b/tools/node_modules/eslint/lib/rules/no-restricted-properties.js @@ -61,6 +61,13 @@ module.exports = { ] }, uniqueItems: true + }, + + messages: { + // eslint-disable-next-line eslint-plugin/report-message-format + restrictedObjectProperty: "'{{objectName}}.{{propertyName}}' is restricted from being used.{{message}}", + // eslint-disable-next-line eslint-plugin/report-message-format + restrictedProperty: "'{{propertyName}}' is restricted from being used.{{message}}" } }, @@ -114,8 +121,7 @@ module.exports = { context.report({ node, - // eslint-disable-next-line eslint-plugin/report-message-format - message: "'{{objectName}}.{{propertyName}}' is restricted from being used.{{message}}", + messageId: "restrictedObjectProperty", data: { objectName, propertyName, @@ -127,8 +133,7 @@ module.exports = { context.report({ node, - // eslint-disable-next-line eslint-plugin/report-message-format - message: "'{{propertyName}}' is restricted from being used.{{message}}", + messageId: "restrictedProperty", data: { propertyName, message diff --git a/tools/node_modules/eslint/lib/rules/no-restricted-syntax.js b/tools/node_modules/eslint/lib/rules/no-restricted-syntax.js index 41aa9fa390a88d..9572603a82485a 100644 --- a/tools/node_modules/eslint/lib/rules/no-restricted-syntax.js +++ b/tools/node_modules/eslint/lib/rules/no-restricted-syntax.js @@ -39,6 +39,11 @@ module.exports = { }, uniqueItems: true, minItems: 0 + }, + + messages: { + // eslint-disable-next-line eslint-plugin/report-message-format + restrictedSyntax: "{{message}}" } }, @@ -48,14 +53,14 @@ module.exports = { const hasCustomMessage = !isStringFormat && Boolean(selectorOrObject.message); const selector = isStringFormat ? selectorOrObject : selectorOrObject.selector; - const message = hasCustomMessage ? selectorOrObject.message : "Using '{{selector}}' is not allowed."; + const message = hasCustomMessage ? selectorOrObject.message : `Using '${selector}' is not allowed.`; return Object.assign(result, { [selector](node) { context.report({ node, - message, - data: hasCustomMessage ? {} : { selector } + messageId: "restrictedSyntax", + data: { message } }); } }); diff --git a/tools/node_modules/eslint/lib/rules/no-return-assign.js b/tools/node_modules/eslint/lib/rules/no-return-assign.js index ea6a6bb49fcf6d..4b57d42eb9952b 100644 --- a/tools/node_modules/eslint/lib/rules/no-return-assign.js +++ b/tools/node_modules/eslint/lib/rules/no-return-assign.js @@ -35,7 +35,12 @@ module.exports = { { enum: ["except-parens", "always"] } - ] + ], + + messages: { + returnAssignment: "Return statement should not contain assignment.", + arrowAssignment: "Arrow function should not return assignment." + } }, create(context) { @@ -61,12 +66,12 @@ module.exports = { if (parent && parent.type === "ReturnStatement") { context.report({ node: parent, - message: "Return statement should not contain assignment." + messageId: "returnAssignment" }); } else if (parent && parent.type === "ArrowFunctionExpression" && parent.body === currentChild) { context.report({ node: parent, - message: "Arrow function should not return assignment." + messageId: "arrowAssignment" }); } } diff --git a/tools/node_modules/eslint/lib/rules/no-return-await.js b/tools/node_modules/eslint/lib/rules/no-return-await.js index 6652b5932dc1b8..d1d89826856dc4 100644 --- a/tools/node_modules/eslint/lib/rules/no-return-await.js +++ b/tools/node_modules/eslint/lib/rules/no-return-await.js @@ -10,8 +10,6 @@ const astUtils = require("./utils/ast-utils"); // Rule Definition //------------------------------------------------------------------------------ -const message = "Redundant use of `await` on a return value."; - module.exports = { meta: { type: "suggestion", @@ -28,7 +26,11 @@ module.exports = { fixable: null, schema: [ - ] + ], + + messages: { + redundantUseOfAwait: "Redundant use of `await` on a return value." + } }, create(context) { @@ -42,7 +44,7 @@ module.exports = { context.report({ node: context.getSourceCode().getFirstToken(node), loc: node.loc, - message + messageId: "redundantUseOfAwait" }); } diff --git a/tools/node_modules/eslint/lib/rules/no-script-url.js b/tools/node_modules/eslint/lib/rules/no-script-url.js index 40e9bfe8b27544..2078fc1dcea122 100644 --- a/tools/node_modules/eslint/lib/rules/no-script-url.js +++ b/tools/node_modules/eslint/lib/rules/no-script-url.js @@ -22,7 +22,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-script-url" }, - schema: [] + schema: [], + + messages: { + unexpectedScriptURL: "Script URL is a form of eval." + } }, create(context) { @@ -34,7 +38,7 @@ module.exports = { const value = node.value.toLowerCase(); if (value.indexOf("javascript:") === 0) { - context.report({ node, message: "Script URL is a form of eval." }); + context.report({ node, messageId: "unexpectedScriptURL" }); } } } diff --git a/tools/node_modules/eslint/lib/rules/no-self-assign.js b/tools/node_modules/eslint/lib/rules/no-self-assign.js index 705d0f409c4128..170e46b05930d1 100644 --- a/tools/node_modules/eslint/lib/rules/no-self-assign.js +++ b/tools/node_modules/eslint/lib/rules/no-self-assign.js @@ -196,7 +196,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + selfAssignment: "'{{name}}' is assigned to itself." + } }, create(context) { @@ -211,7 +215,7 @@ module.exports = { function report(node) { context.report({ node, - message: "'{{name}}' is assigned to itself.", + messageId: "selfAssignment", data: { name: sourceCode.getText(node).replace(SPACES, "") } diff --git a/tools/node_modules/eslint/lib/rules/no-self-compare.js b/tools/node_modules/eslint/lib/rules/no-self-compare.js index 8986240ec5c842..79b6ac7ea0f28d 100644 --- a/tools/node_modules/eslint/lib/rules/no-self-compare.js +++ b/tools/node_modules/eslint/lib/rules/no-self-compare.js @@ -21,7 +21,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-self-compare" }, - schema: [] + schema: [], + + messages: { + comparingToSelf: "Comparing to itself is potentially pointless." + } }, create(context) { @@ -47,7 +51,7 @@ module.exports = { const operators = new Set(["===", "==", "!==", "!=", ">", "<", ">=", "<="]); if (operators.has(node.operator) && hasSameTokens(node.left, node.right)) { - context.report({ node, message: "Comparing to itself is potentially pointless." }); + context.report({ node, messageId: "comparingToSelf" }); } } }; diff --git a/tools/node_modules/eslint/lib/rules/no-sequences.js b/tools/node_modules/eslint/lib/rules/no-sequences.js index 8046a8711a3e9a..d67635d117549e 100644 --- a/tools/node_modules/eslint/lib/rules/no-sequences.js +++ b/tools/node_modules/eslint/lib/rules/no-sequences.js @@ -26,7 +26,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-sequences" }, - schema: [] + schema: [], + + messages: { + unexpectedCommaExpression: "Unexpected use of comma operator." + } }, create(context) { @@ -107,7 +111,7 @@ module.exports = { const firstCommaToken = sourceCode.getTokenAfter(node.expressions[0], astUtils.isCommaToken); - context.report({ node, loc: firstCommaToken.loc, message: "Unexpected use of comma operator." }); + context.report({ node, loc: firstCommaToken.loc, messageId: "unexpectedCommaExpression" }); } }; diff --git a/tools/node_modules/eslint/lib/rules/no-shadow-restricted-names.js b/tools/node_modules/eslint/lib/rules/no-shadow-restricted-names.js index 9030d523b705d2..9647e9a1bcdd9e 100644 --- a/tools/node_modules/eslint/lib/rules/no-shadow-restricted-names.js +++ b/tools/node_modules/eslint/lib/rules/no-shadow-restricted-names.js @@ -32,7 +32,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-shadow-restricted-names" }, - schema: [] + schema: [], + + messages: { + shadowingRestrictedName: "Shadowing of global property '{{name}}'." + } }, create(context) { @@ -46,9 +50,9 @@ module.exports = { if (variable.defs.length > 0 && RESTRICTED.has(variable.name) && !safelyShadowsUndefined(variable)) { context.report({ node: variable.defs[0].name, - message: "Shadowing of global property '{{idName}}'.", + messageId: "shadowingRestrictedName", data: { - idName: variable.name + name: variable.name } }); } diff --git a/tools/node_modules/eslint/lib/rules/no-spaced-func.js b/tools/node_modules/eslint/lib/rules/no-spaced-func.js index 8535881f435e48..961bc681f7eac5 100644 --- a/tools/node_modules/eslint/lib/rules/no-spaced-func.js +++ b/tools/node_modules/eslint/lib/rules/no-spaced-func.js @@ -26,7 +26,11 @@ module.exports = { replacedBy: ["func-call-spacing"], fixable: "whitespace", - schema: [] + schema: [], + + messages: { + noSpacedFunction: "Unexpected space between function name and paren." + } }, create(context) { @@ -62,7 +66,7 @@ module.exports = { context.report({ node, loc: lastCalleeToken.loc.start, - message: "Unexpected space between function name and paren.", + messageId: "noSpacedFunction", fix(fixer) { return fixer.removeRange([prevToken.range[1], parenToken.range[0]]); } diff --git a/tools/node_modules/eslint/lib/rules/no-sparse-arrays.js b/tools/node_modules/eslint/lib/rules/no-sparse-arrays.js index 985109c36b267d..e8407c3faede2d 100644 --- a/tools/node_modules/eslint/lib/rules/no-sparse-arrays.js +++ b/tools/node_modules/eslint/lib/rules/no-sparse-arrays.js @@ -19,7 +19,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-sparse-arrays" }, - schema: [] + schema: [], + + messages: { + unexpectedSparseArray: "Unexpected comma in middle of array." + } }, create(context) { @@ -36,7 +40,7 @@ module.exports = { const emptySpot = node.elements.indexOf(null) > -1; if (emptySpot) { - context.report({ node, message: "Unexpected comma in middle of array." }); + context.report({ node, messageId: "unexpectedSparseArray" }); } } diff --git a/tools/node_modules/eslint/lib/rules/no-sync.js b/tools/node_modules/eslint/lib/rules/no-sync.js index 578bac96d3d061..d8111059631734 100644 --- a/tools/node_modules/eslint/lib/rules/no-sync.js +++ b/tools/node_modules/eslint/lib/rules/no-sync.js @@ -33,7 +33,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + noSync: "Unexpected sync method: '{{propertyName}}'." + } }, create(context) { @@ -45,7 +49,7 @@ module.exports = { [selector](node) { context.report({ node, - message: "Unexpected sync method: '{{propertyName}}'.", + messageId: "noSync", data: { propertyName: node.property.name } diff --git a/tools/node_modules/eslint/lib/rules/no-tabs.js b/tools/node_modules/eslint/lib/rules/no-tabs.js index 3fc0b78b6e741c..ca7be261653c02 100644 --- a/tools/node_modules/eslint/lib/rules/no-tabs.js +++ b/tools/node_modules/eslint/lib/rules/no-tabs.js @@ -35,7 +35,11 @@ module.exports = { } }, additionalProperties: false - }] + }], + + messages: { + unexpectedTab: "Unexpected tab character." + } }, create(context) { @@ -64,7 +68,7 @@ module.exports = { column: match.index + match[0].length } }, - message: "Unexpected tab character." + messageId: "unexpectedTab" }); } }); diff --git a/tools/node_modules/eslint/lib/rules/no-template-curly-in-string.js b/tools/node_modules/eslint/lib/rules/no-template-curly-in-string.js index f7822e961cc1e7..539cd5be5ff9c5 100644 --- a/tools/node_modules/eslint/lib/rules/no-template-curly-in-string.js +++ b/tools/node_modules/eslint/lib/rules/no-template-curly-in-string.js @@ -19,7 +19,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-template-curly-in-string" }, - schema: [] + schema: [], + + messages: { + unexpectedTemplateExpression: "Unexpected template string expression." + } }, create(context) { @@ -30,7 +34,7 @@ module.exports = { if (typeof node.value === "string" && regex.test(node.value)) { context.report({ node, - message: "Unexpected template string expression." + messageId: "unexpectedTemplateExpression" }); } } diff --git a/tools/node_modules/eslint/lib/rules/no-ternary.js b/tools/node_modules/eslint/lib/rules/no-ternary.js index 890f2abfa0c59a..b3ced86056614c 100644 --- a/tools/node_modules/eslint/lib/rules/no-ternary.js +++ b/tools/node_modules/eslint/lib/rules/no-ternary.js @@ -20,7 +20,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-ternary" }, - schema: [] + schema: [], + + messages: { + noTernaryOperator: "Ternary operator used." + } }, create(context) { @@ -28,7 +32,7 @@ module.exports = { return { ConditionalExpression(node) { - context.report({ node, message: "Ternary operator used." }); + context.report({ node, messageId: "noTernaryOperator" }); } }; diff --git a/tools/node_modules/eslint/lib/rules/no-this-before-super.js b/tools/node_modules/eslint/lib/rules/no-this-before-super.js index 6975ea060bf00d..44288c0c97136e 100644 --- a/tools/node_modules/eslint/lib/rules/no-this-before-super.js +++ b/tools/node_modules/eslint/lib/rules/no-this-before-super.js @@ -45,7 +45,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-this-before-super" }, - schema: [] + schema: [], + + messages: { + noBeforeSuper: "'{{kind}}' is not allowed before 'super()'." + } }, create(context) { @@ -187,7 +191,7 @@ module.exports = { const invalidNode = info.invalidNodes[i]; context.report({ - message: "'{{kind}}' is not allowed before 'super()'.", + messageId: "noBeforeSuper", node: invalidNode, data: { kind: invalidNode.type === "Super" ? "super" : "this" diff --git a/tools/node_modules/eslint/lib/rules/no-trailing-spaces.js b/tools/node_modules/eslint/lib/rules/no-trailing-spaces.js index 3a4124f4c0f7a4..98ae62c896359c 100644 --- a/tools/node_modules/eslint/lib/rules/no-trailing-spaces.js +++ b/tools/node_modules/eslint/lib/rules/no-trailing-spaces.js @@ -42,7 +42,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + trailingSpace: "Trailing spaces not allowed." + } }, create(context) { @@ -74,7 +78,7 @@ module.exports = { context.report({ node, loc: location, - message: "Trailing spaces not allowed.", + messageId: "trailingSpace", fix(fixer) { return fixer.removeRange(fixRange); } diff --git a/tools/node_modules/eslint/lib/rules/no-undef-init.js b/tools/node_modules/eslint/lib/rules/no-undef-init.js index 1fdccb867b3c24..5c240fef742b83 100644 --- a/tools/node_modules/eslint/lib/rules/no-undef-init.js +++ b/tools/node_modules/eslint/lib/rules/no-undef-init.js @@ -23,7 +23,11 @@ module.exports = { }, schema: [], - fixable: "code" + fixable: "code", + + messages: { + unnecessaryUndefinedInit: "It's not necessary to initialize '{{name}}' to undefined." + } }, create(context) { @@ -43,7 +47,7 @@ module.exports = { if (init === "undefined" && node.parent.kind !== "const" && !shadowed) { context.report({ node, - message: "It's not necessary to initialize '{{name}}' to undefined.", + messageId: "unnecessaryUndefinedInit", data: { name }, fix(fixer) { if (node.parent.kind === "var") { diff --git a/tools/node_modules/eslint/lib/rules/no-undefined.js b/tools/node_modules/eslint/lib/rules/no-undefined.js index b92f6700637c30..a075d903e21e98 100644 --- a/tools/node_modules/eslint/lib/rules/no-undefined.js +++ b/tools/node_modules/eslint/lib/rules/no-undefined.js @@ -19,7 +19,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-undefined" }, - schema: [] + schema: [], + + messages: { + unexpectedUndefined: "Unexpected use of undefined." + } }, create(context) { @@ -32,7 +36,7 @@ module.exports = { function report(node) { context.report({ node, - message: "Unexpected use of undefined." + messageId: "unexpectedUndefined" }); } diff --git a/tools/node_modules/eslint/lib/rules/no-underscore-dangle.js b/tools/node_modules/eslint/lib/rules/no-underscore-dangle.js index e910e2739a740a..1468198ac4e958 100644 --- a/tools/node_modules/eslint/lib/rules/no-underscore-dangle.js +++ b/tools/node_modules/eslint/lib/rules/no-underscore-dangle.js @@ -49,7 +49,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + unexpectedUnderscore: "Unexpected dangling '_' in '{{identifier}}'." + } }, create(context) { @@ -134,7 +138,7 @@ module.exports = { if (typeof identifier !== "undefined" && hasTrailingUnderscore(identifier) && !isAllowed(identifier)) { context.report({ node, - message: "Unexpected dangling '_' in '{{identifier}}'.", + messageId: "unexpectedUnderscore", data: { identifier } @@ -156,7 +160,7 @@ module.exports = { !isSpecialCaseIdentifierInVariableExpression(identifier) && !isAllowed(identifier)) { context.report({ node, - message: "Unexpected dangling '_' in '{{identifier}}'.", + messageId: "unexpectedUnderscore", data: { identifier } @@ -183,7 +187,7 @@ module.exports = { !isSpecialCaseIdentifierForMemberExpression(identifier) && !isAllowed(identifier)) { context.report({ node, - message: "Unexpected dangling '_' in '{{identifier}}'.", + messageId: "unexpectedUnderscore", data: { identifier } @@ -204,7 +208,7 @@ module.exports = { if (typeof identifier !== "undefined" && enforceInMethodNames && isMethod && hasTrailingUnderscore(identifier)) { context.report({ node, - message: "Unexpected dangling '_' in '{{identifier}}'.", + messageId: "unexpectedUnderscore", data: { identifier } diff --git a/tools/node_modules/eslint/lib/rules/no-unmodified-loop-condition.js b/tools/node_modules/eslint/lib/rules/no-unmodified-loop-condition.js index 3b8e7417d5b586..7031a4dd8b83fc 100644 --- a/tools/node_modules/eslint/lib/rules/no-unmodified-loop-condition.js +++ b/tools/node_modules/eslint/lib/rules/no-unmodified-loop-condition.js @@ -167,7 +167,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-unmodified-loop-condition" }, - schema: [] + schema: [], + + messages: { + loopConditionNotModified: "'{{name}}' is not modified in this loop." + } }, create(context) { @@ -184,7 +188,7 @@ module.exports = { context.report({ node, - message: "'{{name}}' is not modified in this loop.", + messageId: "loopConditionNotModified", data: node }); } 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 893baa34f74917..d4438e2fe08fbe 100644 --- a/tools/node_modules/eslint/lib/rules/no-unneeded-ternary.js +++ b/tools/node_modules/eslint/lib/rules/no-unneeded-ternary.js @@ -47,7 +47,12 @@ module.exports = { } ], - fixable: "code" + fixable: "code", + + messages: { + unnecessaryConditionalExpression: "Unnecessary use of boolean literals in conditional expression.", + unnecessaryConditionalAssignment: "Unnecessary use of conditional expression for default assignment." + } }, create(context) { @@ -118,7 +123,7 @@ module.exports = { context.report({ node, loc: node.consequent.loc.start, - message: "Unnecessary use of boolean literals in conditional expression.", + messageId: "unnecessaryConditionalExpression", fix(fixer) { if (node.consequent.value === node.alternate.value) { @@ -140,7 +145,7 @@ module.exports = { context.report({ node, loc: node.consequent.loc.start, - message: "Unnecessary use of conditional expression for default assignment.", + messageId: "unnecessaryConditionalAssignment", fix: fixer => { const shouldParenthesizeAlternate = ( astUtils.getPrecedence(node.alternate) < OR_PRECEDENCE && diff --git a/tools/node_modules/eslint/lib/rules/no-unreachable.js b/tools/node_modules/eslint/lib/rules/no-unreachable.js index 91c4ca7150903f..415631a6f7d726 100644 --- a/tools/node_modules/eslint/lib/rules/no-unreachable.js +++ b/tools/node_modules/eslint/lib/rules/no-unreachable.js @@ -110,7 +110,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-unreachable" }, - schema: [] + schema: [], + + messages: { + unreachableCode: "Unreachable code." + } }, create(context) { @@ -154,7 +158,7 @@ module.exports = { */ if (!range.isEmpty) { context.report({ - message: "Unreachable code.", + messageId: "unreachableCode", loc: range.location, node: range.startNode }); diff --git a/tools/node_modules/eslint/lib/rules/no-unsafe-finally.js b/tools/node_modules/eslint/lib/rules/no-unsafe-finally.js index a41dff9c80372f..11bf06e872a813 100644 --- a/tools/node_modules/eslint/lib/rules/no-unsafe-finally.js +++ b/tools/node_modules/eslint/lib/rules/no-unsafe-finally.js @@ -29,7 +29,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-unsafe-finally" }, - schema: [] + schema: [], + + messages: { + unsafeUsage: "Unsafe usage of {{nodeType}}." + } }, create(context) { @@ -86,7 +90,7 @@ module.exports = { function check(node) { if (isInFinallyBlock(node, node.label)) { context.report({ - message: "Unsafe usage of {{nodeType}}.", + messageId: "unsafeUsage", data: { nodeType: node.type }, 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 fd0440256be016..26a25b7584bc80 100644 --- a/tools/node_modules/eslint/lib/rules/no-unused-expressions.js +++ b/tools/node_modules/eslint/lib/rules/no-unused-expressions.js @@ -38,7 +38,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + unusedExpression: "Expected an assignment or function call and instead saw an expression." + } }, create(context) { @@ -127,7 +131,7 @@ module.exports = { return { ExpressionStatement(node) { if (!isValidExpression(node.expression) && !isDirective(node, context.getAncestors())) { - context.report({ node, message: "Expected an assignment or function call and instead saw an expression." }); + context.report({ node, messageId: "unusedExpression" }); } } }; 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 63e6e048ef1e46..18c48bf0d7810c 100644 --- a/tools/node_modules/eslint/lib/rules/no-unused-vars.js +++ b/tools/node_modules/eslint/lib/rules/no-unused-vars.js @@ -11,6 +11,18 @@ const astUtils = require("./utils/ast-utils"); +//------------------------------------------------------------------------------ +// Typedefs +//------------------------------------------------------------------------------ + +/** + * Bag of data used for formatting the `unusedVar` lint message. + * @typedef {Object} UnusedVarMessageData + * @property {string} varName The name of the unused var. + * @property {'defined'|'assigned a value'} action Description of the vars state. + * @property {string} additional Any additional info to be appended at the end. + */ + //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -60,7 +72,11 @@ module.exports = { } ] } - ] + ], + + messages: { + unusedVar: "'{{varName}}' is {{action}} but never used{{additional}}." + } }, create(context) { @@ -101,12 +117,12 @@ module.exports = { } /** - * Generate the warning message about the variable being - * defined and unused, including the ignore pattern if configured. + * Generates the message data about the variable being defined and unused, + * including the ignore pattern if configured. * @param {Variable} unusedVar eslint-scope variable object. - * @returns {string} The warning message to be used with this unused variable. + * @returns {UnusedVarMessageData} The message data to be used with this unused variable. */ - function getDefinedMessage(unusedVar) { + function getDefinedMessageData(unusedVar) { const defType = unusedVar.defs && unusedVar.defs[0] && unusedVar.defs[0].type; let type; let pattern; @@ -122,20 +138,29 @@ module.exports = { pattern = config.varsIgnorePattern.toString(); } - const additional = type ? ` Allowed unused ${type} must match ${pattern}.` : ""; + const additional = type ? `. Allowed unused ${type} must match ${pattern}` : ""; - return `'{{name}}' is defined but never used.${additional}`; + return { + varName: unusedVar.name, + action: "defined", + additional + }; } /** * Generate the warning message about the variable being * assigned and unused, including the ignore pattern if configured. - * @returns {string} The warning message to be used with this unused variable. + * @param {Variable} unusedVar eslint-scope variable object. + * @returns {UnusedVarMessageData} The message data to be used with this unused variable. */ - function getAssignedMessage() { - const additional = config.varsIgnorePattern ? ` Allowed unused vars must match ${config.varsIgnorePattern.toString()}.` : ""; - - return `'{{name}}' is assigned a value but never used.${additional}`; + function getAssignedMessageData(unusedVar) { + const additional = config.varsIgnorePattern ? `. Allowed unused vars must match ${config.varsIgnorePattern.toString()}` : ""; + + return { + varName: unusedVar.name, + action: "assigned a value", + additional + }; } //-------------------------------------------------------------------------- @@ -282,7 +307,7 @@ module.exports = { function getRhsNode(ref, prevRhsNode) { const id = ref.identifier; const parent = id.parent; - const granpa = parent.parent; + const grandparent = parent.parent; const refScope = ref.from.variableScope; const varScope = ref.resolved.scope.variableScope; const canBeUsedLater = refScope !== varScope || astUtils.isInLoop(id); @@ -296,7 +321,7 @@ module.exports = { } if (parent.type === "AssignmentExpression" && - granpa.type === "ExpressionStatement" && + grandparent.type === "ExpressionStatement" && id === parent.left && !canBeUsedLater ) { @@ -342,7 +367,7 @@ module.exports = { /* * If it encountered statements, this is a complex pattern. - * Since analyzeing complex patterns is hard, this returns `true` to avoid false positive. + * Since analyzing complex patterns is hard, this returns `true` to avoid false positive. */ return true; } @@ -389,7 +414,7 @@ module.exports = { function isReadForItself(ref, rhsNode) { const id = ref.identifier; const parent = id.parent; - const granpa = parent.parent; + const grandparent = parent.parent; return ref.isRead() && ( @@ -397,12 +422,12 @@ module.exports = { (// in RHS of an assignment for itself. e.g. `a = a + 1` (( parent.type === "AssignmentExpression" && - granpa.type === "ExpressionStatement" && + grandparent.type === "ExpressionStatement" && parent.left === id ) || ( parent.type === "UpdateExpression" && - granpa.type === "ExpressionStatement" + grandparent.type === "ExpressionStatement" ) || rhsNode && isInside(id, rhsNode) && !isInsideOfStorableFunction(id, rhsNode))) @@ -595,10 +620,10 @@ module.exports = { if (unusedVar.defs.length > 0) { context.report({ node: unusedVar.identifiers[0], - message: unusedVar.references.some(ref => ref.isWrite()) - ? getAssignedMessage() - : getDefinedMessage(unusedVar), - data: unusedVar + messageId: "unusedVar", + data: unusedVar.references.some(ref => ref.isWrite()) + ? getAssignedMessageData(unusedVar) + : getDefinedMessageData(unusedVar) }); // If there are no regular declaration, report the first `/*globals*/` comment directive. @@ -608,8 +633,8 @@ module.exports = { context.report({ node: programNode, loc: astUtils.getNameLocationInGlobalDirectiveComment(sourceCode, directiveComment, unusedVar.name), - message: getDefinedMessage(unusedVar), - data: unusedVar + messageId: "unusedVar", + data: getDefinedMessageData(unusedVar) }); } } diff --git a/tools/node_modules/eslint/lib/rules/no-useless-call.js b/tools/node_modules/eslint/lib/rules/no-useless-call.js index 11cf524d124211..afc729d5de0d9b 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-call.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-call.js @@ -58,7 +58,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-useless-call" }, - schema: [] + schema: [], + + messages: { + unnecessaryCall: "Unnecessary '.{{name}}()'." + } }, create(context) { @@ -75,7 +79,7 @@ module.exports = { const thisArg = node.arguments[0]; if (isValidThisArg(expectedThis, thisArg, sourceCode)) { - context.report({ node, message: "unnecessary '.{{name}}()'.", data: { name: node.callee.property.name } }); + context.report({ node, messageId: "unnecessaryCall", data: { name: node.callee.property.name } }); } } }; diff --git a/tools/node_modules/eslint/lib/rules/no-useless-catch.js b/tools/node_modules/eslint/lib/rules/no-useless-catch.js index 37bf453aecd932..f303c272948489 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-catch.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-catch.js @@ -20,7 +20,12 @@ module.exports = { url: "https://eslint.org/docs/rules/no-useless-catch" }, - schema: [] + schema: [], + + messages: { + unnecessaryCatchClause: "Unnecessary catch clause.", + unnecessaryCatch: "Unnecessary try/catch wrapper." + } }, create(context) { @@ -37,12 +42,12 @@ module.exports = { if (node.parent.finalizer) { context.report({ node, - message: "Unnecessary catch clause." + messageId: "unnecessaryCatchClause" }); } else { context.report({ node: node.parent, - message: "Unnecessary try/catch wrapper." + messageId: "unnecessaryCatch" }); } } diff --git a/tools/node_modules/eslint/lib/rules/no-useless-computed-key.js b/tools/node_modules/eslint/lib/rules/no-useless-computed-key.js index 0e0acbea7c381c..e0505a318efaae 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-computed-key.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-computed-key.js @@ -15,8 +15,6 @@ const astUtils = require("./utils/ast-utils"); // Rule Definition //------------------------------------------------------------------------------ -const MESSAGE_UNNECESSARY_COMPUTED = "Unnecessarily computed property [{{property}}] found."; - module.exports = { meta: { type: "suggestion", @@ -38,7 +36,11 @@ module.exports = { }, additionalProperties: false }], - fixable: "code" + fixable: "code", + + messages: { + unnecessarilyComputedProperty: "Unnecessarily computed property [{{property}}] found." + } }, create(context) { const sourceCode = context.getSourceCode(); @@ -68,7 +70,7 @@ module.exports = { if (key.type === "Literal" && (nodeType === "string" || nodeType === "number") && key.value !== allowedKey) { context.report({ node, - message: MESSAGE_UNNECESSARY_COMPUTED, + messageId: "unnecessarilyComputedProperty", data: { property: sourceCode.getText(key) }, fix(fixer) { const leftSquareBracket = sourceCode.getTokenBefore(key, astUtils.isOpeningBracketToken); diff --git a/tools/node_modules/eslint/lib/rules/no-useless-concat.js b/tools/node_modules/eslint/lib/rules/no-useless-concat.js index cdaca273eb003f..aa46742abdd5ca 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-concat.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-concat.js @@ -1,5 +1,5 @@ /** - * @fileoverview disallow unncessary concatenation of template strings + * @fileoverview disallow unnecessary concatenation of template strings * @author Henry Zhu */ "use strict"; @@ -75,7 +75,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-useless-concat" }, - schema: [] + schema: [], + + messages: { + unexpectedConcat: "Unexpected string concatenation of literals." + } }, create(context) { @@ -102,7 +106,7 @@ module.exports = { context.report({ node, loc: operatorToken.loc.start, - message: "Unexpected string concatenation of literals." + messageId: "unexpectedConcat" }); } } diff --git a/tools/node_modules/eslint/lib/rules/no-useless-constructor.js b/tools/node_modules/eslint/lib/rules/no-useless-constructor.js index 2920328c6f39c0..4c34aeda715937 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-constructor.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-constructor.js @@ -115,7 +115,7 @@ function isPassingThrough(ctorParams, superArgs) { * Checks whether the constructor body is a redundant super call. * @param {Array} body constructor body content. * @param {Array} ctorParams The params to check against super call. - * @returns {boolean} true if the construtor body is redundant + * @returns {boolean} true if the constructor body is redundant */ function isRedundantSuperCall(body, ctorParams) { return ( diff --git a/tools/node_modules/eslint/lib/rules/no-useless-rename.js b/tools/node_modules/eslint/lib/rules/no-useless-rename.js index eb570a3ef5c1d3..fa88f37f50b79c 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-rename.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-rename.js @@ -32,7 +32,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + unnecessarilyRenamed: "{{type}} {{name}} unnecessarily renamed." + } }, create(context) { @@ -59,7 +63,7 @@ module.exports = { return context.report({ node, - message: "{{type}} {{name}} unnecessarily renamed.", + messageId: "unnecessarilyRenamed", data: { name, type diff --git a/tools/node_modules/eslint/lib/rules/no-useless-return.js b/tools/node_modules/eslint/lib/rules/no-useless-return.js index 942d4eede9964e..111cb21015fb81 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-return.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-return.js @@ -32,7 +32,7 @@ function remove(array, element) { /** * Checks whether it can remove the given return statement or not. * @param {ASTNode} node The return statement node to check. - * @returns {boolean} `true` if the node is removeable. + * @returns {boolean} `true` if the node is removable. */ function isRemovable(node) { return astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type); @@ -73,7 +73,11 @@ module.exports = { }, fixable: "code", - schema: [] + schema: [], + + messages: { + unnecessaryReturn: "Unnecessary return statement." + } }, create(context) { @@ -208,7 +212,7 @@ module.exports = { context.report({ node, loc: node.loc, - message: "Unnecessary return statement.", + messageId: "unnecessaryReturn", fix(fixer) { if (isRemovable(node) && !sourceCode.getCommentsInside(node).length) { diff --git a/tools/node_modules/eslint/lib/rules/no-var.js b/tools/node_modules/eslint/lib/rules/no-var.js index 74203f8bf3bebf..f2cb96b1f708e9 100644 --- a/tools/node_modules/eslint/lib/rules/no-var.js +++ b/tools/node_modules/eslint/lib/rules/no-var.js @@ -191,7 +191,11 @@ module.exports = { }, schema: [], - fixable: "code" + fixable: "code", + + messages: { + unexpectedVar: "Unexpected var, use let or const instead." + } }, create(context) { @@ -307,7 +311,7 @@ module.exports = { function report(node) { context.report({ node, - message: "Unexpected var, use let or const instead.", + messageId: "unexpectedVar", fix(fixer) { const varToken = sourceCode.getFirstToken(node, { filter: t => t.value === "var" }); diff --git a/tools/node_modules/eslint/lib/rules/no-warning-comments.js b/tools/node_modules/eslint/lib/rules/no-warning-comments.js index a400c446767ff7..d70bd5dd5c4002 100644 --- a/tools/node_modules/eslint/lib/rules/no-warning-comments.js +++ b/tools/node_modules/eslint/lib/rules/no-warning-comments.js @@ -39,7 +39,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + unexpectedComment: "Unexpected '{{matchedTerm}}' comment." + } }, create(context) { @@ -140,7 +144,7 @@ module.exports = { matches.forEach(matchedTerm => { context.report({ node, - message: "Unexpected '{{matchedTerm}}' comment.", + messageId: "unexpectedComment", data: { matchedTerm } diff --git a/tools/node_modules/eslint/lib/rules/no-whitespace-before-property.js b/tools/node_modules/eslint/lib/rules/no-whitespace-before-property.js index 9541401a3176b7..ccd0b091b744e3 100644 --- a/tools/node_modules/eslint/lib/rules/no-whitespace-before-property.js +++ b/tools/node_modules/eslint/lib/rules/no-whitespace-before-property.js @@ -26,7 +26,11 @@ module.exports = { }, fixable: "whitespace", - schema: [] + schema: [], + + messages: { + unexpectedWhitespace: "Unexpected whitespace before property {{propName}}." + } }, create(context) { @@ -49,7 +53,7 @@ module.exports = { context.report({ node, - message: "Unexpected whitespace before property {{propName}}.", + messageId: "unexpectedWhitespace", data: { propName: sourceCode.getText(node.property) }, diff --git a/tools/node_modules/eslint/lib/rules/no-with.js b/tools/node_modules/eslint/lib/rules/no-with.js index 5763661584c061..d3e52e02f3d15a 100644 --- a/tools/node_modules/eslint/lib/rules/no-with.js +++ b/tools/node_modules/eslint/lib/rules/no-with.js @@ -20,14 +20,18 @@ module.exports = { url: "https://eslint.org/docs/rules/no-with" }, - schema: [] + schema: [], + + messages: { + unexpectedWith: "Unexpected use of 'with' statement." + } }, create(context) { return { WithStatement(node) { - context.report({ node, message: "Unexpected use of 'with' statement." }); + context.report({ node, messageId: "unexpectedWith" }); } }; diff --git a/tools/node_modules/eslint/lib/rules/nonblock-statement-body-position.js b/tools/node_modules/eslint/lib/rules/nonblock-statement-body-position.js index 01763cea92f381..34e6eeac39de50 100644 --- a/tools/node_modules/eslint/lib/rules/nonblock-statement-body-position.js +++ b/tools/node_modules/eslint/lib/rules/nonblock-statement-body-position.js @@ -40,7 +40,12 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + expectNoLinebreak: "Expected no linebreak before this statement.", + expectLinebreak: "Expected a linebreak before this statement." + } }, create(context) { @@ -79,13 +84,13 @@ module.exports = { if (tokenBefore.loc.end.line === node.loc.start.line && option === "below") { context.report({ node, - message: "Expected a linebreak before this statement.", + messageId: "expectLinebreak", fix: fixer => fixer.insertTextBefore(node, "\n") }); } else if (tokenBefore.loc.end.line !== node.loc.start.line && option === "beside") { context.report({ node, - message: "Expected no linebreak before this statement.", + messageId: "expectNoLinebreak", fix(fixer) { if (sourceCode.getText().slice(tokenBefore.range[1], node.range[0]).trim()) { return null; diff --git a/tools/node_modules/eslint/lib/rules/object-curly-newline.js b/tools/node_modules/eslint/lib/rules/object-curly-newline.js index e870a69a954180..b48b2526a0b2bd 100644 --- a/tools/node_modules/eslint/lib/rules/object-curly-newline.js +++ b/tools/node_modules/eslint/lib/rules/object-curly-newline.js @@ -159,7 +159,14 @@ module.exports = { } ] } - ] + ], + + messages: { + unexpectedLinebreakBeforeClosingBrace: "Unexpected line break before this closing brace.", + unexpectedLinebreakAfterOpeningBrace: "Unexpected line break after this opening brace.", + expectedLinebreakBeforeClosingBrace: "Expected a line break before this closing brace.", + expectedLinebreakAfterOpeningBrace: "Expected a line break after this opening brace." + } }, create(context) { @@ -215,7 +222,7 @@ module.exports = { if (needsLineBreaks) { if (astUtils.isTokenOnSameLine(openBrace, first)) { context.report({ - message: "Expected a line break after this opening brace.", + messageId: "expectedLinebreakAfterOpeningBrace", node, loc: openBrace.loc.start, fix(fixer) { @@ -229,7 +236,7 @@ module.exports = { } if (astUtils.isTokenOnSameLine(last, closeBrace)) { context.report({ - message: "Expected a line break before this closing brace.", + messageId: "expectedLinebreakBeforeClosingBrace", node, loc: closeBrace.loc.start, fix(fixer) { @@ -251,7 +258,7 @@ module.exports = { (consistent && hasLineBreakBetweenOpenBraceAndFirst && !hasLineBreakBetweenCloseBraceAndLast) ) { context.report({ - message: "Unexpected line break after this opening brace.", + messageId: "unexpectedLinebreakAfterOpeningBrace", node, loc: openBrace.loc.start, fix(fixer) { @@ -271,7 +278,7 @@ module.exports = { (consistent && !hasLineBreakBetweenOpenBraceAndFirst && hasLineBreakBetweenCloseBraceAndLast) ) { context.report({ - message: "Unexpected line break before this closing brace.", + messageId: "unexpectedLinebreakBeforeClosingBrace", node, loc: closeBrace.loc.start, fix(fixer) { diff --git a/tools/node_modules/eslint/lib/rules/object-curly-spacing.js b/tools/node_modules/eslint/lib/rules/object-curly-spacing.js index 117a7a35426103..c0044f5033c005 100644 --- a/tools/node_modules/eslint/lib/rules/object-curly-spacing.js +++ b/tools/node_modules/eslint/lib/rules/object-curly-spacing.js @@ -39,7 +39,14 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + requireSpaceBefore: "A space is required before '{{token}}'.", + requireSpaceAfter: "A space is required after '{{token}}'.", + unexpectedSpaceBefore: "There should be no space before '{{token}}'.", + unexpectedSpaceAfter: "There should be no space after '{{token}}'." + } }, create(context) { @@ -79,7 +86,7 @@ module.exports = { context.report({ node, loc: { start: token.loc.end, end: nextToken.loc.start }, - message: "There should be no space after '{{token}}'.", + messageId: "unexpectedSpaceAfter", data: { token: token.value }, @@ -101,7 +108,7 @@ module.exports = { context.report({ node, loc: { start: previousToken.loc.end, end: token.loc.start }, - message: "There should be no space before '{{token}}'.", + messageId: "unexpectedSpaceBefore", data: { token: token.value }, @@ -121,7 +128,7 @@ module.exports = { context.report({ node, loc: token.loc, - message: "A space is required after '{{token}}'.", + messageId: "requireSpaceAfter", data: { token: token.value }, @@ -141,7 +148,7 @@ module.exports = { context.report({ node, loc: token.loc, - message: "A space is required before '{{token}}'.", + messageId: "requireSpaceBefore", data: { token: token.value }, diff --git a/tools/node_modules/eslint/lib/rules/object-property-newline.js b/tools/node_modules/eslint/lib/rules/object-property-newline.js index bf777b5ff65ba2..074bc775ae35a3 100644 --- a/tools/node_modules/eslint/lib/rules/object-property-newline.js +++ b/tools/node_modules/eslint/lib/rules/object-property-newline.js @@ -37,16 +37,21 @@ module.exports = { } ], - fixable: "whitespace" + fixable: "whitespace", + + messages: { + propertiesOnNewlineAll: "Object properties must go on a new line if they aren't all on the same line.", + propertiesOnNewline: "Object properties must go on a new line." + } }, create(context) { const allowSameLine = context.options[0] && ( (context.options[0].allowAllPropertiesOnSameLine || context.options[0].allowMultiplePropertiesPerLine /* Deprecated */) ); - const errorMessage = allowSameLine - ? "Object properties must go on a new line if they aren't all on the same line." - : "Object properties must go on a new line."; + const messageId = allowSameLine + ? "propertiesOnNewlineAll" + : "propertiesOnNewline"; const sourceCode = context.getSourceCode(); @@ -73,7 +78,7 @@ module.exports = { context.report({ node, loc: firstTokenOfCurrentProperty.loc.start, - message: errorMessage, + messageId, fix(fixer) { const comma = sourceCode.getTokenBefore(firstTokenOfCurrentProperty); const rangeAfterComma = [comma.range[1], firstTokenOfCurrentProperty.range[0]]; diff --git a/tools/node_modules/eslint/lib/rules/object-shorthand.js b/tools/node_modules/eslint/lib/rules/object-shorthand.js index d4afd09c5a52c4..3999ff8b99fb29 100644 --- a/tools/node_modules/eslint/lib/rules/object-shorthand.js +++ b/tools/node_modules/eslint/lib/rules/object-shorthand.js @@ -92,6 +92,16 @@ module.exports = { maxItems: 2 } ] + }, + + messages: { + expectedAllPropertiesShorthanded: "Expected shorthand for all properties.", + expectedLiteralMethodLongform: "Expected longform method syntax for string literal keys.", + expectedPropertyShorthand: "Expected property shorthand.", + expectedPropertyLongform: "Expected longform property syntax.", + expectedMethodShorthand: "Expected method shorthand.", + expectedMethodLongform: "Expected longform method syntax.", + unexpectedMix: "Unexpected mix of shorthand and non-shorthand properties." } }, @@ -211,7 +221,7 @@ module.exports = { // We have at least 1 shorthand property if (shorthandProperties.length > 0) { - context.report({ node, message: "Unexpected mix of shorthand and non-shorthand properties." }); + context.report({ node, messageId: "unexpectedMix" }); } else if (checkRedundancy) { /* @@ -221,7 +231,7 @@ module.exports = { const canAlwaysUseShorthand = properties.every(isRedundant); if (canAlwaysUseShorthand) { - context.report({ node, message: "Expected shorthand for all properties." }); + context.report({ node, messageId: "expectedAllPropertiesShorthanded" }); } } } @@ -430,12 +440,12 @@ module.exports = { // Checks for property/method shorthand. if (isConciseProperty) { if (node.method && (APPLY_NEVER || AVOID_QUOTES && isStringLiteral(node.key))) { - const message = APPLY_NEVER ? "Expected longform method syntax." : "Expected longform method syntax for string literal keys."; + const messageId = APPLY_NEVER ? "expectedMethodLongform" : "expectedLiteralMethodLongform"; // { x() {} } should be written as { x: function() {} } context.report({ node, - message, + messageId, fix: fixer => makeFunctionLongform(fixer, node) }); } else if (APPLY_NEVER) { @@ -443,7 +453,7 @@ module.exports = { // { x } should be written as { x: x } context.report({ node, - message: "Expected longform property syntax.", + messageId: "expectedPropertyLongform", fix: fixer => fixer.insertTextAfter(node.key, `: ${node.key.name}`) }); } @@ -464,7 +474,7 @@ module.exports = { ) { context.report({ node, - message: "Expected method shorthand.", + messageId: "expectedMethodShorthand", fix: fixer => makeFunctionShorthand(fixer, node) }); } @@ -473,7 +483,7 @@ module.exports = { // {x: x} should be written as {x} context.report({ node, - message: "Expected property shorthand.", + messageId: "expectedPropertyShorthand", fix(fixer) { return fixer.replaceText(node, node.value.name); } @@ -486,7 +496,7 @@ module.exports = { // {"x": x} should be written as {x} context.report({ node, - message: "Expected property shorthand.", + messageId: "expectedPropertyShorthand", fix(fixer) { return fixer.replaceText(node, node.value.name); } diff --git a/tools/node_modules/eslint/lib/rules/one-var-declaration-per-line.js b/tools/node_modules/eslint/lib/rules/one-var-declaration-per-line.js index b64656eefed0a9..30ca2cf49834fe 100644 --- a/tools/node_modules/eslint/lib/rules/one-var-declaration-per-line.js +++ b/tools/node_modules/eslint/lib/rules/one-var-declaration-per-line.js @@ -25,12 +25,15 @@ module.exports = { } ], - fixable: "whitespace" + fixable: "whitespace", + + messages: { + expectVarOnNewline: "Expected variable declaration to be on a new line." + } }, create(context) { - const ERROR_MESSAGE = "Expected variable declaration to be on a new line."; const always = context.options[0] === "always"; //-------------------------------------------------------------------------- @@ -67,7 +70,7 @@ module.exports = { if (always || prev.init || current.init) { context.report({ node, - message: ERROR_MESSAGE, + messageId: "expectVarOnNewline", loc: current.loc.start, fix: fixer => fixer.insertTextBefore(current, "\n") }); diff --git a/tools/node_modules/eslint/lib/rules/one-var.js b/tools/node_modules/eslint/lib/rules/one-var.js index e79461ce46c5be..c31a0d2b13c187 100644 --- a/tools/node_modules/eslint/lib/rules/one-var.js +++ b/tools/node_modules/eslint/lib/rules/one-var.js @@ -60,7 +60,17 @@ module.exports = { } ] } - ] + ], + + messages: { + combineUninitialized: "Combine this with the previous '{{type}}' statement with uninitialized variables.", + combineInitialized: "Combine this with the previous '{{type}}' statement with initialized variables.", + splitUninitialized: "Split uninitialized '{{type}}' declarations into multiple statements.", + splitInitialized: "Split initialized '{{type}}' declarations into multiple statements.", + splitRequires: "Split requires to be separated into a single block.", + combine: "Combine this with the previous '{{type}}' statement.", + split: "Split '{{type}}' declarations into multiple statements." + } }, create(context) { @@ -361,7 +371,7 @@ module.exports = { if (options.separateRequires && mixedRequires) { context.report({ node, - message: "Split requires to be separated into a single block." + messageId: "splitRequires" }); } } @@ -384,7 +394,7 @@ module.exports = { if (options[type].initialized === MODE_CONSECUTIVE && options[type].uninitialized === MODE_CONSECUTIVE) { context.report({ node, - message: "Combine this with the previous '{{type}}' statement.", + messageId: "combine", data: { type }, @@ -393,7 +403,7 @@ module.exports = { } else if (options[type].initialized === MODE_CONSECUTIVE && declarationCounts.initialized > 0 && previousDeclCounts.initialized > 0) { context.report({ node, - message: "Combine this with the previous '{{type}}' statement with initialized variables.", + messageId: "combineInitialized", data: { type }, @@ -404,7 +414,7 @@ module.exports = { previousDeclCounts.uninitialized > 0) { context.report({ node, - message: "Combine this with the previous '{{type}}' statement with uninitialized variables.", + messageId: "combineUninitialized", data: { type }, @@ -419,7 +429,7 @@ module.exports = { if (options[type].initialized === MODE_ALWAYS && options[type].uninitialized === MODE_ALWAYS) { context.report({ node, - message: "Combine this with the previous '{{type}}' statement.", + messageId: "combine", data: { type }, @@ -429,7 +439,7 @@ module.exports = { if (options[type].initialized === MODE_ALWAYS && declarationCounts.initialized > 0) { context.report({ node, - message: "Combine this with the previous '{{type}}' statement with initialized variables.", + messageId: "combineInitialized", data: { type }, @@ -442,7 +452,7 @@ module.exports = { } context.report({ node, - message: "Combine this with the previous '{{type}}' statement with uninitialized variables.", + messageId: "combineUninitialized", data: { type }, @@ -462,7 +472,7 @@ module.exports = { // both initialized and uninitialized context.report({ node, - message: "Split '{{type}}' declarations into multiple statements.", + messageId: "split", data: { type }, @@ -473,7 +483,7 @@ module.exports = { // initialized context.report({ node, - message: "Split initialized '{{type}}' declarations into multiple statements.", + messageId: "splitInitialized", data: { type }, @@ -484,7 +494,7 @@ module.exports = { // uninitialized context.report({ node, - message: "Split uninitialized '{{type}}' declarations into multiple statements.", + messageId: "splitUninitialized", data: { type }, diff --git a/tools/node_modules/eslint/lib/rules/operator-assignment.js b/tools/node_modules/eslint/lib/rules/operator-assignment.js index b19ba0d02e1a1b..c4c8671f327a93 100644 --- a/tools/node_modules/eslint/lib/rules/operator-assignment.js +++ b/tools/node_modules/eslint/lib/rules/operator-assignment.js @@ -26,10 +26,10 @@ function isCommutativeOperatorWithShorthand(operator) { } /** - * Checks whether an operator is not commuatative and has an operator assignment + * Checks whether an operator is not commutative and has an operator assignment * shorthand form. * @param {string} operator Operator to check. - * @returns {boolean} True if the operator is not commuatative and has + * @returns {boolean} True if the operator is not commutative and has * a shorthand form. */ function isNonCommutativeOperatorWithShorthand(operator) { @@ -219,7 +219,7 @@ module.exports = { if ( operatorToken.range[1] === firstRightToken.range[0] && - !astUtils.canTokensBeAdjacent(newOperator, firstRightToken) + !astUtils.canTokensBeAdjacent({ type: "Punctuator", value: newOperator }, firstRightToken) ) { rightTextPrefix = " "; // foo+=+bar -> foo= foo+ +bar } diff --git a/tools/node_modules/eslint/lib/rules/operator-linebreak.js b/tools/node_modules/eslint/lib/rules/operator-linebreak.js index bce0ef56a0cc6c..c2fddcffd25c7f 100644 --- a/tools/node_modules/eslint/lib/rules/operator-linebreak.js +++ b/tools/node_modules/eslint/lib/rules/operator-linebreak.js @@ -47,7 +47,14 @@ module.exports = { } ], - fixable: "code" + fixable: "code", + + messages: { + operatorAtBeginning: "'{{operator}}' should be placed at the beginning of the line.", + operatorAtEnd: "'{{operator}}' should be placed at the end of the line.", + badLinebreak: "Bad line breaking before and after '{{operator}}'.", + noLinebreak: "There should be no line break before or after '{{operator}}'." + } }, create(context) { @@ -169,7 +176,7 @@ module.exports = { line: operatorToken.loc.end.line, column: operatorToken.loc.end.column }, - message: "Bad line breaking before and after '{{operator}}'.", + messageId: "badLinebreak", data: { operator }, @@ -184,7 +191,7 @@ module.exports = { line: operatorToken.loc.end.line, column: operatorToken.loc.end.column }, - message: "'{{operator}}' should be placed at the beginning of the line.", + messageId: "operatorAtBeginning", data: { operator }, @@ -199,7 +206,7 @@ module.exports = { line: operatorToken.loc.end.line, column: operatorToken.loc.end.column }, - message: "'{{operator}}' should be placed at the end of the line.", + messageId: "operatorAtEnd", data: { operator }, @@ -214,7 +221,7 @@ module.exports = { line: operatorToken.loc.end.line, column: operatorToken.loc.end.column }, - message: "There should be no line break before or after '{{operator}}'.", + messageId: "noLinebreak", data: { operator }, diff --git a/tools/node_modules/eslint/lib/rules/padded-blocks.js b/tools/node_modules/eslint/lib/rules/padded-blocks.js index dafa88115edd78..f58a7535ba86c2 100644 --- a/tools/node_modules/eslint/lib/rules/padded-blocks.js +++ b/tools/node_modules/eslint/lib/rules/padded-blocks.js @@ -60,7 +60,12 @@ module.exports = { } } } - ] + ], + + messages: { + alwaysPadBlock: "Block must be padded by blank lines.", + neverPadBlock: "Block must not be padded by blank lines." + } }, create(context) { @@ -90,9 +95,6 @@ module.exports = { options.allowSingleLineBlocks = exceptOptions.allowSingleLineBlocks === true; } - const ALWAYS_MESSAGE = "Block must be padded by blank lines.", - NEVER_MESSAGE = "Block must not be padded by blank lines."; - const sourceCode = context.getSourceCode(); /** @@ -145,9 +147,9 @@ module.exports = { } /** - * Checks if the given token is preceeded by a blank line. + * Checks if the given token is preceded by a blank line. * @param {Token} token The token to check - * @returns {boolean} Whether or not the token is preceeded by a blank line + * @returns {boolean} Whether or not the token is preceded by a blank line */ function getLastBlockToken(token) { let last = token, @@ -208,7 +210,7 @@ module.exports = { fix(fixer) { return fixer.insertTextAfter(tokenBeforeFirst, "\n"); }, - message: ALWAYS_MESSAGE + messageId: "alwaysPadBlock" }); } if (!blockHasBottomPadding) { @@ -218,7 +220,7 @@ module.exports = { fix(fixer) { return fixer.insertTextBefore(tokenAfterLast, "\n"); }, - message: ALWAYS_MESSAGE + messageId: "alwaysPadBlock" }); } } else { @@ -230,7 +232,7 @@ module.exports = { fix(fixer) { return fixer.replaceTextRange([tokenBeforeFirst.range[1], firstBlockToken.range[0] - firstBlockToken.loc.start.column], "\n"); }, - message: NEVER_MESSAGE + messageId: "neverPadBlock" }); } @@ -239,7 +241,7 @@ module.exports = { context.report({ node, loc: { line: tokenAfterLast.loc.end.line, column: tokenAfterLast.loc.end.column - 1 }, - message: NEVER_MESSAGE, + messageId: "neverPadBlock", fix(fixer) { return fixer.replaceTextRange([lastBlockToken.range[1], tokenAfterLast.range[0] - tokenAfterLast.loc.start.column], "\n"); } diff --git a/tools/node_modules/eslint/lib/rules/padding-line-between-statements.js b/tools/node_modules/eslint/lib/rules/padding-line-between-statements.js index 350a9dbf2aba15..eea19f5ce5811b 100644 --- a/tools/node_modules/eslint/lib/rules/padding-line-between-statements.js +++ b/tools/node_modules/eslint/lib/rules/padding-line-between-statements.js @@ -243,7 +243,7 @@ function verifyForNever(context, _, nextNode, paddingLines) { context.report({ node: nextNode, - message: "Unexpected blank line before this statement.", + messageId: "unexpectedBlankLine", fix(fixer) { if (paddingLines.length >= 2) { return null; @@ -282,7 +282,7 @@ function verifyForAlways(context, prevNode, nextNode, paddingLines) { context.report({ node: nextNode, - message: "Expected blank line before this statement.", + messageId: "expectedBlankLine", fix(fixer) { const sourceCode = context.getSourceCode(); let prevToken = getActualLastToken(sourceCode, prevNode); @@ -468,6 +468,11 @@ module.exports = { required: ["blankLine", "prev", "next"] }, additionalItems: false + }, + + messages: { + unexpectedBlankLine: "Unexpected blank line before this statement.", + expectedBlankLine: "Expected blank line before this statement." } }, diff --git a/tools/node_modules/eslint/lib/rules/prefer-arrow-callback.js b/tools/node_modules/eslint/lib/rules/prefer-arrow-callback.js index 08126e5b1a5459..d4e0251940c503 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-arrow-callback.js +++ b/tools/node_modules/eslint/lib/rules/prefer-arrow-callback.js @@ -56,7 +56,7 @@ function getVariableOfArguments(scope) { } /** - * Checkes whether or not a given node is a callback. + * Checks whether or not a given node is a callback. * @param {ASTNode} node A node to check. * @returns {Object} * {boolean} retv.isCallback - `true` if the node is a callback. @@ -158,7 +158,11 @@ module.exports = { } ], - fixable: "code" + fixable: "code", + + messages: { + preferArrowCallback: "Unexpected function expression." + } }, create(context) { @@ -267,7 +271,7 @@ module.exports = { ) { context.report({ node, - message: "Unexpected function expression.", + messageId: "preferArrowCallback", fix(fixer) { if ((!callbackInfo.isLexicalThis && scopeInfo.this) || hasDuplicateParams(node.params)) { diff --git a/tools/node_modules/eslint/lib/rules/prefer-destructuring.js b/tools/node_modules/eslint/lib/rules/prefer-destructuring.js index eff37294a9b6ef..1a51956dde53ff 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-destructuring.js +++ b/tools/node_modules/eslint/lib/rules/prefer-destructuring.js @@ -82,7 +82,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + preferDestructuring: "Use {{type}} destructuring." + } }, create(context) { @@ -137,7 +141,7 @@ module.exports = { function report(reportNode, type, fix) { context.report({ node: reportNode, - message: "Use {{type}} destructuring.", + messageId: "preferDestructuring", data: { type }, fix }); 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 00f5fb6d4c8991..1344433f52fa93 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-object-spread.js +++ b/tools/node_modules/eslint/lib/rules/prefer-object-spread.js @@ -98,7 +98,7 @@ function argNeedsParens(node, sourceCode) { /** * Get the parenthesis tokens of a given ObjectExpression node. - * This incldues the braces of the object literal and enclosing parentheses. + * This includes the braces of the object literal and enclosing parentheses. * @param {ASTNode} node The node to get. * @param {Token} leftArgumentListParen The opening paren token of the argument list. * @param {SourceCode} sourceCode The source code object to get tokens. diff --git a/tools/node_modules/eslint/lib/rules/prefer-promise-reject-errors.js b/tools/node_modules/eslint/lib/rules/prefer-promise-reject-errors.js index e142a96b55c78f..56911b67adcc99 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-promise-reject-errors.js +++ b/tools/node_modules/eslint/lib/rules/prefer-promise-reject-errors.js @@ -31,7 +31,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + rejectAnError: "Expected the Promise rejection reason to be an Error." + } }, create(context) { @@ -58,7 +62,7 @@ module.exports = { ) { context.report({ node: callExpression, - message: "Expected the Promise rejection reason to be an Error." + messageId: "rejectAnError" }); } } diff --git a/tools/node_modules/eslint/lib/rules/prefer-reflect.js b/tools/node_modules/eslint/lib/rules/prefer-reflect.js index 796bbdf05fd446..fb2de923bea379 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-reflect.js +++ b/tools/node_modules/eslint/lib/rules/prefer-reflect.js @@ -49,7 +49,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + preferReflect: "Avoid using {{existing}}, instead use {{substitute}}." + } }, create(context) { @@ -65,7 +69,7 @@ module.exports = { preventExtensions: "Object.preventExtensions" }; - const reflectSubsitutes = { + const reflectSubstitutes = { apply: "Reflect.apply", call: "Reflect.apply", defineProperty: "Reflect.defineProperty", @@ -89,7 +93,7 @@ module.exports = { function report(node, existing, substitute) { context.report({ node, - message: "Avoid using {{existing}}, instead use {{substitute}}.", + messageId: "preferReflect", data: { existing, substitute @@ -101,11 +105,11 @@ module.exports = { CallExpression(node) { const methodName = (node.callee.property || {}).name; const isReflectCall = (node.callee.object || {}).name === "Reflect"; - const hasReflectSubsitute = Object.prototype.hasOwnProperty.call(reflectSubsitutes, methodName); + const hasReflectSubsitute = Object.prototype.hasOwnProperty.call(reflectSubstitutes, methodName); const userConfiguredException = exceptions.indexOf(methodName) !== -1; if (hasReflectSubsitute && !isReflectCall && !userConfiguredException) { - report(node, existingNames[methodName], reflectSubsitutes[methodName]); + report(node, existingNames[methodName], reflectSubstitutes[methodName]); } }, UnaryExpression(node) { diff --git a/tools/node_modules/eslint/lib/rules/prefer-rest-params.js b/tools/node_modules/eslint/lib/rules/prefer-rest-params.js index 3a28584f6bc126..3ecea732af8b94 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-rest-params.js +++ b/tools/node_modules/eslint/lib/rules/prefer-rest-params.js @@ -70,7 +70,11 @@ module.exports = { url: "https://eslint.org/docs/rules/prefer-rest-params" }, - schema: [] + schema: [], + + messages: { + preferRestParams: "Use the rest parameters instead of 'arguments'." + } }, create(context) { @@ -84,7 +88,7 @@ module.exports = { context.report({ node: reference.identifier, loc: reference.identifier.loc, - message: "Use the rest parameters instead of 'arguments'." + messageId: "preferRestParams" }); } diff --git a/tools/node_modules/eslint/lib/rules/prefer-spread.js b/tools/node_modules/eslint/lib/rules/prefer-spread.js index 14c05bd97103de..bcb0dc0dd4c1a9 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-spread.js +++ b/tools/node_modules/eslint/lib/rules/prefer-spread.js @@ -59,7 +59,11 @@ module.exports = { }, schema: [], - fixable: null + fixable: null, + + messages: { + preferSpread: "Use the spread operator instead of '.apply()'." + } }, create(context) { @@ -78,7 +82,7 @@ module.exports = { if (isValidThisArg(expectedThis, thisArg, sourceCode)) { context.report({ node, - message: "Use the spread operator instead of '.apply()'." + messageId: "preferSpread" }); } } diff --git a/tools/node_modules/eslint/lib/rules/prefer-template.js b/tools/node_modules/eslint/lib/rules/prefer-template.js index fa6e58d9721e12..e8f980ebd38c6f 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-template.js +++ b/tools/node_modules/eslint/lib/rules/prefer-template.js @@ -142,7 +142,11 @@ module.exports = { }, schema: [], - fixable: "code" + fixable: "code", + + messages: { + unexpectedStringConcatenation: "Unexpected string concatenation." + } }, create(context) { @@ -261,7 +265,7 @@ module.exports = { if (hasNonStringLiteral(topBinaryExpr)) { context.report({ node: topBinaryExpr, - message: "Unexpected string concatenation.", + messageId: "unexpectedStringConcatenation", fix: fixer => fixNonStringBinaryExpression(fixer, node) }); } diff --git a/tools/node_modules/eslint/lib/rules/quote-props.js b/tools/node_modules/eslint/lib/rules/quote-props.js index 4cc53b988f634d..a2a4e1d47923ff 100644 --- a/tools/node_modules/eslint/lib/rules/quote-props.js +++ b/tools/node_modules/eslint/lib/rules/quote-props.js @@ -67,7 +67,16 @@ module.exports = { ] }, - fixable: "code" + fixable: "code", + messages: { + requireQuotesDueToReservedWord: "Properties should be quoted as '{{property}}' is a reserved word.", + inconsistentlyQuotedProperty: "Inconsistently quoted property '{{key}}' found.", + unnecessarilyQuotedProperty: "Unnecessarily quoted property '{{property}}' found.", + unquotedReservedProperty: "Unquoted reserved word '{{property}}' used as key.", + unquotedNumericProperty: "Unquoted number literal '{{property}}' used as key.", + unquotedPropertyFound: "Unquoted property '{{property}}' found.", + redundantQuoting: "Properties shouldn't be quoted as all quotes are redundant." + } }, create(context) { @@ -77,10 +86,6 @@ module.exports = { CHECK_UNNECESSARY = !context.options[1] || context.options[1].unnecessary !== false, NUMBERS = context.options[1] && context.options[1].numbers, - MESSAGE_UNNECESSARY = "Unnecessarily quoted property '{{property}}' found.", - MESSAGE_UNQUOTED = "Unquoted property '{{property}}' found.", - MESSAGE_NUMERIC = "Unquoted number literal '{{property}}' used as key.", - MESSAGE_RESERVED = "Unquoted reserved word '{{property}}' used as key.", sourceCode = context.getSourceCode(); @@ -166,7 +171,7 @@ module.exports = { if (CHECK_UNNECESSARY && areQuotesRedundant(key.value, tokens, NUMBERS)) { context.report({ node, - message: MESSAGE_UNNECESSARY, + messageId: "unnecessarilyQuotedProperty", data: { property: key.value }, fix: fixer => fixer.replaceText(key, getUnquotedKey(key)) }); @@ -174,14 +179,14 @@ module.exports = { } else if (KEYWORDS && key.type === "Identifier" && isKeyword(key.name)) { context.report({ node, - message: MESSAGE_RESERVED, + messageId: "unquotedReservedProperty", data: { property: key.name }, fix: fixer => fixer.replaceText(key, getQuotedKey(key)) }); } else if (NUMBERS && key.type === "Literal" && astUtils.isNumericLiteral(key)) { context.report({ node, - message: MESSAGE_NUMERIC, + messageId: "unquotedNumericProperty", data: { property: key.value }, fix: fixer => fixer.replaceText(key, getQuotedKey(key)) }); @@ -199,7 +204,7 @@ module.exports = { if (!node.method && !node.computed && !node.shorthand && !(key.type === "Literal" && typeof key.value === "string")) { context.report({ node, - message: MESSAGE_UNQUOTED, + messageId: "unquotedPropertyFound", data: { property: key.name || key.value }, fix: fixer => fixer.replaceText(key, getQuotedKey(key)) }); @@ -254,7 +259,7 @@ module.exports = { quotedProps.forEach(property => { context.report({ node: property, - message: "Properties shouldn't be quoted as all quotes are redundant.", + messageId: "redundantQuoting", fix: fixer => fixer.replaceText(property.key, getUnquotedKey(property.key)) }); }); @@ -262,7 +267,7 @@ module.exports = { unquotedProps.forEach(property => { context.report({ node: property, - message: "Properties should be quoted as '{{property}}' is a reserved word.", + messageId: "requireQuotesDueToReservedWord", data: { property: keywordKeyName }, fix: fixer => fixer.replaceText(property.key, getQuotedKey(property.key)) }); @@ -271,7 +276,7 @@ module.exports = { unquotedProps.forEach(property => { context.report({ node: property, - message: "Inconsistently quoted property '{{key}}' found.", + messageId: "inconsistentlyQuotedProperty", data: { key: property.key.name || property.key.value }, fix: fixer => fixer.replaceText(property.key, getQuotedKey(property.key)) }); diff --git a/tools/node_modules/eslint/lib/rules/radix.js b/tools/node_modules/eslint/lib/rules/radix.js index ed3c5cb66b8cdc..3903cb2a6a2b01 100644 --- a/tools/node_modules/eslint/lib/rules/radix.js +++ b/tools/node_modules/eslint/lib/rules/radix.js @@ -18,6 +18,8 @@ const astUtils = require("./utils/ast-utils"); const MODE_ALWAYS = "always", MODE_AS_NEEDED = "as-needed"; +const validRadixValues = new Set(Array.from({ length: 37 - 2 }, (_, index) => index + 2)); + /** * Checks whether a given variable is shadowed or not. * @param {eslint-scope.Variable} variable A variable to check. @@ -47,14 +49,14 @@ function isParseIntMethod(node) { * * The following values are invalid. * - * - A literal except numbers. + * - A literal except integers between 2 and 36. * - undefined. * @param {ASTNode} radix A node of radix to check. * @returns {boolean} `true` if the node is valid. */ function isValidRadix(radix) { return !( - (radix.type === "Literal" && typeof radix.value !== "number") || + (radix.type === "Literal" && !validRadixValues.has(radix.value)) || (radix.type === "Identifier" && radix.name === "undefined") ); } @@ -87,7 +89,14 @@ module.exports = { { enum: ["always", "as-needed"] } - ] + ], + + messages: { + missingParameters: "Missing parameters.", + redundantRadix: "Redundant radix parameter.", + missingRadix: "Missing radix parameter.", + invalidRadix: "Invalid radix parameter, must be an integer between 2 and 36." + } }, create(context) { @@ -106,7 +115,7 @@ module.exports = { case 0: context.report({ node, - message: "Missing parameters." + messageId: "missingParameters" }); break; @@ -114,7 +123,7 @@ module.exports = { if (mode === MODE_ALWAYS) { context.report({ node, - message: "Missing radix parameter." + messageId: "missingRadix" }); } break; @@ -123,12 +132,12 @@ module.exports = { if (mode === MODE_AS_NEEDED && isDefaultRadix(args[1])) { context.report({ node, - message: "Redundant radix parameter." + messageId: "redundantRadix" }); } else if (!isValidRadix(args[1])) { context.report({ node, - message: "Invalid radix parameter." + messageId: "invalidRadix" }); } break; @@ -142,7 +151,7 @@ module.exports = { // Check `parseInt()` variable = astUtils.getVariableByName(scope, "parseInt"); - if (!isShadowed(variable)) { + if (variable && !isShadowed(variable)) { variable.references.forEach(reference => { const node = reference.identifier; @@ -154,7 +163,7 @@ module.exports = { // Check `Number.parseInt()` variable = astUtils.getVariableByName(scope, "Number"); - if (!isShadowed(variable)) { + if (variable && !isShadowed(variable)) { variable.references.forEach(reference => { const node = reference.identifier.parent; diff --git a/tools/node_modules/eslint/lib/rules/require-atomic-updates.js b/tools/node_modules/eslint/lib/rules/require-atomic-updates.js index bdd6d81ebc4758..4f6acceab804d1 100644 --- a/tools/node_modules/eslint/lib/rules/require-atomic-updates.js +++ b/tools/node_modules/eslint/lib/rules/require-atomic-updates.js @@ -223,7 +223,7 @@ module.exports = { /* * Register the variable to verify after ESLint traversed the `writeExpr` node - * if this reference is an assignment to a variable which is referred from other clausure. + * if this reference is an assignment to a variable which is referred from other closure. */ if (writeExpr && writeExpr.parent.right === writeExpr && // ← exclude variable declarations. diff --git a/tools/node_modules/eslint/lib/rules/require-jsdoc.js b/tools/node_modules/eslint/lib/rules/require-jsdoc.js index 416a22ce6c4375..e581b2bee4646a 100644 --- a/tools/node_modules/eslint/lib/rules/require-jsdoc.js +++ b/tools/node_modules/eslint/lib/rules/require-jsdoc.js @@ -52,7 +52,11 @@ module.exports = { ], deprecated: true, - replacedBy: [] + replacedBy: [], + + messages: { + missingJSDocComment: "Missing JSDoc comment." + } }, create(context) { @@ -72,7 +76,7 @@ module.exports = { * @returns {void} */ function report(node) { - context.report({ node, message: "Missing JSDoc comment." }); + context.report({ node, messageId: "missingJSDocComment" }); } /** diff --git a/tools/node_modules/eslint/lib/rules/require-yield.js b/tools/node_modules/eslint/lib/rules/require-yield.js index dbfd759948af78..af2344dfa6b8ff 100644 --- a/tools/node_modules/eslint/lib/rules/require-yield.js +++ b/tools/node_modules/eslint/lib/rules/require-yield.js @@ -20,7 +20,11 @@ module.exports = { url: "https://eslint.org/docs/rules/require-yield" }, - schema: [] + schema: [], + + messages: { + missingYield: "This generator function does not have 'yield'." + } }, create(context) { @@ -51,7 +55,7 @@ module.exports = { const countYield = stack.pop(); if (countYield === 0 && node.body.body.length > 0) { - context.report({ node, message: "This generator function does not have 'yield'." }); + context.report({ node, messageId: "missingYield" }); } } diff --git a/tools/node_modules/eslint/lib/rules/rest-spread-spacing.js b/tools/node_modules/eslint/lib/rules/rest-spread-spacing.js index cd740fd3a99057..4bb5f787c6c568 100644 --- a/tools/node_modules/eslint/lib/rules/rest-spread-spacing.js +++ b/tools/node_modules/eslint/lib/rules/rest-spread-spacing.js @@ -26,7 +26,12 @@ module.exports = { { enum: ["always", "never"] } - ] + ], + + messages: { + unexpectedWhitespace: "Unexpected whitespace after {{type}} operator.", + expectedWhitespace: "Expected whitespace after {{type}} operator." + } }, create(context) { @@ -78,7 +83,7 @@ module.exports = { line: operator.loc.end.line, column: operator.loc.end.column }, - message: "Expected whitespace after {{type}} operator.", + messageId: "expectedWhitespace", data: { type }, @@ -93,7 +98,7 @@ module.exports = { line: operator.loc.end.line, column: operator.loc.end.column }, - message: "Unexpected whitespace after {{type}} operator.", + messageId: "unexpectedWhitespace", data: { type }, diff --git a/tools/node_modules/eslint/lib/rules/semi-spacing.js b/tools/node_modules/eslint/lib/rules/semi-spacing.js index 083dc26199f7bd..92948533d2789e 100644 --- a/tools/node_modules/eslint/lib/rules/semi-spacing.js +++ b/tools/node_modules/eslint/lib/rules/semi-spacing.js @@ -39,7 +39,14 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + unexpectedWhitespaceBefore: "Unexpected whitespace before semicolon.", + unexpectedWhitespaceAfter: "Unexpected whitespace after semicolon.", + missingWhitespaceBefore: "Missing whitespace before semicolon.", + missingWhitespaceAfter: "Missing whitespace after semicolon." + } }, create(context) { @@ -124,7 +131,7 @@ module.exports = { context.report({ node, loc: location, - message: "Unexpected whitespace before semicolon.", + messageId: "unexpectedWhitespaceBefore", fix(fixer) { const tokenBefore = sourceCode.getTokenBefore(token); @@ -137,7 +144,7 @@ module.exports = { context.report({ node, loc: location, - message: "Missing whitespace before semicolon.", + messageId: "missingWhitespaceBefore", fix(fixer) { return fixer.insertTextBefore(token, " "); } @@ -151,7 +158,7 @@ module.exports = { context.report({ node, loc: location, - message: "Unexpected whitespace after semicolon.", + messageId: "unexpectedWhitespaceAfter", fix(fixer) { const tokenAfter = sourceCode.getTokenAfter(token); @@ -164,7 +171,7 @@ module.exports = { context.report({ node, loc: location, - message: "Missing whitespace after semicolon.", + messageId: "missingWhitespaceAfter", fix(fixer) { return fixer.insertTextAfter(token, " "); } diff --git a/tools/node_modules/eslint/lib/rules/semi-style.js b/tools/node_modules/eslint/lib/rules/semi-style.js index da3c4a38742b88..0c9bec4c85ede8 100644 --- a/tools/node_modules/eslint/lib/rules/semi-style.js +++ b/tools/node_modules/eslint/lib/rules/semi-style.js @@ -75,7 +75,11 @@ module.exports = { }, schema: [{ enum: ["last", "first"] }], - fixable: "whitespace" + fixable: "whitespace", + + messages: { + expectedSemiColon: "Expected this semicolon to be at {{pos}}." + } }, create(context) { @@ -97,7 +101,7 @@ module.exports = { if ((expected === "last" && !prevIsSameLine) || (expected === "first" && !nextIsSameLine)) { context.report({ loc: semiToken.loc, - message: "Expected this semicolon to be at {{pos}}.", + messageId: "expectedSemiColon", data: { pos: (expected === "last") ? "the end of the previous line" diff --git a/tools/node_modules/eslint/lib/rules/semi.js b/tools/node_modules/eslint/lib/rules/semi.js index 3491f4765c77a2..d2f0670427b3ab 100644 --- a/tools/node_modules/eslint/lib/rules/semi.js +++ b/tools/node_modules/eslint/lib/rules/semi.js @@ -135,7 +135,7 @@ module.exports = { } /** - * Check whether a given semicolon token is redandant. + * Check whether a given semicolon token is redundant. * @param {Token} semiToken A semicolon token to check. * @returns {boolean} `true` if the next token is `;` or `}`. */ diff --git a/tools/node_modules/eslint/lib/rules/sort-imports.js b/tools/node_modules/eslint/lib/rules/sort-imports.js index 3b7f1d010348ad..65ad9a18a93112 100644 --- a/tools/node_modules/eslint/lib/rules/sort-imports.js +++ b/tools/node_modules/eslint/lib/rules/sort-imports.js @@ -50,7 +50,13 @@ module.exports = { } ], - fixable: "code" + fixable: "code", + + messages: { + sortImportsAlphabetically: "Imports should be sorted alphabetically.", + sortMembersAlphabetically: "Member '{{memberName}}' of the import declaration should be sorted alphabetically.", + unexpectedSyntaxOrder: "Expected '{{syntaxA}}' syntax before '{{syntaxB}}' syntax." + } }, create(context) { @@ -132,7 +138,7 @@ module.exports = { if (currentMemberSyntaxGroupIndex < previousMemberSyntaxGroupIndex) { context.report({ node, - message: "Expected '{{syntaxA}}' syntax before '{{syntaxB}}' syntax.", + messageId: "unexpectedSyntaxOrder", data: { syntaxA: memberSyntaxSortOrder[currentMemberSyntaxGroupIndex], syntaxB: memberSyntaxSortOrder[previousMemberSyntaxGroupIndex] @@ -146,7 +152,7 @@ module.exports = { ) { context.report({ node, - message: "Imports should be sorted alphabetically." + messageId: "sortImportsAlphabetically" }); } } @@ -163,7 +169,7 @@ module.exports = { if (firstUnsortedIndex !== -1) { context.report({ node: importSpecifiers[firstUnsortedIndex], - message: "Member '{{memberName}}' of the import declaration should be sorted alphabetically.", + messageId: "sortMembersAlphabetically", data: { memberName: importSpecifiers[firstUnsortedIndex].local.name }, fix(fixer) { if (importSpecifiers.some(specifier => diff --git a/tools/node_modules/eslint/lib/rules/sort-keys.js b/tools/node_modules/eslint/lib/rules/sort-keys.js index a5ce445f71ae93..8a95ee25d61948 100644 --- a/tools/node_modules/eslint/lib/rules/sort-keys.js +++ b/tools/node_modules/eslint/lib/rules/sort-keys.js @@ -41,7 +41,7 @@ function getPropertyName(node) { * Functions which check that the given 2 names are in specific order. * * Postfix `I` is meant insensitive. - * Postfix `N` is meant natual. + * Postfix `N` is meant natural. * @private */ const isValidOrders = { @@ -109,7 +109,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + sortKeys: "Expected object keys to be in {{natural}}{{insensitive}}{{order}}ending order. '{{thisName}}' should be before '{{prevName}}'." + } }, create(context) { @@ -118,10 +122,10 @@ module.exports = { const order = context.options[0] || "asc"; const options = context.options[1]; const insensitive = options && options.caseSensitive === false; - const natual = options && options.natural; + const natural = options && options.natural; const minKeys = options && options.minKeys; const isValidOrder = isValidOrders[ - order + (insensitive ? "I" : "") + (natual ? "N" : "") + order + (insensitive ? "I" : "") + (natural ? "N" : "") ]; // The stack to save the previous property's name for each object literals. @@ -167,13 +171,13 @@ module.exports = { context.report({ node, loc: node.key.loc, - message: "Expected object keys to be in {{natual}}{{insensitive}}{{order}}ending order. '{{thisName}}' should be before '{{prevName}}'.", + messageId: "sortKeys", data: { thisName, prevName, order, insensitive: insensitive ? "insensitive " : "", - natual: natual ? "natural " : "" + natural: natural ? "natural " : "" } }); } diff --git a/tools/node_modules/eslint/lib/rules/sort-vars.js b/tools/node_modules/eslint/lib/rules/sort-vars.js index e85c6534e3a189..7add2cf74b2940 100644 --- a/tools/node_modules/eslint/lib/rules/sort-vars.js +++ b/tools/node_modules/eslint/lib/rules/sort-vars.js @@ -33,7 +33,11 @@ module.exports = { } ], - fixable: "code" + fixable: "code", + + messages: { + sortVars: "Variables within the same declaration block should be sorted alphabetically." + } }, create(context) { @@ -56,7 +60,7 @@ module.exports = { if (currentVariableName < lastVariableName) { context.report({ node: decl, - message: "Variables within the same declaration block should be sorted alphabetically.", + messageId: "sortVars", fix(fixer) { if (unfixable || fixed) { return null; diff --git a/tools/node_modules/eslint/lib/rules/space-before-blocks.js b/tools/node_modules/eslint/lib/rules/space-before-blocks.js index 038e88db5215f5..9b56481bf355fb 100644 --- a/tools/node_modules/eslint/lib/rules/space-before-blocks.js +++ b/tools/node_modules/eslint/lib/rules/space-before-blocks.js @@ -47,7 +47,12 @@ module.exports = { } ] } - ] + ], + + messages: { + unexpectedSpace: "Unexpected space before opening brace.", + missingSpace: "Missing space before opening brace." + } }, create(context) { @@ -114,7 +119,7 @@ module.exports = { if (requireSpace && !hasSpace) { context.report({ node, - message: "Missing space before opening brace.", + messageId: "missingSpace", fix(fixer) { return fixer.insertTextBefore(node, " "); } @@ -122,7 +127,7 @@ module.exports = { } else if (requireNoSpace && hasSpace) { context.report({ node, - message: "Unexpected space before opening brace.", + messageId: "unexpectedSpace", fix(fixer) { return fixer.removeRange([precedingToken.range[1], node.range[0]]); } diff --git a/tools/node_modules/eslint/lib/rules/space-before-function-paren.js b/tools/node_modules/eslint/lib/rules/space-before-function-paren.js index 3a6d430f362051..af609c2e7c72fa 100644 --- a/tools/node_modules/eslint/lib/rules/space-before-function-paren.js +++ b/tools/node_modules/eslint/lib/rules/space-before-function-paren.js @@ -50,7 +50,12 @@ module.exports = { } ] } - ] + ], + + messages: { + unexpectedSpace: "Unexpected space before function parentheses.", + missingSpace: "Missing space before function parentheses." + } }, create(context) { @@ -123,7 +128,7 @@ module.exports = { context.report({ node, loc: leftToken.loc.end, - message: "Unexpected space before function parentheses.", + messageId: "unexpectedSpace", fix(fixer) { const comments = sourceCode.getCommentsBefore(rightToken); @@ -141,7 +146,7 @@ module.exports = { context.report({ node, loc: leftToken.loc.end, - message: "Missing space before function parentheses.", + messageId: "missingSpace", fix: fixer => fixer.insertTextAfter(leftToken, " ") }); } diff --git a/tools/node_modules/eslint/lib/rules/space-in-parens.js b/tools/node_modules/eslint/lib/rules/space-in-parens.js index 85ee74210d6007..b0a604d955d788 100644 --- a/tools/node_modules/eslint/lib/rules/space-in-parens.js +++ b/tools/node_modules/eslint/lib/rules/space-in-parens.js @@ -169,7 +169,7 @@ module.exports = { } /** - * Determines if a closing paren is immediately preceeded by a required space + * Determines if a closing paren is immediately preceded by a required space * @param {Object} tokenBeforeClosingParen The token before the paren * @param {Object} closingParenToken The paren token * @returns {boolean} True if the closing paren is missing a required space @@ -190,7 +190,7 @@ module.exports = { } /** - * Determines if a closer paren is immediately preceeded by a disallowed space + * Determines if a closer paren is immediately preceded by a disallowed space * @param {Object} tokenBeforeClosingParen The token before the paren * @param {Object} closingParenToken The paren token * @returns {boolean} True if the closing paren has a disallowed space diff --git a/tools/node_modules/eslint/lib/rules/space-infix-ops.js b/tools/node_modules/eslint/lib/rules/space-infix-ops.js index bd2c0ae0e1d3b7..471c22210eb613 100644 --- a/tools/node_modules/eslint/lib/rules/space-infix-ops.js +++ b/tools/node_modules/eslint/lib/rules/space-infix-ops.js @@ -32,7 +32,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + missingSpace: "Operator '{{operator}}' must be spaced." + } }, create(context) { @@ -70,7 +74,7 @@ module.exports = { context.report({ node: mainNode, loc: culpritToken.loc, - message: "Operator '{{operator}}' must be spaced.", + messageId: "missingSpace", data: { operator: culpritToken.value }, @@ -123,11 +127,11 @@ module.exports = { * @private */ function checkConditional(node) { - const nonSpacedConsequesntNode = getFirstNonSpacedToken(node.test, node.consequent, "?"); + const nonSpacedConsequentNode = getFirstNonSpacedToken(node.test, node.consequent, "?"); const nonSpacedAlternateNode = getFirstNonSpacedToken(node.consequent, node.alternate, ":"); - if (nonSpacedConsequesntNode) { - report(node, nonSpacedConsequesntNode); + if (nonSpacedConsequentNode) { + report(node, nonSpacedConsequentNode); } else if (nonSpacedAlternateNode) { report(node, nonSpacedAlternateNode); } diff --git a/tools/node_modules/eslint/lib/rules/spaced-comment.js b/tools/node_modules/eslint/lib/rules/spaced-comment.js index daf56cd6bb42d0..d3221f0ea798ac 100644 --- a/tools/node_modules/eslint/lib/rules/spaced-comment.js +++ b/tools/node_modules/eslint/lib/rules/spaced-comment.js @@ -221,7 +221,16 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + unexpectedSpaceAfterMarker: "Unexpected space or tab after marker ({{refChar}}) in comment.", + expectedExceptionAfter: "Expected exception block, space or tab after '{{refChar}}' in comment.", + unexpectedSpaceBefore: "Unexpected space or tab before '*/' in comment.", + unexpectedSpaceAfter: "Unexpected space or tab after '{{refChar}}' in comment.", + expectedSpaceBefore: "Expected space or tab before '*/' in comment.", + expectedSpaceAfter: "Expected space or tab after '{{refChar}}' in comment." + } }, create(context) { @@ -259,12 +268,12 @@ module.exports = { /** * Reports a beginning spacing error with an appropriate message. * @param {ASTNode} node A comment node to check. - * @param {string} message An error message to report. + * @param {string} messageId An error message to report. * @param {Array} match An array of match results for markers. * @param {string} refChar Character used for reference in the error message. * @returns {void} */ - function reportBegin(node, message, match, refChar) { + function reportBegin(node, messageId, match, refChar) { const type = node.type.toLowerCase(), commentIdentifier = type === "block" ? "/*" : "//"; @@ -284,7 +293,7 @@ module.exports = { return fixer.replaceTextRange([start, end], commentIdentifier + (match[1] ? match[1] : "")); }, - message, + messageId, data: { refChar } }); } @@ -292,11 +301,11 @@ module.exports = { /** * Reports an ending spacing error with an appropriate message. * @param {ASTNode} node A comment node to check. - * @param {string} message An error message to report. + * @param {string} messageId An error message to report. * @param {string} match An array of the matched whitespace characters. * @returns {void} */ - function reportEnd(node, message, match) { + function reportEnd(node, messageId, match) { context.report({ node, fix(fixer) { @@ -309,7 +318,7 @@ module.exports = { return fixer.replaceTextRange([start, end], ""); }, - message + messageId }); } @@ -338,26 +347,26 @@ module.exports = { const marker = hasMarker ? commentIdentifier + hasMarker[0] : commentIdentifier; if (rule.hasExceptions) { - reportBegin(node, "Expected exception block, space or tab after '{{refChar}}' in comment.", hasMarker, marker); + reportBegin(node, "expectedExceptionAfter", hasMarker, marker); } else { - reportBegin(node, "Expected space or tab after '{{refChar}}' in comment.", hasMarker, marker); + reportBegin(node, "expectedSpaceAfter", hasMarker, marker); } } if (balanced && type === "block" && !endMatch) { - reportEnd(node, "Expected space or tab before '*/' in comment."); + reportEnd(node, "expectedSpaceBefore"); } } else { if (beginMatch) { if (!beginMatch[1]) { - reportBegin(node, "Unexpected space or tab after '{{refChar}}' in comment.", beginMatch, commentIdentifier); + reportBegin(node, "unexpectedSpaceAfter", beginMatch, commentIdentifier); } else { - reportBegin(node, "Unexpected space or tab after marker ({{refChar}}) in comment.", beginMatch, beginMatch[1]); + reportBegin(node, "unexpectedSpaceAfterMarker", beginMatch, beginMatch[1]); } } if (balanced && type === "block" && endMatch) { - reportEnd(node, "Unexpected space or tab before '*/' in comment.", endMatch); + reportEnd(node, "unexpectedSpaceBefore", endMatch); } } } diff --git a/tools/node_modules/eslint/lib/rules/use-isnan.js b/tools/node_modules/eslint/lib/rules/use-isnan.js index cd9ccdbaf898ee..7b466be75f2e5e 100644 --- a/tools/node_modules/eslint/lib/rules/use-isnan.js +++ b/tools/node_modules/eslint/lib/rules/use-isnan.js @@ -45,7 +45,7 @@ module.exports = { properties: { enforceForSwitchCase: { type: "boolean", - default: false + default: true }, enforceForIndexOf: { type: "boolean", @@ -66,7 +66,7 @@ module.exports = { create(context) { - const enforceForSwitchCase = context.options[0] && context.options[0].enforceForSwitchCase; + const enforceForSwitchCase = !context.options[0] || context.options[0].enforceForSwitchCase; const enforceForIndexOf = context.options[0] && context.options[0].enforceForIndexOf; /** diff --git a/tools/node_modules/eslint/lib/rules/yoda.js b/tools/node_modules/eslint/lib/rules/yoda.js index be5c59ce072269..c4ff3f81938595 100644 --- a/tools/node_modules/eslint/lib/rules/yoda.js +++ b/tools/node_modules/eslint/lib/rules/yoda.js @@ -49,13 +49,32 @@ function isRangeTestOperator(operator) { * @returns {boolean} True if the node is a negative number that looks like a * real literal and should be treated as such. */ -function looksLikeLiteral(node) { +function isNegativeNumericLiteral(node) { return (node.type === "UnaryExpression" && node.operator === "-" && node.prefix && astUtils.isNumericLiteral(node.argument)); } +/** + * Determines whether a node is a Template Literal which can be determined statically. + * @param {ASTNode} node Node to test + * @returns {boolean} True if the node is a Template Literal without expression. + */ +function isStaticTemplateLiteral(node) { + return node.type === "TemplateLiteral" && node.expressions.length === 0; +} + +/** + * Determines whether a non-Literal node should be treated as a single Literal node. + * @param {ASTNode} node Node to test + * @returns {boolean} True if the node should be treated as a single Literal node. + */ +function looksLikeLiteral(node) { + return isNegativeNumericLiteral(node) || + isStaticTemplateLiteral(node); +} + /** * Attempts to derive a Literal node from nodes that are treated like literals. * @param {ASTNode} node Node to normalize. @@ -65,15 +84,17 @@ function looksLikeLiteral(node) { * 1. The original node if the node is already a Literal * 2. A normalized Literal node with the negative number as the value if the * node represents a negative number literal. - * 3. The Literal node which has the `defaultValue` argument if it exists. - * 4. Otherwise `null`. + * 3. A normalized Literal node with the string as the value if the node is + * a Template Literal without expression. + * 4. The Literal node which has the `defaultValue` argument if it exists. + * 5. Otherwise `null`. */ function getNormalizedLiteral(node, defaultValue) { if (node.type === "Literal") { return node; } - if (looksLikeLiteral(node)) { + if (isNegativeNumericLiteral(node)) { return { type: "Literal", value: -node.argument.value, @@ -81,6 +102,14 @@ function getNormalizedLiteral(node, defaultValue) { }; } + if (isStaticTemplateLiteral(node)) { + return { + type: "Literal", + value: node.quasis[0].value.cooked, + raw: node.quasis[0].value.raw + }; + } + if (defaultValue) { return { type: "Literal", diff --git a/tools/node_modules/eslint/lib/shared/config-validator.js b/tools/node_modules/eslint/lib/shared/config-validator.js index 70eaf0a9670514..458bd2a802b95c 100644 --- a/tools/node_modules/eslint/lib/shared/config-validator.js +++ b/tools/node_modules/eslint/lib/shared/config-validator.js @@ -190,7 +190,7 @@ function validateRules( /** * Validates a `globals` section of a config file - * @param {Object} globalsConfig The `glboals` section + * @param {Object} globalsConfig The `globals` section * @param {string|null} source The name of the configuration source to report in the event of an error. * @returns {void} */ diff --git a/tools/node_modules/eslint/lib/shared/naming.js b/tools/node_modules/eslint/lib/shared/naming.js index b99155f15cafa7..32cff94538af22 100644 --- a/tools/node_modules/eslint/lib/shared/naming.js +++ b/tools/node_modules/eslint/lib/shared/naming.js @@ -78,7 +78,7 @@ function getShorthandName(fullname, prefix) { /** * Gets the scope (namespace) of a term. * @param {string} term The term which may have the namespace. - * @returns {string} The namepace of the term if it has one. + * @returns {string} The namespace of the term if it has one. */ function getNamespaceFromTerm(term) { const match = term.match(NAMESPACE_REGEX); diff --git a/tools/node_modules/eslint/lib/shared/types.js b/tools/node_modules/eslint/lib/shared/types.js index a5bd0200e2792a..f3d1a7f29f02f0 100644 --- a/tools/node_modules/eslint/lib/shared/types.js +++ b/tools/node_modules/eslint/lib/shared/types.js @@ -21,7 +21,7 @@ module.exports = {}; /** * @typedef {Object} ParserOptions * @property {EcmaFeatures} [ecmaFeatures] The optional features. - * @property {3|5|6|7|8|9|10|2015|2016|2017|2018|2019} [ecmaVersion] The ECMAScript version (or revision number). + * @property {3|5|6|7|8|9|10|11|2015|2016|2017|2018|2019|2020} [ecmaVersion] The ECMAScript version (or revision number). * @property {"script"|"module"} [sourceType] The source code type. */ 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 30b4e9ab5c26e3..591d5a7e454ee2 100644 --- a/tools/node_modules/eslint/lib/source-code/source-code.js +++ b/tools/node_modules/eslint/lib/source-code/source-code.js @@ -121,7 +121,7 @@ function isSpaceBetween(sourceCode, first, second, checkInsideOfJSXText) { currentToken.range[1] !== nextToken.range[0] || /* - * For backward compatibility, check speces in JSXText. + * For backward compatibility, check spaces in JSXText. * https://github.com/eslint/eslint/issues/12614 */ ( diff --git a/tools/node_modules/eslint/lib/source-code/token-store/utils.js b/tools/node_modules/eslint/lib/source-code/token-store/utils.js index 444684b52f1bb0..21e1d6ff7c3b6d 100644 --- a/tools/node_modules/eslint/lib/source-code/token-store/utils.js +++ b/tools/node_modules/eslint/lib/source-code/token-store/utils.js @@ -1,5 +1,5 @@ /** - * @fileoverview Define utilify functions for token store. + * @fileoverview Define utility functions for token store. * @author Toru Nagashima */ "use strict"; diff --git a/tools/node_modules/eslint/package.json b/tools/node_modules/eslint/package.json index 25d0d9693c3eb6..2a30f80d3bd096 100644 --- a/tools/node_modules/eslint/package.json +++ b/tools/node_modules/eslint/package.json @@ -64,7 +64,7 @@ "ejs": "^2.6.1", "eslint": "file:.", "eslint-config-eslint": "file:packages/eslint-config-eslint", - "eslint-plugin-eslint-plugin": "^2.0.1", + "eslint-plugin-eslint-plugin": "^2.2.1", "eslint-plugin-internal-rules": "file:tools/internal-rules", "eslint-plugin-jsdoc": "^15.9.5", "eslint-plugin-node": "^9.0.0", @@ -152,5 +152,5 @@ "test:cli": "mocha", "webpack": "node Makefile.js webpack" }, - "version": "7.0.0-alpha.0" + "version": "7.0.0-alpha.1" } \ No newline at end of file