diff --git a/.eslintrc.js b/.eslintrc.js index 6eea9bc6f6fc..4013bc661d5b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,10 +1,17 @@ +"use strict"; + const path = require("path"); module.exports = { root: true, - plugins: ["prettier", "@babel/development", "import", "jest"], - // replace it by `@babel/internal` when `@babel/eslint-config-internal` is published - extends: path.resolve(__dirname, "eslint/babel-eslint-config-internal"), + plugins: [ + "import", + "jest", + "prettier", + "@babel/development", + "@babel/development-internal", + ], + extends: "@babel/internal", rules: { "prettier/prettier": "error", // TODO: remove after babel-eslint-config-internal is fully integrated into this repository. @@ -44,8 +51,8 @@ module.exports = { "jest/no-identical-title": "off", "jest/no-standalone-expect": "off", "jest/no-test-callback": "off", - "jest/valid-describe": "off" - } + "jest/valid-describe": "off", + }, }, { files: ["packages/babel-plugin-*/src/index.js"], @@ -55,5 +62,19 @@ module.exports = { eqeqeq: ["error", "always", { null: "ignore" }], }, }, + { + files: ["packages/babel-parser/src/**/*.js"], + rules: { + "@babel/development-internal/dry-error-messages": [ + "error", + { + errorModule: path.resolve( + __dirname, + "packages/babel-parser/src/parser/error.js" + ), + }, + ], + }, + }, ], }; diff --git a/Makefile b/Makefile index d635783bae32..dd41a0cb0918 100644 --- a/Makefile +++ b/Makefile @@ -84,9 +84,11 @@ build-no-bundle-ci: bootstrap-only watch: build-no-bundle BABEL_ENV=development $(YARN) gulp watch -code-quality-ci: flowcheck-ci lint-ci +code-quality-ci: build-no-bundle-ci + $(MAKE) flowcheck-ci & $(MAKE) lint-ci -flowcheck-ci: bootstrap-flowcheck + +flowcheck-ci: $(MAKE) flow code-quality: flow lint @@ -94,17 +96,15 @@ code-quality: flow lint flow: $(YARN) flow check --strip-root -bootstrap-flowcheck: build-no-bundle-ci - lint-ci: lint-js-ci lint-ts-ci check-compat-data-ci -lint-js-ci: bootstrap-only +lint-js-ci: $(MAKE) lint-js -lint-ts-ci: bootstrap-flowcheck +lint-ts-ci: $(MAKE) lint-ts -check-compat-data-ci: build-no-bundle-ci +check-compat-data-ci: $(MAKE) check-compat-data lint: lint-js lint-ts diff --git a/eslint/babel-eslint-config-internal/index.js b/eslint/babel-eslint-config-internal/index.js index 6bf24402795c..a20fc920a11c 100644 --- a/eslint/babel-eslint-config-internal/index.js +++ b/eslint/babel-eslint-config-internal/index.js @@ -1,7 +1,7 @@ "use strict"; module.exports = { - parser: "babel-eslint", + parser: "@babel/eslint-parser", extends: "eslint:recommended", plugins: ["flowtype"], parserOptions: { diff --git a/eslint/babel-eslint-config-internal/package.json b/eslint/babel-eslint-config-internal/package.json index 292bf0a9081a..f3fac8b8d6fa 100644 --- a/eslint/babel-eslint-config-internal/package.json +++ b/eslint/babel-eslint-config-internal/package.json @@ -13,7 +13,7 @@ }, "main": "index.js", "peerDependencies": { - "babel-eslint": "^10.0.0 || ^11.0.0-0", + "@babel/eslint-parser": "*", "eslint-plugin-flowtype": "^3.0.0" } } diff --git a/eslint/babel-eslint-plugin-development-internal/.npmignore b/eslint/babel-eslint-plugin-development-internal/.npmignore new file mode 100644 index 000000000000..ad69326ce8c2 --- /dev/null +++ b/eslint/babel-eslint-plugin-development-internal/.npmignore @@ -0,0 +1,4 @@ +src +test +.* +*.log diff --git a/eslint/babel-eslint-plugin-development-internal/README.md b/eslint/babel-eslint-plugin-development-internal/README.md new file mode 100644 index 000000000000..b412c36013d8 --- /dev/null +++ b/eslint/babel-eslint-plugin-development-internal/README.md @@ -0,0 +1,70 @@ +# @babel/eslint-plugin-development-internal + +The Babel team's custom ESLint rules for the babel/babel monorepo. + +## Installation + +```sh +$ npm install --save-dev @babel/eslint-plugin-development-internal +``` +or +```sh +$ yarn add --save-dev @babel/eslint-plugin-development-internal +``` + +## Usage + +The plugin can be loaded in your `.eslintrc.*` configuration file as follows: (note that you can omit the `eslint-plugin-` prefix): + +```json +{ + "plugins": ["@babel/development-internal"] +} +``` + +## Rules + +### `@babel/development-internal/dry-error-messages` + +Intended for use in `packages/babel-parser/src/**/*`. When enabled, this rule warns when `this.raise()` invocations raise errors that are not imported from a designated error module. + +Accepts an object configuration option: + +```ts +{ + errorModule: string +} +``` + +`errorModule` (required): The rule expects either an absolute path or a module name (for a module in `node_modules`). Please note that the rule will not check anything if` errorModule` is not given. + +Example configuration: + +```js +{ + rules: { + "@babel/development-internal/dry-error-messages": [ + "error", + { + errorModule: "@babel/shared-error-messages" + } + ] + } +} +``` +and +```js +{ + rules: { + "@babel/development-internal/dry-error-messages": [ + "error", + { + errorModule: path.resolve( + __dirname, + "packages/shared-error-messages/lib/index.js" + ) + } + ] + } +} +``` diff --git a/eslint/babel-eslint-plugin-development-internal/package.json b/eslint/babel-eslint-plugin-development-internal/package.json new file mode 100644 index 000000000000..7fd5eb7c869e --- /dev/null +++ b/eslint/babel-eslint-plugin-development-internal/package.json @@ -0,0 +1,36 @@ +{ + "name": "@babel/eslint-plugin-development-internal", + "version": "0.0.0", + "description": "The Babel Team's ESLint custom rules plugin. Since it's internal, it might not respect semver.", + "main": "lib/index.js", + "repository": { + "type": "git", + "url": "git+https://github.com/babel/babel.git", + "directory": "eslint/babel-eslint-plugin-development-internal" + }, + "keywords": [ + "babel", + "eslint", + "eslintplugin", + "eslint-plugin", + "babel-eslint" + ], + "author": "Kai Cataldo ", + "license": "MIT", + "private": true, + "engines": { + "node": ">=10.9" + }, + "bugs": { + "url": "https://github.com/babel/babel/issues" + }, + "homepage": "https://github.com/babel/babel/tree/master/eslint/babel-eslint-plugin-development-internal", + "peerDependencies": { + "@babel/eslint-parser": "0.0.0", + "eslint": ">=6.0.0" + }, + "devDependencies": { + "@babel/eslint-shared-fixtures": "*", + "eslint": "^6.0.0" + } +} diff --git a/eslint/babel-eslint-plugin-development-internal/src/index.js b/eslint/babel-eslint-plugin-development-internal/src/index.js new file mode 100644 index 000000000000..8761f3903c07 --- /dev/null +++ b/eslint/babel-eslint-plugin-development-internal/src/index.js @@ -0,0 +1,7 @@ +import dryErrorMessages from "./rules/dry-error-messages"; + +module.exports = { + rules: { + "dry-error-messages": dryErrorMessages, + }, +}; diff --git a/eslint/babel-eslint-plugin-development-internal/src/rules/dry-error-messages.js b/eslint/babel-eslint-plugin-development-internal/src/rules/dry-error-messages.js new file mode 100644 index 000000000000..2994d933912a --- /dev/null +++ b/eslint/babel-eslint-plugin-development-internal/src/rules/dry-error-messages.js @@ -0,0 +1,148 @@ +import path from "path"; + +const REL_PATH_REGEX = /^\.{1,2}/; + +function isRelativePath(filePath) { + return REL_PATH_REGEX.test(filePath); +} + +function resolveAbsolutePath(currentFilePath, moduleToResolve) { + return isRelativePath(moduleToResolve) + ? path.resolve(path.dirname(currentFilePath), moduleToResolve) + : moduleToResolve; +} + +function isSourceErrorModule(currentFilePath, targetModulePath, src) { + for (const srcPath of [src, `${src}.js`, `${src}/index`, `${src}/index.js`]) { + if ( + path.normalize(resolveAbsolutePath(currentFilePath, targetModulePath)) === + path.normalize(resolveAbsolutePath(currentFilePath, srcPath)) + ) { + return true; + } + } + + return false; +} + +function isCurrentFileErrorModule(currentFilePath, errorModule) { + return currentFilePath === errorModule; +} + +function findIdNode(node) { + if (node.type === "Identifier") { + return node; + } + + if (node.type === "MemberExpression" && node.object.type === "Identifier") { + return node.object; + } + + return null; +} + +function findReference(node, scope) { + let currentScope = scope; + + while (currentScope) { + const ref = currentScope.set.get(node.name); + + if (ref) { + return ref; + } + + currentScope = currentScope.upper; + } + + return null; +} + +function referencesImportedBinding(node, scope, bindings) { + const ref = findReference(node, scope); + + if (ref) { + const topLevelDef = ref.defs[0]; + + if (topLevelDef.type === "ImportBinding") { + const defNode = topLevelDef.node; + + for (const spec of bindings) { + if ( + spec.loc.start === defNode.loc.start && + spec.loc.end === defNode.loc.end + ) { + return true; + } + } + } + } + + return false; +} + +export default { + meta: { + type: "suggestion", + docs: { + description: + "enforce @babel/parser's error messages to be consolidated in one module", + }, + schema: [ + { + type: "object", + properties: { + errorModule: { type: "string" }, + }, + additionalProperties: false, + required: ["errorModule"], + }, + ], + messages: { + mustBeImported: 'Error messages must be imported from "{{errorModule}}".', + }, + }, + create({ options, report, getFilename, getScope }) { + const [{ errorModule = "" } = {}] = options; + const filename = getFilename(); + const importedBindings = new Set(); + + if ( + // Do not run check if errorModule config option is not given. + !errorModule.length || + // Do not check the target error module file. + isCurrentFileErrorModule(filename, errorModule) + ) { + return {}; + } + + return { + // Check imports up front so that we don't have to check them for every ThrowStatement. + ImportDeclaration(node) { + if (isSourceErrorModule(filename, errorModule, node.source.value)) { + for (const spec of node.specifiers) { + importedBindings.add(spec); + } + } + }, + "CallExpression[callee.type='MemberExpression'][callee.object.type='ThisExpression'][callee.property.name='raise'][arguments.length>=2]"( + node, + ) { + const [, errorMsgNode] = node.arguments; + const nodeToCheck = findIdNode(errorMsgNode); + + if ( + nodeToCheck && + referencesImportedBinding(nodeToCheck, getScope(), importedBindings) + ) { + return; + } + + report({ + node: errorMsgNode, + messageId: "mustBeImported", + data: { errorModule }, + }); + }, + }; + }, +}; diff --git a/eslint/babel-eslint-plugin-development-internal/test/rules/dry-error-messages.js b/eslint/babel-eslint-plugin-development-internal/test/rules/dry-error-messages.js new file mode 100644 index 000000000000..5a3c5bf5336f --- /dev/null +++ b/eslint/babel-eslint-plugin-development-internal/test/rules/dry-error-messages.js @@ -0,0 +1,695 @@ +import path from "path"; +import rule from "../../src/rules/dry-error-messages"; +import RuleTester from "@babel/eslint-shared-fixtures/utils/RuleTester"; + +const FILENAME = path.resolve(__dirname, "test/lib/index.js"); +const ERRORS_MODULE = "errorsModule"; +const MODULE_SAME_DIR = path.resolve(__dirname, "test/lib/errorsModule.js"); +const MODULE_PARENT_DIR = path.resolve(__dirname, "test/errorsModule.js"); + +const ruleTester = new RuleTester(); + +ruleTester.run("dry-error-messages", rule, { + valid: [ + // Ignores malformed `this.raise` invocations. + { + filename: FILENAME, + code: "this.raise(loc);", + options: [{ errorModule: ERRORS_MODULE }], + }, + { + filename: FILENAME, + code: "this.notRaise(loc, 'Uh oh');", + options: [{ errorModule: ERRORS_MODULE }], + }, + { + filename: FILENAME, + code: "throw new Error(this.raise('Uh oh'));", + options: [{ errorModule: ERRORS_MODULE }], + }, + { + filename: FILENAME, + code: "this.raise(() => { throw new Error('Uh oh') });", + options: [{ errorModule: ERRORS_MODULE }], + }, + { + filename: FILENAME, + code: "throw new Error('Uh oh')", + options: [{ errorModule: ERRORS_MODULE }], + }, + { + filename: FILENAME, + code: "throw this.createError('Uh oh')", + options: [{ errorModule: ERRORS_MODULE }], + }, + { + filename: FILENAME, + code: "throw this.error", + options: [{ errorModule: ERRORS_MODULE }], + }, + { + filename: FILENAME, + code: "this.raise", + options: [{ errorModule: ERRORS_MODULE }], + }, + { + filename: FILENAME, + code: "throw obj.error", + options: [{ errorModule: ERRORS_MODULE }], + }, + { + filename: FILENAME, + code: "throw obj.raise", + options: [{ errorModule: ERRORS_MODULE }], + }, + { + filename: FILENAME, + code: + "import { Errors } from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: ERRORS_MODULE }], + }, + { + filename: FILENAME, + code: + "import { Errors } from './errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: MODULE_SAME_DIR }], + }, + { + filename: FILENAME, + code: + "import { Errors } from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: MODULE_PARENT_DIR }], + }, + { + filename: FILENAME, + code: + "import { NotErrors, Errors } from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: ERRORS_MODULE }], + }, + { + filename: FILENAME, + code: + "import { NotErrors, Errors } from './errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: MODULE_SAME_DIR }], + }, + { + filename: FILENAME, + code: + "import { NotErrors, Errors } from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: MODULE_PARENT_DIR }], + }, + { + filename: FILENAME, + code: + "import { Errors } from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: ERRORS_MODULE }], + }, + { + filename: FILENAME, + code: + "import { Errors } from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: MODULE_SAME_DIR }], + }, + { + filename: FILENAME, + code: + "import { Errors } from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: MODULE_PARENT_DIR }], + }, + { + filename: FILENAME, + code: + "import { NotErrors, Errors } from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: ERRORS_MODULE }], + }, + { + filename: FILENAME, + code: + "import { NotErrors, Errors } from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: MODULE_SAME_DIR }], + }, + { + filename: FILENAME, + code: + "import { NotErrors, Errors } from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: MODULE_PARENT_DIR }], + }, + { + filename: FILENAME, + code: + "import Errors from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: ERRORS_MODULE }], + }, + { + filename: FILENAME, + code: + "import Errors from './errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: MODULE_SAME_DIR }], + }, + { + filename: FILENAME, + code: + "import Errors from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: MODULE_PARENT_DIR }], + }, + { + filename: FILENAME, + code: + "import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: ERRORS_MODULE }], + }, + { + filename: FILENAME, + code: + "import Errors, { NotErrors } from './errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: MODULE_SAME_DIR }], + }, + { + filename: FILENAME, + code: + "import Errors, { NotErrors } from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: MODULE_PARENT_DIR }], + }, + { + filename: FILENAME, + code: + "import NotErrors, { Errors } from 'errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: ERRORS_MODULE }], + }, + { + filename: FILENAME, + code: + "import NotErrors, { Errors } from './errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: MODULE_SAME_DIR }], + }, + { + filename: FILENAME, + code: + "import NotErrors, { Errors } from '../errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: MODULE_PARENT_DIR }], + }, + { + filename: FILENAME, + code: + "import Errors from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: ERRORS_MODULE }], + }, + { + filename: FILENAME, + code: + "import Errors from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: MODULE_SAME_DIR }], + }, + { + filename: FILENAME, + code: + "import Errors from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: MODULE_PARENT_DIR }], + }, + { + filename: FILENAME, + code: + "import Errors, { NotErrors } from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: ERRORS_MODULE }], + }, + { + filename: FILENAME, + code: + "import Errors, { NotErrors } from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: MODULE_SAME_DIR }], + }, + { + filename: FILENAME, + code: + "import Errors, { NotErrors } from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: MODULE_PARENT_DIR }], + }, + { + filename: FILENAME, + code: + "import NotErrors, { Errors } from 'errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: ERRORS_MODULE }], + }, + { + filename: FILENAME, + code: + "import NotErrors, { Errors } from './errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: MODULE_SAME_DIR }], + }, + { + filename: FILENAME, + code: + "import NotErrors, { Errors } from '../errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: MODULE_PARENT_DIR }], + }, + + // Do not warn when file linted is error module. + { + filename: FILENAME, + code: "this.raise(loc, 'Oh no!');", + options: [{ errorModule: FILENAME }], + }, + { + filename: MODULE_SAME_DIR, + code: "this.raise(loc, 'Oh no!');", + options: [{ errorModule: MODULE_SAME_DIR }], + }, + + // Do not warn if second argument is missing + { + filename: FILENAME, + code: "this.raise(loc);", + options: [{ errorModule: ERRORS_MODULE }], + }, + ], + invalid: [ + { + filename: FILENAME, + code: "this.raise(loc, new Error('Uh oh'));", + options: [{ errorModule: ERRORS_MODULE }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: ERRORS_MODULE }, + }, + ], + }, + { + filename: FILENAME, + code: "throw this.raise(loc, new Error('Uh oh'));", + options: [{ errorModule: ERRORS_MODULE }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: ERRORS_MODULE }, + }, + ], + }, + { + filename: FILENAME, + code: "this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: ERRORS_MODULE }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: ERRORS_MODULE }, + }, + ], + }, + { + filename: FILENAME, + code: + "const Errors = { someErrorMessage: 'Uh oh!' }; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: ERRORS_MODULE }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: ERRORS_MODULE }, + }, + ], + }, + { + filename: FILENAME, + code: "import { Errors } from 'errorsModule'; this.raise(loc, 'Uh oh!');", + options: [{ errorModule: ERRORS_MODULE }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: ERRORS_MODULE }, + }, + ], + }, + { + filename: FILENAME, + code: + "import { Errors } from 'errorsModule'; const msg = 'Uh oh!'; this.raise(loc, msg);", + options: [{ errorModule: ERRORS_MODULE }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: ERRORS_MODULE }, + }, + ], + }, + { + filename: FILENAME, + code: + "import { Errors } from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: ERRORS_MODULE }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: ERRORS_MODULE }, + }, + ], + }, + { + filename: FILENAME, + code: + "import { Errors } from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: MODULE_SAME_DIR }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: MODULE_SAME_DIR }, + }, + ], + }, + { + filename: FILENAME, + code: + "import { Errors } from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: MODULE_PARENT_DIR }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: MODULE_PARENT_DIR }, + }, + ], + }, + { + filename: FILENAME, + code: + "import { NotErrors, Errors } from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: ERRORS_MODULE }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: ERRORS_MODULE }, + }, + ], + }, + { + filename: FILENAME, + code: + "import { NotErrors, Errors } from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: MODULE_SAME_DIR }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: MODULE_SAME_DIR }, + }, + ], + }, + { + filename: FILENAME, + code: + "import { NotErrors, Errors } from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: MODULE_PARENT_DIR }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: MODULE_PARENT_DIR }, + }, + ], + }, + { + filename: FILENAME, + code: + "import { Errors } from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: ERRORS_MODULE }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: ERRORS_MODULE }, + }, + ], + }, + { + filename: FILENAME, + code: + "import { Errors } from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: MODULE_SAME_DIR }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: MODULE_SAME_DIR }, + }, + ], + }, + { + filename: FILENAME, + code: + "import { Errors } from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: MODULE_PARENT_DIR }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: MODULE_PARENT_DIR }, + }, + ], + }, + { + filename: FILENAME, + code: + "import { NotErrors, Errors } from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: ERRORS_MODULE }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: ERRORS_MODULE }, + }, + ], + }, + { + filename: FILENAME, + code: + "import { NotErrors, Errors } from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: MODULE_SAME_DIR }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: MODULE_SAME_DIR }, + }, + ], + }, + { + filename: FILENAME, + code: + "import { NotErrors, Errors } from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: MODULE_PARENT_DIR }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: MODULE_PARENT_DIR }, + }, + ], + }, + { + filename: FILENAME, + code: + "import Errors from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: ERRORS_MODULE }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: ERRORS_MODULE }, + }, + ], + }, + { + filename: FILENAME, + code: + "import Errors from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: MODULE_SAME_DIR }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: MODULE_SAME_DIR }, + }, + ], + }, + { + filename: FILENAME, + code: + "import Errors from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: MODULE_PARENT_DIR }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: MODULE_PARENT_DIR }, + }, + ], + }, + { + filename: FILENAME, + code: + "import Errors, { NotErrors } from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: ERRORS_MODULE }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: ERRORS_MODULE }, + }, + ], + }, + { + filename: FILENAME, + code: + "import Errors, { NotErrors } from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: MODULE_SAME_DIR }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: MODULE_SAME_DIR }, + }, + ], + }, + { + filename: FILENAME, + code: + "import Errors, { NotErrors } from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: MODULE_PARENT_DIR }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: MODULE_PARENT_DIR }, + }, + ], + }, + { + filename: FILENAME, + code: + "import NotErrors, { Errors } from 'not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: ERRORS_MODULE }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: ERRORS_MODULE }, + }, + ], + }, + { + filename: FILENAME, + code: + "import NotErrors, { Errors } from './not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: MODULE_SAME_DIR }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: MODULE_SAME_DIR }, + }, + ], + }, + { + filename: FILENAME, + code: + "import NotErrors, { Errors } from '../not-errorsModule'; this.raise(loc, Errors.someErrorMessage);", + options: [{ errorModule: MODULE_PARENT_DIR }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: MODULE_PARENT_DIR }, + }, + ], + }, + { + filename: FILENAME, + code: + "import Errors from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: ERRORS_MODULE }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: ERRORS_MODULE }, + }, + ], + }, + { + filename: FILENAME, + code: + "import Errors from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: MODULE_SAME_DIR }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: MODULE_SAME_DIR }, + }, + ], + }, + { + filename: FILENAME, + code: + "import Errors from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: MODULE_PARENT_DIR }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: MODULE_PARENT_DIR }, + }, + ], + }, + { + filename: FILENAME, + code: + "import Errors, { NotErrors } from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: ERRORS_MODULE }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: ERRORS_MODULE }, + }, + ], + }, + { + filename: FILENAME, + code: + "import Errors, { NotErrors } from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: MODULE_SAME_DIR }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: MODULE_SAME_DIR }, + }, + ], + }, + { + filename: FILENAME, + code: + "import Errors, { NotErrors } from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: MODULE_PARENT_DIR }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: MODULE_PARENT_DIR }, + }, + ], + }, + { + filename: FILENAME, + code: + "import NotErrors, { Errors } from 'not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: ERRORS_MODULE }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: ERRORS_MODULE }, + }, + ], + }, + { + filename: FILENAME, + code: + "import NotErrors, { Errors } from './not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: MODULE_SAME_DIR }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: MODULE_SAME_DIR }, + }, + ], + }, + { + filename: FILENAME, + code: + "import NotErrors, { Errors } from '../not-errorsModule'; function fn() { this.raise(loc, Errors.someErrorMessage); }", + options: [{ errorModule: MODULE_PARENT_DIR }], + errors: [ + { + messageId: "mustBeImported", + data: { errorModule: MODULE_PARENT_DIR }, + }, + ], + }, + ], +}); diff --git a/eslint/babel-eslint-plugin-development/src/index.js b/eslint/babel-eslint-plugin-development/src/index.js index ae6662710684..946da90045e2 100644 --- a/eslint/babel-eslint-plugin-development/src/index.js +++ b/eslint/babel-eslint-plugin-development/src/index.js @@ -2,7 +2,7 @@ import noDeprecatedClone from "./rules/no-deprecated-clone"; import noUndefinedIdentifier from "./rules/no-undefined-identifier"; import pluginName from "./rules/plugin-name"; -export default { +module.exports = { rules: { "no-deprecated-clone": noDeprecatedClone, "no-undefined-identifier": noUndefinedIdentifier, diff --git a/eslint/babel-eslint-plugin/package.json b/eslint/babel-eslint-plugin/package.json index 8d9134a40d18..4af39f5d11f4 100644 --- a/eslint/babel-eslint-plugin/package.json +++ b/eslint/babel-eslint-plugin/package.json @@ -34,7 +34,6 @@ }, "devDependencies": { "@babel/eslint-shared-fixtures": "*", - "@babel/eslint-parser": "*", "eslint": "^6.0.0", "lodash.clonedeep": "^4.5.0" } diff --git a/eslint/babel-eslint-plugin/test/helpers/RuleTester.js b/eslint/babel-eslint-plugin/test/helpers/RuleTester.js deleted file mode 100644 index 47166bd51185..000000000000 --- a/eslint/babel-eslint-plugin/test/helpers/RuleTester.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RuleTester } from "eslint"; - -RuleTester.setDefaultConfig({ - parser: require.resolve("@babel/eslint-parser"), - parserOptions: { - babelOptions: { - configFile: require.resolve( - "@babel/eslint-shared-fixtures/config/babel.config.js", - ), - }, - }, -}); - -export default RuleTester; diff --git a/eslint/babel-eslint-plugin/test/rules/new-cap.js b/eslint/babel-eslint-plugin/test/rules/new-cap.js index d5e44984152e..669c51ee5765 100644 --- a/eslint/babel-eslint-plugin/test/rules/new-cap.js +++ b/eslint/babel-eslint-plugin/test/rules/new-cap.js @@ -1,5 +1,5 @@ import rule from "../../src/rules/new-cap"; -import RuleTester from "../helpers/RuleTester"; +import RuleTester from "@babel/eslint-shared-fixtures/utils/RuleTester"; const ruleTester = new RuleTester(); ruleTester.run("@babel/new-cap", rule, { diff --git a/eslint/babel-eslint-plugin/test/rules/no-invalid-this.js b/eslint/babel-eslint-plugin/test/rules/no-invalid-this.js index 7fdde00b7227..47cd9d89ad10 100644 --- a/eslint/babel-eslint-plugin/test/rules/no-invalid-this.js +++ b/eslint/babel-eslint-plugin/test/rules/no-invalid-this.js @@ -1,6 +1,6 @@ import cloneDeep from "lodash.clonedeep"; import rule from "../../src/rules/no-invalid-this"; -import RuleTester from "../helpers/RuleTester"; +import RuleTester from "@babel/eslint-shared-fixtures/utils/RuleTester"; /** * A constant value for non strict mode environment. diff --git a/eslint/babel-eslint-plugin/test/rules/no-unused-expressions.js b/eslint/babel-eslint-plugin/test/rules/no-unused-expressions.js index 991bf6fa80b4..9ba9b5773952 100644 --- a/eslint/babel-eslint-plugin/test/rules/no-unused-expressions.js +++ b/eslint/babel-eslint-plugin/test/rules/no-unused-expressions.js @@ -1,5 +1,5 @@ import rule from "../../src/rules/no-unused-expressions"; -import RuleTester from "../helpers/RuleTester"; +import RuleTester from "@babel/eslint-shared-fixtures/utils/RuleTester"; const ruleTester = new RuleTester(); ruleTester.run("@babel/no-unused-expressions", rule, { diff --git a/eslint/babel-eslint-plugin/test/rules/object-curly-spacing.js b/eslint/babel-eslint-plugin/test/rules/object-curly-spacing.js index 8a08a09516c7..1c3e270582e7 100644 --- a/eslint/babel-eslint-plugin/test/rules/object-curly-spacing.js +++ b/eslint/babel-eslint-plugin/test/rules/object-curly-spacing.js @@ -1,13 +1,8 @@ import rule from "../../src/rules/object-curly-spacing"; -import RuleTester from "../helpers/RuleTester"; +import RuleTester from "@babel/eslint-shared-fixtures/utils/RuleTester"; const ruleTester = new RuleTester(); ruleTester.run("@babel/object-curly-spacing", rule, { - valid: [ - { - code: 'export x from "mod";', - }, - ], - + valid: ['export x from "mod";'], invalid: [], }); diff --git a/eslint/babel-eslint-plugin/test/rules/semi.js b/eslint/babel-eslint-plugin/test/rules/semi.js index d7a757b62616..815aeb00747c 100644 --- a/eslint/babel-eslint-plugin/test/rules/semi.js +++ b/eslint/babel-eslint-plugin/test/rules/semi.js @@ -1,5 +1,5 @@ import rule from "../../src/rules/semi"; -import RuleTester from "../helpers/RuleTester"; +import RuleTester from "@babel/eslint-shared-fixtures/utils/RuleTester"; const ruleTester = new RuleTester(); diff --git a/eslint/babel-eslint-shared-fixtures/package.json b/eslint/babel-eslint-shared-fixtures/package.json index 96bbb96dde67..1946669fe5c4 100644 --- a/eslint/babel-eslint-shared-fixtures/package.json +++ b/eslint/babel-eslint-shared-fixtures/package.json @@ -5,6 +5,7 @@ "license": "MIT", "private": true, "dependencies": { + "@babel/eslint-parser": "*", "@babel/plugin-proposal-class-properties": "^7.1.0", "@babel/plugin-proposal-decorators": "^7.1.2", "@babel/plugin-proposal-do-expressions": "^7.7.4", diff --git a/eslint/babel-eslint-shared-fixtures/utils/RuleTester.js b/eslint/babel-eslint-shared-fixtures/utils/RuleTester.js new file mode 100644 index 000000000000..58be2ff8d47e --- /dev/null +++ b/eslint/babel-eslint-shared-fixtures/utils/RuleTester.js @@ -0,0 +1,17 @@ +const path = require("path"); +const { RuleTester } = require("eslint"); + +RuleTester.setDefaultConfig({ + parser: require.resolve("@babel/eslint-parser"), + parserOptions: { + sourceType: "module", + ecmaVersion: 11, + babelOptions: { + configFile: require.resolve( + path.join(__dirname, "../config/babel.config.js") + ), + }, + }, +}); + +module.exports = RuleTester; diff --git a/package.json b/package.json index 1b63836e5f94..12da041f1d0d 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,10 @@ "devDependencies": { "@babel/cli": "^7.10.1", "@babel/core": "^7.10.2", - "@babel/eslint-plugin-development": "^1.0.1", + "@babel/eslint-config-internal": "link:./eslint/babel-eslint-config-internal", + "@babel/eslint-parser": "link:./eslint/babel-eslint-parser", + "@babel/eslint-plugin-development": "link:./eslint/babel-eslint-plugin-development", + "@babel/eslint-plugin-development-internal": "link:./eslint/babel-eslint-plugin-development-internal", "@babel/plugin-proposal-class-properties": "^7.10.1", "@babel/plugin-proposal-dynamic-import": "^7.10.1", "@babel/plugin-proposal-export-namespace-from": "^7.10.1", diff --git a/packages/babel-parser/src/parser/error-message.js b/packages/babel-parser/src/parser/error-message.js index a738624bf254..5a7df725361c 100644 --- a/packages/babel-parser/src/parser/error-message.js +++ b/packages/babel-parser/src/parser/error-message.js @@ -59,6 +59,7 @@ export const ErrorMessages = Object.freeze({ ImportCallSpreadArgument: "... is not allowed in import()", ImportMetaOutsideModule: `import.meta may appear only with 'sourceType: "module"'`, ImportOutsideModule: `'import' and 'export' may appear only with 'sourceType: "module"'`, + InvalidBigIntLiteral: "Invalid BigIntLiteral", InvalidCodePoint: "Code point out of bounds", InvalidDigit: "Expected number in radix %0", InvalidEscapeSequence: "Bad character escape sequence", diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 8c4dc7bd191b..cc6278c2f532 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -1467,7 +1467,9 @@ export default class ExpressionParser extends LValParser { error += " or class properties"; } + /* eslint-disable @babel/development-internal/dry-error-messages */ this.raise(metaProp.start, error); + /* eslint-enable @babel/development-internal/dry-error-messages */ } return metaProp; diff --git a/packages/babel-parser/src/parser/lval.js b/packages/babel-parser/src/parser/lval.js index 647d48a5389d..a952219dd482 100644 --- a/packages/babel-parser/src/parser/lval.js +++ b/packages/babel-parser/src/parser/lval.js @@ -143,7 +143,9 @@ export default class LValParser extends NodeUtils { ? Errors.PatternHasAccessor : Errors.PatternHasMethod; + /* eslint-disable @babel/development-internal/dry-error-messages */ this.raise(prop.key.start, error); + /* eslint-enable @babel/development-internal/dry-error-messages */ } else if (prop.type === "SpreadElement" && !isLast) { this.raiseRestNotLast(prop.start); } else { @@ -356,6 +358,7 @@ export default class LValParser extends NodeUtils { ? isStrictBindReservedWord(expr.name, this.inModule) : isStrictBindOnlyReservedWord(expr.name)) ) { + /* eslint-disable @babel/development-internal/dry-error-messages */ this.raise( expr.start, bindingType === BIND_NONE @@ -363,6 +366,7 @@ export default class LValParser extends NodeUtils { : Errors.StrictEvalArgumentsBinding, expr.name, ); + /* eslint-enable @babel/development-internal/dry-error-messages */ } if (checkClashes) { @@ -459,6 +463,7 @@ export default class LValParser extends NodeUtils { break; default: { + /* eslint-disable @babel/development-internal/dry-error-messages */ this.raise( expr.start, bindingType === BIND_NONE @@ -466,6 +471,7 @@ export default class LValParser extends NodeUtils { : Errors.InvalidLhsBinding, contextDescription, ); + /* eslint-enable @babel/development-internal/dry-error-messages */ } } } diff --git a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index e201cfcd36cc..9bbed6ca25f1 100644 --- a/packages/babel-parser/src/parser/statement.js +++ b/packages/babel-parser/src/parser/statement.js @@ -2019,6 +2019,7 @@ export default class StatementParser extends ExpressionParser { name: string, ): void { if (this.state.exportedIdentifiers.indexOf(name) > -1) { + /* eslint-disable @babel/development-internal/dry-error-messages */ this.raise( node.start, name === "default" @@ -2026,6 +2027,7 @@ export default class StatementParser extends ExpressionParser { : Errors.DuplicateExport, name, ); + /* eslint-enable @babel/development-internal/dry-error-messages */ } this.state.exportedIdentifiers.push(name); } diff --git a/packages/babel-parser/src/parser/util.js b/packages/babel-parser/src/parser/util.js index cc91ab28133a..8928698e6b70 100644 --- a/packages/babel-parser/src/parser/util.js +++ b/packages/babel-parser/src/parser/util.js @@ -132,7 +132,9 @@ export default class UtilParser extends Tokenizer { // Throws if the current token and the prev one are separated by a space. assertNoSpace(message: string = "Unexpected space."): void { if (this.state.start > this.state.lastTokEnd) { + /* eslint-disable @babel/development-internal/dry-error-messages */ this.raise(this.state.lastTokEnd, message); + /* eslint-enable @babel/development-internal/dry-error-messages */ } } @@ -146,7 +148,9 @@ export default class UtilParser extends Tokenizer { if (typeof messageOrType !== "string") { messageOrType = `Unexpected token, expected "${messageOrType.label}"`; } + /* eslint-disable @babel/development-internal/dry-error-messages */ throw this.raise(pos != null ? pos : this.state.start, messageOrType); + /* eslint-enable @babel/development-internal/dry-error-messages */ } expectPlugin(name: string, pos?: ?number): true { @@ -178,16 +182,10 @@ export default class UtilParser extends Tokenizer { this.state.yieldPos !== -1 && (this.state.awaitPos === -1 || this.state.yieldPos < this.state.awaitPos) ) { - this.raise( - this.state.yieldPos, - "Yield cannot be used as name inside a generator function", - ); + this.raise(this.state.yieldPos, Errors.YieldBindingIdentifier); } if (this.state.awaitPos !== -1) { - this.raise( - this.state.awaitPos, - "Await cannot be used as name inside an async function", - ); + this.raise(this.state.awaitPos, Errors.AwaitBindingIdentifier); } } diff --git a/packages/babel-parser/src/plugins/flow.js b/packages/babel-parser/src/plugins/flow.js index f2558916a006..508845d1046c 100644 --- a/packages/babel-parser/src/plugins/flow.js +++ b/packages/babel-parser/src/plugins/flow.js @@ -2,6 +2,9 @@ /*:: declare var invariant; */ +// Error messages are colocated with the plugin. +/* eslint-disable @babel/development-internal/dry-error-messages */ + import type Parser from "../parser"; import { types as tt, type TokenType } from "../tokenizer/types"; import * as N from "../types"; @@ -473,6 +476,7 @@ export default (superClass: Class): Class => ) { const label = this.state.value; const suggestion = exportSuggestions[label]; + throw this.raise( this.state.start, FlowErrors.UnsupportedDeclareExportKind, diff --git a/packages/babel-parser/src/plugins/jsx/index.js b/packages/babel-parser/src/plugins/jsx/index.js index ba91d78aeab2..c8a44b1f78e3 100644 --- a/packages/babel-parser/src/plugins/jsx/index.js +++ b/packages/babel-parser/src/plugins/jsx/index.js @@ -1,5 +1,8 @@ // @flow +// Error messages are colocated with the plugin. +/* eslint-disable @babel/development-internal/dry-error-messages */ + import * as charCodes from "charcodes"; import XHTMLEntities from "./xhtml"; diff --git a/packages/babel-parser/src/plugins/typescript/index.js b/packages/babel-parser/src/plugins/typescript/index.js index 2477a62e408d..6309c8ea8fcb 100644 --- a/packages/babel-parser/src/plugins/typescript/index.js +++ b/packages/babel-parser/src/plugins/typescript/index.js @@ -2,6 +2,9 @@ /*:: declare var invariant; */ +// Error messages are colocated with the plugin. +/* eslint-disable @babel/development-internal/dry-error-messages */ + import type { TokenType } from "../../tokenizer/types"; import type State from "../../tokenizer/state"; import { types as tt } from "../../tokenizer/types"; diff --git a/packages/babel-parser/src/tokenizer/index.js b/packages/babel-parser/src/tokenizer/index.js index 55cda33a6ed5..1a8af6cbbdd8 100644 --- a/packages/babel-parser/src/tokenizer/index.js +++ b/packages/babel-parser/src/tokenizer/index.js @@ -420,12 +420,14 @@ export default class Tokenizer extends ParserErrors { // misleading this.expectPlugin("recordAndTuple"); if (this.getPluginOption("recordAndTuple", "syntaxType") !== "hash") { + /* eslint-disable @babel/development-internal/dry-error-messages */ throw this.raise( this.state.pos, next === charCodes.leftCurlyBrace ? Errors.RecordExpressionHashIncorrectStartSyntaxType : Errors.TupleExpressionHashIncorrectStartSyntaxType, ); + /* eslint-enable @babel/development-internal/dry-error-messages */ } if (next === charCodes.leftCurlyBrace) { @@ -1148,7 +1150,7 @@ export default class Tokenizer extends ParserErrors { if (next === charCodes.plusSign || next === charCodes.dash) { ++this.state.pos; } - if (this.readInt(10) === null) this.raise(start, "Invalid number"); + if (this.readInt(10) === null) this.raise(start, Errors.InvalidNumber); isFloat = true; next = this.input.charCodeAt(this.state.pos); } @@ -1171,7 +1173,7 @@ export default class Tokenizer extends ParserErrors { // disallow floats, legacy octal syntax and non octal decimals // new style octal ("0o") is handled in this.readRadixNumber if (isFloat || octal || isNonOctalDecimalInt) { - this.raise(start, "Invalid BigIntLiteral"); + this.raise(start, Errors.InvalidBigIntLiteral); } ++this.state.pos; isBigInt = true; diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-1/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-1/output.json index 7fb0d2ac2cda..e2da3742e2f0 100644 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-1/output.json +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-1/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, "errors": [ - "SyntaxError: Yield cannot be used as name inside a generator function (2:7)" + "SyntaxError: Can not use 'yield' as identifier inside a generator (2:7)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-2/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-2/output.json index f526c3252076..06385571b6c1 100644 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-2/output.json +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-2/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":53,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, "errors": [ - "SyntaxError: Yield cannot be used as name inside a generator function (2:15)" + "SyntaxError: Can not use 'yield' as identifier inside a generator (2:15)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-3/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-3/output.json index f6e29bf0fdb1..010f31c93aa5 100644 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-3/output.json +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-3/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":42,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, "errors": [ - "SyntaxError: Yield cannot be used as name inside a generator function (2:7)" + "SyntaxError: Can not use 'yield' as identifier inside a generator (2:7)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-4/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-4/output.json index 427ec4363f69..13407641824c 100644 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-4/output.json +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-4/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, "errors": [ - "SyntaxError: Yield cannot be used as name inside a generator function (2:17)" + "SyntaxError: Can not use 'yield' as identifier inside a generator (2:17)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-5/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-5/output.json index 4f2ee50da949..dfc02f63790c 100644 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-5/output.json +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-5/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":47,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, "errors": [ - "SyntaxError: Yield cannot be used as name inside a generator function (2:8)", + "SyntaxError: Can not use 'yield' as identifier inside a generator (2:8)", "SyntaxError: Binding invalid left-hand side in function parameter list (2:8)" ], "program": { diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-6/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-6/output.json index b78292c7993d..ae3b4ae99d77 100644 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-6/output.json +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-6/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":41,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, "errors": [ - "SyntaxError: Yield cannot be used as name inside a generator function (2:8)" + "SyntaxError: Can not use 'yield' as identifier inside a generator (2:8)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-1/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-1/output.json index ff99d56fa462..a36032ac4b88 100644 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-1/output.json +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-1/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, "errors": [ - "SyntaxError: Yield cannot be used as name inside a generator function (2:3)", + "SyntaxError: Can not use 'yield' as identifier inside a generator (2:3)", "SyntaxError: Binding invalid left-hand side in function parameter list (2:3)" ], "program": { diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-2/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-2/output.json index fae1c616f040..57995f28ee4f 100644 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-2/output.json +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-2/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, "errors": [ - "SyntaxError: Yield cannot be used as name inside a generator function (2:3)", + "SyntaxError: Can not use 'yield' as identifier inside a generator (2:3)", "SyntaxError: Binding invalid left-hand side in function parameter list (2:3)" ], "program": { diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-3/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-3/output.json index 6e589aab512a..44660a84d0c9 100644 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-3/output.json +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-3/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":41,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, "errors": [ - "SyntaxError: Yield cannot be used as name inside a generator function (2:9)", + "SyntaxError: Can not use 'yield' as identifier inside a generator (2:9)", "SyntaxError: Binding invalid left-hand side in function parameter list (2:9)" ], "program": { diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/async-await-as-arrow-binding-identifier/output.json b/packages/babel-parser/test/fixtures/es2017/async-functions/async-await-as-arrow-binding-identifier/output.json index f41c5e0fe4e6..09b554179dcb 100644 --- a/packages/babel-parser/test/fixtures/es2017/async-functions/async-await-as-arrow-binding-identifier/output.json +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/async-await-as-arrow-binding-identifier/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, "errors": [ - "SyntaxError: Await cannot be used as name inside an async function (1:6)" + "SyntaxError: Can not use 'await' as identifier inside an async function (1:6)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-binding-inside-arrow-params-inside-async-arrow-params/output.json b/packages/babel-parser/test/fixtures/es2017/async-functions/await-binding-inside-arrow-params-inside-async-arrow-params/output.json index c6a76429a103..1cd8424fcc9b 100644 --- a/packages/babel-parser/test/fixtures/es2017/async-functions/await-binding-inside-arrow-params-inside-async-arrow-params/output.json +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/await-binding-inside-arrow-params-inside-async-arrow-params/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":36}}, "errors": [ - "SyntaxError: Await cannot be used as name inside an async function (1:20)" + "SyntaxError: Can not use 'await' as identifier inside an async function (1:20)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arguments-of-async-call-inside-parameters-of-async-arrow-function/output.json b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arguments-of-async-call-inside-parameters-of-async-arrow-function/output.json index fe9f611da097..40be26a790f4 100644 --- a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arguments-of-async-call-inside-parameters-of-async-arrow-function/output.json +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arguments-of-async-call-inside-parameters-of-async-arrow-function/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":63,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, "errors": [ - "SyntaxError: Await cannot be used as name inside an async function (2:23)" + "SyntaxError: Can not use 'await' as identifier inside an async function (2:23)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters-of-nested-arrow-function/output.json b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters-of-nested-arrow-function/output.json index 46e14510807e..b0a4f4215a5f 100644 --- a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters-of-nested-arrow-function/output.json +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters-of-nested-arrow-function/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, "errors": [ - "SyntaxError: Await cannot be used as name inside an async function (2:7)" + "SyntaxError: Can not use 'await' as identifier inside an async function (2:7)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters-of-nested-async-arrow-function/output.json b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters-of-nested-async-arrow-function/output.json index da4bfb18b9e8..64f74b32e873 100644 --- a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters-of-nested-async-arrow-function/output.json +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters-of-nested-async-arrow-function/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":52,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, "errors": [ - "SyntaxError: Await cannot be used as name inside an async function (2:13)" + "SyntaxError: Can not use 'await' as identifier inside an async function (2:13)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-default/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-default/output.json index 4081ebee04bb..def9e45bf335 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-default/output.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-default/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}}, "errors": [ - "SyntaxError: Yield cannot be used as name inside a generator function (1:21)" + "SyntaxError: Can not use 'yield' as identifier inside a generator (1:21)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameter/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameter/output.json index 2ef911f25615..64ad613826ec 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameter/output.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameter/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":30,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":30}}, "errors": [ - "SyntaxError: Yield cannot be used as name inside a generator function (1:16)", + "SyntaxError: Can not use 'yield' as identifier inside a generator (1:16)", "SyntaxError: Binding invalid left-hand side in function parameter list (1:16)" ], "program": { diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameters/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameters/output.json index 5656f98e9947..64047fad86b2 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameters/output.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameters/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}}, "errors": [ - "SyntaxError: Yield cannot be used as name inside a generator function (1:25)", + "SyntaxError: Can not use 'yield' as identifier inside a generator (1:25)", "SyntaxError: Binding invalid left-hand side in function parameter list (1:25)" ], "program": { diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/yield-generator-arrow-default/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/yield-generator-arrow-default/output.json index a560dd2c5e32..90f20d4f5718 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/yield-generator-arrow-default/output.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/yield-generator-arrow-default/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":35}}, "errors": [ - "SyntaxError: Yield cannot be used as name inside a generator function (1:21)" + "SyntaxError: Can not use 'yield' as identifier inside a generator (1:21)" ], "program": { "type": "Program", diff --git a/yarn.lock b/yarn.lock index e657ab15d887..7d3013447c76 100644 --- a/yarn.lock +++ b/yarn.lock @@ -56,10 +56,21 @@ semver "^5.4.1" source-map "^0.5.0" -"@babel/eslint-plugin-development@^1.0.1": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@babel/eslint-plugin-development/-/eslint-plugin-development-1.0.1.tgz#1f5206ae95795db09b65e7dbc2b158d66497a44c" - integrity sha512-ioEhN8HgKr4Yx8ef+XryNpKN4FimSFceb0qVVxvoUzpFn3xyq17MlY5AquEqtXObE7Nu7WKq7QL9INzjCrugyw== +"@babel/eslint-config-internal@link:./eslint/babel-eslint-config-internal": + version "0.0.0" + uid "" + +"@babel/eslint-parser@link:./eslint/babel-eslint-parser": + version "0.0.0" + uid "" + +"@babel/eslint-plugin-development-internal@link:./eslint/babel-eslint-plugin-development-internal": + version "0.0.0" + uid "" + +"@babel/eslint-plugin-development@link:./eslint/babel-eslint-plugin-development": + version "0.0.0" + uid "" "@babel/generator@^7.10.1", "@babel/generator@^7.10.2", "@babel/generator@^7.4.0": version "7.10.2"