Skip to content

Commit a800061

Browse files
committed
调整格式化方案
1 parent ea29e88 commit a800061

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

.eslintrc.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
module.exports = {
2-
extends: ["airbnb", "plugin:prettier/recommended"],
2+
extends: ["airbnb", "plugin:react/recommended"],
33
rules: {
4+
"react/jsx-indent": [2, 2, { checkAttributes: true }],
5+
"no-tabs": ["error", { allowIndentationTabs: true }],
6+
"no-mixed-spaces-and-tabs": ["error", "smart-tabs"],
47
"react/jsx-filename-extension": "off",
58
"react/forbid-prop-types": "off",
69
"jsx-a11y/anchor-is-valid": "off",
@@ -10,9 +13,11 @@ module.exports = {
1013
"jsx-a11y/anchor-is-valid": "off",
1114
"react/no-array-index-key": "off",
1215
"react/jsx-props-no-spreading": "off",
13-
"no-console": "off"
16+
"no-console": "off",
17+
semi: ["error", "always"],
18+
quotes: ["error", "double"],
1419
},
1520
env: {
16-
browser: true
17-
}
21+
browser: true,
22+
},
1823
};

.prettierrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
2-
printWidth: 120, //一行的字符数,如果超过会进行换行,默认为80
3-
tabWidth: 2 //一个tab代表几个空格数,默认为2
2+
tabWidth: 2, //一个tab代表几个空格数,默认为2
3+
trailingComma: "es5", // 对象属性最后有 ","
44
};

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
"build": "react-scripts build",
1313
"test": "react-scripts test",
1414
"eject": "react-scripts eject",
15-
"lint": "eslint src"
15+
"lint": "eslint src --fix",
16+
"format": "npm run lint && pretty-quick --staged"
1617
},
1718
"husky": {
1819
"hooks": {
19-
"pre-commit": "npm run lint && pretty-quick --staged"
20+
"pre-commit": "npm run format"
2021
}
2122
},
2223
"eslintConfig": {

vscode_settings.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"workbench.editor.enablePreview": true,
3+
"workbench.iconTheme": "vscode-great-icons",
4+
"editor.fontSize": 17,
5+
"editor.tabSize": 2,
6+
"editor.codeActionsOnSave": {
7+
"source.fixAll": true
8+
},
9+
"editor.formatOnSave": false,
10+
"eslint.options": {
11+
"extensions": [".js", ".ts", ".tsx"]
12+
},
13+
"eslint.validate": ["javascript", "typescript", "typescriptreact"],
14+
"[javascript]": {
15+
"editor.defaultFormatter": "esbenp.prettier-vscode"
16+
},
17+
"launch": {
18+
"configurations": [],
19+
"compounds": []
20+
}
21+
}

0 commit comments

Comments
 (0)