Home

Awesome

eslint-plugin-eslint-plugin CI NPM version Conventional Commits <!-- omit from toc -->

An ESLint plugin for linting ESLint plugins. Rules written in CJS, ESM, and TypeScript are all supported.

<!-- vscode-markdown-toc --> <!-- 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:

npm i eslint --save-dev

Next, install eslint-plugin-eslint-plugin:

npm install eslint-plugin-eslint-plugin --save-dev

<a name='Usage'></a>Usage

Here's an example ESLint configuration that:

<a name='eslintrc'></a>.eslintrc.json

{
  "extends": ["plugin:eslint-plugin/recommended"],
  "rules": {
    "eslint-plugin/require-meta-docs-description": "error"
  }
}

<a name='flat'></a>eslint.config.js (requires eslint>=v8.23.0)

const eslintPlugin = require('eslint-plugin-eslint-plugin');
module.exports = [
  eslintPlugin.configs['flat/recommended'],
  {
    rules: {
      'eslint-plugin/require-meta-docs-description': 'error',
    },
  },
];

<a name='Rules'></a>Rules

<!-- begin auto-generated rules list -->

💼 Configurations enabled in.
✅ Set in the recommended configuration.
🔧 Automatically fixable by the --fix CLI option.
💡 Manually fixable by editor suggestions.
💭 Requires type information.

Rules

Name                           Description💼🔧💡💭
fixer-returnrequire fixer functions to return a fix✅
meta-property-orderingenforce the order of meta properties🔧
no-deprecated-context-methodsdisallow usage of deprecated methods on rule context objects✅🔧
no-deprecated-report-apidisallow the version of context.report() with multiple arguments✅🔧
no-meta-schema-defaultdisallow rules meta.schema properties to include defaults
no-missing-message-idsdisallow messageIds that are missing from meta.messages✅
no-missing-placeholdersdisallow missing placeholders in rule report messages✅
no-property-in-nodedisallow using in to narrow node types instead of looking at properties💭
no-unused-message-idsdisallow unused messageIds in meta.messages✅
no-unused-placeholdersdisallow unused placeholders in rule report messages✅
no-useless-token-rangedisallow unnecessary calls to sourceCode.getFirstToken() and sourceCode.getLastToken()✅🔧
prefer-message-idsrequire using messageId instead of message or desc to report rule violations✅
prefer-object-ruledisallow function-style rules✅🔧
prefer-placeholdersrequire using placeholders for dynamic report messages
prefer-replace-textrequire using replaceText() instead of replaceTextRange()
report-message-formatenforce a consistent format for rule report messages
require-meta-default-optionsrequire only rules with options to implement a meta.defaultOptions property🔧
require-meta-docs-descriptionrequire rules to implement a meta.docs.description property with the correct format
require-meta-docs-recommendedrequire rules to implement a meta.docs.recommended property💡
require-meta-docs-urlrequire rules to implement a meta.docs.url property🔧
require-meta-fixablerequire rules to implement a meta.fixable property✅
require-meta-has-suggestionsrequire suggestable rules to implement a meta.hasSuggestions property✅🔧
require-meta-schemarequire rules to implement a meta.schema property✅💡
require-meta-schema-descriptionrequire rules meta.schema properties to include descriptions
require-meta-typerequire rules to implement a meta.type property✅

Tests

Name                       Description💼🔧💡💭
consistent-outputenforce consistent use of output assertions in rule tests
no-identical-testsdisallow identical tests✅🔧
no-only-testsdisallow the test case property only✅💡
prefer-output-nulldisallow invalid RuleTester test cases where the output matches the code✅🔧
test-case-property-orderingrequire the properties of a test case to be placed in a consistent order🔧
test-case-shorthand-stringsenforce consistent usage of shorthand strings for test cases with no options🔧
<!-- end auto-generated rules list -->

<a name='Presets'></a>Presets

NameDescription
✅recommendedenables all recommended rules in this plugin
rules-recommendedenables all recommended rules that are aimed at linting ESLint rule files
tests-recommendedenables all recommended rules that are aimed at linting ESLint test files
allenables all rules in this plugin, excluding those requiring type information
all-type-checkedenables all rules in this plugin, including those requiring type information
rulesenables all rules that are aimed at linting ESLint rule files
testsenables 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

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"]
    }
  ]
}