在vue3会出现以下报错 Parsing error: '>' expected.eslint 在.eslintrc.json文件内新增一行:"parser": "vue-eslint-parser"来解决 在VScode安装ESLint和Prettier - Code formatter 安装Prettier npm i prettier eslint-config-prettier eslint-plugin-prettier -D 在根目录创建.prettierrc,更多规则看官网:https:...
最后,你可以通过运行 ESLint 命令来验证配置是否生效: bash npx eslint --ext .ts,.vue src 这条命令会检查 src 目录下所有 .ts 和.vue 文件是否符合 ESLint 规则。 完成以上步骤后,你的 Vue 3 + TypeScript 项目就应该已经配置好了 ESLint 9。你可以根据项目的实际情况进一步调整 ESLint 配置。
//禁止定义未使用的变量'@typescript-eslint/prefer-ts-expect-error': 2,//禁止使用 @ts-ignore'@typescript-eslint/no-explicit-any': 0,//禁止使用 any 类型'@typescript-eslint/no-non-null-assertion': 0,'
一、Eslint:用于检测代码 安装eslint相关依赖 yarn add eslint eslint-plugin-vue @typescript-eslint/parser @typescript-eslint/eslint-plugin -D eslint-plugin-vue:仅支持vue,提供的规则可以支持 .vue\js\jsx\ts\tsx 文件校验 @typescript-eslint/parser:解析器,让ESLint拥有规范TypeScript代码的能力 @ty...
"@typescript-eslint", "vue" ], "rules": { } } 在package.json的script中添加命令 "scripts": { "lint": "eslint --ext .ts,.vue,.js, --fix --quiet ./" }, 在App.vue中添加一个未使用变量testProp import HelloWorld from "./...
直接control+s键保存,VSCode 会自动修复代码 ESLint 检测出的错误,帮助我们去除了;逗号。 总结 再遇到类似的 Vue3 + TS 项目时,可以查阅和参考这篇文章,快速为项目加入 ESLint 代码检查。 也可以把自己的 ESLint 配置抽离为一份可共享的配置,方便你的其他项目通过 ESLint 的 extends 键扩展可共享的配置。
一、警告:warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any 解决方案:关闭any类型的警告。 //在 .eslintrc.js文件中找到rules 添加一行代码即可"@typescript-eslint/no-explicit-any": ["off"] 添加完成之后,重新运行项目即可。
Error while loading rule '@typescript-eslint/dot-notation': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.Occurred while linting D:\project\test\vite-vue3-ts-eslint...
简介:vue3+ts项目:.eslintrc.js 一、背景 记录eslintrc.js的配置,方便日后回顾: 二、配置文件包括: package.json、.eslintrc.js 三、常见配置项: root:true ESLint 自动在要检测的文件目录里寻找配置文件,紧接着是父级目录,一直到文件系统的根目录(除非指定 root: true)。当你想对一个项目的不同部分的...
一、Eslint:用于检测代码 安装eslint相关依赖 yarn add eslint eslint-plugin-vue @typescript-eslint/parser @typescript-eslint/eslint-plugin -D eslint-plugin-vue:仅支持vue,提供的规则可以支持 .vue\js\jsx\ts\tsx 文件校验 @typescript-eslint/parser:解析器,让ESLint拥有规范TypeScript代码的能力 ...