-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin ruleNew rule option for an existing eslint-plugin rulepackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin
Description
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have read the FAQ and my problem is not listed.
Repro
{
"rules": {
"@typescript-eslint/explicit-function-return-type": ["error"]
}
}
interface SomeObject {
hello: string;
callback: () => string;
}
function foo(): SomeObject {
return {
hello: 'world',
callback: () => 'this is a callback', // Missing return type on function.eslint@typescript-eslint/explicit-function-return-type
};
}
function bar(): SomeObject {
return {
hello: 'world',
callback: () => 'this is a callback', // This one is fine.
} as SomeObject;
}
Expected Result
When returning an object from a function (that itself has a type signature) you arguably don't need the explicit return type here as you have it in the function's type signature. It would be nice to be able to have an option to ignore this case. This is most useful when you have factory functions.
Actual Result
Missing return type on function.eslint@typescript-eslint/explicit-function-return-type
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
4.9.0 |
@typescript-eslint/parser |
4.9.0 |
TypeScript |
3.9.7 |
ESLint |
7.6.0 |
node |
v12.2.0 |
Metadata
Metadata
Assignees
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin ruleNew rule option for an existing eslint-plugin rulepackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin