2. 在 Vite Vue3 TS 项目中初始化 ESLint 接下来,你需要初始化 ESLint 配置。在项目根目录下运行以下命令: bash npx eslint --init 这个命令会引导你完成 ESLint 配置的初始化过程。你可以选择使用推荐的配置,或者根据项目的具体需求进行自定义配置。 3. 配置 ESLint 规则 初始化完成后,ESLint 会在项目...
需要安装@eslint/eslintrc pnpmadd@eslint/eslintrc--save-dev 具体代码: importglobalsfrom"globals";importpluginJsfrom"@eslint/js";importtseslintfrom"typescript-eslint";importpluginVuefrom"eslint-plugin-vue";import{FlatCompat}from"@eslint/eslintrc";importpathfrom"path";import{fileURLToPath}from...
5、配置vite.config.ts文件 import { defineConfig } from 'vite'; import vue from'@vitejs/plugin-vue'; import eslintPlugin from'vite-plugin-eslint';//https://vitejs.dev/config/exportdefaultdefineConfig({ plugins: [ vue(), eslintPlugin({ include: ['src/**/*.ts', 'src/**/*.vue',...
我们的项目需要支持vue 和 ts,所以这里我们直接用官方推荐的插件和配置就行了,前面初始化eslint 选项的时候,就已经自动安装了相关依赖包 [eslint-plugin-vue] 和@typescript-eslint/parser { parser: 'vue-eslint-parser', extends: [ 'plugin:vue/vue3-recommended', 'plugin:@typescript-eslint/recommended'...
一:创建项目 github完整配置地址[https://github.com/suhonghai/vue3-vite-ts-eslint] 使用vite官网命令安装 tsco...
ESLint 是一个流行的 JavaScript 代码检查工具,可以确保代码风格的一致性。ESLint 支持多种规则配置,可以帮助开发者规范代码编写。在本文中,我们将关注 Vite + Vue 3 + TypeScript 的 ESLint 规则配置。 5.Vite + Vue 3 + TypeScript 的 ESLint 规则配置 为了实现这套配置,我们需要在项目根目录下创建或修改...
下面是一些常见的ESLint规则,可以帮助我们在Vite + Vue 3 + TypeScript项目中提高代码质量。 1.使用官方推荐的ESLint配置:ESLint提供了一些官方推荐的配置,可以直接在项目中使用,如"@vue/eslint-config-typescript"和"@vue/eslint-config-standard"。这些配置包含了一些常用的规则和插件,可以帮助我们遵循最佳实践...
'comma-dangle': ['error','never']//eslint的配置 } }) 三、配置vscode { "prettier.enable":false, "editor.formatOnSave":false, "editor.codeActionsOnSave":{ "source.fixAll.eslint":"explicit", "source.organizeImports":"never" },
此时页面会出现一个.eslintrc.cjs文件 配置package.json 增加lint命令 "scripts": { "dev": "vite", "build": "vue-tsc && vite build", "preview": "vite preview", "lint": "eslint './src/**/*.{js,jsx,vue,ts,tsx}' --fix"
上回我们说到配置ESLint以及添加vue-recommended、airbnb-base、prettier规则,一切都很顺利。唯有一点需要注意的就是 .eslintrc 文件extends配置项中,plugin:prettier/recommended一定要在airbnb-base之后添加,…