eslint-plugin-eslint-plugin
An ESLint plugin for linting ESLint plugins. Rules written in CJS, ESM, and TypeScript are all supported.
Installation
You'll first need to install ESLint:
npm i eslint --save-dev
Next, install eslint-plugin-eslint-plugin
:
npm install eslint-plugin-eslint-plugin --save-dev
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
{
"extends": ["plugin:eslint-plugin/recommended"],
"rules": {
"eslint-plugin/require-meta-docs-description": "error"
}
}
const eslintPlugin = require('eslint-plugin-eslint-plugin');
module.exports = [
eslintPlugin.configs['flat/recommended'],
{
rules: {
'eslint-plugin/require-meta-docs-description': 'error',
},
},
];
Rules
💼 Configurations enabled in.
✅ Set in the recommended
configuration.
🔧 Automatically fixable by the --fix
CLI option.
💡 Manually fixable by editor suggestions.
💭 Requires type information.
Rules
Tests
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, excluding those requiring type information |
| all-type-checked | enables all rules in this plugin, including those requiring type information |
| rules | enables all rules that are aimed at linting ESLint rule files |
| tests | enables all rules that are aimed at linting ESLint test files |
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.
Preset usage
Both flat and eslintrc configs are supported. For example, to enable the recommended
preset, use:
eslint.config.js
const eslintPlugin = require('eslint-plugin-eslint-plugin');
module.exports = [eslintPlugin.configs['flat/recommended']];
.eslintrc.json
{
"extends": ["plugin:eslint-plugin/recommended"]
}
Or to apply linting only to the appropriate rule or test files:
eslint.config.js
const eslintPlugin = require('eslint-plugin-eslint-plugin');
module.exports = [
{
files: ['lib/rules/*.{js,ts}'],
...eslintPlugin.configs['flat/rules-recommended'],
},
{
files: ['tests/lib/rules/*.{js,ts}'],
...eslintPlugin.configs['flat/tests-recommended'],
},
];
.eslintrc.js
{
"overrides": [
{
"files": ["lib/rules/*.{js,ts}"],
"extends": ["plugin:eslint-plugin/rules-recommended"]
},
{
"files": ["tests/lib/rules/*.{js,ts}"],
"extends": ["plugin:eslint-plugin/tests-recommended"]
}
]
}