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
Copy file name to clipboardexpand all lines: crates/oxc_linter/src/rules/eslint/no_self_assign.rs
+66-4
Original file line number
Diff line number
Diff line change
@@ -32,16 +32,70 @@ impl Default for NoSelfAssign {
32
32
declare_oxc_lint!(
33
33
/// ### What it does
34
34
///
35
-
/// Disallow assignments where both sides are exactly the same
35
+
/// Disallow assignments where both sides are exactly the same.
36
36
///
37
37
/// ### Why is this bad?
38
38
///
39
-
/// Self assignments have no effect, so probably those are an error due to incomplete refactoring. Those indicate that what you should do is still remaining.
39
+
/// Self assignments have no effect, so probably those are an error due to incomplete
40
+
/// refactoring. Those indicate that what you should do is still remaining.
40
41
///
41
-
/// ### Example
42
+
/// ### Examples
43
+
///
44
+
/// Examples of **incorrect** code for this rule:
42
45
/// ```javascript
43
46
/// foo = foo;
44
-
/// [bar, baz] = [bar, qiz];
47
+
///
48
+
/// [a, b] = [a, b];
49
+
/// [a, ...b] = [x, ...b];
50
+
///
51
+
/// ({a, b} = {a, x});
52
+
///
53
+
/// foo &&= foo;
54
+
/// foo ||= foo;
55
+
/// foo ??= foo;
56
+
/// ```
57
+
///
58
+
/// ```javascript
59
+
/// obj.a = obj.a;
60
+
/// obj.a.b = obj.a.b;
61
+
/// obj["a"] = obj["a"];
62
+
/// obj[a] = obj[a];
63
+
/// ```
64
+
///
65
+
/// Examples of **correct** code for this rule:
66
+
/// ```javascript
67
+
/// foo = bar;
68
+
/// [a, b] = [b, a];
69
+
///
70
+
/// // This pattern is warned by the `no-use-before-define` rule.
71
+
/// let foo = foo;
72
+
///
73
+
/// // The default values have an effect.
74
+
/// [foo = 1] = [foo];
75
+
///
76
+
/// // This ignores if there is a function call.
77
+
/// obj.a().b = obj.a().b;
78
+
/// a().b = a().b;
79
+
///
80
+
/// // `&=` and `|=` have an effect on non-integers.
81
+
/// foo &= foo;
82
+
/// foo |= foo;
83
+
/// ```
84
+
///
85
+
/// ### Options
86
+
///
87
+
/// #### props
88
+
///
89
+
/// `{ type: boolean, default: true }`
90
+
///
91
+
/// The `props` option when set to `false`, disables the checking of properties.
92
+
///
93
+
/// With `props` set to `false` the following are examples of correct code:
0 commit comments