| Summary: | [eslint] no-self-assign rule doesn't handle assignment operators like += | ||
|---|---|---|---|
| Product: | [ECD] Orion | Reporter: | Curtis Windatt <curtis.windatt.public> |
| Component: | JS Tools | Assignee: | Curtis Windatt <curtis.windatt.public> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | Michael_Rennie, Olivier_Thomann |
| Version: | 12.0 | ||
| Target Milestone: | 13.0 | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
|
Description
Curtis Windatt
This is less clear than a = a; a += a; really means: a = a + a; So this means the same as: a *= 2; So I would not include this check for no-self-assign rule. Am I missing something ? (In reply to Olivier Thomann from comment #1) > So I would not include this check for no-self-assign rule. Am I missing > something ? The check is included today. a **= a, a -= a, a *= a are all marked as 'assigning to itself is pointless'. What the code is doing could be expressed more clearly, but the error message is wrong. I am suggesting we don't mark these as errors. (In reply to Curtis Windatt from comment #2) > (In reply to Olivier Thomann from comment #1) > > So I would not include this check for no-self-assign rule. Am I missing > > something ? > > The check is included today. a **= a, a -= a, a *= a are all marked as > 'assigning to itself is pointless'. What the code is doing could be > expressed more clearly, but the error message is wrong. I am suggesting we > don't mark these as errors. We should only be marking an assignment with the '=' operator. All the info is in the node itself. We should also try to support default values, spread elements and update the warning message to match upstream eslint: "'{{name}}' is assigned to itself." |