Disable Biome Import Type Formatting
Guide to 3 ways to disable automatic import type conversion in Biome
When working with Biome ↗, you may encounter situations where the linter automatically converts regular imports to import type. While this feature helps with optimization, sometimes you want to preserve your existing import syntax. This guide covers 3 ways to disable this behavior.
The Problem#
Biome has a useImportType rule that automatically converts imports containing only types to import type:
// Before Biome format
import { Icons } from '../../libs/icons';
// After Biome format
import type { Icons } from '../../libs/icons';typescriptThis can be annoying when:
- You want to keep regular import syntax consistent
- The import also contains runtime values (not just types)
- You’re migrating from ESLint and want to preserve code style
Solutions#
Option 1: Disable the Rule Globally#
The simplest approach is to disable the useImportType rule in your biome.json file:
{
"linter": {
"enabled": true,
"rules": {
"style": {
"useImportType": "off"
}
}
}
}json[!TIP] After modifying
biome.json, remember to restart your IDE or Biome extension for changes to take effect.
Option 2: Disable for a Specific File#
If you only want to disable it for a specific file or line, use a suppress comment:
// biome-ignore lint/style/useImportType: preserving regular import syntax
import { Icons } from '../../libs/icons';typescriptOr place the comment at the top of the file to apply to the entire file:
// biome-ignore-file lint/style/useImportType
import { Icons } from '../../libs/icons';
import { OtherType } from './other';typescriptOption 3: Disable All Import Organization#
If Biome is moving, sorting, or restructuring your type imports during formatting, you can disable the organizeImports feature entirely:
{
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": {
"enabled": false
}
}
}
}
}json[!WARNING] This disables all import organization features, not just type imports. Consider carefully before using this approach.
When to Use Each Approach#
| Approach | When to Use | Pros | Cons |
|---|---|---|---|
| Global | Team wants consistent regular imports | Applies to entire project, easy to manage | Loses import type optimization benefits |
| Specific File | Only a few files need exception | Flexible, doesn’t affect other code | Requires manual comment additions |
| Disable organizeImports | Want complete control over import organization | Disables all import automation | Loses many useful features |
Practical Example#
Suppose you have an Astro component using type imports:
---
import type { Icons } from '../../libs/icons';
interface Props {
name: keyof typeof Icons;
}
---astroAfter disabling useImportType, you can write:
---
import { Icons } from '../../libs/icons';
interface Props {
name: keyof typeof Icons;
}
---astroBiome will no longer automatically convert it back to import type.