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
Support Angular @Component
decorator alias
#16256
Comments
Regarding the open PR, Wouldn’t it be better to change the code understand any alias name instead of hard coding these Page and Layout names? I haven’t seen this convention in Angular ecosystem. I don’t doubt that it exists but I feel like that it isn’t something that is regarded standard way. And prettier would need to start to add all the aliases that people request. I could be wrong and this is something that Angular is promoting in their style guide. If that it’s the case, then this change makes a lot sense. |
@rubiesonthesky I have updated the code, now it will support any alias name :) |
Page
and Layout
aliases for Angular @Component
decorator @Component
decorator alias
I am against adding this feature. But I am not familiar with Angular, so let me ask a question. Is this rule common among people who write Angular? Or is it only needed by you and your team? |
It seems that prettier is not parsing the
Component
import statement and using the hard string "Component" to detect if it's an Angular component or not(node.callee.name === "Component"
) which means that this would work:But this will not:
-> Prettier will not be able to detect the template since the callee name is
Page
.Same thing for this:
-> Prettier will not be able to detect the template since the callee name is
Layout
.The
Component
decorator name in Angular is so "generic", could be used as aComponent
,Page
(route) and aLayout
, using an alias will make it easier to read and understand.Adding a support for those aliases is so easy too, all we need is to change one line:
Now prettier will detect the new component aliases
Page
andLayout
:)The text was updated successfully, but these errors were encountered: