Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cheap-glitch/eslint-plugin-cascading-imports
⛲ Sort import declarations into a pleasing and readable cascade.
https://github.com/cheap-glitch/eslint-plugin-cascading-imports
eslint eslint-plugin imports style
Last synced: about 1 month ago
JSON representation
⛲ Sort import declarations into a pleasing and readable cascade.
- Host: GitHub
- URL: https://github.com/cheap-glitch/eslint-plugin-cascading-imports
- Owner: cheap-glitch
- License: isc
- Created: 2022-01-20T11:31:25.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-30T10:35:28.000Z (almost 3 years ago)
- Last Synced: 2024-11-28T23:47:58.868Z (about 2 months ago)
- Topics: eslint, eslint-plugin, imports, style
- Language: TypeScript
- Homepage:
- Size: 246 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ⛲ eslint-plugin-cascading-imports
[![License](https://shields.io/github/license/cheap-glitch/eslint-plugin-cascading-imports)](LICENSE)
[![Latest release](https://shields.io/github/v/release/cheap-glitch/eslint-plugin-cascading-imports?sort=semver&label=latest%20release&color=green)](https://github.com/cheap-glitch/eslint-plugin-cascading-imports/releases/latest)
[![Coverage status](https://shields.io/coveralls/github/cheap-glitch/eslint-plugin-cascading-imports)](https://coveralls.io/github/cheap-glitch/eslint-plugin-cascading-imports)This plugin allows to automatically enforce a visual "cascading" order for
import declarations.Imports in each block will be sorted according to the length of their bindings,
and if equal then according to the length of their specifier. Imports without
bindings will be left untouched, as their order may be important.Before:
```javascript
import { lorem, ipsum } from 'cicero';
import foo from 'foo';
import { bar as baz } from 'bar';
import { xizzy } from 'magic-words';import './beforehand.css';
import './after.css';
import { Bandersnatch } from './jabberwocky.js';
import * as nebula from './lib/galaxy.js';
```After:
```javascript
import foo from 'foo';
import { xizzy } from 'magic-words';
import { bar as baz } from 'bar';
import { lorem, ipsum } from 'cicero';import './beforehand.css';
import './after.css';
import * as nebula from './lib/galaxy.js';
import { Bandersnatch } from './jabberwocky.js';
```> Note: only ES6 import syntax is supported.
## Installation
```
npm i -D eslint-plugin-cascading-imports
```Make sure you've also [installed ESLint](https://eslint.org/docs/user-guide/getting-started#installation-and-usage).
## Usage
This plugin exports a single rule, called `cascading-imports`:
```json
{
"plugins": [
"cascading-imports"
],
"rules": {
"cascading-imports/cascading-imports": "warn"
}
}
```The reported problems can be automatically fixed by running ESLint with the `--fix` option.
Please note this plugin only works properly if each import is on its own line. You can use the
[newline-after-import](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/newline-after-import.md)
from [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import) to enforce this.Also note that this plugin could conflict with other sorting rules, e.g.
[eslint-plugin-import/order](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md).
To alleviate this, separate your imports in blocks according to their "type" (external, internal, etc).## Changelog
See the full changelog [here](https://github.com/cheap-glitch/eslint-plugin-cascading-imports/releases).
## Contributing
Contributions are welcomed! Please open an issue before submitting substantial changes.
## Related
* [`sort-imports`](https://eslint.org/docs/rules/sort-imports#import-sorting-sort-imports) – Core ESLint rule to sort imports and their bindings
* [`eslint-plugin-import`](https://github.com/import-js/eslint-plugin-import) – Various ESLint rules to validate your imports## License
ISC