Analyzer
Rome’s analyzer provides a series of features that users can leverage.
Imports Sorting
Rome allows to sort import statement using natural ordering.
This feature is opt-in via configuration:
{
"organizeImports": {
"enabled": true
}
}
You can apply the sorting in two way: via LSP or CLI
Imports sorting via CLI
Due the nature of the language, the sorting of imports is categorised as unsafe, and you can apply it using the --apply-unsafe
option:
rome check --apply-unsafe ./path/to/src
Imports sorting via VSCode extension
The Rome VS Code extension has experimental support for imports sorting through the “Organize Imports” code action. By default this action can be run using the ⇧+Alt+O keyboard shortcut, or is accessible through the Command Palette (Ctrl/⌘+⇧+P) by selecting Organize Imports.
You can add the following to your editor configuration if you want the action to run automatically on save instead of calling it manually:
{
"editor.codeActionsOnSave":{
"source.organizeImports.rome": true
}
}