最后,你可以通过运行 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...
这里应该就已经不是eslint的问题了,可能是VSCode编辑器审查语法的问题了。VSCode语法检查、tsc编译都需要依赖tsconfig.json文件中的配置,那我们就再配置一下TS中的别名看看。 //tsconfig.json{"compilerOptions": {"target":"esnext","module":"esnext","moduleResolution":"node","strict":true,"jsx":"preserve...
本文介绍vue3-element-admin如何通过ESLint 检测 JS/TS 代码、Prettier 格式化代码、Stylelint 检测 CSS/SCSS 代码和配置EditorConfig来全方位约束和统一前端代码规范。 ESLint 代码检测 ESLint可组装的JavaScript和JSX检查工具,目标是保证代码的一致性和避免错误。
直接control+s键保存,VSCode 会自动修复代码 ESLint 检测出的错误,帮助我们去除了;逗号。 总结 再遇到类似的 Vue3 + TS 项目时,可以查阅和参考这篇文章,快速为项目加入 ESLint 代码检查。 也可以把自己的 ESLint 配置抽离为一份可共享的配置,方便你的其他项目通过 ESLint 的 extends 键扩展可共享的配置。
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...
上回我们说到配置ESLint以及添加vue-recommended、airbnb-base、prettier规则,一切都很顺利。唯有一点需要注意的就是 .eslintrc 文件extends配置项中,plugin:prettier/recommended一定要在airbnb-base之后添加,…
npx eslint --init 按照提示进行配置 然后在初始化后的自动创建的.eslintrc.json文件编写自己需要的rules规则,更多规则可以去官网:https://eslint.bootcss.com/docs/rules/ { ..."rules": {"semi": ["warn", "never"],"indent": ["error",4, ...
在你的 package.json 文件中添加一个脚本来运行 Eslint : {"scripts":{"lint:eslint":"eslint --cache --max-warnings 0 \"{src,mock}/**/*.{vue,ts,tsx}\" --fix",}} 三、Prettier 安装与配置 Prettier 是一个代码格式化程序 1、安装 ...