Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upA standard for usage of snake case, camel case, pascal case etc? #452
Comments
This comment has been minimized.
This comment has been minimized.
|
Virtually every javascript I've seen uses It's important that it only checks when declaring new variables though. Also, it should allow leading There is an eslint rule for this here: http://eslint.org/docs/rules/camelcase Would be very interesting to run the test on all repos with this enabled :) |
feross
added
the
enhancement
label
Mar 7, 2016
This comment has been minimized.
This comment has been minimized.
slang800
commented
Mar 9, 2016
|
|
This comment has been minimized.
This comment has been minimized.
grantcarthew
commented
Mar 28, 2016
|
I disagree with using all caps with const variables. As do the developers working on Node by the looks of it. I am using const in my node modules when requiring modules. All caps would look very messy. |
This comment has been minimized.
This comment has been minimized.
sotojuan
commented
Mar 31, 2016
|
I also dislike all caps for constants, but sadly everyone in the React/Redux community uses them for actions, so it'd break a lot of stuff. Of course, this is supposed to be an opinionated project so ultimately it's up to @feross. |
This comment has been minimized.
This comment has been minimized.
|
I am using |
This comment has been minimized.
This comment has been minimized.
|
@LinusU I agree with you, would like to see what breakage this would cause in the ecosystem before considering it. |
This comment has been minimized.
This comment has been minimized.
simonratner
commented
Apr 4, 2016
|
I am with @grantcarthew and @ilearnio; |
This comment has been minimized.
This comment has been minimized.
|
@simonratner Yes, this is a good point. I don't think we can ever assume that all But enforcing camel-case instead of snake case is more likely to work, i.e. not cause a bunch of test failures :) |
This comment has been minimized.
This comment has been minimized.
|
Camel case variables are now enforced in standard |
feross
closed this
Apr 24, 2016
This comment has been minimized.
This comment has been minimized.
bganicky
commented
Apr 27, 2016
•
|
Any suggestion how to solve scenario where I have keys in a dataset from an API (I can't modify it) and want to use object destructuring assignment? |
This comment has been minimized.
This comment has been minimized.
|
I suppose this would work: let { route_id: routeId, std_date: stdDate, std_time: stdTime } = flight |
This comment has been minimized.
This comment has been minimized.
bganicky
commented
Apr 27, 2016
|
So obvious. Thanks! :) |
This comment has been minimized.
This comment has been minimized.
mderazon
commented
May 4, 2016
•
|
This breaks my heart Aesthetically I prefer snake_case but i'm willing to change it to comply with Standard. Problem is that our api keys are 100% snake_case and also keys stored in our db (Mongo). I know that camel case is not enforced on props, but I don't want code that's half camel half snake or worry about translating between them all the time like @feross suggested above. I understand the decision though. Maybe on a new project I will do stuff differently, but for my current one I guess it's back to ESLint |
This comment has been minimized.
This comment has been minimized.
sorahn
commented
May 16, 2016
|
@mderazon use eslint with eslint-config-standard then just override the rule for camelcase. |
This comment has been minimized.
This comment has been minimized.
|
@mderazon Yeah, I respect your decision to use eslint directly. |
This comment has been minimized.
This comment has been minimized.
wmhilton
commented
Dec 11, 2016
|
I wanted to complain bitterly because I had a project that used standard and was fine, and then I came back to it after months and now it's telling me to use camelCase and I thought... "Really? I have to rename ALL my variables? Functions and methods use camelCase, but surely people use snake_case for local variables..." and then I look around (literally, I just looked through a bunch of files in "But I used snake_case?! Where on earth did I learn that?" I wondered. Then it hit me: python. I quickly googled "python tutorial" and the first one that pops up used snake_case:
"I'm not crazy!" I thought. "I came to JavaScript from CoffeeScript; I bet I carried that over from Python!" I rushed to the CoffeeScript website to confirm, but no! The CoffeeScript docs used camelCase. "Am I going crazy?" I thought. "Where the heck did I pick up this convention?" But finally, I went to the CoffeeScript Cookbook site, and found a good many of the code snippets there used snake_case... inconsistently. TL;DR And that's the story of how I realized I've been naming variables weird for a long time. A tale of anger, curiosity, confusion, panic, soul-searching, and (finally) self-understanding. |
This comment has been minimized.
This comment has been minimized.
|
@wmhilton Heh, thanks for sharing your story ;-) |
ilearnio commentedMar 6, 2016
For example, I'm using snake case for variables and object properties, camel case for functions/methods and pascal case for classes. And it is really sad when someone else starts to use a different approach in the same project.
A rule for which case type to use when defining of variables, functions and methods etc would be highly appreciated!
Thanks!