Skip to content

Commit cbdf261

Browse files
authored
docs(linter): Document no-shadow-restricted-names rule config options. (#14843)
Part of #14743. Generated docs: ``` ## Configuration This rule accepts a configuration object with the following properties: ### reportGlobalThis type: `boolean` default: `false` If true, also report shadowing of `globalThis`. ```
1 parent 646c2ab commit cbdf261

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use oxc_ast::AstKind;
33
use oxc_diagnostics::OxcDiagnostic;
44
use oxc_macros::declare_oxc_lint;
55
use oxc_span::Span;
6+
use schemars::JsonSchema;
67
use serde_json::Value;
78

89
const PRE_DEFINE_VAR: [&str; 5] = ["Infinity", "NaN", "arguments", "eval", "undefined"];
@@ -16,16 +17,18 @@ fn no_shadow_restricted_names_diagnostic(shadowed_name: &str, span: Span) -> Oxc
1617
#[derive(Debug, Default, Clone)]
1718
pub struct NoShadowRestrictedNames(Box<NoShadowRestrictedNamesConfig>);
1819

19-
#[derive(Debug, Default, Clone)]
20+
#[derive(Debug, Default, Clone, JsonSchema)]
21+
#[serde(rename_all = "camelCase", default)]
2022
pub struct NoShadowRestrictedNamesConfig {
23+
/// If true, also report shadowing of `globalThis`.
2124
report_global_this: bool,
2225
}
2326

2427
declare_oxc_lint!(
2528
/// ### What it does
2629
///
27-
/// Disallows the redefining of global variables such as `undefined`, `NaN`, `Infinity`, `eval`
28-
/// and `arguments`.
30+
/// Disallows the redefining of global variables such as `undefined`, `NaN`, `Infinity`,
31+
/// `eval`, and `arguments`.
2932
///
3033
/// ### Why is this bad?
3134
///
@@ -78,7 +81,8 @@ declare_oxc_lint!(
7881
/// ```
7982
NoShadowRestrictedNames,
8083
eslint,
81-
correctness
84+
correctness,
85+
config = NoShadowRestrictedNamesConfig
8286
);
8387

8488
impl Rule for NoShadowRestrictedNames {

0 commit comments

Comments
 (0)