Skip to content

Commit 06e76f2

Browse files
committed
remove manually written config docs, use generated config docs
1 parent bc085b2 commit 06e76f2

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

crates/oxc_linter/src/rules/eslint/no_unused_vars/mod.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -186,24 +186,11 @@ declare_oxc_lint!(
186186
/// // Not respected, use ES6 modules instead.
187187
/// var global_var = 42;
188188
/// ```
189-
/// ### Options
190-
///
191-
/// #### ignoreRestSiblings
192-
///
193-
/// `{ type: boolean, default: false }`
194-
///
195-
/// The `ignoreRestSiblings` option is set to `false` by default, meaning unused siblings of the object rest property are flagged.
196-
/// With the option set to `false`, the code below would be flagged.
197-
///
198-
/// ```js
199-
/// const { password, ...profile } = user; // `password` is unused.
200-
/// return Response.json(profile);
201-
/// ```
202-
/// With the option set to `true`, the code would be allowed.
203189
NoUnusedVars,
204190
eslint,
205191
correctness,
206-
dangerous_suggestion
192+
dangerous_suggestion,
193+
config = NoUnusedVarsOptions
207194
);
208195

209196
impl Deref for NoUnusedVars {

crates/oxc_linter/src/rules/eslint/no_unused_vars/options.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ use std::{borrow::Cow, ops::Deref};
22

33
use lazy_regex::{Regex, RegexBuilder};
44
use oxc_diagnostics::OxcDiagnostic;
5+
use schemars::JsonSchema;
56
use serde_json::Value;
67

78
/// See [ESLint - no-unused-vars config schema](https://github.com/eslint/eslint/blob/53b1ff047948e36682fade502c949f4e371e53cd/lib/rules/no-unused-vars.js#L61)
8-
#[derive(Debug, Clone)]
9+
#[derive(Debug, Clone, JsonSchema)]
10+
#[serde(rename_all = "camelCase")]
911
#[must_use]
1012
#[non_exhaustive]
1113
pub struct NoUnusedVarsOptions {
@@ -34,6 +36,7 @@ pub struct NoUnusedVarsOptions {
3436
/// var b = 10;
3537
/// console.log(b);
3638
/// ```
39+
#[schemars(skip)]
3740
pub vars_ignore_pattern: IgnorePattern<Regex>,
3841

3942
/// Controls how unused arguments are checked.
@@ -65,6 +68,7 @@ pub struct NoUnusedVarsOptions {
6568
/// }
6669
/// foo(1, 2);
6770
/// ```
71+
#[schemars(skip)]
6872
pub args_ignore_pattern: IgnorePattern<Regex>,
6973

7074
/// Using a Rest property it is possible to "omit" properties from an
@@ -108,6 +112,7 @@ pub struct NoUnusedVarsOptions {
108112
/// console.error("Error caught in catch block");
109113
/// }
110114
/// ```
115+
#[schemars(skip)]
111116
pub caught_errors_ignore_pattern: IgnorePattern<Regex>,
112117

113118
/// This option specifies exceptions within destructuring patterns that will
@@ -132,6 +137,7 @@ pub struct NoUnusedVarsOptions {
132137
/// console.log(n);
133138
/// });
134139
/// ```
140+
#[schemars(skip)]
135141
pub destructured_array_ignore_pattern: IgnorePattern<Regex>,
136142

137143
/// The `ignoreClassWithStaticInitBlock` option is a boolean (default:
@@ -368,7 +374,8 @@ impl Default for NoUnusedVarsOptions {
368374
}
369375
}
370376

371-
#[derive(Debug, Default, Clone, PartialEq, Eq)]
377+
#[derive(Debug, Default, Clone, PartialEq, Eq, JsonSchema)]
378+
#[serde(rename_all = "camelCase")]
372379
pub enum VarsOption {
373380
/// All variables are checked for usage, including those in the global scope.
374381
#[default]
@@ -383,7 +390,8 @@ impl VarsOption {
383390
}
384391
}
385392

386-
#[derive(Debug, Default, Clone, PartialEq, Eq)]
393+
#[derive(Debug, Default, Clone, PartialEq, Eq, JsonSchema)]
394+
#[serde(rename_all = "camelCase")]
387395
pub enum ArgsOption {
388396
/// Unused positional arguments that occur before the last used argument
389397
/// will not be checked, but all named arguments and all positional
@@ -412,7 +420,8 @@ impl ArgsOption {
412420
}
413421
}
414422

415-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
423+
#[derive(Debug, Clone, Copy, PartialEq, Eq, JsonSchema)]
424+
#[serde(rename_all = "camelCase")]
416425
#[repr(transparent)]
417426
pub struct CaughtErrors(bool);
418427

0 commit comments

Comments
 (0)