less.js
less.js copied to clipboard
Fix eslint warnimg
What: fix #3224
Why:
How:
Use a new utils function replace v == null to fix eslint warning.
It's a code style issue. We also can chage ESlint config option "no-eq-null" to fix it. Which plan are we going to take? I will update my pr if it needs to change.
Checklist:
- [ ] Documentation N/A
- [ ] Added/updated unit tests N/A
- [x] Code complete
So, I don't agree with this approach. I think the better way is to figure out what foo == null was intended to check for. If it's just checking for a "falsey" value, it should just be !foo.
That is, someone should log all these cases of == null with a typeof during testing to see what exactly are the types of values getting loosely checked against null, and then re-write this in a way that is more clear. That's IMO a better approach rather than just adding a bunch of function wrappers, which possibly degrades performance.
- Conclusion:
currentDirectory---- is related to the file, there are only two possible undefined, normal value currentDirectory comes from the file information in thenodeand will be given a default value of{}. Path: packages/less/src/less/environment/environment.js
Path: packages/less/src/ess/tree/node.js

- Conclusion:
vhas three possible values null, undefined, normal. Path: packages/less/src/less/functions/default.js
- Conclusion:
unithas only two possible values null, normal value. Path: packages/less/src/less/functions/math-helper.js
MathHelper is only used in two places.
Path: packages/less/src/less/functions/math.js
It is normal.
Path: packages/less/src/less/functions/number.js
It is normal or null. - Conclusion:
value.valuehas only two possible values undefined, normal value. Path: packages/less/src/less/parser/paser.js
Path: packages/less/src/less/parser/paser.js
It is normal or undefind.
Path: packages/less/src/less/parser/paser.js
It is undefind.
Path: packages/less/src/less/parser/paser.js
It is undefind.
Path: packages/less/src/less/parser/paser.js
It is normal or undefind. - Conclusion:
this.visibilityBlockshas only two possible values undefined, normal value Path: packages/less/src/less/tree/node.js
Default value is undefind, Invalid information is filtered. - Conclusion: escaped has two possible values, boolean value, default value undefined
Path: packages/less/src/less/tree/quoted.js
Path: packages/less/src/less/parser/parser.js
It is undefind.
Path: packages/less/src/less/parser/parser.js
It is undefind or boolean. - Conclusion:
nestedSelectorhas only two possible values null, normal value. Path: packages/less/src/less/tree/ruleset.js
Path: packages/less/src/less/tree/ruleset.js
nestedSelectorinstanceof Selector or return null. - Conclusion:
evaldConditionhas three possible values null, undefined, normal. Path: packages/less/src/less/tree/selector.js
Path: packages/less/src/less/tree/ruleset.js
It is undefind.
Path: packages/less/src/less/tree/atrule.js
It is null.
Thanks for doing this research!