原文链接: eslint import 排序和单词拼写检查 插件
上一篇: ts import type和export type 解决vite中导入类型报错的问题
下一篇: vite worker 简单使用
对import语句进行排序, 这样可以保持项目中引入位置是一致的, 单词检查主要是减少拼写错误, 这个插件还有待完善, 但可以不定期试试, 减少typo
运行时提示缺啥就装啥
.eslintrc
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: ['tsconfig.json'],
},
plugins: ['@typescript-eslint', "spellcheck","simple-import-sort"],
rules: {
'no-unused-vars': 'off',
"spellcheck/spell-checker": [1,
{
"comments": false,
"strings": false,
"identifiers": false,
"lang": "en_US",
"skipWords": [
"dict",
"aff",
"hunspellchecker",
"hunspell",
"utils",
"lottie"
],
"skipIfMatch": [
"http://[^s]*",
"^[-\\w]+\/[-\\w\\.]+$" //For MIME Types
],
"skipWordIfMatch": [
"^foobar.*$" // words that begin with foobar will not be checked
],
"minLength": 5
}
],
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"import/first": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error"
},
overrides: [
{
files: ['**/*.ts'],
rules: {
'no-undef': 'off',
},
},
],
};