-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
A standard for usage of snake case, camel case, pascal case etc? #452
Comments
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 :) |
👍 for enforcing |
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. |
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. |
I am using |
@LinusU I agree with you, would like to see what breakage this would cause in the ecosystem before considering it. |
I am with @grantcarthew and @ilearnio; |
@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 :) |
Camel case variables are now enforced in standard |
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? |
I suppose this would work: let { route_id: routeId, std_date: stdDate, std_time: stdTime } = flight |
So obvious. Thanks! :) |
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 |
@mderazon use eslint with eslint-config-standard then just override the rule for camelcase. |
@mderazon Yeah, I respect your decision to use eslint directly. |
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. |
@wmhilton Heh, thanks for sharing your story ;-) |
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!
The text was updated successfully, but these errors were encountered: