Skip to content

Commit d5be037

Browse files
committed
docs(linter/typescript/switch-exhaustiveness-check): clarify default case comment pattern (#26100)
## Summary - clarify that `defaultCaseCommentPattern` recognizes a trailing comment in place of an omitted `default` clause - document the required location, absence of a live `default`, and the `considerDefaultExhaustiveForUnions` requirement for union switches - regenerate the JSON schema and TypeScript configuration types Fixes #26087
1 parent 60b945d commit d5be037

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

apps/oxlint/src-js/package/config.generated.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6212,9 +6212,11 @@ export interface SwitchExhaustivenessCheckConfig {
62126212
*/
62136213
considerDefaultExhaustiveForUnions?: boolean;
62146214
/**
6215-
* Regular expression pattern that when matched in a default case comment,
6216-
* will suppress the exhaustiveness check.
6217-
* Example: `"@skip-exhaustive-check"` to allow `default: // @skip-exhaustive-check`
6215+
* Regular expression pattern for a comment that acts as an omitted `default` case.
6216+
* The comment must appear after the final case and the switch must not have a `default` case.
6217+
* For union types, it suppresses the exhaustiveness check only when
6218+
* `considerDefaultExhaustiveForUnions` is enabled.
6219+
* Example: `"^skip default$"` to allow a switch ending in `// skip default`.
62186220
*/
62196221
defaultCaseCommentPattern?: string;
62206222
/**

crates/oxc_linter/src/rules/typescript/switch_exhaustiveness_check.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ pub struct SwitchExhaustivenessCheckConfig {
1717
/// When true, a switch statement with a `default` case is considered exhaustive
1818
/// even if not all union members are handled explicitly.
1919
pub consider_default_exhaustive_for_unions: bool,
20-
/// Regular expression pattern that when matched in a default case comment,
21-
/// will suppress the exhaustiveness check.
22-
/// Example: `"@skip-exhaustive-check"` to allow `default: // @skip-exhaustive-check`
20+
/// Regular expression pattern for a comment that acts as an omitted `default` case.
21+
/// The comment must appear after the final case and the switch must not have a `default` case.
22+
/// For union types, it suppresses the exhaustiveness check only when
23+
/// `considerDefaultExhaustiveForUnions` is enabled.
24+
/// Example: `"^skip default$"` to allow a switch ending in `// skip default`.
2325
#[serde(skip_serializing_if = "Option::is_none")]
2426
pub default_case_comment_pattern: Option<String>,
2527
/// Whether to require default cases on switches over union types that are not exhaustive.

npm/oxlint/configuration_schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19247,9 +19247,9 @@
1924719247
"markdownDescription": "Whether to consider `default` cases exhaustive for union types.\nWhen true, a switch statement with a `default` case is considered exhaustive\neven if not all union members are handled explicitly."
1924819248
},
1924919249
"defaultCaseCommentPattern": {
19250-
"description": "Regular expression pattern that when matched in a default case comment,\nwill suppress the exhaustiveness check.\nExample: `\"@skip-exhaustive-check\"` to allow `default: // @skip-exhaustive-check`",
19250+
"description": "Regular expression pattern for a comment that acts as an omitted `default` case.\nThe comment must appear after the final case and the switch must not have a `default` case.\nFor union types, it suppresses the exhaustiveness check only when\n`considerDefaultExhaustiveForUnions` is enabled.\nExample: `\"^skip default$\"` to allow a switch ending in `// skip default`.",
1925119251
"type": "string",
19252-
"markdownDescription": "Regular expression pattern that when matched in a default case comment,\nwill suppress the exhaustiveness check.\nExample: `\"@skip-exhaustive-check\"` to allow `default: // @skip-exhaustive-check`"
19252+
"markdownDescription": "Regular expression pattern for a comment that acts as an omitted `default` case.\nThe comment must appear after the final case and the switch must not have a `default` case.\nFor union types, it suppresses the exhaustiveness check only when\n`considerDefaultExhaustiveForUnions` is enabled.\nExample: `\"^skip default$\"` to allow a switch ending in `// skip default`."
1925319253
},
1925419254
"requireDefaultForNonUnion": {
1925519255
"description": "Whether to require default cases on switches over union types that are not exhaustive.\nWhen true, switches with non-exhaustive union types must have a default case.",

0 commit comments

Comments
 (0)