Style for the import-sort package which is compatible with eslint-plugin-import's import/first rule with absolute-first option, thus making it compatible with the StandardJS and Airbnb configs. The remaining order is based on the default eslint sort-imports order.
Install with npm install import-sort-style-absolute --save-dev
Use with
"importSort": {
".js, .jsx, .es6, .es": {
"parser": "babylon",
"style": "absolute"
}
}
in your package.json.
Sorts imports as follows:
- import 'foo'
- import * as _ from 'bar'
- import * as Foo from 'bar'
- import * as foo from 'bar'
- import _, * as bar from 'baz'
- import Foo, * as bar from 'baz'
- import foo, * as bar from 'baz'
- import _, { bar, … } from 'baz'
- import Foo, { bar, … } from 'baz'
- import foo, { bar, … } from 'baz'
- import { _, bar, … } from 'baz'
- import { Foo, bar, … } from 'baz'
- import { foo, bar, … } from 'baz'
- import _ from 'bar'
- import Foo from 'bar'
- import foo from 'bar'
- import './foo'
- import * as _ from './bar'
- import * as Foo from './bar'
- import * as foo from './bar'
- import _, * as bar from './baz'
- import Foo, * as bar from './baz'
- import foo, * as bar from './baz'
- import _, { bar, … } from './baz'
- import Foo, { bar, … } from './baz'
- import foo, { bar, … } from './baz'
- import { _, bar, … } from './baz'
- import { Foo, bar, … } from './baz'
- import { foo, bar, … } from './baz'
- import _ from './bar'
- import Foo from './bar'
- import foo from './bar'
- import-sort - Sort ES2015 (aka ES6) imports
MIT © 2017 Alexander Bast
Enjoy!