Skip to content

Commit 693f484

Browse files
author
linfeng
committed
feat: add prettierrc and remove prettier from eslint
1 parent b501a31 commit 693f484

6 files changed

Lines changed: 49 additions & 135 deletions

File tree

.eslintrc

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,7 @@
1313
},
1414
"import/resolver": {
1515
"node": {
16-
"extensions": [
17-
".js",
18-
".jsx",
19-
".ts",
20-
".tsx",
21-
".eslintrc"
22-
]
16+
"extensions": [".js", ".jsx", ".ts", ".tsx", ".eslintrc"]
2317
},
2418
"webpack": {
2519
"config": {
@@ -32,37 +26,18 @@
3226
}
3327
}
3428
},
35-
"plugins": [
36-
"babel",
37-
"@typescript-eslint",
38-
"react-hooks"
39-
],
29+
"plugins": ["babel", "@typescript-eslint", "react-hooks"],
4030
"extends": [
4131
"eslint:recommended",
4232
"plugin:@typescript-eslint/recommended",
4333
"plugin:react/recommended",
4434
"airbnb-base",
4535
"prettier/@typescript-eslint",
46-
"plugin:prettier/recommended",
4736
"prettier"
4837
],
4938
"rules": {
50-
"prettier/prettier": [
51-
"error",
52-
{
53-
"printWidth": 120,
54-
"semi": true,
55-
"singleQuote": true,
56-
"tabWidth": 2,
57-
"useTabs": false,
58-
"trailingComma": "all"
59-
}
60-
],
6139
"func-names": 0,
62-
"one-var": [
63-
1,
64-
"never"
65-
],
40+
"one-var": [1, "never"],
6641
"prefer-const": 1,
6742
"no-unused-expressions": 1,
6843
"new-cap": 2,
@@ -84,11 +59,7 @@
8459
"no-console": [
8560
2,
8661
{
87-
"allow": [
88-
"info",
89-
"error",
90-
"warn"
91-
]
62+
"allow": ["info", "error", "warn"]
9263
}
9364
],
9465
"no-duplicate-imports": 2,
@@ -101,10 +72,7 @@
10172
"no-unused-vars": 0,
10273
"@typescript-eslint/no-unused-vars": 1,
10374
"react/self-closing-comp": 2,
104-
"react/jsx-indent-props": [
105-
2,
106-
2
107-
],
75+
"react/jsx-indent-props": [2, 2],
10876
"no-plusplus": 0,
10977
"react/jsx-uses-vars": 1,
11078
"react/no-multi-comp": [
@@ -154,4 +122,4 @@
154122
}
155123
]
156124
}
157-
}
125+
}

.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"printWidth": 120,
3+
"semi": true,
4+
"singleQuote": true,
5+
"tabWidth": 2,
6+
"useTabs": false,
7+
"trailingComma": "all"
8+
}

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
"eslint.provideLintTask": true,
1818
"typescript.format.enable": false,
1919
"javascript.format.enable": false
20-
}
20+
}

src/built-in-plugins/ensure-project-files/plugin/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const main = async () => {
2929
ensureTsconfig();
3030
ensureVscode();
3131
ensureEslint();
32+
ensurePrettier();
3233
ensureRootPackageJson();
3334
ensurePriConfig();
3435

@@ -136,6 +137,17 @@ function ensureEslint() {
136137
});
137138
}
138139

