jquery / 2012-dev-summit

Information regarding the 2012 Developer Summit in DC
14 stars 14 forks source link

Find and/or build a style guide sniffer and integrate it into grunt #54

Closed mikesherov closed 12 years ago

mikesherov commented 12 years ago

When building, jQuery JSHints the build to check for correctness. It should also be able to check for style guide issues. jQuery has a pretty gnarly set of style rules, but we should be able to cover most of the basics.

Once we find a suitable style sniffer, it should be rolled into grunt so contributors can fix any style issues before submitting pull requests.

rwaldron commented 12 years ago

@james-huston is going to research adding new rules to JSHint and ideally will have a proof of concept

patrickkettner commented 12 years ago

something like https://github.com/sindresorhus/grunt-codestyle?

rwaldron commented 12 years ago

Yes, something like that... @sindresorhus should weigh in here—it looks like it's unfinished

sindresorhus commented 12 years ago

Yeah, never had the time to finish it, and the author of the underlaying node module has no intention of continuing development on it, and the code is a mess, so not sure if it's worth the trouble.

Ideally I'd like a tool based on Esprima that does that with a simple DSL to add new rules, and with an active maintainer.

Maybe even something to discuss with @antonkovalyov for JSHint.

james-huston commented 12 years ago

Some white space checking is already built into JSHint. It can be enabled by adding the following to the .jshintrc file:

"white": true

This properly handles spaces before and after ( and ) in and if for example but does NOT allow spaces after ( or before ). The formatting rules for spaces are hard coded with each block rule (i.e. if block, do block, for block, etc) and the block type is not passed into the space check method so in order to allow these spaces each individual block would have to have it's code formatting modified which is pretty ugly.

The "white" rule that enables white space checking is also on the Legacy list of features for jshint and is not documented at all.

JSLint also supports notifying of "messy" white space but it uses the same code as JSHint. So close in fact that it looks like it might be a refactored version code.

dmethvin commented 12 years ago

Migrated to http://bugs.jquery.com/ticket/12757