Skip to content

Commit

Permalink
docs(eslint-plugin): explicit-function-return-type: missing allowFunc…
Browse files Browse the repository at this point in the history
…tionsWithoutTypeParameters sections (#6475)

docs: explicit-function-return-type/allowFunctionsWithoutTypeParameters
  • Loading branch information
eranhirsch committed Feb 15, 2023
1 parent c46c793 commit fc803cc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/eslint-plugin/docs/rules/explicit-function-return-type.md
Expand Up @@ -242,6 +242,38 @@ const log = (message: string) => {
var log = (message: string) => void console.log(message);
```

### `allowFunctionsWithoutTypeParameters`

Examples of code for this rule with `{ allowFunctionsWithoutTypeParameters: true }`:

<!--tabs-->

#### ❌ Incorrect

```ts
function foo<T>(t: T) {
return t;
}

const bar = <T>(t: T) => t;
```

#### ✅ Correct

```ts
function foo<T>(t: T): T {
return t;
}

const bar = <T>(t: T): T => t;

const allowedFunction(x: string) {
return x;
}

const allowedArrow = (x: string) => x;
```

### `allowedNames`

You may pass function/method names you would like this rule to ignore, like so:
Expand Down
Expand Up @@ -93,6 +93,7 @@ export default util.createRule<Options, MessageIds>({
allowHigherOrderFunctions: true,
allowDirectConstAssertionInArrowFunctions: true,
allowConciseArrowFunctionExpressionsStartingWithVoid: false,
allowFunctionsWithoutTypeParameters: false,
allowedNames: [],
allowIIFEs: false,
},
Expand Down

0 comments on commit fc803cc

Please sign in to comment.