Eslint-plugin-react: jsx-no-literals with allowStrings doesn't work in props

Created on 19 Jul 2020  ·  3Comments  ·  Source: yannickcr/eslint-plugin-react

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

bug help wanted

Most helpful comment

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

All 3 comments

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

The ignoreProps option might help, however.

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.

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

Was this page helpful?
0 / 5 - 0 ratings