From 9868c5d3794fcc96ab290add1f5c0c1c9f2f4218 Mon Sep 17 00:00:00 2001 From: Bryan Mishkin <698306+bmish@users.noreply.github.com> Date: Thu, 12 Oct 2023 15:05:10 -0400 Subject: [PATCH] docs: auto-generate some rule option lists with eslint-doc-generator --- docs/rules/require-meta-docs-description.md | 8 ++++++-- docs/rules/require-meta-docs-url.md | 10 +++++++--- docs/rules/require-meta-fixable.md | 8 ++++++-- docs/rules/require-meta-schema.md | 8 ++++++-- lib/rules/consistent-output.js | 1 + lib/rules/require-meta-docs-description.js | 3 +++ lib/rules/require-meta-docs-url.js | 6 +++++- lib/rules/require-meta-fixable.js | 2 ++ lib/rules/require-meta-schema.js | 2 ++ package.json | 2 +- 10 files changed, 39 insertions(+), 11 deletions(-) diff --git a/docs/rules/require-meta-docs-description.md b/docs/rules/require-meta-docs-description.md index 8de0b5bf..7679935e 100644 --- a/docs/rules/require-meta-docs-description.md +++ b/docs/rules/require-meta-docs-description.md @@ -49,9 +49,13 @@ module.exports = { ## Options -This rule takes an optional object containing: + -* `String` — `pattern` — A regular expression that the description must match. Use `'.+'` to allow anything. Defaults to `^(enforce|require|disallow)`. +| Name | Description | Type | Default | +| :-------- | :---------------------------------------------------------------------------------- | :----- | :---------------------------- | +| `pattern` | A regular expression that the description must match. Use `'.+'` to allow anything. | String | `^(enforce|require|disallow)` | + + ## Further Reading diff --git a/docs/rules/require-meta-docs-url.md b/docs/rules/require-meta-docs-url.md index 7c2f1740..be534c19 100644 --- a/docs/rules/require-meta-docs-url.md +++ b/docs/rules/require-meta-docs-url.md @@ -77,7 +77,13 @@ module.exports = { ## Options -This rule has an option. + + +| Name | Description | Type | +| :-------- | :----------------------------------------------------------------------------------------------------------------------------------------------- | :----- | +| `pattern` | A pattern to enforce rule's document URL. It replaces `{{name}}` placeholder by each rule name. The rule name is the basename of each rule file. | String | + + ```json { @@ -87,8 +93,6 @@ This rule has an option. } ``` -- `pattern` (`string`) ... A pattern to enforce rule's document URL. It replaces `{{name}}` placeholder by each rule name. The rule name is the basename of each rule file. Default is `undefined` which allows any URL. - If you set the `pattern` option, this rule adds `meta.docs.url` property automatically when you execute `eslint --fix` command. ## Version specific URL diff --git a/docs/rules/require-meta-fixable.md b/docs/rules/require-meta-fixable.md index 28148a3e..b6b6fcc3 100644 --- a/docs/rules/require-meta-fixable.md +++ b/docs/rules/require-meta-fixable.md @@ -92,9 +92,13 @@ module.exports = { ## Options -This rule takes an optional object containing: + -* `boolean` — `catchNoFixerButFixableProperty` — default `false` - Whether the rule should attempt to detect rules that do not have a fixer but enable the `meta.fixable` property. This option is off by default because it increases the chance of false positives since fixers can't always be detected when helper functions are used. +| Name | Description | Type | +| :------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------ | +| `catchNoFixerButFixableProperty` | Whether the rule should attempt to detect rules that do not have a fixer but enable the `meta.fixable` property. This option is off by default because it increases the chance of false positives since fixers can't always be detected when helper functions are used. | Boolean | + + ## Further Reading diff --git a/docs/rules/require-meta-schema.md b/docs/rules/require-meta-schema.md index 066eb0ba..5b768087 100644 --- a/docs/rules/require-meta-schema.md +++ b/docs/rules/require-meta-schema.md @@ -75,9 +75,13 @@ module.exports = { ## Options -This rule takes an optional object containing: + -* `boolean` — `requireSchemaPropertyWhenOptionless` — Whether the rule should require the `meta.schema` property to be specified (with `schema: []`) for rules that have no options. Defaults to `true`. +| Name | Description | Type | Default | +| :------------------------------------ | :----------------------------------------------------------------------------------------------------------------------------- | :------ | :------ | +| `requireSchemaPropertyWhenOptionless` | Whether the rule should require the `meta.schema` property to be specified (with `schema: []`) for rules that have no options. | Boolean | `true` | + + ## When Not To Use It diff --git a/lib/rules/consistent-output.js b/lib/rules/consistent-output.js index a5c621d7..21a1c3ee 100644 --- a/lib/rules/consistent-output.js +++ b/lib/rules/consistent-output.js @@ -27,6 +27,7 @@ module.exports = { { type: 'string', enum: ['always', 'consistent'], + default: 'consistent', }, ], messages: { diff --git a/lib/rules/require-meta-docs-description.js b/lib/rules/require-meta-docs-description.js index 0a9b390d..85a374e8 100644 --- a/lib/rules/require-meta-docs-description.js +++ b/lib/rules/require-meta-docs-description.js @@ -27,6 +27,9 @@ module.exports = { properties: { pattern: { type: 'string', + description: + "A regular expression that the description must match. Use `'.+'` to allow anything.", + default: '^(enforce|require|disallow)', }, }, additionalProperties: false, diff --git a/lib/rules/require-meta-docs-url.js b/lib/rules/require-meta-docs-url.js index 0894c67a..862e6dde 100644 --- a/lib/rules/require-meta-docs-url.js +++ b/lib/rules/require-meta-docs-url.js @@ -31,7 +31,11 @@ module.exports = { { type: 'object', properties: { - pattern: { type: 'string' }, + pattern: { + type: 'string', + description: + "A pattern to enforce rule's document URL. It replaces `{{name}}` placeholder by each rule name. The rule name is the basename of each rule file. Omitting this allows any URL.", + }, }, additionalProperties: false, }, diff --git a/lib/rules/require-meta-fixable.js b/lib/rules/require-meta-fixable.js index 74b79e7a..be3edf19 100644 --- a/lib/rules/require-meta-fixable.js +++ b/lib/rules/require-meta-fixable.js @@ -29,6 +29,8 @@ module.exports = { catchNoFixerButFixableProperty: { type: 'boolean', default: false, + description: + "Whether the rule should attempt to detect rules that do not have a fixer but enable the `meta.fixable` property. This option is off by default because it increases the chance of false positives since fixers can't always be detected when helper functions are used.", }, }, additionalProperties: false, diff --git a/lib/rules/require-meta-schema.js b/lib/rules/require-meta-schema.js index 339d14bc..26a1cef9 100644 --- a/lib/rules/require-meta-schema.js +++ b/lib/rules/require-meta-schema.js @@ -25,6 +25,8 @@ module.exports = { requireSchemaPropertyWhenOptionless: { type: 'boolean', default: true, + description: + 'Whether the rule should require the `meta.schema` property to be specified (with `schema: []`) for rules that have no options.', }, }, additionalProperties: false, diff --git a/package.json b/package.json index dd079284..f06ecacb 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "eslint": "^8.23.0", "eslint-config-not-an-aardvark": "^2.1.0", "eslint-config-prettier": "^8.5.0", - "eslint-doc-generator": "^1.4.3", + "eslint-doc-generator": "^1.5.0", "eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-eslint-plugin": "file:./", "eslint-plugin-markdown": "^3.0.0",