记录vue-cli3.0+typescript项目:Eslint+prettier遇到的一些错误及解决方法得到1.一直报错Delete'........',或者警告Delete,警告Insert'..',找不到错误的解决方法。可执行代码:npmrunlint--fix2,typescriptdataspecifiedtype一直报非预期的类型。这个问题是因为我没有配置typescrpt。我需要将配置解析器:'typescript'添加到.prettierrc.js并重新启动项目。查了各种资料,原来是.prettierrc.js和.eslintrc.js的配置问题。一开始是去配置tslint.json,但是很多博主说eslint停止维护了,不需要他了。这是新的.prettierrc.js和..eslintrc.js配置文件,1-2作为记录不会被删除,方便以后回头看看走过的路。eslint的原理是先解析代码的AST语法树,然后分析找出代码质量和风格问题。因此,需要指定一个解析器来解析代码语法。一方面,我们要让eslint理解vue的语法。因此,parser的值需要设置为'vue-eslint-parser'。推荐设置"extends":["plugin:vue/base"]或"extends":["plugin:vue/base"],也设置了vue语法解析器和eslint规则有一点需要注意这里parser不能再指定其他值,否则会报错“Usethelatestvue-eslint-parser”(https://vuejs.github.io/eslint-plugin-vue/user-guide/#faq)另一方面,我们必须让eslint理解typescript的语法。所以作为补充,需要添加配置parserOptions:{parser:'@typescript-eslint/parser'}module.exports={printWidth:120,//newlinestringthresholdtabWidth:4,//为每个水平设置工具indentation空格个数singleQuote:true,//使用单引号semi:false,//是否在句末加分号trailingComma:'none',//在最后一个对象元素后面加逗号bracketSpacing:true,//为对象和数组添加空格jsxBracketSameLine:true,//jsx>是否开始换行arrowParens:'always',//(x)=>{}是否有括号parser:'typescript'//指定哪个要使用的解析器}module.exports={root:true,env:{node:true},extends:['plugin:vue/essential',"plugin:prettier/recommended",'@vue/prettier','eslint:推荐','@vue/typescript/recommended','@vue/prettier/@typescript-eslint'],rules:{'no-console':process.env.NODE\_ENV\==='production'?'warn':'off','no-debugger':process.env.NODE\_ENV\==='production'?'warn':'off','no-unused-vars':'off','@typescript-eslint/no-unused-vars':'off','@typescript-eslint/no-explicit-any':'off','prefer-const':'off'},/*指定如何解析语法,可以为空,但如果不为空,则仅匹配这个值*/parser:'vue-eslint-parser',parserOptions:{ecmaVersion:2020,parser:'@typescript-eslint/parser'},overrides:[{files:['**\_\_tests\_\_\*.{j,t}s?(x)'],env:{mocha:true}}]}但是启动项目后还是会出现警告,可以启动项目,但是我这个问题找了很久。找不到解决办法,有没有大佬补充一下?代码是黄色波浪线
