Analyzer Configuration
Code analysis settings for import organization and maintainability
Usage
Import the analyzer configuration in your biome.json:
{
"$schema": "https://biomejs.dev/schemas/2.3.8/schema.json",
"extends": ["@accelint/biome-config/analyzer"]
}Features
Import Organization
Automatically organizes imports when using Biome's source actions.
Configuration
- Level: On (enabled)
- Type Imports Grouping: false (types are not grouped separately)
Behavior
Organizes imports alphabetically within their categories without separating type imports:
// Before organization
import { useEffect } from 'react';
import type { User } from './types';
import { formatDate } from './utils';
import { useState } from 'react';
import type { Config } from './config';
// After organization
import { useEffect, useState } from 'react';
import type { Config } from './config';
import type { User } from './types';
import { formatDate } from './utils';Editor Integration
VSCode
Configure automatic import organization on save in .vscode/settings.json:
{
"editor.codeActionsOnSave": {
"source.organizeImports.biome": "explicit"
}
}On Demand
Trigger import organization through your editor's code actions menu (usually Cmd+. or Ctrl+.).
CLI Usage
Organize imports using the Biome CLI:
# Check and fix all files
pnpm biome check --write .
# Fix specific files
pnpm biome check --write src/**/*.tsThe check command runs all enabled checks including import organization.
Import Organization Rules
Grouping
Imports are organized into groups:
- External dependencies (node_modules)
- Internal absolute imports (using path aliases)
- Relative imports (./ and ../)
// ✅ Organized imports
import { useState, useEffect } from 'react';
import { formatISO } from 'date-fns';
import { useAuth } from '@/hooks/useAuth';
import type { User } from '@/types';
import { formatDate } from './utils';
import { Button } from './Button';Sorting
Within each group, imports are sorted:
- Side-effect imports (no specifiers)
- Named imports (alphabetically by module)
- Type imports (not separated, mixed with value imports)
// ✅ Sorted within group
import './styles.css';
import { Button } from './components/Button';
import { Input } from './components/Input';
import type { Theme } from './components/types';
import { formatDate, parseDate } from './utils';Combining Imports
Imports from the same module are automatically combined:
// ❌ Before
import { useState } from 'react';
import { useEffect } from 'react';
import type { FC } from 'react';
// ✅ After
import { useEffect, useState } from 'react';
import type { FC } from 'react';Customization
Separate Type Imports
Enable type import grouping in your biome.json:
{
"extends": ["@accelint/biome-config/analyzer"],
"assist": {
"actions": {
"source": {
"organizeImports": {
"level": "on",
"options": {
"groups": [{ "type": true }]
}
}
}
}
}
}With type grouping enabled:
// Type imports grouped separately
import { useState, useEffect } from 'react';
import type { FC, ReactNode } from 'react';
import type { User } from './types';Disable Import Organization
Disable for specific files using overrides:
{
"extends": ["@accelint/biome-config/analyzer"],
"overrides": [
{
"include": ["**/*.test.ts"],
"assist": {
"actions": {
"source": {
"organizeImports": {
"level": "off"
}
}
}
}
}
]
}Example: Before and After
Before Organization
import { formatDate } from './utils';
import type { User } from './types';
import { Button } from './components/Button';
import { useEffect, useState } from 'react';
import type { Config } from './config';
import { Input } from './components/Input';
import './styles.css';After Organization
import { useEffect, useState } from 'react';
import './styles.css';
import { Button } from './components/Button';
import { Input } from './components/Input';
import type { Config } from './config';
import type { User } from './types';
import { formatDate } from './utils';Integration with Linter
The analyzer works alongside the linter configuration. When both are enabled:
- Linter catches
noUnusedImportsviolations - Analyzer removes unused imports automatically
- Linter validates import order and grouping
{
"extends": [
"@accelint/biome-config/linter",
"@accelint/biome-config/analyzer"
]
}Troubleshooting
Imports Not Organizing
Ensure source actions are enabled in your editor:
VSCode:
{
"editor.codeActionsOnSave": {
"source.organizeImports.biome": "explicit"
}
}Conflicting with Other Tools
If using multiple import organizers (e.g., ESLint, TypeScript), disable them to prevent conflicts:
{
"eslint.codeActionsOnSave.rules": null,
"typescript.preferences.organizeImportsOnSave": false
}