Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <milos.djermanovic@gmail.com> * 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 <milos.djermanovic@gmail.com> * 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 <milos.djermanovic@gmail.com>
- Loading branch information