@@ -69,6 +69,8 @@ type Options = {
69
69
allowTypedFunctionExpressions? : boolean ;
70
70
// if true, functions immediately returning another function expression will not be checked
71
71
allowHigherOrderFunctions? : boolean ;
72
+ // if true, arrow functions immediately returning a `as const` value will not be checked
73
+ allowDirectConstAssertionInArrowFunctions? : boolean ;
72
74
// if true, concise arrow functions that start with the void keyword will not be checked
73
75
allowConciseArrowFunctionExpressionsStartingWithVoid? : boolean ;
74
76
};
@@ -77,6 +79,7 @@ const defaults = {
77
79
allowExpressions: false ,
78
80
allowTypedFunctionExpressions: true ,
79
81
allowHigherOrderFunctions: true ,
82
+ allowDirectConstAssertionInArrowFunctions: true ,
80
83
allowConciseArrowFunctionExpressionsStartingWithVoid: true ,
81
84
};
82
85
```
@@ -201,6 +204,22 @@ function fn() {
201
204
}
202
205
```
203
206
207
+ ### ` allowDirectConstAssertionInArrowFunctions `
208
+
209
+ Examples of ** incorrect** code for this rule with ` { allowDirectConstAssertionInArrowFunctions: true } ` :
210
+
211
+ ``` ts
212
+ const func = (value : number ) => ({ type: ' X' , value } as any );
213
+ const func = (value : number ) => ({ type: ' X' , value } as Action );
214
+ ```
215
+
216
+ Examples of ** correct** code for this rule with ` { allowDirectConstAssertionInArrowFunctions: true } ` :
217
+
218
+ ``` ts
219
+ const func = (value : number ) => ({ foo: ' bar' , value } as const );
220
+ const func = () => x as const ;
221
+ ```
222
+
204
223
### ` allowConciseArrowFunctionExpressionsStartingWithVoid `
205
224
206
225
Examples of ** incorrect** code for this rule with ` { allowConciseArrowFunctionExpressionsStartingWithVoid: true } ` :
0 commit comments