Skip to content

Commit f60763b

Browse files
authored
docs(linter): Add configuration option docs for eslint/no-useless-computed-key rule. (#15054)
These docs already existed, just needed to be moved. Part of #14743. Generated docs: ```md ## Configuration This rule accepts a configuration object with the following properties: ### enforceForClassMembers type: `boolean` default: `true` The `enforceForClassMembers` option controls whether the rule applies to class members (methods and properties). Examples of **correct** code for this rule with the `{ "enforceForClassMembers": false }` option: \```js class SomeClass { ["foo"] = "bar"; [42] = "baz"; get ['b']() {} set ['c'](value) {} static ["foo"] = "bar"; } \``` ```
1 parent c8911d4 commit f60763b

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

crates/oxc_linter/src/rules/eslint/no_useless_computed_key.rs

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use oxc_ast::{AstKind, ast::Expression};
22
use oxc_diagnostics::OxcDiagnostic;
33
use oxc_macros::declare_oxc_lint;
44
use oxc_span::{Atom, GetSpan, Span};
5+
use schemars::JsonSchema;
56
use serde_json::Value;
67

78
use 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)]
1921
pub 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

119115
impl Rule for NoUselessComputedKey {

0 commit comments

Comments
 (0)