Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[explicit-function-return-type] allowExpressions should not allow methods #950

Closed
whatisaphone opened this issue Sep 5, 2019 · 0 comments · Fixed by #952
Closed

[explicit-function-return-type] allowExpressions should not allow methods #950

whatisaphone opened this issue Sep 5, 2019 · 0 comments · Fixed by #952
Labels
bug Something isn't working good first issue Good for newcomers has pr there is a PR raised to close this package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@whatisaphone
Copy link

Repro

{
  "rules": {
    "@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}]
  }
}
class C {
  public method = () => {};
}
const variable = () => {};

Expected Result

Both lines should get hit with the error: "Missing return type on function".

Actual Result

Only variable gets the error; method does not. method is erroneously allowed due to allowExpressions.

Additional Info

From reading old issues, it looks like the idea behind allowExpressions is to allow expressions, but not to allow pure declarations which consist of only a function expression (source). This categorization is working great already for variable declarartions. I think the allowExpressions option should follow the same reasoning for both, and also treat a class property method declaration as a function declaration.

Versions

package version
@typescript-eslint/eslint-plugin 2.1.0
@typescript-eslint/parser 2.1.0
TypeScript 3.5.1
ESLint 6.3.0
node 8.10.0
npm 5.6.0
@whatisaphone whatisaphone added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Sep 5, 2019
@bradzacher bradzacher added bug Something isn't working good first issue Good for newcomers and removed triage Waiting for maintainers to take a look labels Sep 5, 2019
@bradzacher bradzacher added the has pr there is a PR raised to close this label Sep 7, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers has pr there is a PR raised to close this package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
2 participants