-
Notifications
You must be signed in to change notification settings - Fork 660
🐛 This variable is unused when import decorator #3197
Comments
This is the limitation of our parser, it would skip parsing |
Thank you for the quick response - according to my understanding, currently, we should temporarily disable this rule until the Bcs we use monorepo on our project if we disable this rule --> Affects all packages. But seem Rome now doesn't support config for each folder(`overwrite), file like Eslint, Prettier. So do you have any suggestions for that @IWANABETHATGUY ? |
@ematipico , any thoughts? |
That's a good question, and I am not sure I have the right answer. Theoretically, we might be able to fix the rule by looking at the On the other hand, this proposal is actually different from the previous one, which we don't plan to support (the previous one). There's also the fact that this proposal has been stripped out of the |
I think that even if our grammar currently doesn't support decorators, these skipped tokens are still getting parsed as identifiers, and since the semantic model cannot precisely interpret what's going on there, we could conservatively emit fake read and write events for all the identifiers we find in skipped tokens sections. @xunilrj would this work ? |
How would you envision that? Our parser only returns skipped token trivia. It's no longer know if any of those used to be an identifier before. |
This issue is stale because it has been open 14 days with no activity. |
The problem is that the "@controller" today is parsed as
The only for the semantic model to generate reference events from this would be to parse it. For this probably makes more sense to parse this inside the parser itself. |
This issue is stale because it has been open 14 days with no activity. |
What popular JS-only frameworks is using decorators according to the ECMA spec? Typescript is immensely popular nowadays, why not consider them the defacto standard when it comes to decorators (considering Angular relies heavily on decorators), and merge to ECMA when it makes sense to do so? Surely it doesn't differ by that much. |
Just read more on the TS side, looks like the new decorators won't land until TS 5.0 |
tc39/proposal-decorators#47 (comment) This is where there's a good argument for proceeding with how decorators are defined right now. Parameter decorators are heavily used in frameworks like Angular, and also heavily used in projects like the VSCode source code. The currently Stage 3 proposal does not mention parameter decorators. This is unlikely to change/resolve for another couple of years or so, if it does at all, which kind of makes the ECMA decorator standard a ghost standard until it it starts to cover popular projects out there. There's a big disconnect between what ECMA defines and reality, and that isn't going to change anytime soon. |
I am also experiencing this issue in a Nest.js project. A possible workaround is for Rome to "overlook" decorators or even imported variables and only lint |
👋 @rome/staff please triage this issue by adding one of the following labels: |
as mentioned in #4049, I think there should be a stopgap solution that allows such an important rule to be able to be used. The bare minimum being parsing @decorator values just so the import statements can be considered 'used'. This rule is so important and it would be extremely disadvantageous for an angular developer to use Rome without that rule in place. |
Yup! I am still here waiting for the Rome team to upgrade this 😆. Not only Angular FE dev, this includes more like Lite, NestJs, Knex, Sequelize... all the tools use a decorator feature 😆! |
looks like this can be closed due to #4252 |
Not yet, the feature hasn't been released. Let's close when the feature is released (at least in a nightly) |
Haha, near 8 months to complete this 🤣 - Thanks for your team's work hard 🥰 We really appreciate this. |
The Stage 3 decorators have been implemented and the code works now. Closing! FYI these are the new Stage 3 decorators, so decorator parameters won't work just yet. This means that this code: class B {
get(@Get params) {}
} Will still throw errors. |
Environment information
TS CONFIG file
What happened?
Our project uses NestJs for backend API. So we must use the
decorator
feature.But currently, seem Rome does not detect this correctly.
Here the code playground
https://play.rome.tools/?code=import+%7B+Controller%2C+Get+%7D+from+%27%40nestjs%2Fcommon%27%3B%0A%0A%40Controller%28%29%0Aexport+class+WelcomeController+%7B%0A%09%40Get%28%29%0A%09welcome%28%29+%7B%0A%09%09return+%7B%0A%09%09%09message%3A+%27Welcome+to+OneMind+API%27%2C%0A%09%09%7D%3B%0A%09%7D%0A%7D%0A&lineWidth=80&indentStyle=tab"eStyle=double"eProperties=as-needed&indentWidth=2&sourceType=module&typescript=true&jsx=false#aQBtAHAAbwByAHQAIAB7ACAAQwBvAG4AdAByAG8AbABsAGUAcgAsACAARwBlAHQAIAB9ACAAZgByAG8AbQAgACcAQABuAGUAcwB0AGoAcwAvAGMAbwBtAG0AbwBuACcAOwAKAAoAQABDAG8AbgB0AHIAbwBsAGwAZQByACgAKQAKAGUAeABwAG8AcgB0ACAAYwBsAGEAcwBzACAAVwBlAGwAYwBvAG0AZQBDAG8AbgB0AHIAbwBsAGwAZQByACAAewAKAAkAQABHAGUAdAAoACkACgAJAHcAZQBsAGMAbwBtAGUAKAApACAAewAKAAkACQByAGUAdAB1AHIAbgAgAHsACgAJAAkACQBtAGUAcwBzAGEAZwBlADoAIAAnAFcAZQBsAGMAbwBtAGUAIAB0AG8AIABPAG4AZQBNAGkAbgBkACAAQQBQAEkAJwAsAAoACQAJAH0AOwAKAAkAfQAKAH0ACgA=
Expected result
It works correctly like import type or something like that 😆
Code of Conduct
The text was updated successfully, but these errors were encountered: