-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add jscs to check style #1565
Add jscs to check style #1565
Conversation
@hzoo thank you so much for this! thanks again! |
@@ -25,7 +25,7 @@ define(['Modernizr', 'createElement'], function( Modernizr, createElement ) { | |||
try { | |||
div.style.fontSize = '3rem'; | |||
} | |||
catch( er ) {} | |||
catch ( er ) {} |
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.
Can we add a rule here to make it drop the whitespace inside the parenthesis too?
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.
Sure - I'm just using the google
preset as a base/start so yeah feel free for more suggestions in rules to add/remove.
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.
believe that would be "disallowSpacesInsideParentheses": true
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.
looks like google aligns pretty closely with our own style. it generates the least amount of style changes from all of the presets (crockford is 7k haha).
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.
Yeah I think I picked the one with the least errors (forgot)
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.
Yep let's set that to true as we're pretty inconsistent on that front looking at the files.
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.
Interesting.. I don't know why but I had nulled the disallowSpacesInsideParentheses
rule in the PR haha.
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.
while we are at it, requireCurlyBraces
should be true
as well
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.
Ok so with that if (elem === false) return props[i];
would be
if (elem === false) {
return props[i];
}
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.
correctamundo
Another thing we would want to add is a |
@ryanseddon you mean something like |
hah - didn't notice the link. agreed |
Yes exactly like that and our |
Ok so in the current Line 221 in 9e249d5
There's already the |
we would want to change that from |
@@ -49,6 +49,16 @@ module.exports = function( grunt ) { | |||
] | |||
} | |||
}, | |||
jscs: { | |||
src: [ | |||
'Gruntfile.js', |
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.
These are the same a jshint - any changes needed?
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.
should be good
Autofix is great! Changed the requireCurly's manually since autofix only does whitespace currently (so those shouldn't break anything). Ran |
since this commit modified the Grunt file, saucelabs won't run. I am running them locally just to confirm (I can't imagine it would break anything, but weirder crap has come up previously). Once it goes green I am good to merge 👍 |
@@ -0,0 +1,9 @@ | |||
{ | |||
"preset": "google", |
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.
Can you make this 2 spaces to match other rc files
sall good. great work, @hzoo! |
Add jscs to check style
ugh, sorry @ryanseddon. I'll update real quick |
no problem it's not a huge one |
Cool! - I guess |
@ryanseddon
from #1551 (comment).
I just copied the format from jshint so it will run it in on the same files (and same ignores).
I didn't know what the rules should be (so we can start discussing that now based on the code) so I just picked the google preset as a start (using the jscs autoconfigure option (
jscs --autoconfigure src/ lib/ feature-detects/
)One option is to use it as a base or just copy the rules from the preset and add/remove as needed. If there isn't a written style guide or another one to follow we can just look at what's the majority.
Another thing would be how to go about fixing the styles after determining rules.
We can use the autofix setting
jscs --auto-fix
(only in master branch) to fix most of the whitespace changes and everything else would be manual. I went ahead and did the autofix changes in a seperate commit so the potential changes of using the google preset can be seen. I can remove the 2nd commit or make a new PR to actually fix the changes later.And then adding it to the
grunt test
task after all that's fixed? Maybe that should be a separate issue? Right now you can dogrunt jscs
though after an npm install.