You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OxcDiagnostic::warn(format!("'{name}' is already defined as a built-in global variable."))
18
+
.with_label(span)
26
19
}
27
20
28
21
#[derive(Debug,Default,Clone)]
@@ -33,17 +26,35 @@ pub struct NoRedeclare {
33
26
declare_oxc_lint!(
34
27
/// ### What it does
35
28
///
36
-
/// Disallow variable redeclaration
29
+
/// This rule disallows redeclaring variables within the same scope, ensuring that each variable
30
+
/// is declared only once. It helps avoid confusion and unintended behavior in code.
37
31
///
38
32
/// ### Why is this bad?
39
33
///
40
-
/// n JavaScript, it’s possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.
34
+
/// Redeclaring variables in the same scope can lead to unexpected behavior, overwriting existing values,
35
+
/// and making the code harder to understand and maintain.
41
36
///
42
-
/// ### Example
37
+
/// ### Examples
38
+
///
39
+
/// Examples of **incorrect** code for this rule:
43
40
/// ```javascript
44
41
/// var a = 3;
45
42
/// var a = 10;
46
43
/// ```
44
+
///
45
+
/// Examples of **correct** code for this rule:
46
+
/// ```javascript
47
+
/// var a = 3;
48
+
/// a = 10;
49
+
/// ```
50
+
///
51
+
/// ### Options
52
+
///
53
+
/// #### builtinGlobals
54
+
///
55
+
/// `{ type: bool, default: false }`
56
+
///
57
+
/// When set `true`, it flags redeclaring built-in globals (e.g., `let Object = 1;`).
0 commit comments