Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simonwep/eslint-plugin-align-import
⚙ ESLint plugin to align all your import statements.
https://github.com/simonwep/eslint-plugin-align-import
eslint eslint-plugin eslint-rules eslintplugin
Last synced: 21 days ago
JSON representation
⚙ ESLint plugin to align all your import statements.
- Host: GitHub
- URL: https://github.com/simonwep/eslint-plugin-align-import
- Owner: simonwep
- License: mit
- Created: 2020-05-18T17:48:22.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T20:25:14.000Z (almost 2 years ago)
- Last Synced: 2024-10-06T10:44:08.542Z (about 1 month ago)
- Topics: eslint, eslint-plugin, eslint-rules, eslintplugin
- Language: JavaScript
- Homepage:
- Size: 183 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
eslint-plugin-align-import### What is this?
This plugin / rule will align all your import statements:
> from```js
import defaultExport from "module-name";
import * as name from "module-name";
import { export1 } from "module-name";
import { export2 as alias1 } from "module-name";
import { export3 , export4 } from "module-name";
import { foo , bar } from "module-name/path/to/specific/un-exported/file";
import { export5 , export6 as alias7 } from "module-name";
import defaultExport2, { export8 } from "module-name";
import defaultExport3, * as name2 from "module-name";
```> to
```js
import defaultExport from "module-name";
import * as name from "module-name";
import { export1 } from "module-name";
import { export2 as alias1 } from "module-name";
import { export3 , export4 } from "module-name";
import { foo , bar } from "module-name/path/to/specific/un-exported/file";
import { export5 , export6 as alias7 } from "module-name";
import defaultExport2, { export8 } from "module-name";
import defaultExport3, * as name2 from "module-name";
```### Installation
You'll first need to install [ESLint](http://eslint.org):
```
$ npm install eslint --save-dev
```Next, install `eslint-plugin-align-import`:
```
$ npm install eslint-plugin-align-import --save-dev
```**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-align-import` globally.
### Usage
Add `eslint-plugin-align-import` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
```json
{
"plugins": [
"align-import"
]
}
```You might have to update the [`no-multi-spaces`](https://eslint.org/docs/rules/no-multi-spaces) rule to allow multiple spaces in front of `from`:
```json
{
"rules": {
"no-multi-spaces": ["error", {"exceptions": {"ImportDeclaration": true}}]
}
}
```There are two rules available:
| rule | description |
| ---- | ----------- |
| [align-import/align-import](docs/rules/align-import.md) | Aligns your import statements, this is probably the rule you're looking for. |
| [align-import/trim-import](docs/rules/trim-import.md) | This rule will remove any extra space around your `import` keyword. |