140+
function ensurePrettier() {
141+
pri.project.addProjectFiles({
142+
fileName: path.join(pri.projectRootPath, '.prettierrc'),
143+
pipeContent: async () => {
144+
const prettierConfig = await fs.readFile(path.join(__dirname, '../../../../.prettierrc'));
145+
146+
return `${prettierConfig.toString()}\n`;
147+
},
148+
});
149+
}
150+
139151
function ensureVscode() {
140152
pri.project.addProjectFiles({
141153
fileName: path.join(pri.projectRootPath, '.vscode/settings.json'),

src/utils/structor-config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export const ignoreScanFiles = _.union([
126126
'package.json',
127127
'tsconfig.json',
128128
'.eslintrc',
129+
'.prettierrc',
129130
'.npmrc',
130131
'.travis.yml',
131132
'.prettierignore',

yarn.lock

Lines changed: 21 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,11 +1497,6 @@
14971497
resolved "https://registry.npm.alibaba-inc.com/@types/node/download/@types/node-12.6.8.tgz#e469b4bf9d1c9832aee4907ba8a051494357c12c"
14981498
integrity sha1-5Gm0v50cmDKu5JB7qKBRSUNXwSw=
14991499

1500-
"@types/normalize-package-data@^2.4.0":
1501-
version "2.4.0"
1502-
resolved "https://registry.npm.alibaba-inc.com/@types/normalize-package-data/download/@types/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"
1503-
integrity sha1-5IbQ2XOW15vu3QpuM/RTT/a0lz4=
1504-
15051500
"@types/prop-types@*":
15061501
version "15.7.1"
15071502
resolved "https://registry.npm.alibaba-inc.com/@types/prop-types/download/@types/prop-types-15.7.1.tgz#f1a11e7babb0c3cad68100be381d1e064c68f1f6"
@@ -3656,9 +3651,9 @@ cors@2.8.5:
36563651
object-assign "^4"
36573652
vary "^1"
36583653

3659-
cosmiconfig@^5.0.0, cosmiconfig@^5.2.1:
3654+
cosmiconfig@^5.0.0, cosmiconfig@^5.0.7:
36603655
version "5.2.1"
3661-
resolved "https://registry.npm.alibaba-inc.com/cosmiconfig/download/cosmiconfig-5.2.1.tgz#040f726809c591e77a17c0a3626ca45b4f168b1a"
3656+
resolved "https://registry.npm.taobao.org/cosmiconfig/download/cosmiconfig-5.2.1.tgz#040f726809c591e77a17c0a3626ca45b4f168b1a"
36623657
integrity sha1-BA9yaAnFked6F8CjYmykW08Wixo=
36633658
dependencies:
36643659
import-fresh "^2.0.0"
@@ -5263,14 +5258,6 @@ find-up@^3.0.0:
52635258
dependencies:
52645259
locate-path "^3.0.0"
52655260

5266-
find-up@^4.0.0:
5267-
version "4.1.0"
5268-
resolved "https://registry.npm.alibaba-inc.com/find-up/download/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19"
5269-
integrity sha1-l6/n1s3AvFkoWEt8jXsW6KmqXRk=
5270-
dependencies:
5271-
locate-path "^5.0.0"
5272-
path-exists "^4.0.0"
5273-
52745261
findup-sync@^2.0.0:
52755262
version "2.0.0"
52765263
resolved "https://registry.npm.alibaba-inc.com/findup-sync/download/findup-sync-2.0.0.tgz#9326b1488c22d1a6088650a86901b2d9a90a2cbc"
@@ -5551,11 +5538,6 @@ get-stdin@^6.0.0:
55515538
resolved "https://registry.npm.alibaba-inc.com/get-stdin/download/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b"
55525539
integrity sha1-ngm/cSs2CrkiXoEgSPcf3pyJZXs=
55535540

5554-
get-stdin@^7.0.0:
5555-
version "7.0.0"
5556-
resolved "https://registry.npm.alibaba-inc.com/get-stdin/download/get-stdin-7.0.0.tgz#8d5de98f15171a125c5e516643c7a6d0ea8a96f6"
5557-
integrity sha1-jV3pjxUXGhJcXlFmQ8em0OqKlvY=
5558-
55595541
get-stream@^3.0.0:
55605542
version "3.0.0"
55615543
resolved "https://registry.npm.alibaba-inc.com/get-stream/download/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14"
@@ -6373,21 +6355,21 @@ https-proxy-agent@^2.2.1:
63736355
agent-base "^4.3.0"
63746356
debug "^3.1.0"
63756357

6376-
husky@3.0.0:
6377-
version "3.0.0"
6378-
resolved "https://registry.npm.alibaba-inc.com/husky/download/husky-3.0.0.tgz#de63821a7049dc412b1afd753c259e2f6e227562"
6379-
integrity sha1-3mOCGnBJ3EErGv11PCWeL24idWI=
6358+
husky@1.3.1:
6359+
version "1.3.1"
6360+
resolved "https://registry.npm.taobao.org/husky/download/husky-1.3.1.tgz#26823e399300388ca2afff11cfa8a86b0033fae0"
6361+
integrity sha1-JoI+OZMAOIyir/8Rz6ioawAz+uA=
63806362
dependencies:
6381-
cosmiconfig "^5.2.1"
6363+
cosmiconfig "^5.0.7"
63826364
execa "^1.0.0"
6383-
get-stdin "^7.0.0"
6365+
find-up "^3.0.0"
6366+
get-stdin "^6.0.0"
63846367
is-ci "^2.0.0"
6385-
opencollective-postinstall "^2.0.2"
6386-
pkg-dir "^4.2.0"
6368+
pkg-dir "^3.0.0"
63876369
please-upgrade-node "^3.1.1"
6388-
read-pkg "^5.1.1"
6370+
read-pkg "^4.0.1"
63896371
run-node "^1.0.0"
6390-
slash "^3.0.0"
6372+
slash "^2.0.0"
63916373

63926374
hyphenate-style-name@^1.0.3:
63936375
version "1.0.3"
@@ -8019,11 +8001,6 @@ liftoff@^3.1.0:
80198001
rechoir "^0.6.2"
80208002
resolve "^1.1.7"
80218003

8022-
lines-and-columns@^1.1.6:
8023-
version "1.1.6"
8024-
resolved "https://registry.npm.alibaba-inc.com/lines-and-columns/download/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
8025-
integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=
8026-
80278004
load-json-file@^1.0.0:
80288005
version "1.1.0"
80298006
resolved "https://registry.npm.alibaba-inc.com/load-json-file/download/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0"
@@ -8095,13 +8072,6 @@ locate-path@^3.0.0:
80958072
p-locate "^3.0.0"
80968073
path-exists "^3.0.0"
80978074

8098-
locate-path@^5.0.0:
8099-
version "5.0.0"
8100-
resolved "https://registry.npm.alibaba-inc.com/locate-path/download/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0"
8101-
integrity sha1-Gvujlq/WdqbUJQTQpno6frn2KqA=
8102-
dependencies:
8103-
p-locate "^4.1.0"
8104-
81058075
lodash._arrayeach@^3.0.0:
81068076
version "3.0.0"
81078077
resolved "https://registry.npm.alibaba-inc.com/lodash._arrayeach/download/lodash._arrayeach-3.0.0.tgz#bab156b2a90d3f1bbd5c653403349e5e5933ef9e"
@@ -9055,7 +9025,7 @@ nopt@^4.0.1:
90559025
abbrev "1"
90569026
osenv "^0.1.4"
90579027

9058-
normalize-package-data@^2.3.2, normalize-package-data@^2.3.4, normalize-package-data@^2.5.0:
9028+
normalize-package-data@^2.3.2, normalize-package-data@^2.3.4:
90599029
version "2.5.0"
90609030
resolved "https://registry.npm.alibaba-inc.com/normalize-package-data/download/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8"
90619031
integrity sha1-5m2xg4sgDB38IzIl0SyzZSDiNKg=
@@ -9329,11 +9299,6 @@ open@6.4.0:
93299299
dependencies:
93309300
is-wsl "^1.1.0"
93319301

9332-
opencollective-postinstall@^2.0.2:
9333-
version "2.0.2"
9334-
resolved "https://registry.npm.alibaba-inc.com/opencollective-postinstall/download/opencollective-postinstall-2.0.2.tgz#5657f1bede69b6e33a45939b061eb53d3c6c3a89"
9335-
integrity sha1-Vlfxvt5ptuM6RZObBh61PTxsOok=
9336-
93379302
opener@^1.5.1:
93389303
version "1.5.1"
93399304
resolved "https://registry.npm.alibaba-inc.com/opener/download/opener-1.5.1.tgz#6d2f0e77f1a0af0032aca716c2c1fbb8e7e8abed"
@@ -9473,7 +9438,7 @@ p-limit@^1.1.0:
94739438
dependencies:
94749439
p-try "^1.0.0"
94759440

9476-
p-limit@^2.0.0, p-limit@^2.2.0:
9441+
p-limit@^2.0.0:
94779442
version "2.2.0"
94789443
resolved "https://registry.npm.alibaba-inc.com/p-limit/download/p-limit-2.2.0.tgz#417c9941e6027a9abcba5092dd2904e255b5fbc2"
94799444
integrity sha1-QXyZQeYCepq8ulCS3SkE4lW1+8I=
@@ -9494,13 +9459,6 @@ p-locate@^3.0.0:
94949459
dependencies:
94959460
p-limit "^2.0.0"
94969461

9497-
p-locate@^4.1.0:
9498-
version "4.1.0"
9499-
resolved "https://registry.npm.alibaba-inc.com/p-locate/download/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07"
9500-
integrity sha1-o0KLtwiLOmApL2aRkni3wpetTwc=
9501-
dependencies:
9502-
p-limit "^2.2.0"
9503-
95049462
p-map@^2.0.0:
95059463
version "2.1.0"
95069464
resolved "https://registry.npm.alibaba-inc.com/p-map/download/p-map-2.1.0.tgz#310928feef9c9ecc65b68b17693018a665cea175"
@@ -9631,16 +9589,6 @@ parse-json@^4.0.0:
96319589
error-ex "^1.3.1"
96329590
json-parse-better-errors "^1.0.1"
96339591

9634-
parse-json@^5.0.0:
9635-
version "5.0.0"
9636-
resolved "https://registry.npm.alibaba-inc.com/parse-json/download/parse-json-5.0.0.tgz#73e5114c986d143efa3712d4ea24db9a4266f60f"
9637-
integrity sha1-c+URTJhtFD76NxLU6iTbmkJm9g8=
9638-
dependencies:
9639-
"@babel/code-frame" "^7.0.0"
9640-
error-ex "^1.3.1"
9641-
json-parse-better-errors "^1.0.1"
9642-
lines-and-columns "^1.1.6"
9643-
96449592
parse-node-version@^1.0.0:
96459593
version "1.0.1"
96469594
resolved "https://registry.npm.alibaba-inc.com/parse-node-version/download/parse-node-version-1.0.1.tgz#e2b5dbede00e7fa9bc363607f53327e8b073189b"
@@ -9707,11 +9655,6 @@ path-exists@^3.0.0:
97079655
resolved "https://registry.npm.alibaba-inc.com/path-exists/download/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515"
97089656
integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=
97099657

9710-
path-exists@^4.0.0:
9711-
version "4.0.0"
9712-
resolved "https://registry.npm.alibaba-inc.com/path-exists/download/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3"
9713-
integrity sha1-UTvb4tO5XXdi6METfvoZXGxhtbM=
9714-
97159658
path-is-absolute@1.0.1, path-is-absolute@^1.0.0, path-is-absolute@^1.0.1:
97169659
version "1.0.1"
97179660
resolved "https://registry.npm.alibaba-inc.com/path-is-absolute/download/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
@@ -9856,13 +9799,6 @@ pkg-dir@^3.0.0:
98569799
dependencies:
98579800
find-up "^3.0.0"
98589801

9859-
pkg-dir@^4.2.0:
9860-
version "4.2.0"
9861-
resolved "https://registry.npm.alibaba-inc.com/pkg-dir/download/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3"
9862-
integrity sha1-8JkTPfft5CLoHR2ESCcO6z5CYfM=
9863-
dependencies:
9864-
find-up "^4.0.0"
9865-
98669802
please-upgrade-node@^3.1.1:
98679803
version "3.1.1"
98689804
resolved "https://registry.npm.alibaba-inc.com/please-upgrade-node/download/please-upgrade-node-3.1.1.tgz#ed320051dfcc5024fae696712c8288993595e8ac"
@@ -10791,15 +10727,14 @@ read-pkg@^3.0.0:
1079110727
normalize-package-data "^2.3.2"
1079210728
path-type "^3.0.0"
1079310729

10794-
read-pkg@^5.1.1:
10795-
version "5.2.0"
10796-
resolved "https://registry.npm.alibaba-inc.com/read-pkg/download/read-pkg-5.2.0.tgz#7bf295438ca5a33e56cd30e053b34ee7250c93cc"
10797-
integrity sha1-e/KVQ4yloz5WzTDgU7NO5yUMk8w=
10730+
read-pkg@^4.0.1:
10731+
version "4.0.1"
10732+
resolved "https://registry.npm.taobao.org/read-pkg/download/read-pkg-4.0.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fread-pkg%2Fdownload%2Fread-pkg-4.0.1.tgz#963625378f3e1c4d48c85872b5a6ec7d5d093237"
10733+
integrity sha1-ljYlN48+HE1IyFhytabsfV0JMjc=
1079810734
dependencies:
10799-
"@types/normalize-package-data" "^2.4.0"
10800-
normalize-package-data "^2.5.0"
10801-
parse-json "^5.0.0"
10802-
type-fest "^0.6.0"
10735+
normalize-package-data "^2.3.2"
10736+
parse-json "^4.0.0"
10737+
pify "^3.0.0"
1080310738

1080410739
"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.5, readable-stream@^2.3.6, readable-stream@~2.3.6:
1080510740
version "2.3.6"
@@ -11662,11 +11597,6 @@ slash@^2.0.0:
1166211597
resolved "https://registry.npm.alibaba-inc.com/slash/download/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44"
1166311598
integrity sha1-3lUoUaF1nfOo8gZTVEL17E3eq0Q=
1166411599

11665-
slash@^3.0.0:
11666-
version "3.0.0"
11667-
resolved "https://registry.npm.alibaba-inc.com/slash/download/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
11668-
integrity sha1-ZTm+hwwWWtvVJAIg2+Nh8bxNRjQ=
11669-
1167011600
slice-ansi@^2.1.0:
1167111601
version "2.1.0"
1167211602
resolved "https://registry.npm.alibaba-inc.com/slice-ansi/download/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636"
@@ -12662,11 +12592,6 @@ type-fest@^0.5.2:
1266212592
resolved "https://registry.npm.alibaba-inc.com/type-fest/download/type-fest-0.5.2.tgz#d6ef42a0356c6cd45f49485c3b6281fc148e48a2"
1266312593
integrity sha1-1u9CoDVsbNRfSUhcO2KB/BSOSKI=
1266412594

12665-
type-fest@^0.6.0:
12666-
version "0.6.0"
12667-
resolved "https://registry.npm.alibaba-inc.com/type-fest/download/type-fest-0.6.0.tgz#8d2a2370d3df886eb5c90ada1c5bf6188acf838b"
12668-
integrity sha1-jSojcNPfiG61yQraHFv2GIrPg4s=
12669-
1267012595
type-is@^1.6.16, type-is@~1.6.17, type-is@~1.6.18:
1267112596
version "1.6.18"
1267212597
resolved "https://registry.npm.alibaba-inc.com/type-is/download/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131"

0 commit comments

Comments
 (0)