| 1 | # @babel/eslint-plugin-development-internal |
| 2 | |
| 3 | The Babel team's custom ESLint rules for the babel/babel monorepo. |
| 4 | |
| 5 | ## Installation |
| 6 | |
| 7 | ```sh |
| 8 | $ npm install --save-dev @babel/eslint-plugin-development-internal |
| 9 | ``` |
| 10 | or |
| 11 | ```sh |
| 12 | $ yarn add --save-dev @babel/eslint-plugin-development-internal |
| 13 | ``` |
| 14 | |
| 15 | ## Usage |
| 16 | |
| 17 | The plugin can be loaded in your `.eslintrc.*` configuration file as follows: (note that you can omit the `eslint-plugin-` prefix): |
| 18 | |
| 19 | ```json |
| 20 | { |
| 21 | "plugins": ["@babel/development-internal"] |
| 22 | } |
| 23 | ``` |
| 24 | |
| 25 | ## Rules |
| 26 | |
| 27 | ### `@babel/development-internal/report-error-message-format` |
| 28 | |
| 29 | This rule is inspired by https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/report-message-format.md. |
| 30 | |
| 31 | Intended for use in `packages/babel-parser/src/**/*`. When enabled, this rule warns for inconsistently error messages format in arguments of `makeErrorTemplates` function calls. |
| 32 | |
| 33 | Basically, it starts with an uppercase Latin letter(A~Z) and ends with a period(.) or a question(?). But it can start with `'keyword'` or `` `code` `` to include JavaScript keywords or code in error messages. |
| 34 | |
| 35 | valid: |
| 36 | |
| 37 | ```js |
| 38 | makeErrorTemplates({ ThisIsAnError: "This is an error." }); |
| 39 | makeErrorTemplates({ ThisIsAnError: "'this' is an error." }); |
| 40 | makeErrorTemplates({ ThisIsAnError: "`this` is an error." }); |
| 41 | makeErrorTemplates({ ThisIsAnError: "This is an error?" }); |
| 42 | makeErrorTemplates({ ThisIsAnError: "'this' is an error?" }); |
| 43 | makeErrorTemplates({ ThisIsAnError: "`this` is an error?" }); |
| 44 | ``` |
| 45 | |
| 46 | invalid: |
| 47 | |
| 48 | ```js |
| 49 | makeErrorTemplates({ ThisIsAnError: 'this is an error.' }); |
| 50 | makeErrorTemplates({ ThisIsAnError: 'This is an error' }); |
| 51 | makeErrorTemplates({ ThisIsAnError: 'this is an error?' }); |
| 52 | makeErrorTemplates({ ThisIsAnError: '`this` is an error' }); |
| 53 | makeErrorTemplates({ ThisIsAnError: "'this' is an error" }); |
| 54 | ``` |
| 55 | |
| 56 | Example configuration: |
| 57 | |
| 58 | ```js |
| 59 | { |
| 60 | rules: { |
| 61 | "@babel/development-internal/report-error-message-format": "error" |
| 62 | } |
| 63 | } |
| 64 | ``` |