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
organize imports has conflict with prettier on "formatOnSave" #13
Comments
This is a know timing issue. After Prettier was run than this extension run, and the main issue is that vscode timeout the extension, At the moment I dont really have a fix for this. :-/ For most part this issue dont appear (The speed of your pc, how many other program your running and the size of your files all influence how often this happens ) |
If I want to keep multiline imports, how would I do that? It seems the organizer always keeps it as a single line even though I want multiline. |
@alfnielsen what about making a setting to format the same way as Prettier? It's what the JS/TS Import/Export Sorter extension is adding over here: daidodo/format-imports-vscode#39 |
FWIW I made a VSCode extension that can run a sequence of commands as a code action: Run commands as code actions You can set a delay per command if necessary and enforce a "waterfall" of commands. Here is an example configuration: "editor.formatOnSave": false,
"editor.codeActionsOnSave": [
"source.organizeImports", // For example
"source.runCommandsAsCodeActions.formatAndSave"
],
"run-commands-as-code-actions.formatAndSave": [{
"command": "prettier.forceFormatDocument",
"delay": 0
}, {
"command": "tsImportSorter.command.sortImports",
"delay": 400 // Shorter might also work, but this is safe
}, {
"command": "workbench.action.files.saveWithoutFormatting",
"delay": 400 // Shorter might also work, but this is safe
}],
}, I wrote it to solve a longstanding Prettier issue with multi-line imports |
The issue happens when prettier decides to format the import in a multi-line manner but organize imports want to format the same import as a single line.
The text was updated successfully, but these errors were encountered: