-
-
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
coding style #1359
Comments
Yes, big +1 on this.
Like you, I don't feel strongly. I agree that braces for conditionals and semi-colons to separate statements are a good idea to make the codebase more approachable.
Anything that we agree on should be enforceable. I suggest using both If we don't make |
Yes, I tend to always make |
And if you do, you'll just be scaring away contributors with travis errors. The thing is: travis can't distinguish between real errors and linter complaints, it all looks the same. And when you see "build failed" when there isn't anything wrong with the code, that's annoying. "+1" for editorconfig however. It's completely optional, and it's useful if you have an editor that supports it. |
The code is wrong inasmuch as it fails the lint check, which means it's still wrong. I won't merge linty code into the codebase, and I don't want to hand-edit a bunch of linty PRs. There's no point in attempting to adhere to a style if it's not enforced in some way. If/when we do this, the lint check should be part of "Scaring away contributors" is far-fetched. I fail to see how expecting contributors to submit code as per any project's guidelines is too much to ask. This is basic OSS etiquette. |
+1 for .editorconfig |
+1 for enforcing the coding style. |
If using jshint, you might want to take a look at https://github.com/jshint/fixmyjs -- I haven't used it myself, but it seems to give you a good head start. |
@gtramontina Thanks for the link. I've also been experimenting recently with JSCS and have had good results. So maybe a combination of JSCS + JSHint would be cool. |
Bump. I'd vote to go with JSHint, and start deciding the code style rules. :) |
With JSHint, defaults (empty .jshintrc) 267 Bad line breaking before ','. with Felixes it seems even more: 243 Bad line breaking before ','. excluded node_modules and tests. I suggest starting with empty (default jshint, make first cleanup, and then fine tune) |
Mocha.js itself have this list: mocha.js: line 7, col 7, Comma warnings can be turned off with 'laxcomma'. so once you agree, I can spent some time fixing them and retesting. |
or we can start linting by default only main file: _mocha .js, please see: https://github.com/ainthek/mocha/commit/0d98a3b00132999668b88c835dbde6438110deea |
How do you want to approach garbage included from externals ? lib/browser/diff.js: node_modules/diff/diff.js |
Ignore files from other modules, imo. |
Closing, since #1750 has now been merged. |
I'm unable to really get a handle on it, and what with all the PRs over the years, the codebase seems pretty inconsistent.
We have leading commas in some places, not in others, semi-colons here, no semi-colons there, blocks here and no blocks there.
I'm proposing: let's clean it up!
We could go whatever direction, but in the interest of full disclosure my coding style is different than TJ's. My style aligns pretty closely with Felix's Style Guide, but I'm more in the "Crockford" camp than he is.
However...
I would strongly prefer to always use semi-colons, because it is more friendly to developers who don't know how to not use semi-colons. (We get a lot of PRs.)
I would strongly prefer using curly braces in conditionals and loops, because I don't trust myself to write a complex "if/else if/else if/else" conditional without them.
I strongly prefer not to using leading commas, because it is untoward and impure.
We can set up
.jshintrc
and go with that; add ajshint
target to theMakefile
. Usually I have one for production code, and another for test code (which will have different global vars/functions). We can specifybrowser: true
andnode: true
and solve the issue of having Mocha run in dual contexts.Also an
.editorconfig
would be helpful.As far as actually reformatting things, I use PyCharm which is pretty smart about it, and could turn this around pretty quickly.
So my questions are:
The text was updated successfully, but these errors were encountered: