diff --git a/packages/eslint-plugin/docs/rules/explicit-function-return-type.md b/packages/eslint-plugin/docs/rules/explicit-function-return-type.md index 3cafe4224eb8..9e5b4c841bf2 100644 --- a/packages/eslint-plugin/docs/rules/explicit-function-return-type.md +++ b/packages/eslint-plugin/docs/rules/explicit-function-return-type.md @@ -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; }; @@ -77,6 +79,7 @@ const defaults = { allowExpressions: false, allowTypedFunctionExpressions: true, allowHigherOrderFunctions: true, + allowDirectConstAssertionInArrowFunctions: true, allowConciseArrowFunctionExpressionsStartingWithVoid: true, }; ``` @@ -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 }`: