Eslint-plugin-react: jsx-boolean-value: don't warn if the value attribute of an <option> tag

Created on 29 Jan 2017  路  5Comments  路  Source: yannickcr/eslint-plugin-react

In my opinion the plugin should not warn when the JSX is something like <option value={ true }>True</option>

Most helpful comment

Actually thats totally valid. <option value={ "true" } /> is strictly better for matching the DOM output. Thanks for the recommendation.

All 5 comments

Why? <option value> is equivalent and more concise.

React's output for <option value> ends up resulting in <option value="true"> since React is casting that prop to true. I prefer having my React syntax match the output HTML syntax as closely as possible when rendering base-level V-DOM nodes.

I don't mind if this isn't the default setting but I would at least like a control to turn off warning in this case.

<option value={true} /> should be outputting the same thing. In other words, if you want the syntaxes to match you should do <option value={String(true)} /> instead of relying on React to coerce for you.

I don't think an option to allow this case is a good idea.

Actually thats totally valid. <option value={ "true" } /> is strictly better for matching the DOM output. Thanks for the recommendation.

In that case I'm going to close this; happy to reopen if you want to continue making the case for the option.

Was this page helpful?
0 / 5 - 0 ratings