@4c/import-sort 中文文档教程
@4c/import-sort
import-sort 样式配置和 Javascript 和 Typescript 的自定义解析器(使用 babel)。
Install
yarn add -D @4c/import-sort
Configuration
在 package.json
中:
{
"importSort": {
".js": {
"parser": "@4c/import-sort/parser",
"style": "@4c/import-sort"
},
".ts, .tsx": {
"parser": "@4c/import-sort/parser-ts",
"style": "@4c/import-sort"
}
}
}
Style
导入分为三组:第三方代码、本地代码、样式和资产
import fs from 'fs'; // Node core modules first
import pick from 'lodash/pick'; // third party deps
import Env from '@4c/env'; // scoped
import Foo from '../Foo'; // local, in shared.
import Bar from './Bar';
import Baz from './Baz';
import styles from 'styles.scss'; // style imports
@4c/import-sort
An import-sort style config and custom parser for Javascript and Typescript (using babel).
Install
yarn add -D @4c/import-sort
Configuration
In a package.json
:
{
"importSort": {
".js": {
"parser": "@4c/import-sort/parser",
"style": "@4c/import-sort"
},
".ts, .tsx": {
"parser": "@4c/import-sort/parser-ts",
"style": "@4c/import-sort"
}
}
}
Style
Imports are sorted into three groups: third party code, local code, styles and assets
import fs from 'fs'; // Node core modules first
import pick from 'lodash/pick'; // third party deps
import Env from '@4c/env'; // scoped
import Foo from '../Foo'; // local, in shared.
import Bar from './Bar';
import Baz from './Baz';
import styles from 'styles.scss'; // style imports