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

jsx-no-literals with allowStrings doesn't work in props #2720

Closed
e110c0 opened this issue Jul 19, 2020 · 3 comments · Fixed by #2736
Closed

jsx-no-literals with allowStrings doesn't work in props #2720

e110c0 opened this issue Jul 19, 2020 · 3 comments · Fixed by #2736

Comments

@e110c0
Copy link

e110c0 commented Jul 19, 2020

the following setup seems not to work:

<button type="button" ></button>

with the rule

    'react/jsx-no-literals': [
      'warn',
      {
        noStrings: true,
        allowedStrings: ['button', 'submit'],
      },
    ],

produces the following error: Invalid prop value: “type="button"” react/jsx-no-literals

Context: I'm trying to find a balance between enforcing no literals but also react/button-has-type

@ljharb
Copy link
Member

ljharb commented Jul 20, 2020

That should definitely work - jsx-no-literals shouldn't be warning on a prop value.

The ignoreProps option might help, however.

@e110c0
Copy link
Author

e110c0 commented Jul 20, 2020

ignoreProps works, in general, but also doesn't check any props at all. It seems that the allowedStrings are not checked in props at all.

@karolina-benitez
Copy link
Contributor

I believe I have a solution for this. I will open a PR later today

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