我已经按照以下顺序导入了:react first,外部包,代码库,当前目录
比如说
import * as React from "react"
import { css } from "emotion"
import a from "hooks" // this lives below emotion because I want to sort on package name
import Form from "my/own/component/path" // notice I also want gap between these imports
import Something from "./something" // import from current directory
如何使用eslint-plugin-import
来更正规则?
到目前为止,我有这样的东西:
"import/order": [
"error",
{
"alphabetize": {
"caseInsensitive": true,
"order": "asc"
},
"groups": ["external", "builtin", "parent", ["sibling", "index"]],
"newlines-between": "never",
"pathGroups": [
{
"group": "external",
"pattern": "react",
"position": "before"
},
{
"group": "builtin",
"pattern": "**",
"position": "after"
},
{
"group": "external",
"pattern": "./**",
"position": "after"
}
],
"pathGroupsExcludedImportTypes": ["builtin"]
}
]
1条答案
按热度按时间ozxc1zmp1#
您可以使用此插件创建自定义导入组:https://github.com/azat-io/eslint-plugin-perfectionist