vicary
vicary11mo ago

Deno fmt with verbatimModuleSyntax?

Currently Deno fmt sorts verbatim imports alphabetically, this is conflicting with the Organize Imports in VS Code where it sorts import { type ... } entries individually at the end. Example:
// VS Code
import {
bar,
foo,
type Bar,
type Foo
} from "module";

// Deno fmt
import {
type Bar,
bar,
type Foo,
foo
} from "module";
// VS Code
import {
bar,
foo,
type Bar,
type Foo
} from "module";

// Deno fmt
import {
type Bar,
bar,
type Foo,
foo
} from "module";
When combined with the following VS Code option, all of the files flashes between the two formats in random order depending on how formatOnSave is configured.
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
Is it possible to add an option for Deno fmt, either disabling that part or expose an option to align with VS Code?
1 Reply
Deno AI Helper
Deno AI Helper11mo ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the information you've provided, it seems like there is a conflict between the formatting rules of Deno fmt and the Organize Imports feature of VS Code. From the example you've given, there are no obvious syntax errors or mistakes. The issue appears to be related to the different sorting behaviors of the two tools. Unfortunately, without specific documentation or official guidance on this matter, I can't provide a definitive solution. Please note that the advice given here is not based on the Deno documentation, and I would advise you to double-check the accuracy of this advice. It might be worth exploring if there are any configuration options for Deno fmt or the VS Code TypeScript plugin that could align their behaviors, or if there's a plugin that can enforce a consistent import order that satisfies both tools. If this is causing significant disruption, you might also consider raising an issue in the Deno repository or the relevant VS Code extension repository to seek a more integrated solution.