pnpm i -D eslint @antfu/eslint-config// 如果没有在 page.json 配置 "type": "module"
const antfu = require('@antfu/eslint-config').default
module.exports = antfu()
// 配置了 "type": "module"
import antfu from '@antfu/eslint-config'
export default antfu()
{
// Enable the ESlint flat config support
"eslint.experimental.useFlatConfig": true,
// Disable the default formatter, use eslint instead
"prettier.enable": false,
"editor.formatOnSave": false,
// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},
// Silent the stylistic rules in you IDE, but still auto fix them
"eslint.rules.customizations": [
{ "rule": "style/*", "severity": "off" },
{ "rule": "*-indent", "severity": "off" },
{ "rule": "*-spacing", "severity": "off" },
{ "rule": "*-spaces", "severity": "off" },
{ "rule": "*-order", "severity": "off" },
{ "rule": "*-dangle", "severity": "off" },
{ "rule": "*-newline", "severity": "off" },
{ "rule": "*quotes", "severity": "off" },
{ "rule": "*semi", "severity": "off" }
],
// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml"
]
}
module.exports = antfu({
overrides: {
vue: {
'vue/component-name-in-template-casing': ['off'],
},
},
})
解释:
在使用ts校验忽略的时候需要加上注解就不会报错了
错误
// @ts-expect-error
正确
// @ts-expect-error 插件类型不匹配