https://github.com/dherault/eslint-plugin-single-line-imports
A Eslint plugin to enforce imports to use a single line
https://github.com/dherault/eslint-plugin-single-line-imports
Last synced: about 1 month ago
JSON representation
A Eslint plugin to enforce imports to use a single line
- Host: GitHub
- URL: https://github.com/dherault/eslint-plugin-single-line-imports
- Owner: dherault
- License: mit
- Created: 2026-05-13T09:44:04.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2026-05-13T09:59:32.000Z (2 months ago)
- Last Synced: 2026-05-13T11:39:11.072Z (2 months ago)
- Language: TypeScript
- Size: 52.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# eslint-plugin-single-line-imports
An ESLint plugin to enforce that imports are written on a single line.
## Installation
```bash
npm install --save-dev eslint-plugin-single-line-imports
```
## Configuration
Add the plugin to your ESLint config (`eslint.config.js`):
```javascript
import singleLineImports from 'eslint-plugin-single-line-imports'
export default [
// ... other configs
singleLineImports.configs.recommended,
]
```
Or enable the rule manually:
```javascript
import singleLineImports from 'eslint-plugin-single-line-imports'
export default [
{
plugins: {
'single-line-imports': singleLineImports,
},
rules: {
'single-line-imports/enforce-single-line-imports': 'error',
},
},
]
```
## Rules
### `enforce-single-line-imports`
Enforces that every `import` declaration fits on a single line. This rule is auto-fixable.
**Bad:**
```typescript
import {
a,
b,
c,
} from 'module'
```
**Good:**
```typescript
import { a, b, c } from 'module'
```
Works with type imports, inline type specifiers, default imports, and mixed forms:
```typescript
import type { A, B } from 'module'
import { a, type A } from 'module'
import defaultExport, { a, b } from 'module'
```
## License
MIT