File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
packages/eslint-config-ts-lib Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ # arrow-body-style
2+
3+ > 来自 [ eslint] ( https://eslint.org/docs/rules/ ) 的规则。
4+
5+ > ts-lib-scripts 推荐使用。遵循简洁的原则。
6+
7+ > 当箭头函数体的大括号是可以省略的,则强制不使用它们。
8+
9+ ## 示例
10+
11+ ### 错误用法
12+
13+ ``` javascript
14+ const foo = () => {
15+ return 0 ;
16+ };
17+
18+ const foo = () => {
19+ return {
20+ bar: {
21+ foo: 1 ,
22+ bar: 2 ,
23+ },
24+ };
25+ };
26+ ```
27+
28+ ### 正确用法
29+
30+ ``` javascript
31+ let foo = () => 0 ;
32+ let foo = () => ({
33+ bar: {
34+ foo: 1 ,
35+ bar: 2 ,
36+ },
37+ });
38+ ```
39+
40+ ## 参考文档
41+
42+ - [ arrow-body-style 官方文档] ( https://eslint.org/docs/rules/arrow-body-style )
43+ - [ arrow-body-style 中文教程] ( https://eslint.cn/docs/rules/arrow-body-style )
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ const functionRules = {
2525 ] ,
2626 '@typescript-eslint/explicit-function-return-type' : 0 ,
2727 'no-empty-function' : 'off' ,
28+ 'arrow-body-style' : [ 'error' , 'as-needed' ] ,
2829} ;
2930
3031module . exports = functionRules ;
You can’t perform that action at this time.
0 commit comments