Open daidodo opened 3 hours ago
你好,Nicholas!
import 'a/path'
是一个script import,而script imports是不支持自动排序的,因为可能有副作用。
你当然可以手动排序。或者你100%确定它们没有副作用,还有一个折中的办法,设置subGroups:
{
"flags": "scripts",
"subGroups": ["^@/styles/", "^[.]/styles/", "^styles/"],
"regex": "[.](less|scss|css)$"
},
这样会把例子里的script imports根据路径前缀(sub groups)排序,但是无法根据文件名排序。
Output:
import '@/styles/index.scss';
import '@/styles/bar.scss';
import './styles/foo.scss';
import './styles/bar.scss';
import 'styles/foo.scss';
import 'styles/index.scss';
import { ref } from '@vue/composition-api';
PS:
{
"regex": "@vue/composition-api"
}
可以简化成"@vue/composition-api"
。例如:
"tsImportSorter.configuration.groupRules": [
{
"flags": "scripts",
"subGroups": ["^@/styles/", "^[.]/styles/", "^styles/"],
"regex": "[.](less|scss|css)$"
},
"@vue/composition-api",
{},
"^@(basecom|bizcom)",
"^@/configs/",
"^@/constants/",
...
],
From Nicholas:
I am using the extension in a Vue project.
Importing styles did not meet my expectations. I am not sure if the configuration is incorrect. Therefore, I did not submit an issue but sent you an email for help.
My current configuration is as follows:
Import Example:
Expected import:
This extension is awesome, thanks for the idea!
Regards, Nicholas