Skip to content

Commit 367faaf

Browse files
committed
build(eslint): 增加prettierrc
1 parent af13aec commit 367faaf

6 files changed

+60
-10
lines changed

.eslintrc.js

+4-9
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,20 @@
22
* @Author: 秦少卫
33
* @Date: 2022-09-03 19:22:16
44
* @LastEditors: 秦少卫
5-
* @LastEditTime: 2023-02-09 13:22:52
5+
* @LastEditTime: 2023-02-16 20:38:11
66
* @Description: file content
77
*/
88
module.exports = {
99
root: true,
1010
env: {
1111
node: true,
1212
},
13-
extends: [
14-
'plugin:vue/essential',
15-
'@vue/airbnb',
16-
],
13+
extends: ['plugin:vue/essential', '@vue/airbnb', 'plugin:prettier/recommended'],
1714
parserOptions: {
1815
parser: '@babel/eslint-parser',
1916
},
2017
rules: {
18+
'prettier/prettier': 'error',
2119
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
2220
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
2321
'no-plusplus': 'off',
@@ -31,10 +29,7 @@ module.exports = {
3129
},
3230
overrides: [
3331
{
34-
files: [
35-
'**/__tests__/*.{j,t}s?(x)',
36-
'**/tests/unit/**/*.spec.{j,t}s?(x)',
37-
],
32+
files: ['**/__tests__/*.{j,t}s?(x)', '**/tests/unit/**/*.spec.{j,t}s?(x)'],
3833
env: {
3934
jest: true,
4035
},

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pnpm-debug.log*
1515

1616
# Editor directories and files
1717
.idea
18-
.vscode
18+
# .vscode
1919
*.suo
2020
*.ntvs*
2121
*.njsproj

.prettierignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
5+
6+
# local env files
7+
.env.local
8+
.env.*.local
9+
10+
# Log files
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
pnpm-debug.log*
15+
16+
# Editor directories and files
17+
.idea
18+
.vscode
19+
*.suo
20+
*.ntvs*
21+
*.njsproj
22+
*.sln
23+
*.sw?
24+
25+
yarn.lock

.prettierrc.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
"printWidth": 100, // 指定代码长度,超出换行
3+
"tabWidth": 2, // tab 键的宽度
4+
"useTabs": false, // 不使用tab
5+
"semi": true, // 结尾加上分号
6+
"singleQuote": true, // 使用单引号
7+
"quoteProps": "as-needed", // 要求对象字面量属性是否使用引号包裹,(‘as-needed’: 没有特殊要求,禁止使用,'consistent': 保持一致 , preserve: 不限制,想用就用)
8+
"jsxSingleQuote": false, // jsx 语法中使用单引号
9+
"trailingComma": "es5", // 确保对象的最后一个属性后有逗号
10+
"bracketSpacing": true, // 大括号有空格 { name: 'rose' }
11+
"jsxBracketSameLine": false, // 在多行JSX元素的最后一行追加 >
12+
"arrowParens": "always", // 箭头函数,单个参数添加括号
13+
"requirePragma": false, // 是否严格按照文件顶部的特殊注释格式化代码
14+
"insertPragma": false, // 是否在格式化的文件顶部插入Pragma标记,以表明该文件被prettier格式化过了
15+
"proseWrap": "preserve", // 按照文件原样折行
16+
"htmlWhitespaceSensitivity": "ignore", // html文件的空格敏感度,控制空格是否影响布局
17+
"endOfLine": "auto" // 结尾是 \n \r \n\r auto
18+
}

.vscode/settings.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"eslint.enable": true,
3+
"editor.codeActionsOnSave": {
4+
"source.fixAll.eslint": true
5+
},
6+
"editor.formatOnSave": true,
7+
"editor.defaultFormatter": "esbenp.prettier-vscode",
8+
"prettier.requireConfig": true // 需要Prettier的配置文件
9+
}

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,17 @@
4141
"@vue/vue2-jest": "^27.0.0-alpha.2",
4242
"babel-jest": "^27.0.6",
4343
"eslint": "^7.32.0",
44+
"eslint-config-prettier": "^8.6.0",
4445
"eslint-plugin-import": "^2.25.3",
46+
"eslint-plugin-prettier": "^4.2.1",
4547
"eslint-plugin-vue": "^8.0.3",
4648
"eslint-plugin-vuejs-accessibility": "^1.1.0",
4749
"husky": "^8.0.0",
4850
"jest": "^27.0.5",
4951
"less": "^4.0.0",
5052
"less-loader": "^8.0.0",
5153
"lint-staged": "^13.1.1",
54+
"prettier": "2.8.4",
5255
"vue-template-compiler": "^2.6.14"
5356
},
5457
"lint-staged": {

0 commit comments

Comments
 (0)