Skip to content

Commit 74eebc7

Browse files
committed
chore: update eslint and babel config
1 parent 0180f10 commit 74eebc7

File tree

5 files changed

+149
-57
lines changed

5 files changed

+149
-57
lines changed

.eslintrc.json

Lines changed: 75 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,31 @@
66
"plugin:prettier/recommended"
77
],
88
"overrides": [
9-
{
10-
"files": [
11-
"packages/**/test/**/*.test.js",
12-
"packages/**/test/**/test.js"
13-
],
14-
"rules": {
15-
"taro/no-stateless-component": "off",
16-
"react/react-in-jsx-scope": "off",
17-
"react/no-find-dom-node": "off",
18-
"no-unused-vars": [
19-
"error",
20-
{
21-
"varsIgnorePattern": "Nerv"
22-
}
23-
]
24-
}
25-
},
269
{
2710
"files": [
2811
"packages/**/*.ts",
2912
"packages/**/*.tsx"
3013
],
3114
"parser": "@typescript-eslint/parser",
15+
"parserOptions": {
16+
"ecmaVersion": 2017,
17+
"sourceType": "module",
18+
"ecmaFeatures": {
19+
"jsx": true
20+
},
21+
"warnOnUnsupportedTypeScriptVersion": true
22+
},
3223
"plugins": [
3324
"@typescript-eslint"
3425
],
3526
"extends": [
36-
"eslint:recommended",
3727
"plugin:@typescript-eslint/eslint-recommended",
3828
"plugin:@typescript-eslint/recommended",
3929
"plugin:import/errors",
4030
"plugin:import/warnings",
4131
"plugin:import/typescript",
4232
"plugin:react/recommended",
43-
"plugin:react-hooks/recommended",
44-
"plugin:prettier/recommended"
33+
"plugin:react-hooks/recommended"
4534
],
4635
"rules": {
4736
"@typescript-eslint/no-explicit-any": [
@@ -52,7 +41,6 @@
5241
],
5342
"class-methods-use-this": "off",
5443
"prefer-rest-params": "off",
55-
"arrow-body-style": "warn",
5644
"react/jsx-filename-extension": [
5745
2,
5846
{
@@ -63,34 +51,73 @@
6351
".tsx"
6452
]
6553
}
54+
],
55+
"no-unused-vars": [
56+
"error",
57+
{
58+
"varsIgnorePattern": "React"
59+
}
60+
],
61+
"no-console": [
62+
"error",
63+
{
64+
"allow": [
65+
"warn",
66+
"error"
67+
]
68+
}
69+
],
70+
"camelcase": [
71+
"error",
72+
{
73+
"allow": [
74+
"^UNSAFE_"
75+
]
76+
}
6677
]
78+
},
79+
"settings": {
80+
"react": {
81+
"version": "detect"
82+
}
6783
}
6884
},
6985
{
7086
"files": [
71-
"packages/taro-ui-docs/**/*.js",
72-
"packages/taro-ui-docs/**/*.jsx"
87+
"packages/**/*.js",
88+
"packages/**/*.jsx"
7389
],
7490
"parser": "babel-eslint",
7591
"parserOptions": {
92+
"ecmaVersion": 2017,
93+
"ecmaFeatures": {
94+
"jsx": true
95+
},
7696
"babelOptions": {
7797
"configFile": "./babel.config.json",
7898
"rootMode": "upward"
7999
}
80100
},
81101
"extends": [
82-
"eslint:recommended",
83102
"plugin:import/errors",
84103
"plugin:import/warnings",
85104
"plugin:react/recommended",
86-
"plugin:react-hooks/recommended",
87-
"plugin:prettier/recommended"
105+
"plugin:react-hooks/recommended"
88106
],
89107
"rules": {
90108
"class-methods-use-this": "off",
91109
"prefer-rest-params": "off",
92-
"arrow-body-style": "warn",
93-
"taro/custom-component-children": "off",
110+
"react/jsx-filename-extension": [
111+
2,
112+
{
113+
"extensions": [
114+
".js",
115+
".jsx",
116+
".ts",
117+
".tsx"
118+
]
119+
}
120+
],
94121
"no-unused-vars": [
95122
"error",
96123
{
@@ -131,6 +158,9 @@
131158
"packages/taro-ui-docs"
132159
]
133160
}
161+
},
162+
"react": {
163+
"version": "detect"
134164
}
135165
}
136166
},
@@ -139,10 +169,26 @@
139169
"packages/taro-ui-docs/build/*.js"
140170
],
141171
"rules": {
142-
"import/no-commonjs": "off",
143172
"no-console": "off",
144173
"no-undefined": "off"
145174
}
175+
},
176+
{
177+
"files": [
178+
"packages/**/test/**/*.test.js",
179+
"packages/**/test/**/test.js"
180+
],
181+
"rules": {
182+
"taro/no-stateless-component": "off",
183+
"react/react-in-jsx-scope": "off",
184+
"react/no-find-dom-node": "off",
185+
"no-unused-vars": [
186+
"error",
187+
{
188+
"varsIgnorePattern": "Nerv"
189+
}
190+
]
191+
}
146192
}
147193
]
148194
}

babel.config.json

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
{
22
"overrides": [
3-
{
4-
"include": "packages/taro-ui-demo/**",
5-
"presets": [
6-
[
7-
"taro",
8-
{
9-
"framework": "react",
10-
"ts": true
11-
}
12-
]
13-
]
14-
},
153
{
164
"include": "packages/taro-ui-docs/**",
175
"presets": [
@@ -31,19 +19,15 @@
3119
},
3220
"loose": false,
3321
"forceAllTransforms": true,
34-
"useBuiltIns": "entry"
22+
"useBuiltIns": "entry",
23+
"corejs": "3.6"
3524
}
36-
]
25+
],
26+
"@babel/preset-react"
3727
],
3828
"plugins": [
3929
"@babel/plugin-syntax-dynamic-import",
40-
"@babel/plugin-proposal-class-properties",
41-
[
42-
"@babel/plugin-transform-react-jsx",
43-
{
44-
"pragma": "React.createElement"
45-
}
46-
]
30+
"@babel/plugin-proposal-class-properties"
4731
]
4832
}
4933
]

packages/taro-ui-demo/.eslintrc.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

packages/taro-ui-demo/.eslintrc.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"root": true,
3+
"extends": [
4+
"plugin:import/errors",
5+
"plugin:import/warnings",
6+
"plugin:react/recommended",
7+
"plugin:react-hooks/recommended",
8+
"taro/react"
9+
],
10+
"overrides": [
11+
{
12+
"files": [
13+
"*.ts",
14+
"*.tsx"
15+
],
16+
"extends": [
17+
"plugin:@typescript-eslint/eslint-recommended",
18+
"plugin:@typescript-eslint/recommended",
19+
"plugin:import/typescript"
20+
],
21+
"rules": {
22+
"@typescript-eslint/no-explicit-any": [
23+
"off"
24+
],
25+
"@typescript-eslint/member-delimiter-style": [
26+
"off"
27+
],
28+
"no-console": [
29+
"error",
30+
{
31+
"allow": [
32+
"warn",
33+
"error"
34+
]
35+
}
36+
],
37+
"camelcase": [
38+
"error",
39+
{
40+
"allow": [
41+
"^UNSAFE_"
42+
]
43+
}
44+
]
45+
}
46+
},
47+
{
48+
"files": [
49+
"./babel.config.js"
50+
],
51+
"rules": {
52+
"import/no-commonjs": "off"
53+
}
54+
}
55+
]
56+
}

packages/taro-ui-demo/babel.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// babel-preset-taro 更多选项和默认值:
2+
// https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
3+
module.exports = {
4+
presets: [
5+
[
6+
'taro',
7+
{
8+
framework: 'react',
9+
ts: true
10+
}
11+
]
12+
]
13+
}

0 commit comments

Comments
 (0)