Commit b0d72c9
feat: add rule logical-assignment-operators (#16102)
* feat: add rule logical-assignment-operators
Fixes #13689
* docs: update rule documentation
- State the concept of the rule clearer
- Increase the heading level for options
* chore: unify ast-utils import
* fix: only check for void 0 in undefined checks
* fix: always fix for the logical pattern
* feat: support yoda conditions in if conditions
* fix: remove parenthesis around assignment target if necessary
* fix: parenthesize logical pattern if needed
* fix: add semicolon for if patterns with a body if needed
* fix: remove file extension from import
Co-authored-by: Milos Djermanovic <[email protected]>
* fix: check strictness of global scope instead of current scope to avoid checking for with
* fix: check for mixed ?? and ||/&& operators in the fix for never
* fix: check previous token for continuation problems in the if fix
* feat: support else if (and fix suggest cases for if)
* fix: do not remove else keyword for else if
* fix: if cases also suggest based on potential getter
* fix: also fix if only a single property is accessed for the if pattern
* fix: do not fix logical patterns with a deeper access
* fix: check whether Boolean references a global
* fix: allow test conditions to access the same static property (a.b <=> a['b'])
* fix: use the whole assignment operator with equals in the message and add operator for 'if' messages
* docs: remove edit_link
* docs: remove description from docs as it is autogenerated from rule.meta.docs.description
* docs: move introductory text before rule details
* docs: add missing 'logical' to rule description
* docs: fix formatting for options
* docs: include all logical operators for option 'never'
* docs: add examples for option 'always'
* docs: add examples of for the 'enforceForIfStatements' option and swap correct with incorrect sections
* fix: disallow optional chaining for the logical pattern
* fix: fixer does not delete parenthesis around the right operand in the assignment pattern
* fix: remove multiple parenthesis around the right operand in the logical pattern
* test: add data property for suggestions
* docs: add missing comma in description
Co-authored-by: Milos Djermanovic <[email protected]>
* test: clean up unnecessary data, add missing data and pass missing options for test case
* fix: do not allow property accesses in a computed property when checking for a single property access
* test: add test cases for private identifiers
Co-authored-by: Milos Djermanovic <[email protected]>1 parent f02bcd9 commit b0d72c9
File tree
5 files changed
+2067
-0
lines changed- docs/src/rules
- lib/rules
- tests/lib/rules
- tools
5 files changed
+2067
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| |||
0 commit comments