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

Getting warnings even with allowTypedFunctionExpressions set to true #384

Closed
saranshkataria opened this issue Mar 28, 2019 · 8 comments
Closed
Labels
package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look

Comments

@saranshkataria
Copy link

saranshkataria commented Mar 28, 2019

After adding the
rules: { allowTypedFunctionExpressions: true }
for the alpha release (#149), I still see them as warnings

image

Repro

Code repo: https://github.com/saranshkataria/frontend-starter-kit

{
  rules: {
    allowTypedFunctionExpressions: true,
  }
}
import React from 'react';
import { hot } from 'react-hot-loader/root';

const App: React.FunctionComponent<{}> = () => <div>Hello World</div>;
App.displayName = 'App';
export default hot(App);

Expected Result
No warnings

Actual Result
Get warnings

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 1.5.1-alpha.5
@typescript-eslint/parser 1.5.1-alpha.5
TypeScript 3.3.4000
ESLint 5.15.3
node 8.15.0
npm 6.4.1
@saranshkataria saranshkataria added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Mar 28, 2019
@bradzacher
Copy link
Member

In this instance, you have eslint misconfigured.
The correct syntax for configuring rules is:

{
  "rules": {
    "<rule_name>": ["<level>", <options>],
  }
}

I.e. for @typescript-eslint/explicit-function-return-type:

{
  "rules": {
    "@typescript-eslint/explicit-function-return-type": ["error", {
      "allowTypedFunctionExpressions": true
    }],
  }
}

@saranshkataria
Copy link
Author

Thanks!

@saranshkataria
Copy link
Author

@bradzacher I made the changes and it works for tsx files, but when I run lint, it fails on test files. Since I already have the types included, it shouldn't?

@saranshkataria
Copy link
Author

I have that enabled as well, but I still see an error

@saranshkataria
Copy link
Author

I put in core-js3 in my babel config and the issue got resolved. Not sure why though.

@ben-xD
Copy link

ben-xD commented Aug 11, 2019

Should @typescript-eslint not default to enabling allowTypedFunctionExpressions. Seems like everyone would face this issue otherwise? Am i overlooking something?

@bradzacher
Copy link
Member

It's going to be the default in v2. There is a PR waiting to be merged (the last one before the v2 release)

@typescript-eslint typescript-eslint locked as resolved and limited conversation to collaborators Feb 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look
Projects
None yet
Development

No branches or pull requests

3 participants