@wiajs/core 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.oxfmtrc.jsonc +47 -0
- package/.oxlintrc.json +78 -0
- package/dist/core.cjs +306 -12
- package/dist/core.js +726 -11
- package/dist/core.min.js +11 -5
- package/dist/core.mjs +306 -13
- package/dist/jsx-runtime.js +127 -105
- package/package.json +27 -27
- package/util/tool.js +215 -0
- package/.eslintignore +0 -5
- package/.eslintrc.js +0 -121
- package/.prettierignore +0 -24
- package/prettier.config.js +0 -13
package/package.json
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wiajs/core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "wia app core package",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"core",
|
|
7
|
+
"wia"
|
|
8
|
+
],
|
|
9
|
+
"homepage": "https://www.wia.pub/core",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/wiajs/core/issues"
|
|
12
|
+
},
|
|
13
|
+
"license": "ELv2",
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "Sibyl Yu",
|
|
16
|
+
"email": "sibyl@wia.pub"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/wiajs/wia.git"
|
|
21
|
+
},
|
|
5
22
|
"main": "./dist/core.cjs",
|
|
6
23
|
"module": "./dist/core.mjs",
|
|
7
24
|
"types": "./types/core.d.ts",
|
|
8
|
-
|
|
9
|
-
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
10
27
|
"types": "./types/core.d.ts",
|
|
11
28
|
"require": "./dist/core.cjs",
|
|
12
29
|
"import": "./dist/core.mjs",
|
|
13
30
|
"default": "./dist/core.mjs"
|
|
14
31
|
},
|
|
15
|
-
"./jsx-runtime":
|
|
16
|
-
"./jsx-dev-runtime": "./dist/jsx-runtime.js",
|
|
32
|
+
"./jsx-runtime": "./dist/jsx-runtime.js",
|
|
33
|
+
"./jsx-dev-runtime": "./dist/jsx-runtime.js",
|
|
17
34
|
"./util/*": [
|
|
18
35
|
"./util/*.js",
|
|
19
36
|
"./util/*.d.ts"
|
|
20
|
-
]
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
21
41
|
},
|
|
22
42
|
"scripts": {
|
|
23
43
|
"build": "cross-env NODE_ENV=production gulp build",
|
|
24
44
|
"build-dev": "cross-env NODE_ENV=development gulp build",
|
|
25
45
|
"dev": "cross-env NODE_ENV=development gulp cjs",
|
|
26
|
-
"dev:umd": "cross-env NODE_ENV=development gulp umd",
|
|
27
46
|
"dev:esm": "cross-env NODE_ENV=development gulp esm",
|
|
47
|
+
"dev:umd": "cross-env NODE_ENV=development gulp umd",
|
|
28
48
|
"release": "bash release.sh"
|
|
29
49
|
},
|
|
30
|
-
"repository": {
|
|
31
|
-
"type": "git",
|
|
32
|
-
"url": "git+https://github.com/wiajs/wia.git"
|
|
33
|
-
},
|
|
34
|
-
"keywords": [
|
|
35
|
-
"wia",
|
|
36
|
-
"core"
|
|
37
|
-
],
|
|
38
|
-
"author": {
|
|
39
|
-
"name": "Sibyl Yu",
|
|
40
|
-
"email": "sibyl@wia.pub"
|
|
41
|
-
},
|
|
42
|
-
"license": "ELv2",
|
|
43
|
-
"bugs": {
|
|
44
|
-
"url": "https://github.com/wiajs/core/issues"
|
|
45
|
-
},
|
|
46
|
-
"homepage": "https://www.wia.pub/core",
|
|
47
|
-
"publishConfig": {
|
|
48
|
-
"access": "public"
|
|
49
|
-
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@rollup/plugin-babel": "^6.0.3",
|
|
52
52
|
"@rollup/plugin-commonjs": "^25.0.1",
|
package/util/tool.js
CHANGED
|
@@ -200,6 +200,220 @@ function serObj(obj) {
|
|
|
200
200
|
.join('&');
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
+
/**
|
|
204
|
+
* 金额千位分隔符字符串转换为 Number,单位分
|
|
205
|
+
* 避免运算误差!
|
|
206
|
+
* @param {String} v 金额千位分隔符金额字符串
|
|
207
|
+
* @returns Number 整型金额,单位分
|
|
208
|
+
*/
|
|
209
|
+
function toFen(v) {
|
|
210
|
+
let R = v
|
|
211
|
+
if (typeof v === 'string') R = Math.round(Number.parseFloat(v.replaceAll(',', '')) * 100)
|
|
212
|
+
return R
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* 金额千位分隔符字符串
|
|
217
|
+
* @param {Number} v 金额,单位分
|
|
218
|
+
* @returns
|
|
219
|
+
*/
|
|
220
|
+
function toYuan(v) {
|
|
221
|
+
let R = v
|
|
222
|
+
|
|
223
|
+
if (typeof v === 'number') {
|
|
224
|
+
v = `${(v * 0.01).toFixed(2)}` // 分到元
|
|
225
|
+
// 千分符的正则
|
|
226
|
+
const reg = v.includes('.') ? /(\d{1,3})(?=(?:\d{3})+\.)/g : /(\d{1,3})(?=(?:\d{3})+$)/g
|
|
227
|
+
R = v.replace(reg, '$1,') // 千分位格式化
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return R
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* 延迟promise,可以 await 或 then
|
|
235
|
+
* @param {number} ms - 毫秒
|
|
236
|
+
*/
|
|
237
|
+
function delay(ms) {
|
|
238
|
+
return new Promise(succ => {
|
|
239
|
+
setTimeout(succ, ms)
|
|
240
|
+
})
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* 简单异步函数转换为promise函数
|
|
245
|
+
* @param {*} f
|
|
246
|
+
* @param {*} type
|
|
247
|
+
* 0:一个回调,一个参数,无失败参数,仅仅返回执行结果
|
|
248
|
+
* 1: 一个回调函数,第一个参数为 err,第二个参数为成功结果
|
|
249
|
+
* 2:两个回调函数,第一个为成功回调,第二个为失败回调
|
|
250
|
+
* 3:两个回调函数,第一个为失败回调,第二个为成功回调
|
|
251
|
+
* @returns
|
|
252
|
+
*/
|
|
253
|
+
function promisify(f, type = 1) {
|
|
254
|
+
return (...arg) =>
|
|
255
|
+
new Promise((res, rej) => {
|
|
256
|
+
if (type == null || type === 1)
|
|
257
|
+
f(...arg, (err, rs) => {
|
|
258
|
+
if (err) rej(err)
|
|
259
|
+
else res(rs)
|
|
260
|
+
})
|
|
261
|
+
else if (type === 0) f(...arg, rs => res(rs))
|
|
262
|
+
else if (type === 2)
|
|
263
|
+
f(
|
|
264
|
+
...arg,
|
|
265
|
+
rs => res(rs),
|
|
266
|
+
rs => rej(rs || new Error('reject'))
|
|
267
|
+
)
|
|
268
|
+
else if (type === 3)
|
|
269
|
+
f(
|
|
270
|
+
...arg,
|
|
271
|
+
rs => res(rs),
|
|
272
|
+
rs => rej(rs || new Error('reject'))
|
|
273
|
+
)
|
|
274
|
+
})
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* 格式化数字:保留 cnt 位小数并添加千位分隔符
|
|
279
|
+
* @param {number} num - 需要格式化的数字
|
|
280
|
+
* @param {number} [cnt] - 小数位数
|
|
281
|
+
* @returns {string} 格式化后的字符串
|
|
282
|
+
*/
|
|
283
|
+
function formatNum(num, cnt = 2) {
|
|
284
|
+
if (typeof num !== 'number' || isNaN(num)) {
|
|
285
|
+
return '0.00' // 如果不是数字,返回默认值
|
|
286
|
+
}
|
|
287
|
+
return num.toLocaleString('en-US', {
|
|
288
|
+
minimumFractionDigits: cnt, // 最少保留 2 位小数
|
|
289
|
+
maximumFractionDigits: cnt, // 最多保留 2 位小数
|
|
290
|
+
})
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* 判断参数是否为空
|
|
295
|
+
* @param {*} p
|
|
296
|
+
* @returns {boolean}
|
|
297
|
+
* true: undefined/null/''/空对象/空数组/空Map/空Set
|
|
298
|
+
* false: false/0/非空对象、非空数组、值
|
|
299
|
+
*/
|
|
300
|
+
function isEmpty(p) {
|
|
301
|
+
if (p === undefined || p === null || p === '') {
|
|
302
|
+
return true
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (typeof p === 'string' && p.trim() === '') {
|
|
306
|
+
return true
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (Array.isArray(p) && p.length === 0) {
|
|
310
|
+
return true
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (p instanceof Map && p.size === 0) {
|
|
314
|
+
return true
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (p instanceof Set && p.size === 0) {
|
|
318
|
+
return true
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// 检查普通空对象
|
|
322
|
+
if (typeof p === 'object' && p !== null && p.constructor === Object && Object.keys(p).length === 0) {
|
|
323
|
+
return true
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return false
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* 日期判断
|
|
331
|
+
* @param {*} v
|
|
332
|
+
* @returns
|
|
333
|
+
*/
|
|
334
|
+
function isDate(v) {
|
|
335
|
+
return v instanceof Date
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* 是否为数字
|
|
340
|
+
* @param {*} value
|
|
341
|
+
* @returns {boolean}
|
|
342
|
+
*/
|
|
343
|
+
function isNumber(value) {
|
|
344
|
+
let R = false
|
|
345
|
+
if (typeof value === 'number') R = true
|
|
346
|
+
else R = Number.isFinite(Number(value)) && value.trim() !== ''
|
|
347
|
+
|
|
348
|
+
return R
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* 检查参数,不满足条件抛出异常
|
|
353
|
+
* 1. 非数组:null/undefined/''/空对象
|
|
354
|
+
* 2. 数组:其中一个元素 null/undefined/''/空对象
|
|
355
|
+
* @param {*} p 参数
|
|
356
|
+
* @param {string=} msg
|
|
357
|
+
*/
|
|
358
|
+
function needParam(p, msg) {
|
|
359
|
+
if (isEmpty(p)) throw new Err(Err.MissParam, msg)
|
|
360
|
+
|
|
361
|
+
if (Array.isArray(p)) {
|
|
362
|
+
if (p.some(m => isEmpty(m))) throw new Err(Err.MissParam, msg)
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* 签名,添加 signTime 和 sign 属性
|
|
368
|
+
* 签名120/30秒内有效,只能使用一次,防止重放攻击或重复提交
|
|
369
|
+
* signTime:1970/1/1 以来的【毫秒数】,不用秒,避免重复
|
|
370
|
+
* post 签名,参数需排序,signTime、Sign 不参与排序放最后,其他字段按字母排序
|
|
371
|
+
* 不同时刻,不同用户pid,不同订单编号,可避免签名重复
|
|
372
|
+
* 同用户pid的高密集并发重复请求可能导致签名重复
|
|
373
|
+
* 可在入参中增加一个nonce随机数,避免签名重复
|
|
374
|
+
* 【注意】日期类型,自动转换字符串为:Sat Jul 08 2023 21:48:24 GMT+0800 (China Standard Time)
|
|
375
|
+
* 需手动 toISOString 转换为 "2011-10-05T14:48:00.000Z"
|
|
376
|
+
* @param {*} r 被签名对象
|
|
377
|
+
* @param {*} secret 签名密钥
|
|
378
|
+
* @param {{start?: string, nonce?: boolean}} [opts={}] 起始日期,默认 1970
|
|
379
|
+
* @returns 带签名的字符串
|
|
380
|
+
*/
|
|
381
|
+
async function sign(r, secret, opts = {nonce: true}) {
|
|
382
|
+
let R = ''
|
|
383
|
+
|
|
384
|
+
const {start, nonce} = opts
|
|
385
|
+
// 签名时刻,默认 1970/1/1 以来的毫秒
|
|
386
|
+
let signTime = Date.now()
|
|
387
|
+
|
|
388
|
+
if (start) signTime = Math.trunc(Date.now() - Date.parse(start))
|
|
389
|
+
|
|
390
|
+
// 可选,无实际用途的随机参数,避免签名重复
|
|
391
|
+
if (nonce && !r.nonce) r.nonce = Math.floor(Math.random() * 1000000) // 6位随机数
|
|
392
|
+
|
|
393
|
+
R = Object.keys(r)
|
|
394
|
+
.sort()
|
|
395
|
+
.map(k => (isDate(r[k]) ? `${k}=${r[k].toISOString()}` : `${k}=${r[k]}`))
|
|
396
|
+
.join('&')
|
|
397
|
+
|
|
398
|
+
// 兼容 DSC 旧的签名模式(UAir,大写开头)
|
|
399
|
+
if (start) {
|
|
400
|
+
R += `&SignTime=${signTime}`
|
|
401
|
+
r.SignTime = signTime
|
|
402
|
+
r.Sign = (await sha1(`${R}${secret}`)).toUpperCase()
|
|
403
|
+
R += `&Sign=${r.Sign}`
|
|
404
|
+
} else {
|
|
405
|
+
R += `&signTime=${signTime}`
|
|
406
|
+
r.signTime = signTime
|
|
407
|
+
r.sign = (await sha1(`${R}${secret}`)).toUpperCase()
|
|
408
|
+
R += `&sign=${r.sign}`
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// 调试时使用,生产务必关闭,避免泄露密码!!!
|
|
412
|
+
// log.debug(`sign r:${JSON.stringify(r)} R:${R} secret: ${secret}`)
|
|
413
|
+
|
|
414
|
+
return R
|
|
415
|
+
}
|
|
416
|
+
|
|
203
417
|
export {
|
|
204
418
|
StringBuf,
|
|
205
419
|
format,
|
|
@@ -211,4 +425,5 @@ export {
|
|
|
211
425
|
sortObj,
|
|
212
426
|
serObj,
|
|
213
427
|
setTitle,
|
|
428
|
+
toYuan, toFen, promisify, delay, formatNum, isNumber, isDate, needParam, sign
|
|
214
429
|
};
|
package/.eslintrc.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
const rules = {
|
|
2
|
-
// Disable for console/alert
|
|
3
|
-
// 0 关闭 1 警告 2 报错 https://eslint.org/docs/rules/ 中文网址:http://eslint.cn/docs/rules/
|
|
4
|
-
// "arrow-parens": [2, "as-needed"],
|
|
5
|
-
'arrow-parens': [2, 'as-needed', {requireForBlockBody: false}],
|
|
6
|
-
'arrow-body-style': [2, 'as-needed'],
|
|
7
|
-
'global-require': 0,
|
|
8
|
-
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
|
9
|
-
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
|
10
|
-
quotes: [1, 'single'],
|
|
11
|
-
'no-alert': 0,
|
|
12
|
-
'no-trailing-spaces': 0,
|
|
13
|
-
'nonblock-statement-body-position': 0, // [2, "beside"], // if else 强制单行
|
|
14
|
-
'block-spacing': 0, // 对象空格
|
|
15
|
-
'function-paren-newline': 0, // 函数参数换行
|
|
16
|
-
'linebreak-style': 0,
|
|
17
|
-
'lines-between-class-members': 0,
|
|
18
|
-
'class-methods-use-this': 0,
|
|
19
|
-
'import/no-extraneous-dependencies': 0,
|
|
20
|
-
indent: [2, 2, {SwitchCase: 1}],
|
|
21
|
-
'object-curly-spacing': 0,
|
|
22
|
-
'no-plusplus': 0,
|
|
23
|
-
'no-multi-spaces': 0,
|
|
24
|
-
'no-param-reassign': ['warn', {props: false}],
|
|
25
|
-
'no-use-before-define': [2, {functions: false, classes: true}],
|
|
26
|
-
'no-unused-expressions': ['error', {allowShortCircuit: true}],
|
|
27
|
-
'no-underscore-dangle': 0,
|
|
28
|
-
'no-unused-vars': [1, {vars: 'local', args: 'after-used'}],
|
|
29
|
-
'no-cond-assign': ['error', 'except-parens'],
|
|
30
|
-
'no-return-assign': [2, 'except-parens'],
|
|
31
|
-
'no-await-in-loop': 0,
|
|
32
|
-
'import/prefer-default-export': 0,
|
|
33
|
-
'operator-linebreak': 0,
|
|
34
|
-
'generator-star-spacing': 0,
|
|
35
|
-
// if while function 后面的{必须与if在同一行,java风格。
|
|
36
|
-
// "brace-style": [2, "1tbs", { "allowSingleLine": true }]
|
|
37
|
-
|
|
38
|
-
// 数组和对象键值对最后一个逗号, never 参数:不能带末尾的逗号, always参数:必须带末尾的逗号,
|
|
39
|
-
// always-multiline:多行模式必须带逗号,单行模式不能带逗号
|
|
40
|
-
'comma-dangle': [2, 'only-multiline'],
|
|
41
|
-
// 控制逗号前后的空格
|
|
42
|
-
'comma-spacing': [2, {before: false, after: true}],
|
|
43
|
-
// 控制逗号在行尾出现还是在行首出现
|
|
44
|
-
// http://eslint.org/docs/rules/comma-style
|
|
45
|
-
'comma-style': [0, 'last'],
|
|
46
|
-
'max-len': [2, 120, 2],
|
|
47
|
-
curly: [0, 'multi'], // 单行无需大括号
|
|
48
|
-
// 强制方法必须返回值,TypeScript强类型,不配置
|
|
49
|
-
'consistent-return': 0,
|
|
50
|
-
'object-curly-newline': 0,
|
|
51
|
-
semi: 0, // 分号检查
|
|
52
|
-
'space-before-function-paren': 0, // ["error", "never"]
|
|
53
|
-
'func-names': ['error', 'never'],
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
module.exports = {
|
|
57
|
-
root: true, // 停止父目录查找配置
|
|
58
|
-
parser: '@babel/eslint-parser', // "typescript-eslint-parser", "babel-eslint",
|
|
59
|
-
env: {
|
|
60
|
-
es6: true,
|
|
61
|
-
es2017: true,
|
|
62
|
-
es2020: true,
|
|
63
|
-
es2021: true,
|
|
64
|
-
browser: true, // 浏览器环境中的全局变量
|
|
65
|
-
worker: true,
|
|
66
|
-
node: true,
|
|
67
|
-
commonjs: true,
|
|
68
|
-
mongo: true,
|
|
69
|
-
jest: true,
|
|
70
|
-
jquery: true,
|
|
71
|
-
},
|
|
72
|
-
globals: {
|
|
73
|
-
XMLHttpRequest: true,
|
|
74
|
-
Blob: true,
|
|
75
|
-
Document: true,
|
|
76
|
-
FormData: true,
|
|
77
|
-
Dom: true,
|
|
78
|
-
$: true,
|
|
79
|
-
document: true,
|
|
80
|
-
window: true,
|
|
81
|
-
},
|
|
82
|
-
parserOptions: {
|
|
83
|
-
ecmaVersion: 'latest',
|
|
84
|
-
sourceType: 'module',
|
|
85
|
-
ecmaFeatures: {
|
|
86
|
-
jsx: true,
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
plugins: [
|
|
90
|
-
// 插件,需安装好,配置时省略 eslint-plugin-
|
|
91
|
-
// babel,
|
|
92
|
-
// react,
|
|
93
|
-
],
|
|
94
|
-
extends: [
|
|
95
|
-
// 继承规则 // 'airbnb', 'eslint:recommended'
|
|
96
|
-
'plugin:react/recommended',
|
|
97
|
-
'airbnb',
|
|
98
|
-
'plugin:prettier/recommended',
|
|
99
|
-
'plugin:import/recommended',
|
|
100
|
-
],
|
|
101
|
-
rules: {
|
|
102
|
-
...rules,
|
|
103
|
-
},
|
|
104
|
-
overrides: [
|
|
105
|
-
{
|
|
106
|
-
files: ['src/**/*.js'],
|
|
107
|
-
extends: [
|
|
108
|
-
'plugin:react/recommended',
|
|
109
|
-
'airbnb-base',
|
|
110
|
-
'plugin:prettier/recommended',
|
|
111
|
-
'plugin:import/recommended'
|
|
112
|
-
],
|
|
113
|
-
plugins: ['react'],
|
|
114
|
-
rules: {
|
|
115
|
-
...rules,
|
|
116
|
-
'react/no-unknown-property': ['off'],
|
|
117
|
-
'react/jsx-key': ['off'],
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
};
|
package/.prettierignore
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
.*
|
|
2
|
-
*.ejs
|
|
3
|
-
*.ico
|
|
4
|
-
*.map
|
|
5
|
-
*.png
|
|
6
|
-
*.svg
|
|
7
|
-
*.xml
|
|
8
|
-
|
|
9
|
-
.eslintignore
|
|
10
|
-
.eslintrc
|
|
11
|
-
.eslintrc.js
|
|
12
|
-
.prettierignore
|
|
13
|
-
.prettierrc
|
|
14
|
-
prettier.config.js
|
|
15
|
-
wiamap.yml
|
|
16
|
-
|
|
17
|
-
package.json
|
|
18
|
-
package-lock.json
|
|
19
|
-
yarn.lock
|
|
20
|
-
|
|
21
|
-
node_modules
|
|
22
|
-
dist
|
|
23
|
-
doc
|
|
24
|
-
.vscode
|
package/prettier.config.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
tabWidth: 2, // 使用 2 个空格缩进
|
|
3
|
-
useTabs: false, // 不使用缩进符,而使用空格
|
|
4
|
-
semi: true, // 行尾需要有分号
|
|
5
|
-
singleQuote: true, // 使用单引号
|
|
6
|
-
bracketSpacing: false, // 大括号内的首尾需要空格
|
|
7
|
-
trailingComma: 'es5', // 末尾是否需要逗号
|
|
8
|
-
jsxBracketSameLine: true, // jsx 标签的反尖括号不换行
|
|
9
|
-
arrowParens: 'avoid', // 尽可能省略箭头函数参数括号。 示例:x => x
|
|
10
|
-
printWidth: 100, // 代码换行长度
|
|
11
|
-
endOfLine: 'auto',
|
|
12
|
-
// jsxSingleQuote: false, // jsx 使用双引号
|
|
13
|
-
};
|