代码编织梦想

1 安装 yarn add prettier eslint eslint-plugin-vue 

2 配置文件 .prettierrc 

{

"tabWidth": 2,

"printWidth": 120,

"semi": true,

"singleQuote": true,

"bracketSpacing": true,

"jsxBracketSameLine": false,

"arrowParens": "avoid",

"requirePragma": false,

"proseWrap": "preserve"

}

3配置.eslintrc.cjs

/* eslint-env node */

require('@rushstack/eslint-patch/modern-module-resolution');

module.exports = {

root: true,

extends: ['plugin:vue/vue3-essential', 'eslint:recommended', '@vue/eslint-config-prettier'],

plugins: ['prettier'],

parserOptions: {

ecmaVersion: 'latest',

},

rules: {

'no-unused-vars': 0,

indent: ['error', 2],

'vue/multi-word-component-names': 0,

'prettier/prettier': [

'error',

{

tabWidth: 2,

},

],

},

};

4每次服务器写完代码就

  •  

    npx prettier --write "src/**/*.js"

  •  

    npx prettier --write "src/**/*.vue"

  •  

    npx prettier --write "src/**/*.tsx"

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/xiaobai215sl/article/details/131022231