diff --git a/crates/oxc_linter/src/rules/typescript/consistent_type_definitions.rs b/crates/oxc_linter/src/rules/typescript/consistent_type_definitions.rs index 222da008a9714..71c1f766aa249 100644 --- a/crates/oxc_linter/src/rules/typescript/consistent_type_definitions.rs +++ b/crates/oxc_linter/src/rules/typescript/consistent_type_definitions.rs @@ -45,16 +45,50 @@ declare_oxc_lint!( /// The two are generally very similar, and can often be used interchangeably. /// Using the same type declaration style consistently helps with code readability. /// - /// ### Example - /// ```ts - /// // incorrect, when set to "interface" + /// ### Examples + /// + /// By default this rule enforces the use of interfaces for object types. + /// + /// Examples of **incorrect** code for this rule: + /// ```typescript /// type T = { x: number }; + /// ``` + /// + /// Examples of **correct** code for this rule: + /// ```typescript + /// type T = string; + /// type Foo = string | {}; + /// + /// interface T { + /// x: number; + /// } + /// ``` + /// + /// ### Options /// - /// // incorrect when set to "type" + /// This rule has a single string option: + /// + /// `{ type: string, default: "interface" }` + /// + /// ### interface + /// + /// This is the default option. + /// + /// ### type + /// + /// Enforces the use of types for object type definitions. + /// + /// Examples of **incorrect** code for this option: + /// ```typescript /// interface T { - /// x: number; + /// x: number; /// } /// ``` + /// + /// Examples of **correct** code for this option: + /// ```typescript + /// type T = { x: number }; + /// ``` ConsistentTypeDefinitions, typescript, style,