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

Implement arrow-parens to support type parameters #417

Merged
merged 1 commit into from
Jul 18, 2019

Conversation

lyleunderwood
Copy link
Contributor

@lyleunderwood lyleunderwood commented Jul 18, 2019

This should resolve #344.

I did this quick and dirty, and I'm not sure if it's the correct approach. What I did was:

  1. Copied arrow-parens rule and tests into eslint-plugin-flowtype from eslint,
  2. Resolved various linting issues and glued code together to work with eslint-plugin-flowtype environment,
  3. Added tests specific to flow support,
  4. Modified behavior of arrow-parens rule so that the tests passed.

Let me know if there's a better way to override an eslint rule. Also, I'm not sure if this should go into the recommended config or whatever.

This may also be of interest to typescript-eslint/typescript-eslint#14.

"flowtype/require-return-type": 0,
"flowtype/require-valid-file-annotation": 0,
"flowtype/require-readonly-react-props": 0,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a post-commit hook modified this file?

// can therefore be safely ignored.
if (node.typeParameters) {
return;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the relevant bit. My assumption is that if the arrow function has type parameters, then we can safely ignore it because any arrow function with type parameters and no parens is always a parse error.


Enforces the consistent use of parentheses in arrow functions.

This rule has a string option and an object one.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grabbed all this stuff from the eslint documentation here.

@gajus gajus merged commit 94a9e8b into gajus:master Jul 18, 2019
@gajus
Copy link
Owner

gajus commented Jul 18, 2019

Thank you. LGTM

@gajus
Copy link
Owner

gajus commented Jul 18, 2019

🎉 This PR is included in version 3.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False-positive of arrow-parens with generic arrow function
2 participants