Skip to content

Commit

Permalink
docs(eslint-plugin): add info about `allowDirectConstAssertionInArrow…
Browse files Browse the repository at this point in the history
…Functions` option (#2586)
  • Loading branch information
magurotuna committed Sep 27, 2020
1 parent c72ba77 commit d78ae54
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/eslint-plugin/docs/rules/explicit-function-return-type.md
Expand Up @@ -69,6 +69,8 @@ type Options = {
allowTypedFunctionExpressions?: boolean;
// if true, functions immediately returning another function expression will not be checked
allowHigherOrderFunctions?: boolean;
// if true, arrow functions immediately returning a `as const` value will not be checked
allowDirectConstAssertionInArrowFunctions?: boolean;
// if true, concise arrow functions that start with the void keyword will not be checked
allowConciseArrowFunctionExpressionsStartingWithVoid?: boolean;
};
Expand All @@ -77,6 +79,7 @@ const defaults = {
allowExpressions: false,
allowTypedFunctionExpressions: true,
allowHigherOrderFunctions: true,
allowDirectConstAssertionInArrowFunctions: true,
allowConciseArrowFunctionExpressionsStartingWithVoid: true,
};
```
Expand Down Expand Up @@ -201,6 +204,22 @@ function fn() {
}
```

### `allowDirectConstAssertionInArrowFunctions`

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

```ts
const func = (value: number) => ({ type: 'X', value } as any);
const func = (value: number) => ({ type: 'X', value } as Action);
```

Examples of **correct** code for this rule with `{ allowDirectConstAssertionInArrowFunctions: true }`:

```ts
const func = (value: number) => ({ foo: 'bar', value } as const);
const func = () => x as const;
```

### `allowConciseArrowFunctionExpressionsStartingWithVoid`

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

0 comments on commit d78ae54

Please sign in to comment.