Style error information
https://eslint.org/docs/rules/no-mixed-operators
Remark
Code refactoring, no NON-ES6 changes is correct!
In `history.es6.js`, I extracted to a new variable. It's easier to understand!
How to Review
## 1. Apply Patch
## 2. Review Code Changes
## 3. Confirm no Code Standard Errors
yarn & yarn lint:core-js-passing
## 4.1 If `NO` errors, mark the issue as `Reviewed & tested by the community` (Don't be shy, we're all friendly)
## 4.2 If `HAS` errors, fix it and upload a new patch (Just do it and you can!!!)
Background
- #2912962: Step 1 JS codestyle: [meta] Fix JS coding standards in core
- We adapted the airbnb coding standard (#2815077: Adopt airbnb javascript style guide v14.1 as new baseline javascript coding standards for Drupal 8 core and contrib), but we are not fully compliant to it yet.
More Information
- Using ES6 in Core
https://www.drupal.org/node/2815083
- To find JS code standard errors stats
yarn & yarn lint:core-js-stats
Valuable Follow-up
- Extract conditions to named variables. Sometimes it's easier to understand. @see: https://dzone.com/articles/code-smells-if-statements
(It's not required all time anyway :p)
Comment | File | Size | Author |
---|---|---|---|
#6 | eslint-no-mixed-operators.patch | 5.5 KB | droplet |
eslint-no-mixed-operators.patch | 5.5 KB | droplet | |
Comments
Comment #2
droplet CreditAttribution: droplet commentedComment #3
droplet CreditAttribution: droplet commentedComment #4
dawehnerFor my own interest and the sake of reviewing this patch: OPerator precendence in javascript: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operat...
These ones are weird. In theory the additional () wouldn't be needed because multiplication would be preferred over addition / subtraction anyway, but well, these are the eslint rules :)
I'm was a bit confused that some of the changes don't end up in changes of the actual JS files, but I guess that's how it is ...
Comment #6
droplet CreditAttribution: droplet commented@dawehner,
that's ESLint limits I bet. Actually, I like the no parentheses version for some changes. Should we drop inline comment to skip the error?
** reroll to remove .eslintrc.passing.json conflicts only.
Comment #7
droplet CreditAttribution: droplet commentedComment #8
dawehnerYeah I'm not sure its worth writing a comment vs adding some parenthesis :) I have no idea how hard it would be to fix this in eslint, but maybe the ideal/better approach would be to fix it upstream and then improve the code later.
The patch, at least for me, is fine as it is in its current state.
Comment #9
alexpottCrediting @dawehner because #4 is helpful when reviewing the patch.
Comment #10
alexpottCommitted e113f8f and pushed to 8.5.x. Thanks!