Closed kbd closed 5 years ago
Same here. Even if it can be avoided by manually ordering imports, it is a quite a problematic issue, especially if you save your file without noticing the mess…
I played around with this a bit and it seems like the issue is a combination of ordered-imports
and quotemark
in tslint.json. Specifically it seems like if you are trying to use ordered-imports
and have quotemark
set to single
it mangles things. If you remove quotemark
completely or if you set it to double
that seemed to fix the problem for me. That said, once I removed quotemark
from tslint.json I couldn't find a way to enforce this rule using prettier. No matter what that is set to, I still always get double quotes.
Long story short, I haven't really completely solved the issue, but hoping this may help troubleshoot the problem.
This is probably a tslint
issue, not prettier-tslint
. Since prettier
does not re-order imports.
Let me know if you can reproduce this issue still. Fork this repository to start with.
Looks like many errors were being caused by an undefined parent
property on AST nodes, which has now been fixed by e06519376f9acb30d6e05e02be49a4505d0b7dd2 (which will be released soon).
Environment:
"module": "commonjs"
in tsconfig.json"ordered-imports": true
in tslint.jsonSteps taken:
Created
testing.ts
with the following in it:Upon calling "Format Document" in VS Code, it gets mangled to:
Correct is:
The vscode-tslint extension with
tslint.autoFixOnSave
set totrue
doesn't have this bug and correctly reorders imports on save.