jsx-eslint/eslint-plugin-react

New Rule: Prevent boolean values for unknown props

Open

#1.695 geöffnet am 15. Feb. 2018

Auf GitHub ansehen
 (4 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (2.797 Forks)batch import
enhancementhelp wantedreact 16

Repository-Metriken

Stars
 (8.630 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

React 16 does not ignore Boolean values for unknown props anymore.

So while this code "worked" in react 15:

<div onClick={!disabled && onClick}/>

It would try to assing false to the DOM elements onClick handler when disabled === true (which would be ignored by the browser).

React 16 will print an error message in the console though.

How about a rule that does not allow boolean results for unknown props?

See https://reactjs.org/blog/2017/09/08/dom-attributes-in-react-16.html#changes-in-detail "Non-boolean attributes with boolean values"

Contributor Guide