eslint-plugin-react: [7.31.4] `no-unknown-property` throwing on valid props
Related to #3380
I’m seeing the following errors in my project:
Unknown property 'onToggle' found
<details> supports onToggle.
Invalid property 'fill' found on tag 'path', but it is only allowed on: svg
<path> supports fill.
Unknown property 'as' found
<link> supports as.
Edit: It looks like there are even more valid use cases that this rule is not covering. I’d suggest reverting the changes to the no-unknown-property rule for v7 and releasing it under a new major version. React Known Props can be used to get all the known props, and users can use the ignore option on the rule to add other props like css.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 15
- Comments: 24 (7 by maintainers)
Commits related to this issue
- fix(eslint-config): new versions of react plugin need whitelisting of emotions css prop See https://github.com/jsx-eslint/eslint-plugin-react/issues/3384#issuecomment-1236371796 — committed to tablecheck/frontend by SimeonC 2 years ago
- fix(eslint-config): new versions of react plugin need whitelisting of emotions css prop See https://github.com/jsx-eslint/eslint-plugin-react/issues/3384#issuecomment-1236371796 — committed to tablecheck/frontend by SimeonC 2 years ago
- Update eslint-plugin-react to latest version This requires ignoring a new rule added since the last version. More information at the following links: https://github.com/jsx-eslint/eslint-plugin-reac... — committed to ScottG489/scottg489.github.io by ScottG489 a year ago
(Like @diegohaz already said in the modified issue comment) The rule is already configurable with
ignore, so the users ofemotionshould addcssas ignored property, when configuring this rule:@ljharb I made a commit that adds this to the rule documentation in #3390
Also having issue with css property of emotion library
I upgraded to 7.31.4 and I’m still seeing this with
playsInlinewith thevideoelement.Good news is that 7.31.4 fixed all the other false positives.
I also get
Unknown property 'scrolling' foundon<iframe>@ljharb @peter-resmed I opened a ticket in the emotion js repository: https://github.com/emotion-js/emotion/issues/2878
also I confirm @guyellis message about
playsInlineMDN Video HTML Element attribute playsInline, @sjarva could you please add that one too, to your PR #3385? Thank you for all the fixes you already added to that PRAlso getting an issue with the
fillattribute ongReact does allow custom attributes without
data-in certain circumstances. I guess a lot of people would expect the lint rule to work accordingly to that.@diegohaz Please upgrade to v7.31.4. Are you still seeing these issues?
@Meemaw @christian98 @Primajin @dermoumi a fix for these will be out later today.
@peter-resmed custom attributes that don’t start with data- are invalid - is there an issue filed on emotion for this?
I am also getting this error on
defaultCheckedSame thing for
onPointerDown(and probably other pointer events https://reactjs.org/blog/2018/05/23/react-v-16-4.html)Getting an unknown property “controls” error as well, on a video element
Hello, I am using the latest version of eslint-plugin-react (^7.31.5), and that one is still to correct Error: Unknown property ‘controls’ found react/no-unknown-property (in a video player)
Cheers for the rapid fix 😃
First of all a big thank you for the quick turn around ❤️
Regarding emotion css - I guess the cleanest way would be to feed an ignore pattern or list of things to ignore.
cssper-se is not a valid HTML attribute but total valid react prop in the context of emotion-css. I’m pretty sure other libraries add other funky attributes / props so I’d vote for allowlisting them. 🤞🏻It also fails when explicitly passing
<div children={...} />, which should work just like<div>{...}</div>