@@ -2,6 +2,7 @@ use oxc_ast::{AstKind, ast::Expression};
22use oxc_diagnostics:: OxcDiagnostic ;
33use oxc_macros:: declare_oxc_lint;
44use oxc_span:: { Atom , GetSpan , Span } ;
5+ use schemars:: JsonSchema ;
56use serde_json:: Value ;
67
78use crate :: { AstNode , context:: LintContext , rule:: Rule } ;
@@ -15,8 +16,22 @@ fn no_useless_computed_key_diagnostic(span: Span, raw: Option<Atom>) -> OxcDiagn
1516 . with_label ( span)
1617}
1718
18- #[ derive( Debug , Clone ) ]
19+ #[ derive( Debug , Clone , JsonSchema ) ]
20+ #[ serde( rename_all = "camelCase" , default ) ]
1921pub struct NoUselessComputedKey {
22+ /// The `enforceForClassMembers` option controls whether the rule applies to
23+ /// class members (methods and properties).
24+ ///
25+ /// Examples of **correct** code for this rule with the `{ "enforceForClassMembers": false }` option:
26+ /// ```js
27+ /// class SomeClass {
28+ /// ["foo"] = "bar";
29+ /// [42] = "baz";
30+ /// get ['b']() {}
31+ /// set ['c'](value) {}
32+ /// static ["foo"] = "bar";
33+ /// }
34+ /// ```
2035 enforce_for_class_members : bool ,
2136}
2237
@@ -90,30 +105,11 @@ declare_oxc_lint!(
90105 /// static ["prototype"]; // runtime error, it would be a parsing error without `[]`
91106 /// }
92107 /// ```
93- ///
94- /// ### Options
95- ///
96- /// #### enforceForClassMembers
97- ///
98- /// `{ type: boolean, default: true }`
99- ///
100- /// The `enforceForClassMembers` option controls whether the rule applies to
101- /// class members (methods and properties).
102- ///
103- /// Examples of **correct** code for this rule with the `{ "enforceForClassMembers": false }` option:
104- /// ```js
105- /// class SomeClass {
106- /// ["foo"] = "bar";
107- /// [42] = "baz";
108- /// get ['b']() {}
109- /// set ['c'](value) {}
110- /// static ["foo"] = "bar";
111- /// }
112- /// ```
113108 NoUselessComputedKey ,
114109 eslint,
115110 style,
116- pending
111+ pending,
112+ config = NoUselessComputedKey ,
117113) ;
118114
119115impl Rule for NoUselessComputedKey {
0 commit comments