Skip to content
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

Route segments naming convention #374

Closed
Windvis opened this issue Jan 11, 2019 · 6 comments
Closed

Route segments naming convention #374

Windvis opened this issue Jan 11, 2019 · 6 comments
Labels

Comments

@Windvis
Copy link
Contributor

Windvis commented Jan 11, 2019

Can anyone explain why snake_case is the recommended naming convention for route segments?

The route-segments-snake-case documentation mentions Ember doesn't have to do extra serialization in order to resolve promises but I'm not sure what that means exactly.

I would prefer to just use camelCase in our apps, but I first want to understand why snake_case was recommended in the first place 😄

@bmish bmish added the question label Nov 6, 2019
@Turbo87
Copy link
Member

Turbo87 commented Apr 9, 2020

@rwjblue do you happen to know the answer? I stumbled upon this question yesterday too and couldn't find an answer

@rwjblue
Copy link
Member

rwjblue commented Apr 13, 2020

Basically _id is treated specially in the default Route.prototype.model implementation:

https://github.com/emberjs/ember.js/blob/b815c77d62840c3c252b7177fa442a38e4584659/packages/@ember/-internals/routing/lib/system/route.ts#L1162-L1191

IMHO, this has aged pretty poorly and should be reconsidered, but given that this type of implicit behavior is actually kinda hard to migrate away from the exact transition path is tricky.

@rwjblue
Copy link
Member

rwjblue commented Apr 13, 2020

We could probably make that regexp match either post_id or postId, but it isn't immediately clear if that should be considered breaking in and of itself. 😩

Copy link
Member

rwjblue commented Apr 13, 2020

FWIW, I think we could tweak the rule to make it clearer that _id is the only snake case thing suggested. Everything else could be camel. 🤔

@Turbo87
Copy link
Member

Turbo87 commented Apr 13, 2020

could we make it an optional feature to use postId instead of post_id, or something like that?

@mmun
Copy link
Member

mmun commented Apr 20, 2021

I would like to find a path towards dropping snake-casing conventions entirely.

EDIT: Looks like there's an RFC: emberjs/rfcs#556.

Windvis added a commit to lblod/frontend-loket that referenced this issue May 6, 2022
This rule is only needed if your app depends on the fallback model loading behaviour. That behaviour is considered bad practise and will be deprecated in the future. That means we can disable the linting rule that forces snake_case and can start using camelCase instead.

ember-cli/eslint-plugin-ember#374
Windvis added a commit to lblod/frontend-loket that referenced this issue Jul 12, 2022
This is more in line with the JS ecosystem and the snake_case version provides no benefits for us.

ember-cli/eslint-plugin-ember#374
@Windvis Windvis closed this as completed Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants