Skip to content

Commit 93aa641

Browse files
committed
feat: eslint & prettier
1 parent a4d48f9 commit 93aa641

40 files changed

+6376
-4390
lines changed

.babelrc

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
11
{
22
"plugins": [
3-
["module-resolver", {
4-
"root": ["./src"],
5-
"alias": {}
6-
}]
3+
"@babel/plugin-proposal-class-properties",
4+
"@babel/plugin-proposal-object-rest-spread",
5+
[
6+
"module-resolver",
7+
{
8+
"root": [
9+
"./src"
10+
],
11+
"alias": {}
12+
}
13+
]
714
],
815
"presets": [
9-
["env", {"loose": true, "modules": "commonjs"}]
16+
"@babel/typescript",
17+
[
18+
"@babel/env",
19+
{
20+
"targets": {
21+
"chrome": "67"
22+
},
23+
"loose": true,
24+
"useBuiltIns": "usage",
25+
"corejs": {
26+
"version": 3,
27+
"proposals": true
28+
},
29+
"modules": "commonjs"
30+
}
31+
]
1032
]
1133
}

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
src/weui-wxss
3+
miniprogram_dist
4+
miniprogram_dev

.eslintrc.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
module.exports = {
2+
root: true,
3+
parser: '@typescript-eslint/parser',
4+
parserOptions: {
5+
ecmaVersion: 6,
6+
sourceType: 'module'
7+
},
8+
env: {
9+
es6: true,
10+
browser: true,
11+
jest: true,
12+
commonjs: true,
13+
node: true
14+
},
15+
plugins: [
16+
'@typescript-eslint',
17+
'prettier'
18+
],
19+
extends: [
20+
'eslint:recommended',
21+
'plugin:@typescript-eslint/eslint-recommended',
22+
'plugin:@typescript-eslint/recommended',
23+
'prettier/@typescript-eslint'
24+
],
25+
globals: {
26+
wx: true,
27+
App: true,
28+
Page: true,
29+
Component: true
30+
},
31+
rules: {
32+
'prettier/prettier': 'error',
33+
'no-console': ["error", { allow: ["warn", "error"] } ],
34+
'@typescript-eslint/ban-ts-ignore': 'off',
35+
'@typescript-eslint/no-empty-function': 'off'
36+
}
37+
}

.prettierrc.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module.exports = {
2+
// 一行最多 100 字符
3+
printWidth: 100,
4+
// 使用 4 个空格缩进
5+
tabWidth: 4,
6+
// 不使用缩进符,而使用空格
7+
useTabs: false,
8+
// 行尾需要有分号
9+
semi: true,
10+
// 使用单引号
11+
singleQuote: true,
12+
// 对象的 key 仅在必要时用引号
13+
quoteProps: 'as-needed',
14+
// 末尾不需要逗号
15+
trailingComma: 'none',
16+
// 大括号内的首尾需要空格
17+
bracketSpacing: true,
18+
// 箭头函数,只有一个参数的时候,也需要括号
19+
arrowParens: 'always',
20+
// 每个文件格式化的范围是文件的全部内容
21+
rangeStart: 0,
22+
rangeEnd: Infinity,
23+
// 不需要写文件开头的 @prettier
24+
requirePragma: false,
25+
// 不需要自动在文件开头插入 @prettier
26+
insertPragma: false,
27+
// 使用默认的折行标准
28+
proseWrap: 'preserve',
29+
// 根据显示样式决定 html 要不要折行
30+
htmlWhitespaceSensitivity: 'css',
31+
// 换行符使用 lf
32+
endOfLine: 'lf'
33+
};

0 commit comments

Comments
 (0)