docs(linter): Add config docs for typescript/ban-ts-comment rule#16287
docs(linter): Add config docs for typescript/ban-ts-comment rule#16287graphite-app[bot] merged 1 commit intomainfrom
typescript/ban-ts-comment rule#16287Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
There was a problem hiding this comment.
Pull request overview
This PR adds configuration documentation for the typescript/ban-ts-comment lint rule by adding struct-level and field-level doc comments, JsonSchema derives, and serde attributes to enable automatic schema generation. The PR also refactors the from_configuration method to be more concise and adds a test case for block comment support.
Key changes:
- Added comprehensive documentation comments to
BanTsCommentConfigstruct explaining configuration options - Added
JsonSchemaderive and serde attributes (rename_all,rename) for schema generation - Refactored
from_configurationmethod to extract config object once and reuse it - Added test case for
/* @ts-ignore */block comment syntax
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodSpeed Performance ReportMerging #16287 will not alter performanceComparing Summary
Footnotes
|
Merge activity
|
…16287) Part of #14743. Generated docs (with the change to `doc_page.rs` to actually pull the doc comment above each config object, see #16288): ```md ## Configuration This rule allows you to specify how different TypeScript directive comments should be handled. For each directive (`@ts-expect-error`, `@ts-ignore`, `@ts-nocheck`, `@ts-check`), you can choose one of the following options: - `true`: Disallow the directive entirely, preventing its use in the entire codebase. - `false`: Allow the directive without any restrictions. - `"allow-with-description"`: Allow the directive only if it is followed by a description explaining its use. The description must meet the minimum length specified by `minimumDescriptionLength`. - `{ "descriptionFormat": "<regex>" }`: Allow the directive only if the description matches the specified regex pattern. For example: \```json { "ts-expect-error": "allow-with-description", "ts-ignore": true, "ts-nocheck": { "descriptionFormat": "^: TS\\d+ because .+$" }, "ts-check": false, "minimumDescriptionLength": 3 } \``` This rule accepts a configuration object with the following properties: ### minimumDescriptionLength type: `integer` default: `3` Minimum description length required when using directives with `allow-with-description`. ### ts-check How to handle the `@ts-check` directive. ### ts-expect-error How to handle the `@ts-expect-error` directive. ### ts-ignore How to handle the `@ts-ignore` directive. ### ts-nocheck How to handle the `@ts-nocheck` directive. ```
ea596c2 to
7613957
Compare
…nfig docs (#16288) This is necessary for a proper config object explanation to be provided on some complex rules, and is just generally useful. I'm assuming we do not want this to show up on rules that only have the link to the original source, so I updated various rules accordingly. For example, from #16287: ```md ## Configuration This rule allows you to specify how different TypeScript directive comments should be handled. For each directive (`@ts-expect-error`, `@ts-ignore`, `@ts-nocheck`, `@ts-check`), you can choose one of the following options: - `true`: Disallow the directive entirely, preventing its use in the entire codebase. - `false`: Allow the directive without any restrictions. - `"allow-with-description"`: Allow the directive only if it is followed by a description explaining its use. The description must meet the minimum length specified by `minimumDescriptionLength`. - `{ "descriptionFormat": "<regex>" }`: Allow the directive only if the description matches the specified regex pattern. For example: \```json { "ts-expect-error": "allow-with-description", "ts-ignore": true, "ts-nocheck": { "descriptionFormat": "^: TS\\d+ because .+$" }, "ts-check": false, "minimumDescriptionLength": 3 } \``` This rule accepts a configuration object with the following properties: ### minimumDescriptionLength type: `integer` default: `3` Minimum description length required when using directives with `allow-with-description`. ### ts-check How to handle the `@ts-check` directive. ### ts-expect-error How to handle the `@ts-expect-error` directive. ### ts-ignore How to handle the `@ts-ignore` directive. ### ts-nocheck How to handle the `@ts-nocheck` directive. ```
…xc-project#16287) Part of oxc-project#14743. Generated docs (with the change to `doc_page.rs` to actually pull the doc comment above each config object, see oxc-project#16288): ```md ## Configuration This rule allows you to specify how different TypeScript directive comments should be handled. For each directive (`@ts-expect-error`, `@ts-ignore`, `@ts-nocheck`, `@ts-check`), you can choose one of the following options: - `true`: Disallow the directive entirely, preventing its use in the entire codebase. - `false`: Allow the directive without any restrictions. - `"allow-with-description"`: Allow the directive only if it is followed by a description explaining its use. The description must meet the minimum length specified by `minimumDescriptionLength`. - `{ "descriptionFormat": "<regex>" }`: Allow the directive only if the description matches the specified regex pattern. For example: \```json { "ts-expect-error": "allow-with-description", "ts-ignore": true, "ts-nocheck": { "descriptionFormat": "^: TS\\d+ because .+$" }, "ts-check": false, "minimumDescriptionLength": 3 } \``` This rule accepts a configuration object with the following properties: ### minimumDescriptionLength type: `integer` default: `3` Minimum description length required when using directives with `allow-with-description`. ### ts-check How to handle the `@ts-check` directive. ### ts-expect-error How to handle the `@ts-expect-error` directive. ### ts-ignore How to handle the `@ts-ignore` directive. ### ts-nocheck How to handle the `@ts-nocheck` directive. ```
…nfig docs (oxc-project#16288) This is necessary for a proper config object explanation to be provided on some complex rules, and is just generally useful. I'm assuming we do not want this to show up on rules that only have the link to the original source, so I updated various rules accordingly. For example, from oxc-project#16287: ```md ## Configuration This rule allows you to specify how different TypeScript directive comments should be handled. For each directive (`@ts-expect-error`, `@ts-ignore`, `@ts-nocheck`, `@ts-check`), you can choose one of the following options: - `true`: Disallow the directive entirely, preventing its use in the entire codebase. - `false`: Allow the directive without any restrictions. - `"allow-with-description"`: Allow the directive only if it is followed by a description explaining its use. The description must meet the minimum length specified by `minimumDescriptionLength`. - `{ "descriptionFormat": "<regex>" }`: Allow the directive only if the description matches the specified regex pattern. For example: \```json { "ts-expect-error": "allow-with-description", "ts-ignore": true, "ts-nocheck": { "descriptionFormat": "^: TS\\d+ because .+$" }, "ts-check": false, "minimumDescriptionLength": 3 } \``` This rule accepts a configuration object with the following properties: ### minimumDescriptionLength type: `integer` default: `3` Minimum description length required when using directives with `allow-with-description`. ### ts-check How to handle the `@ts-check` directive. ### ts-expect-error How to handle the `@ts-expect-error` directive. ### ts-ignore How to handle the `@ts-ignore` directive. ### ts-nocheck How to handle the `@ts-nocheck` directive. ```
Part of #14743.
Generated docs (with the change to
doc_page.rsto actually pull the doc comment above each config object, see #16288):