UNPKG

ec0lint-plugin-ec0lint-plugin

Version:

An ec0lint plugin for linting ec0lint plugins

133 lines (108 loc) 9.03 kB
# eslint-plugin-eslint-plugin ![CI](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/workflows/CI/badge.svg) [![NPM version](https://img.shields.io/npm/v/eslint-plugin-eslint-plugin.svg?style=flat)](https://npmjs.org/package/eslint-plugin-eslint-plugin) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) An ESLint plugin for linting ESLint plugins. Rules written in CJS, ESM, and TypeScript are all supported. <!-- vscode-markdown-toc --> * [Installation](#Installation) * [Usage](#Usage) * [Rules](#Rules) * [Presets](#Presets) * [Semantic versioning policy](#Semanticversioningpolicy) * [Preset usage](#Presetusage) <!-- vscode-markdown-toc-config numbering=false autoSave=true /vscode-markdown-toc-config --> <!-- /vscode-markdown-toc --> ## <a name='Installation'></a>Installation You'll first need to install [ESLint](https://eslint.org): ```sh npm i eslint --save-dev ``` Next, install `eslint-plugin-eslint-plugin`: ```sh npm install eslint-plugin-eslint-plugin --save-dev ``` ## <a name='Usage'></a>Usage Here's an example ESLint configuration that: * Sets `sourceType` to `script` for CJS plugins (most users) (use `module` for ESM/TypeScript) * Enables the `recommended` configuration * Enables an optional/non-recommended rule ```json { "parserOptions": { "sourceType": "script" }, "extends": [ "plugin:eslint-plugin/recommended" ], "rules": { "eslint-plugin/require-meta-docs-description": "error" } } ``` ## <a name='Rules'></a>Rules * ✔️ if the rule belongs to the `recommended` configuration * 🛠 if some problems reported by the rule are automatically fixable by the `--fix` [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) option * 💡 if some problems reported by the rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions) <!-- __BEGIN AUTOGENERATED TABLE__ --> Name | ✔️ | 🛠 | 💡 | Description ----- | ----- | ----- | ----- | ----- [consistent-output](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/consistent-output.md) | ✔️ | | | enforce consistent use of `output` assertions in rule tests [fixer-return](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/fixer-return.md) | ✔️ | | | require fixer functions to return a fix [meta-property-ordering](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/meta-property-ordering.md) | | 🛠 | | enforce the order of meta properties [no-deprecated-context-methods](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-deprecated-context-methods.md) | ✔️ | 🛠 | | disallow usage of deprecated methods on rule context objects [no-deprecated-report-api](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-deprecated-report-api.md) | ✔️ | 🛠 | | disallow the version of `context.report()` with multiple arguments [no-identical-tests](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-identical-tests.md) | ✔️ | 🛠 | | disallow identical tests [no-missing-placeholders](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-missing-placeholders.md) | ✔️ | | | disallow missing placeholders in rule report messages [no-only-tests](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-only-tests.md) | ✔️ | | 💡 | disallow the test case property `only` [no-unused-placeholders](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-unused-placeholders.md) | ✔️ | | | disallow unused placeholders in rule report messages [no-useless-token-range](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-useless-token-range.md) | ✔️ | 🛠 | | disallow unnecessary calls to `sourceCode.getFirstToken()` and `sourceCode.getLastToken()` [prefer-message-ids](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/prefer-message-ids.md) | | | | require using `messageId` instead of `message` to report rule violations [prefer-object-rule](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/prefer-object-rule.md) | ✔️ | 🛠 | | disallow rule exports where the export is a function [prefer-output-null](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/prefer-output-null.md) | | 🛠 | | disallow invalid RuleTester test cases where the `output` matches the `code` [prefer-placeholders](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/prefer-placeholders.md) | | | | require using placeholders for dynamic report messages [prefer-replace-text](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/prefer-replace-text.md) | | | | require using `replaceText()` instead of `replaceTextRange()` [report-message-format](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/report-message-format.md) | | | | enforce a consistent format for rule report messages [require-meta-docs-description](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/require-meta-docs-description.md) | | | | require rules to implement a `meta.docs.description` property with the correct format [require-meta-docs-url](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/require-meta-docs-url.md) | | 🛠 | | require rules to implement a `meta.docs.url` property [require-meta-fixable](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/require-meta-fixable.md) | ✔️ | | | require rules to implement a `meta.fixable` property [require-meta-has-suggestions](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/require-meta-has-suggestions.md) | ✔️ | 🛠 | | require suggestable rules to implement a `meta.hasSuggestions` property [require-meta-schema](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/require-meta-schema.md) | ✔️ | | 💡 | require rules to implement a `meta.schema` property [require-meta-type](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/require-meta-type.md) | ✔️ | | | require rules to implement a `meta.type` property [test-case-property-ordering](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/test-case-property-ordering.md) | | 🛠 | | require the properties of a test case to be placed in a consistent order [test-case-shorthand-strings](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/test-case-shorthand-strings.md) | | 🛠 | | enforce consistent usage of shorthand strings for test cases with no options <!-- __END AUTOGENERATED TABLE__ --> ## <a name='Presets'></a>Presets | | Name | Description | |:--|:-----|:------------| | ✔️ | `recommended` | enables all recommended rules in this plugin | | | `rules-recommended` | enables all recommended rules that are aimed at linting ESLint rule files | | | `tests-recommended` | enables all recommended rules that are aimed at linting ESLint test files | | | `all` | enables all rules in this plugin | | | `rules` | enables all rules that are aimed at linting ESLint rule files | | | `tests` | enables all rules that are aimed at linting ESLint test files | ### <a name='Semanticversioningpolicy'></a>Semantic versioning policy The list of recommended rules will only change in a major release of this plugin. However, new non-recommended rules might be added in a minor release of this plugin. Therefore, using the `all`, `rules`, and `tests` presets is **not recommended for production use**, because the addition of new rules in a minor release could break your build. ### <a name='Presetusage'></a>Preset usage Presets are enabled by adding a line to the `extends` list in your config file. For example, to enable the `recommended` preset, use: ```json { "extends": [ "plugin:eslint-plugin/recommended" ] } ``` Or to apply linting only to the appropriate rule or test files: ```json { "overrides": [ { "files": ["lib/rules/*.{js,ts}"], "extends": ["plugin:eslint-plugin/rules-recommended"] }, { "files": ["tests/lib/rules/*.{js,ts}"], "extends": ["plugin:eslint-plugin/tests-recommended"] }, ] } ```