-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eslint - enforces many more rules. #139
Conversation
(I was using an older verson of eslint locally)
@@ -136,11 +136,11 @@ var computeLayout = (function() { | |||
case 'column-reverse': value = node.style.marginTop; break; | |||
} | |||
|
|||
if (value != null) { | |||
if (value !== null && typeof value !== 'undefined') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should do
value !== undefined
The typeof check is when the variable may or may not exist. This is useful for checking globals. But in this case we know it exists so we can just check against the undefined value.
@vjeux @devongovett - I've relaxed the eqeqeq rule to permit eqeq checks against null, as @devongovett rightly points out this allows you to check for both null and undefined with a single test. |
As an side, it does feel like the |
See how React and Relay have eslint set up – they use a common config from the fbjs-scripts package. |
@spicyj thanks for the heads up, didn't realise there was a centralised lint configuration. I've updated the PR to use the |
@@ -410,7 +410,7 @@ var computeLayout = (function() { | |||
// When the user specifically sets a value for width or height | |||
function setDimensionFromStyle(node, axis) { | |||
// The parent already computed us a width or height. We just skip it | |||
if (node.layout[dim[axis]] != null) { | |||
if (typeof node.layout[dim[axis]] !== 'undefined') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use x === undefined
instead of typeof x === 'undefined'
Sweet! Outside of the typeof undefined and null, looks very good! Thanks for doing that |
Fair point, guarding against redefinition of
No problems :-) |
Feel free to land if travis passes :) |
Travis is happy - all done 👍 |
Eslint - enforces many more rules.
Based on the review comments I saw for #138 I thought the linting rules could do with being 'tightened up'.
I checked the
.eslintrc
and found that the only thing being checked was the quotes style, and that was only being applied toLayout.js
!I've auto-configured ESLint based on the existing codebase, then added a few rules that I think are most important. Let me know what you think.