Skip to content

Commit 3f1c3c7

Browse files
howenyapCopilot
andauthored
docs(linter): Add documentation on ignoreRestSiblings option for no-unused-vars rule (#14807)
Explains the `ignoreRestSiblings` config option for the [no unused vars](https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unused-vars) rule. Related to [this](#14764) issue. --------- Signed-off-by: howen <108785851+howenyap@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent df75190 commit 3f1c3c7

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ declare_oxc_lint!(
189189
NoUnusedVars,
190190
eslint,
191191
correctness,
192-
dangerous_suggestion
192+
dangerous_suggestion,
193+
config = NoUnusedVarsOptions
193194
);
194195

195196
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)