"eslint-config-prettier": "^8.3.0", "eslint-import-resolver-alias": "^1.1.2", "eslint-plugin-import": "^2.25.4", "eslint-plugin-jest": "^25.7.0", "eslint-plugin-vue": "^8.3.0", } eslint 的配置采用 JS 文件格式,经过几次
defineProps属于Vue3的规则校验,需要在eslint-plugin-vue官方指南中寻找对应配置。通过查阅文档发现: 编译器宏,例如defineProps和defineEmits会生成no-undef没有声明问题。 需要使用vue-eslint-parserV9.0.0或最新版本。 以前您必须使用vue/setup-compiler-macros,现在不再需要了。
解决方案:找到eslint.js文件,在env处添加代码 'vue/setup-compiler-macros': true,即可解决,如图
解决之道,在/package.json的eslintConfig.env中加入一行: "vue/setup-compiler-macros": true 1. 网上找答案,总是扯什么修改.eslint.js文件,须知改文件位于node_modules,如大海捞针,并且有多个。改这里是没有道理的,也没有效果。可能是很久之前的答案了吧。
args: any[]) => any } type DefaultComputed = { [key: string]: any } export type VueProxy< PropsOptions, RawBindings, Data = DefaultData<Vue>, Computed = DefaultComputed, Methods = DefaultMethods<Vue> > = Vue2ComponentOptions< Vue, ShallowUnwrapRef<RawBindings> & Data, Methods, ...
/ eslint 报错解决:'ref' is not defined// eslintrc: {// enabled: true, // Default `false`// filepath: './.eslintrc-auto-import.json', // Default `./.eslintrc-auto-import.json`// globalsPropValue: true// }// })UnoCSS(),viteCompression({verbose:true,// 默认即可disable:false...
可能会出现TypeScript-eslint监测不识别的问题 typescript 报错:'ref'is not defined. 解决方案 1、运行项目 pnpm dev 此时,插件unplugin-auto-import会在项目的根目录生成一个文件:auto-imports.d.ts 2、将生成的TypeScript声明文件引入Vite和tsconfig
ESLint:使用ESLint来检查代码质量。 npm install eslint eslint-plugin-vue --save-dev 配置ESLint规则: module.exports = { "rules": { "vue/no-unused-components": "error", "vue/multi-word-component-names": "error" } }; Prettier:使用Prettier来统一代码格式。
(带样式) resolvers: [ElementPlusResolver(), IconsResolver({})], eslintrc: { enabled: false, filepath: "./.eslintrc-auto-import.json", globalsPropValue: true, }, vueTemplate: true, // 配置文件生成位置(false:关闭自动生成) dts: false, // dts: "src/typings/auto-imports.d.ts", }...
globals: { // 以下是全局变量 eslint 不会报'EncryptionPlugin' is not defined.eslint (no-undef) EncryptionPlugin: "readonly", $encryptionPlugin: "readonly", }, 2: 页面使用 import { inject } from 'vue'; // 使用 inject 函数获取 encryptionPlugin const encryptionPlugin = inject("encryption...