1、首先分别下载三个依赖,eslint、@antfu/eslint-config、eslint-plugin-vue
2、在项目根目录下添加配置文件eslint.config.js,内容如下:
const config = require('@antfu/eslint-config').default
module.exports = config(
{},
{
rules: {
'curly': [
'error',
'all',
],
'style/brace-style': [
'error',
'1tbs',
],
'no-console': 'off',
'vue/no-deprecated-v-on-native-modifier': 'off',
'no-undef': 'off',
'no-unused-vars': 'off',
'no-useless-escape': 'off',
'vue/v-on-event-hyphenation': 'off',
'unused-imports/no-unused-vars': 'off',
'@typescript-eslint/no-this-alias': 'off',
},
},
)
如果做了以上配置还是不生效,则在设置中打开setting.json文件中添加一句配置:
"eslint.experimental.useFlatConfig": true。
若还是不行,重启下vscode试试吧,以上内容仅供参考。