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

support jsx-no-literals on specific attributes #2486

Closed
davidwkeith opened this issue Nov 4, 2019 · 5 comments · Fixed by #2496 or #2782
Closed

support jsx-no-literals on specific attributes #2486

davidwkeith opened this issue Nov 4, 2019 · 5 comments · Fixed by #2496 or #2782

Comments

@davidwkeith
Copy link

For react/jsx-no-literals the default likely should not allow string literals on "title" and "alt" attributes, but allow configuration for component patterns that pass user strings in other ways.

@ljharb
Copy link
Member

ljharb commented Nov 5, 2019

such as?

@ljharb
Copy link
Member

ljharb commented Nov 5, 2019

All HTML element attributes that aren’t enums should always be checked by this rule, I’d think.

@davidwkeith
Copy link
Author

Makes sense to me. Just noticed a few alt and title attributes that were missed.

@ljharb
Copy link
Member

ljharb commented Nov 5, 2019

Can you provide example code, how you expect it to be linted, and how it is?

@davidwkeith
Copy link
Author

davidwkeith commented Nov 5, 2019

yep

Fail:

<img alt='alt string' {...props} />
<figure title='title string' {...props} />

Pass:

<img alt={translate(strings.altString)} {...props} />
<figure title={translate(strings.titleString)} {...props} />

Currently both pass

ljharb pushed a commit to TaLeaMonet/eslint-plugin-react that referenced this issue Sep 16, 2020
Co-authored-by: TaLea Carpenter <[email protected]>
Co-authored-by: tanmoyopenroot <[email protected]>

Fixes #jsx-eslint#2486
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants