Style error information
https://eslint.org/docs/rules/no-empty
Remark
Code refactoring and Improvement
It merged the conditions.
** It only affects single file, I assigned to Quickedit for further checking by maintainer and contributors.
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
- N/A
Comment | File | Size | Author |
---|---|---|---|
#14 | eslint-no-empty-2914718-14.patch | 2.13 KB | droplet |
#9 | eslint-no-empty.patch | 2.13 KB | droplet |
#7 | eslint-no-empty.patch | 2.26 KB | droplet |
|
Comments
Comment #2
nod_I'd reverse the condition instead of returning early but it works the same.
Comment #3
nod_Comment #4
alexpottI'd reverse it too... also the patch no longer applies.
Comment #5
droplet CreditAttribution: droplet commentedComment #7
droplet CreditAttribution: droplet commentedComment #8
alexpott@droplet can we swap the logic around too?
I think we want something like this...
Comment #9
droplet CreditAttribution: droplet commentedwhy not :)
Comment #11
alexpottI might be wrong but I think this needs to be
&&
Comment #12
droplet CreditAttribution: droplet commentedOh Oh. Made a simple mistake.
What do you think this version to keep separate comments:
Comment #13
dawehnerLet's set the correct status at the moment.
At least for me #12 feels less readable actually.
Comment #14
droplet CreditAttribution: droplet commentedI prefer the early return in #7 and think that's more common in JS :p
It need not compute the && logic (0.00000000001s faster). So while on debugging, you see either one meet the condition, you got it!
Comment #15
dawehnerLet's go with it!
Comment #16
droplet CreditAttribution: droplet commentedGuardClause:
http://wiki.c2.com/?GuardClause
Refactoring: Improving the Design of Existing Code
Comment #18
xjmIt's JavaScript even I can read!
The fact that the inline comment more closely matches the changed code in #14 makes me agree that this way around makes more sense.
I confirmed that:
yarn lint:core-js-stats
).Committed and pushed to 8.5.x. Thanks!