-
Notifications
You must be signed in to change notification settings - Fork 71
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
Add support @typescript-eslint/parser@6 #157
Add support @typescript-eslint/parser@6 #157
Conversation
@lydell due to exclusion some tests from node v14 (because of uncompatibility with typescript-eslint/parser@6) coverage for node 14 was decreased. |
Should we restrict max version of |
We can remove Node.js 14 from CI. While at it, we could remove Node.js 16 too (which EOL too). So we’ll just test Node.js 18 and 20.
I don’t think so. This is the first time there has been a compatibility issue. For the rest of the time, it’s nice not having to wait for me updating the max version. |
This PR doesn't add any tests; I think it deserves a case for these statements inside of namespaces (where IMO they should not be sorted). |
Why should they not be sorted inside of namespaces? |
I'm on the fence about it... I think that it makes some sense to do this for It's less clear to me that it makes sense to do this for Historically, this syntax existed pre-modules when namespaces were not called namespaces, but "internal modules". This was the only way to split files apart and reference each other, creating local variables that were just object accesses under the hood, along with being able to reference types within them.
So, I should really revise my statement to be that I don't think that |
Can sorting them break anything? Organize Imports in VSCode seems to move them to the bottom of an empty-line-delimited chunk of imports, but does not change their internal order. (Which was something I originally considered in #144) |
Sorting between them, likely not, but if you want to reexport them as values, the imports of have to be before the exports (usually...), so nothing different than regular imports/exports.
I haven't been able to get organize imports to touch |
I made a new directory, and created index.ts with these contents: import b from "./b"
import BC = B.C
import npm from "npm"
import AC = A.C
import a from "./a"
console.log(a, b, npm) Then I opened VSCode in that directory ( import npm from "npm"
import a from "./a"
import b from "./b"
import BC = B.C
import AC = A.C
console.log(a, b, npm) Notice how the import assignments “fell to the bottom” and maintained their internal order. |
I see. I guess that's okay, then. I'm still not sure that I feel that this should also happen within namespaces (because they're not "really" imports and organize imports doesn't touch those?), but I feel better knowing that TS is doing this. |
I still don’t understand why “inside namespace” should be a special case. Is it because “I don’t think VSCode’s Organize Imports does that”? If so, why doesn’t VSCode do it? |
I don't really have any concrete reason other than that I don't feel like these are actually imports as most people know them, i.e. a part of a module system like ESM or CJS. They're an artifact of namespaces, and TS does not generally implement things like auto-imports and so on for them. |
Well, in that case, we are not satisfied with how your rule works. it should not break the sorting of our projects. I'm going to publish a fork of this rule soon. If the parser has changed the structure, this is the parser's problem, and we should not suffer from it. I consider the decision to roll back this fix to be erroneous. |
Have you watched it? Weren't there any of these tests? They were and worked on the 5th parser. |
Please let me know once you’ve got your fork up so I can link to it! |
Reverting everything was not the outcome I was expecting... I still think sorting the CJS style imports/exports could be valuable.
I didn't see any added for the inside namespace case, which is the code that crashed. Adding the other parser tests can make sense, but it didn't seem like they were testing the same crash? |
The problem was in the parser, the same tests that were already there earlier, including tests for exporting from namespace, work fine on the fifth version, but break on the sixth. Therefore, in this case, it is not necessary to add new special test cases. |
You're right, sorry. I see them now. |
@lydell You are of course free to take or not take anything you want for the project, but feel pretty bad that I seemingly got this all removed. That was totally not my intention; I was just looking for consistency with tsserver and it sounded like we were converging on that... |
Instead, we decided to use @trivago/prettier-plugin-sort-imports. |
There’s also https://github.com/simonhaenisch/prettier-plugin-organize-imports which I stumbled upon recently and am keeping an eye on. |
In v5 we had this structure for
export import
:In v6 this structure was changed:
Property
isExport
inTSImportEqualsDeclaration
was removed, andTSImportEqualsDeclaration
placed intoExportNamedDeclaration.declaration
instead.To maintain the current logic, added processing of the new structure. But perhaps in the future it is worth considering equating
export import
to exports instead of imports.Closes: #156