{"id":13596821,"url":"https://github.com/bmish/eslint-doc-generator","last_synced_at":"2025-05-16T07:04:11.183Z","repository":{"id":60578308,"uuid":"543183889","full_name":"bmish/eslint-doc-generator","owner":"bmish","description":"Automatic documentation generator for ESLint plugins and rules.","archived":false,"fork":false,"pushed_at":"2025-05-12T19:20:16.000Z","size":4128,"stargazers_count":97,"open_issues_count":47,"forks_count":10,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-13T14:08:00.320Z","etag":null,"topics":["documentation","eslint","eslint-plugin","generator","javascript","lint","linter","linting","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bmish.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-29T15:05:03.000Z","updated_at":"2025-05-08T21:40:02.000Z","dependencies_parsed_at":"2023-12-18T22:50:38.881Z","dependency_job_id":"c261b920-329f-4f8b-981a-bb180fd6b91d","html_url":"https://github.com/bmish/eslint-doc-generator","commit_stats":{"total_commits":410,"total_committers":9,"mean_commits":45.55555555555556,"dds":0.3390243902439024,"last_synced_commit":"39ec71433c0e6a24924f9833f81658cd80188ecf"},"previous_names":[],"tags_count":68,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmish%2Feslint-doc-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmish%2Feslint-doc-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmish%2Feslint-doc-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmish%2Feslint-doc-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bmish","download_url":"https://codeload.github.com/bmish/eslint-doc-generator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254485053,"owners_count":22078767,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["documentation","eslint","eslint-plugin","generator","javascript","lint","linter","linting","typescript"],"created_at":"2024-08-01T16:02:49.667Z","updated_at":"2025-05-16T07:04:11.160Z","avatar_url":"https://github.com/bmish.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","Developing for ESLint"],"sub_categories":["Testing Tools"],"readme":"# eslint-doc-generator\u003c!-- omit from toc --\u003e\n\n[![npm version][npm-image]][npm-url] ![test coverage](https://img.shields.io/badge/test%20coverage-100%25-green)\n\nAutomatic documentation generator for [ESLint](https://eslint.org/) plugins and rules. Inspired by documentation conventions from ESLint and [top](#users) ESLint [plugins](https://eslint.org/docs/latest/developer-guide/working-with-plugins).\n\nGenerates the following documentation covering a [wide variety](#column-and-notice-types) of rule metadata:\n\n- `README.md` rules table\n- `README.md` configs table\n- Rule doc titles and notices\n- Rule doc options lists\n\nAlso performs [configurable](#configuration-options) section consistency checks on rule docs:\n\n- Contains an `## Options` or  `## Config` section and mentions each named option (for rules with options)\n\n## Table of contents\u003c!-- omit from toc --\u003e\n\n- [Motivation](#motivation)\n- [Setup](#setup)\n  - [Scripts](#scripts)\n  - [Update `README.md`](#update-readmemd)\n  - [Update rule docs](#update-rule-docs)\n  - [Configure linting](#configure-linting)\n- [Usage](#usage)\n- [Examples](#examples)\n  - [Rules list table](#rules-list-table)\n  - [Configs list table](#configs-list-table)\n  - [Rule doc notices](#rule-doc-notices)\n  - [Rule doc options lists](#rule-doc-options-lists)\n  - [Users](#users)\n- [Configuration options](#configuration-options)\n  - [Column and notice types](#column-and-notice-types)\n  - [`--config-format`](#--config-format)\n  - [`--rule-doc-title-format`](#--rule-doc-title-format)\n  - [Configuration file](#configuration-file)\n  - [Badges](#badges)\n- [Compatibility](#compatibility)\n  - [Build tools](#build-tools)\n  - [markdownlint](#markdownlint)\n  - [prettier](#prettier)\n- [Semantic versioning policy](#semantic-versioning-policy)\n- [Related](#related)\n\n## Motivation\n\n- Standardize documentation across thousands of ESLint plugins and rules\n- Improve the discoverability of key rule information and thus rule usability\n- Streamline the process of adding/updating rules while ensuring documentation is kept up-to-date\n- Eliminate the custom documentation scripts and tests previously built and maintained by many ESLint plugins\n\n## Setup\n\nInstall it:\n\n```sh\nnpm i --save-dev eslint-doc-generator\n```\n\n### Scripts\n\nAdd scripts to `package.json`:\n\n- Both a lint script to ensure everything is up-to-date in CI and an update script for contributors to run locally\n- Add any [config options](#configuration-options) in the `update:eslint-docs` script only (or use a [config file](#configuration-file))\n- Alternative scripts may be needed with [build tools](#build-tools), [markdownlint](#markdownlint), or [prettier](#prettier)\n\n```json\n{\n  \"scripts\": {\n    \"lint\": \"npm-run-all \\\"lint:*\\\"\",\n    \"lint:docs\": \"markdownlint \\\"**/*.md\\\"\",\n    \"lint:eslint-docs\": \"npm run update:eslint-docs -- --check\",\n    \"lint:js\": \"eslint .\",\n    \"update:eslint-docs\": \"eslint-doc-generator\"\n  }\n}\n```\n\n### Update `README.md`\n\nDelete any old rules list from your `README.md`. A new one will be automatically added to your `## Rules` section (along with the following marker comments if they don't already exist):\n\n```md\n\u003c!-- begin auto-generated rules list --\u003e\n\u003c!-- end auto-generated rules list --\u003e\n```\n\nOptionally, add these marker comments to your `README.md` in a `## Configs` section or similar location (uses the `meta.docs.description` property exported by each config if available):\n\n```md\n\u003c!-- begin auto-generated configs list --\u003e\n\u003c!-- end auto-generated configs list --\u003e\n```\n\n### Update rule docs\n\nDelete any old recommended/fixable/etc. notices from your rule docs. A new title and notices will be automatically added to the top of each rule doc (along with a marker comment if it doesn't already exist).\n\n```md\n\u003c!-- end auto-generated rule header --\u003e\n```\n\nOptionally, add these marker comments to your rule docs in an `## Options` section or similar location:\n\n```md\n\u003c!-- begin auto-generated rule options list --\u003e\n\u003c!-- end auto-generated rule options list --\u003e\n```\n\nNote that rule option lists are subject-to-change as we add support for more kinds and properties of schemas. To fully take advantage of them, you'll want to ensure your rules have the `meta.schema` property fleshed out with properties like `description`, `type`, `enum`, `default`, `required`, `deprecated`.\n\n### Configure linting\n\nAnd be sure to enable the `recommended` rules from [eslint-plugin-eslint-plugin](https://github.com/eslint-community/eslint-plugin-eslint-plugin) as well as:\n\n- [eslint-plugin/require-meta-docs-description](https://github.com/eslint-community/eslint-plugin-eslint-plugin/blob/main/docs/rules/require-meta-docs-description.md) to ensure your rules have consistent descriptions for use in the generated docs\n- [eslint-plugin/require-meta-docs-url](https://github.com/eslint-community/eslint-plugin-eslint-plugin/blob/main/docs/rules/require-meta-docs-url.md) to ensure your rule docs are linked to by editors on highlighted violations\n- [eslint-plugin/require-meta-schema](https://github.com/eslint-community/eslint-plugin-eslint-plugin/blob/main/docs/rules/require-meta-schema.md) to ensure your rules have schemas for use in determining options\n\n## Usage\n\nRun the script from `package.json` to start out or any time you add a rule or update rule metadata in your plugin:\n\n```sh\nnpm run update:eslint-docs\n```\n\n## Examples\n\nFor examples, see our [users](#users) or the in-house examples below. Note that the in-house examples intentionally show all possible columns and notices.\n\n### Rules list table\n\nSee the generated rules table and legend in our example [`README.md`](./docs/examples/eslint-plugin-test/README.md#rules).\n\n### Configs list table\n\nSee the generated configs table in our example [`README.md`](./docs/examples/eslint-plugin-test/README.md#configs).\n\n### Rule doc notices\n\nSee the generated rule doc title and notices in our example rule docs [`no-foo.md`](./docs/examples/eslint-plugin-test/docs/rules/no-foo.md), [`prefer-bar.md`](./docs/examples/eslint-plugin-test/docs/rules/prefer-bar.md), [`require-baz.md`](./docs/examples/eslint-plugin-test/docs/rules/require-baz.md).\n\n### Rule doc options lists\n\nSee the generated rule doc options lists in our example rule doc [`no-foo.md`](./docs/examples/eslint-plugin-test/docs/rules/no-foo.md).\n\n### Users\n\nThis tool is used by popular ESLint plugins like:\n\n- [eslint-plugin-ava](https://github.com/avajs/eslint-plugin-ava#rules)\n- [eslint-plugin-ember](https://github.com/ember-cli/eslint-plugin-ember#-rules)\n- [eslint-plugin-eslint-plugin](https://github.com/eslint-community/eslint-plugin-eslint-plugin#rules)\n- [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import#rules)\n- [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest#rules)\n- [eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#supported-rules)\n- [eslint-plugin-promise](https://github.com/eslint-community/eslint-plugin-promise#rules)\n- [eslint-plugin-qunit](https://github.com/platinumazure/eslint-plugin-qunit#rules)\n- [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react#list-of-supported-rules)\n- [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn#rules)\n\n## Configuration options\n\nThese can be provided as CLI options or as [config file](#configuration-file) options. All options are optional.\n\nThe CLI has an optional path argument if you need to point the CLI to an ESLint plugin directory that isn't just the current directory:\n\n```sh\neslint-doc-generator path/to/eslint-plugin\n```\n\nThere's also a `postprocess` option that's only available via a [config file](#configuration-file).\n\n| Name | Description | Default |\n| :-- | :-- | :-- |\n| `--check` | Whether to check for and fail if there is a diff. Any diff will be displayed but no output will be written to files. Typically used during CI. | `false` |\n| `--config-emoji` | Custom emoji to use for a config. Format is `config-name,emoji`. Option can be repeated. | Default emojis are provided for [common configs](./lib/emojis.ts). See [Badges](#badges) for an alternative to emojis. |\n| `--config-format` | The format to use for config names. See choices in below [table](#--config-format). | `name` |\n| `--ignore-config` | Config to ignore from being displayed. Often used for an `all` config. Option can be repeated. | |\n| `--ignore-deprecated-rules` | Whether to ignore deprecated rules from being checked, displayed, or updated. | `false` |\n| `--init-rule-docs` | Whether to create rule doc files if they don't yet exist. | `false` |\n| `--path-rule-doc` | Path to markdown file for each rule doc. Use `{name}` placeholder for the rule name. A function can also be provided for this option via a [config file](#configuration-file). | `docs/rules/{name}.md` |\n| `--path-rule-list` | Path to markdown file where the rules table list should live. Option can be repeated. | `README.md` |\n| `--rule-doc-notices` | Ordered, comma-separated list of notices to display in rule doc. Non-applicable notices will be hidden. See choices in below [table](#column-and-notice-types). | `deprecated`, `configs`, `fixableAndHasSuggestions`, `requiresTypeChecking` |\n| `--rule-doc-section-exclude` | Disallowed section in each rule doc. Exit with failure if present. Option can be repeated. | |\n| `--rule-doc-section-include` | Required section in each rule doc. Exit with failure if missing. Option can be repeated. | |\n| `--rule-doc-section-options` | Whether to require an \"Options\" or \"Config\" rule doc section and mention of any named options for rules with options. | `true` |\n| `--rule-doc-title-format` | The format to use for rule doc titles. See choices in below [table](#--rule-doc-title-format). | `desc-parens-prefix-name` |\n| `--rule-list-columns` | Ordered, comma-separated list of columns to display in rule list. Empty columns will be hidden. See choices in below [table](#column-and-notice-types). | `name`, `description`, `configsError`, `configsWarn`, `configsOff`, `fixable`, `hasSuggestions`, `requiresTypeChecking`, `deprecated` |\n| `--rule-list-split` | Rule property(s) to split the rules list by. A separate list and header will be created for each value. Example: `meta.type`. A function can also be provided for this option via a [config file](#configuration-file). | |\n| `--url-configs` | Link to documentation about the ESLint configurations exported by the plugin. | |\n| `--url-rule-doc` | Link to documentation for each rule. Useful when it differs from the rule doc path on disk (e.g. custom documentation site in use). Use `{name}` placeholder for the rule name. A function can also be provided for this option via a [config file](#configuration-file). | |\n\n### Column and notice types\n\nThese are the types of rule metadata that are available for display in rule list columns (`--rule-list-columns`) and/or rule doc notices (`--rule-doc-notices`).\n\n| Emoji | Type | Column? | Notice? | Description |\n| :-- | :-- | :-- | :-- | :-- |\n| 💼 | `configsError` | Yes | No | Whether a rule is set to `error` in a config. |\n| 🚫 | `configsOff` | Yes | No | Whether a rule is set to `off` in a config. |\n| ⚠️ | `configsWarn` | Yes | No | Whether a rule is set to `warn` in a config. |\n| 💼 | `configs` | No | Yes | What configs set a rule to what [severities](https://eslint.org/docs/latest/user-guide/configuring/rules#rule-severities). |\n| ❌ | `deprecated`  | Yes | Yes | Whether a rule is deprecated (i.e. likely to be removed/renamed in a future major version). |\n| | `description`  | Yes | Yes | The rule description. |\n| 🔧💡 | `fixableAndHasSuggestions` | Yes | Yes | Whether a rule is [fixable](https://eslint.org/docs/latest/developer-guide/working-with-rules#applying-fixes) and/or has [suggestions](https://eslint.org/docs/latest/developer-guide/working-with-rules#providing-suggestions). |\n| 🔧 | `fixable` | Yes | Yes | Whether a rule is [fixable](https://eslint.org/docs/latest/developer-guide/working-with-rules#applying-fixes). |\n| 💡 | `hasSuggestions` | Yes | Yes | Whether a rule has [suggestions](https://eslint.org/docs/latest/developer-guide/working-with-rules#providing-suggestions). |\n| | `name` | Yes | No | The rule name. |\n| ⚙️ | `options` | Yes | Yes | Whether a rule has [options](https://eslint.org/docs/latest/developer-guide/working-with-rules#options-schemas). |\n| 💭 | `requiresTypeChecking` | Yes | Yes | Whether a rule requires [type checking](https://typescript-eslint.io/linting/typed-linting/). |\n| 🗂️ | `type` | Yes | Yes | The rule [type](https://eslint.org/docs/latest/developer-guide/working-with-rules#rule-basics) (`problem`, `suggestion`, or `layout`). |\n\n### `--config-format`\n\nWhere `recommended` is the config name and `eslint-plugin-test` is the plugin name.\n\n| Value | Example |\n| :-- | :-- |\n| `name` (default) | `recommended` |\n| `plugin-colon-prefix-name` | `plugin:test/recommended` |\n| `prefix-name` | `test/recommended` |\n\n### `--rule-doc-title-format`\n\nWhere `no-foo` is the rule name, `Disallow use of foo` is the rule description, and `eslint-plugin-test` is the plugin name.\n\n| Value | Example |\n| :-- | :-- |\n| `desc` | `# Disallow use of foo` |\n| `desc-parens-name` | `# Disallow use of foo (no-foo)` |\n| `desc-parens-prefix-name` (default) | `# Disallow use of foo (test/no-foo)` |\n| `name` | `# no-foo` |\n| `prefix-name` | `# test/no-foo` |\n\n### Configuration file\n\nThere are a few ways to create a config file (as an alternative to passing the options via CLI):\n\n- An object exported by `.eslint-doc-generatorrc.js`, `.eslint-doc-generatorrc.json`, or any other config file format/name supported by [cosmiconfig](https://github.com/davidtheclark/cosmiconfig#searchplaces)\n- An object under the `eslint-doc-generator` key in `package.json`\n\nConfig files support all the [CLI options](#configuration-options) but in camelCase.\n\nSome options are exclusive to a JavaScript-based config file:\n\n- `postprocess` - A function-only option useful for applying custom transformations such as formatting with tools like prettier. See [prettier example](#prettier).\n- [`ruleListSplit`](#configuration-options) with a function - This is useful for customizing the grouping of rules into lists.\n\nExample `.eslint-doc-generatorrc.js`:\n\n```js\n/** @type {import('eslint-doc-generator').GenerateOptions} */\nconst config = {\n  ignoreConfig: ['all'],\n};\n\nmodule.exports = config;\n```\n\nExample `.eslint-doc-generatorrc.js` with `pathRuleDoc` function:\n\n```js\n/** @type {import('eslint-doc-generator').GenerateOptions} */\nconst config = {\n  pathRuleDoc(name) {\n    // e.g. rule name format is `some-plugin/some-rule`, and rule is in a monorepo under different package.\n    const [plugin, rule] = name.split(\"/\");\n    return `packages/eslint-plugin-${plugin}/src/rules/${rule}.md`;\n  },\n};\n\nmodule.exports = config;\n```\n\nExample `.eslint-doc-generatorrc.js` with `ruleListSplit` function:\n\n```js\n/** @type {import('eslint-doc-generator').GenerateOptions} */\nconst config = {\n  ruleListSplit(rules) {\n    return [\n      {\n        // No header for this list.\n        rules: rules.filter(([name, rule]) =\u003e !rule.meta.someProp),\n      },\n      {\n        title: 'Foo',\n        rules: rules.filter(([name, rule]) =\u003e rule.meta.someProp === 'foo'),\n      },\n      {\n        title: 'Bar',\n        rules: rules.filter(([name, rule]) =\u003e rule.meta.someProp === 'bar'),\n      },\n    ];\n  },\n};\n\nmodule.exports = config;\n```\n\nExample `.eslint-doc-generatorrc.js` with `urlRuleDoc` function:\n\n```js\n/** @type {import('eslint-doc-generator').GenerateOptions} */\nconst config = {\n  urlRuleDoc(name, page) {\n    if (page === 'README.md') {\n      // Use URLs only in the readme.\n      return `https://example.com/rules/${name}.html`;\n    }\n  },\n};\n\nmodule.exports = config;\n```\n\n### Badges\n\nWhile emojis are the recommended representations of configs that a rule belongs to, you can alternatively use a text/image/icon badge for configs by supplying the following markdown for the emoji using the [`--config-emoji`](#configuration-options) option.\n\nFor example, here's the markdown for a text badge representing a custom `fun` config that displays in blue (note that the markdown includes alt text followed by the image URL):\n\n```md\n![fun config badge](https://img.shields.io/badge/-fun-blue.svg)\n```\n\nHere's how you'd configure it:\n\n```js\n/** @type {import('eslint-doc-generator').GenerateOptions} */\nconst config = {\n  configEmoji: [\n    ['fun', '![fun config badge](https://img.shields.io/badge/-fun-blue.svg)'],\n  ],\n};\n\nmodule.exports = config;\n```\n\nAnd how it looks:\n\n![fun config badge](https://img.shields.io/badge/-fun-blue.svg)\n\n## Compatibility\n\n### Build tools\n\nIf you have a build step for your code like [Babel](https://babeljs.io/) or [TypeScript](https://www.typescriptlang.org/), you may need to adjust your scripts to run your build before this tool to ensure the documentation is generated from the latest plugin information:\n\n```json\n{\n  \"build\": \"tsc\",\n  \"update:eslint-docs\": \"npm run build \u0026\u0026 eslint-doc-generator\"\n}\n```\n\n### markdownlint\n\nThe output of this tool should be compatible with the default configuration of [markdownlint](https://github.com/DavidAnson/markdownlint), which you might use to lint your markdown. If it's not, you can follow the [prettier example](#prettier) to tweak your scripts or use the `postprocess` option. See [here](https://github.com/DavidAnson/markdownlint/blob/main/helpers/README.md#applying-recommended-fixes) for an example of markdownlint's Node API for applying fixes to use in your `postprocess` function.\n\n### prettier\n\nIf you use [prettier](https://prettier.io/) to format your markdown, you can provide a `postprocess` function to ensure the documentation generated by this tool is formatted correctly:\n\n```javascript\nconst prettier = require('prettier');\nconst { prettier: prettierRC } = require('./package.json'); // or wherever your prettier config lies\n\n/** @type {import('eslint-doc-generator').GenerateOptions} */\nconst config = {\n  postprocess: (content, path) =\u003e\n    prettier.format(content, { ...prettierRC, parser: 'markdown' }),\n};\n\nmodule.exports = config;\n```\n\nAlternatively, you can configure your scripts to run `prettier` after this tool:\n\n```json\n{\n  \"format\": \"prettier --write .\",\n  \"lint:eslint-docs\": \"npm run update:eslint-docs \u0026\u0026 git diff --exit-code\",\n  \"update:eslint-docs\": \"eslint-doc-generator \u0026\u0026 npm run format\"\n}\n```\n\n## Semantic versioning policy\n\nThis tool follows [semantic versioning](https://semver.org/).\n\nNew features will be released as a minor version, while bug fixes will be released as a patch version.\n\nBreaking changes will be released as a major version and include:\n\n- Changing an option default\n- Renaming or removing an option\n- Other backwards-incompatible changes to the CLI / API\n- Raising Node or ESLint version requirements\n\nTweaks to the generated documentation output can take place in any type of release including minor and patch versions. This can break your build, as even a small formatting change will cause a diff, but you can simply re-run the tool to fix.\n\n## Related\n\n- [eslint-plugin-eslint-plugin](https://github.com/eslint-community/eslint-plugin-eslint-plugin) - Linter for ESLint plugins ([related list](https://eslint.org/docs/latest/developer-guide/working-with-plugins#linting))\n- [generator-eslint](https://github.com/eslint/generator-eslint) - Generates initial ESLint plugin and rule files but without the sophisticated documentation provided by eslint-doc-generator\n\n[npm-image]: https://badge.fury.io/js/eslint-doc-generator.svg\n[npm-url]: https://www.npmjs.com/package/eslint-doc-generator\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmish%2Feslint-doc-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbmish%2Feslint-doc-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmish%2Feslint-doc-generator/lists"}