创建vue3项目时,配置eslint+prettier规范代码
记录一下自己在创建项目时配置一些代码规范的步骤
1. vscode安装插件
vscode安装ESLint和Prettier插件
2. 创建vue3项目
vue create vue3demo
// 进行选择
? Please pick a preset: Manually select features
? Check the features needed for your project: Choose Vue version, Babel, TS, Router, Vuex, Linter
? Choose a version of Vue.js that you want to start the project with 3.x // 选择vue版本为3.x
? Use class-style component syntax? No
? Use Babel alongside TypeScript (required for modern mode, auto-detected polyfills, transpiling JSX)? Yes
? Use history mode for router? (Requires proper server setup for index fallback in production) Yes
? Pick a linter / formatter config: Prettier
? Pick additional lint features: Lint on save, Lint and fix on commit
? Where do you prefer placing config for Babel, ESLint, etc.? In dedicated config files
? Save this as a preset for future projects? No
在创建项目的过程中,进行到Pick a linter / formatter config时,选择ESLint + Prettier。