Skip to content

Commit d78ae54

Browse files
authored
docs(eslint-plugin): add info about allowDirectConstAssertionInArrowFunctions option (typescript-eslint#2586)
1 parent c72ba77 commit d78ae54

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

packages/eslint-plugin/docs/rules/explicit-function-return-type.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ type Options = {
6969
allowTypedFunctionExpressions?: boolean;
7070
// if true, functions immediately returning another function expression will not be checked
7171
allowHigherOrderFunctions?: boolean;
72+
// if true, arrow functions immediately returning a `as const` value will not be checked
73+
allowDirectConstAssertionInArrowFunctions?: boolean;
7274
// if true, concise arrow functions that start with the void keyword will not be checked
7375
allowConciseArrowFunctionExpressionsStartingWithVoid?: boolean;
7476
};
@@ -77,6 +79,7 @@ const defaults = {
7779
allowExpressions: false,
7880
allowTypedFunctionExpressions: true,
7981
allowHigherOrderFunctions: true,
82+
allowDirectConstAssertionInArrowFunctions: true,
8083
allowConciseArrowFunctionExpressionsStartingWithVoid: true,
8184
};
8285
```
@@ -201,6 +204,22 @@ function fn() {
201204
}
202205
```
203206

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+
204223
### `allowConciseArrowFunctionExpressionsStartingWithVoid`
205224

206225
Examples of **incorrect** code for this rule with `{ allowConciseArrowFunctionExpressionsStartingWithVoid: true }`:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy