Skip to content

Commit 3b413c0

Browse files
authored
docs(code-style): match import organization to eslint config (#9238)
Since #8362 the import-x/order rule keeps all type-only imports in one group between internal and relative imports, but the docs still said they go at the end of each section. Update the list and the example to match what ESLint actually enforces.
1 parent e8f11ea commit 3b413c0

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

‎docs/code-style.md‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,21 +197,29 @@ The repository includes a `.vscode` directory with recommended settings that wil
197197

198198
### Import Organization
199199

200-
Organize imports in this order:
200+
Import order is enforced by the `import-x/order` rule in [`eslint.config.js`](../eslint.config.js), so `pnpm lint:fix` will sort your imports for you. Imports are grouped in this order, with an empty line between groups and alphabetical order within each group:
201201

202202
1. Node.js built-in modules
203-
2. External library imports (Including `@node-core/*`)
204-
3. Relative imports (`./*`, `../*`, `#specifier/`)
205-
4. Type-only imports at the end of each given section
203+
2. External library imports (Including `@node-core/*` and `#platform/*`)
204+
3. Internal imports using subpath specifiers (`#site/*`, `#ui/*`)
205+
4. Type-only imports, all together in one group no matter where they are imported from
206+
5. Relative imports (`./*`, `../*`)
207+
6. Relative CSS imports (`./*.css`, `../*.css`)
206208

207209
```tsx
208210
import { readFile } from 'node:fs/promises';
209211

210212
import { SomeComponent } from '@node-core/ui-components/Common/SomeComponent';
213+
import { useTranslations } from 'next-intl';
214+
215+
import { BASE_URL } from '#site/next.constants.mjs';
216+
217+
import type { MyComponentProps } from './types';
211218
import type { FC } from 'react';
212219

213220
import { myHook } from '../hooks/myHook';
214-
import type { MyComponentProps } from './types';
221+
222+
import styles from './index.module.css';
215223
```
216224

217225
## Documentation Standards

0 commit comments

Comments
 (0)