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

Function type parameters spacing issues #24

Open
hsimah opened this issue Jan 4, 2022 · 2 comments · May be fixed by #25
Open

Function type parameters spacing issues #24

hsimah opened this issue Jan 4, 2022 · 2 comments · May be fixed by #25

Comments

@hsimah
Copy link

hsimah commented Jan 4, 2022

I have noticed two issues around type parameters:

  1. Function type parameters get spaces
  2. Utility functions such as $NonMaybeType and indexed accessor

My .eslintrc
image

Issue 1

When using a React state hook I want to explicitly type the state property useState<?string>(null). This is being formatted as useState < ?string > (null); by the plugin. This causes no linting warnings or errors based on recommended settings.
image

Issue 2

When using $NonMaybeType with indexed types I get a trailing space added $NonMaybeType<SomeType['someNestedArray'][0]> comes out like $NonMaybeType<SomeType['someNestedArray'][0] >. This now throws a linting warning (recommended settings) that the generic parameter should not have trailing spaces.
image

I would love to contribute, if I have time to take a look. Let me know if this is expected behaviour.

@Brianzchen
Copy link
Member

Thanks for submitting the issue. Happy for you to raise some fixes if they make sense. I haven't come across this issue myself probably because I don't use those rules.

But as I'm trying to test this issue though it looks like the rule doesn't even work on my environment and I have no clue why, might be some other issues in this rule after all.

But if you can figure out what's wrong with your usage happy for you to raise a PR.

@hsimah hsimah linked a pull request Jan 5, 2022 that will close this issue
@hsimah
Copy link
Author

hsimah commented Jan 5, 2022

I created a new rule type-annotation-spacing and raised a PR. This was the most complex linting rule I've authored, so it may need some refinement.

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

Successfully merging a pull request may close this issue.

2 participants