Skip to content

Commit 2c58952

Browse files
committed
docs(linter): Add config docs for no-restricted-globals rule. (#15662)
Part of #14743. Generated docs: ```md ## Configuration This rule accepts a configuration object with the following properties: ### restrictedGlobals type: `Record<string, string>` default: `{}` Objects in the format `{ "name": "event", "message": "Use local parameter instead." }`, which define what globals are restricted from use. ``` This is technically a positional argument and so should maybe be held back until we have a solution for documenting this kind of configuration option?
1 parent f5ce55a commit 2c58952

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use oxc_diagnostics::OxcDiagnostic;
33
use oxc_macros::declare_oxc_lint;
44
use oxc_span::Span;
55
use rustc_hash::FxHashMap;
6+
use schemars::JsonSchema;
67
use serde_json::Value;
78

89
use crate::{AstNode, context::LintContext, rule::Rule};
@@ -17,8 +18,12 @@ fn no_restricted_globals(global_name: &str, suffix: &str, span: Span) -> OxcDiag
1718
OxcDiagnostic::warn(warn_text).with_label(span)
1819
}
1920

20-
#[derive(Debug, Default, Clone)]
21+
#[derive(Debug, Default, Clone, JsonSchema)]
22+
#[serde(rename_all = "camelCase", default)]
2123
pub struct NoRestrictedGlobals {
24+
/// Objects in the format
25+
/// `{ "name": "event", "message": "Use local parameter instead." }`, which define what globals
26+
/// are restricted from use.
2227
restricted_globals: Box<FxHashMap<String, String>>,
2328
}
2429

@@ -54,6 +59,7 @@ declare_oxc_lint!(
5459
NoRestrictedGlobals,
5560
eslint,
5661
restriction,
62+
config = NoRestrictedGlobals,
5763
);
5864

5965
impl Rule for NoRestrictedGlobals {

crates/oxc_linter/tests/rule_configuration_documentation_test.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ fn test_rules_with_custom_configuration_have_schema() {
3838
"eslint/no-else-return",
3939
"eslint/no-empty-function",
4040
"eslint/no-fallthrough",
41-
"eslint/no-restricted-globals",
4241
"eslint/no-restricted-imports",
4342
"eslint/no-warning-comments",
4443
"eslint/yoda",

0 commit comments

Comments
 (0)