babel/eslint/babel-eslint-plugin-development-internal
Nicolò Ribaudo d04842a700
Avoid using CJS globals in internal source files (#12963)
* Lint against CJS globals in modules

* Use `import.meta.url` instead of `__filename` in `src` files

* Prepare fixtures runner for `import.meta.url`

* Use `import.meta.url` instead of `__filename` in `test/index` files

* Remove `__dirname` from remaining test files

dirname

* Avoid using `module` in `src` files

* Avoid using `require` in `src` files

* Avoid using `require` in `test` files

* Update `@types/node`

* Compile dynamic import in `@babel/node`

* Fix windows

* Use `@babel/plugin-proposal-dynamic-import` from npm
2021-03-05 19:55:36 +01:00
..
2020-10-16 00:36:30 +02:00

@babel/eslint-plugin-development-internal

The Babel team's custom ESLint rules for the babel/babel monorepo.

Installation

$ npm install --save-dev @babel/eslint-plugin-development-internal

or

$ 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):

{
  "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:

{
  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:

{
  rules: {
    "@babel/development-internal/dry-error-messages": [
      "error",
      {
        errorModule: "@babel/shared-error-messages"
      }
    ]
  }
}

and

{
  rules: {
    "@babel/development-internal/dry-error-messages": [
      "error",
      {
        errorModule: path.resolve(
          __dirname,
          "packages/shared-error-messages/lib/index.js"
        )
      }
    ]
  }
}