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

False positives on react/jsx-props-no-multi-spaces with generic component #2181

Closed
luixo opened this issue Feb 28, 2019 · 9 comments · Fixed by #2256
Closed

False positives on react/jsx-props-no-multi-spaces with generic component #2181

luixo opened this issue Feb 28, 2019 · 9 comments · Fixed by #2256

Comments

@luixo
Copy link

luixo commented Feb 28, 2019

Setup: eslint 5.14.1 with @typescript-eslint/eslint-plugin 1.4.0
Minimal case:

<Foo<T> bar />

Error:
Expected only one space between "Foo" and "bar"

@ljharb
Copy link
Member

ljharb commented Feb 28, 2019

It's very surprising that TS allows that; Foo<T> looks like a type, but the first item in a jsx element has to be a value.

@G-Rath
Copy link
Contributor

G-Rath commented Apr 4, 2019

It's very surprising that TS allows that

That's how you do generic JSX components in TypeScript.

@ljharb
Copy link
Member

ljharb commented Apr 4, 2019

I'm still surprised they chose to deviate from the jsx spec for that.

@G-Rath
Copy link
Contributor

G-Rath commented Apr 4, 2019

But is it actually deviating from the spec, since it's never actually in the jsx when it gets compiled?

Like, I think its fuzzy on both sides - I can't think of a cleaner way they could have done it 😕

@ljharb
Copy link
Member

ljharb commented Apr 4, 2019

Yes, it is. I'd say <Foo: Foo<T> /> would be much cleaner, and would stick to the "stuff after : is types" space.

That ship has obviously sailed, though.

@G-Rath
Copy link
Contributor

G-Rath commented Apr 4, 2019

I've not got the jsx spec in front of me, but why is it deviating from the spec to have a generic type straight after the component name, but not a colon?

@ljharb
Copy link
Member

ljharb commented Apr 4, 2019

I suppose it’s more than in typescript itself, generics syntax only appears in type space, and in this case, it’s appearing in value space - so it seems inconsistent with typescript too.

@G-Rath
Copy link
Contributor

G-Rath commented Apr 4, 2019

Fair enough. What are the chances of getting a fix? Even if it has to be behind a typescript: true style option?

@ljharb
Copy link
Member

ljharb commented Apr 4, 2019

I don't think it has to be behind an option; this change would be removing a false error only for typescript users.

I think a PR would be fine.

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

Successfully merging a pull request may close this issue.

3 participants