# 创建项目
pnpm create vite vite-eslint --template vue
cd vite-eslint
pnpm install
pnpm run dev
# 安装插件
pnpm i prettier -D
# 创建配置文件
echo {}> .prettierrc.json
# 安装ESLint
pnpm i eslint eslint-plugin-vue -D
# 安装 eslint-config-prettier
pnpm i eslint-config-prettier -D
cat > .eslintrc.js <<EOF
module.exports = {
env: {
node: true,
},
extends: [
'eslint:recommended',
'plugin:vue/vue3-recommended',
"prettier"
],
rules: {
// override/add rules settings here, such as:
// 'vue/no-unused-vars': 'error'
//...
"vue/require-default-prop": "off",
}
}
EOF
// package.json
"scripts":{
//...
"lint": "eslint --ext .js,.vue --ignore-path .gitignore --fix src",
"format": "prettier . --write"
}
// Code/User/settings.json
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"vetur.validation.template": false,
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
}
标签:插件,prettier,VSCode,eslint,pnpm,vite,ESLint
From: https://www.cnblogs.com/leoshi/p/17298344.html