Unify formatting, linting, and imports with Biome
Use formatter.organizeImports and biome ci to replace Prettier, ESLint, and import sorters with one binary and one config.
29 Aug 2025, 19:48 UTC

One config file, three responsibilities
Our TypeScript service used Prettier for formatting, ESLint for linting, and a separate plugin to sort and prune imports. Each tool ran in its own Node process, parsed the same files, and carried its own configuration. On a large repository the CI lint stage spent most of its time starting tools rather than checking code, and rules occasionally contradicted each other.
Biome is a single Rust binary that combines formatting, linting, and import organization. Enabling formatter.organizeImports in biome.json makes the formatter treat import cleanup as part of formatting, while biome ci provides a read-only gate for continuous integration. Together they let you replace the separate toolchain without losing the safety net.
What formatter.organizeImports actually does
When set to true, the formatter removes imports that static analysis cannot tie to any usage, sorts named specifiers alphabetically, and merges duplicate imports from the same module. It runs during the format pass, so there is no round-trip between a linter and a formatter.
{
"formatter": {
"organizeImports": true
}
}
Save this as biome.json at the repository root. All other Biome configuration lives in the same file.
Worked example: cleaning an import block
Create src/utils/formatName.ts:
import { unusedHelper } from './utils/helpers';
import { formatDate } from './utils/date';
import './UserCard.css';
export function formatName(name: string): string {
return formatDate(name);
}
Run the formatter from the repository root. No elevated permissions are required. Replace <BIOME_VERSION> with your pinned release:
npx @biomejs/biome@<BIOME_VERSION> format --write src/utils/formatName.ts
Expected result: unusedHelper is removed, ./UserCard.css remains because Biome recognizes the CSS extension as a side effect, and the remaining specifiers are sorted. Verify with git diff before committing.
Risk: an import that only registers a global or polyfill may be dropped if no binding is referenced. Audit the diff after enabling the feature.
CI gate: biome ci versus biome check --apply
biome ci reads the same biome.json developers use locally, prints format and lint violations to stdout, exits non-zero on any violation, and never writes files. biome check --apply writes only safe auto-fixes; --apply-unsafe may alter code semantics and should be inspected on a local branch first.
Sample GitHub Actions step:
- name: Biome CI
run: npx @biomejs/biome@<BIOME_VERSION> ci
Pin the Biome version in package.json so rule defaults do not drift between runs.
Limitation: side-effect imports and rule coverage
Biome's static analysis is conservative but not perfect. A module that only registers a global, such as a polyfill, can lose its import because no exported binding is used. Mitigate this with formatter ignore patterns or a // biome-ignore comment on the line. Not every ESLint plugin rule has a Biome equivalent, so you may need to keep ESLint for specific rules.
Verification checklist before merging
- Add an unused import to a scratch file, run
biome format --write, and confirm the import is removed and the file is formatted. - Run
biome cion a clean checkout; it should pass with no output. - Intentionally break formatting in one file, run
biome ciagain, and confirm a non-zero exit with no files written. - Run
biome --versionand confirm it matches the pinned version inpackage.json.
Because format --write and check --apply modify files, run them on a branch. If the diff is unexpected, roll back with git checkout -- . or revert the commit.
If all four checks pass, you have one binary, one configuration file, and a deterministic CI gate for formatting, linting, and imports.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.