Open ljharb opened 7 years ago
This works for me
settings:
react:
pragma: 'createElement'
rules:
no-unused-vars: 'error'
react/jsx-uses-react: 'error'
react/jsx-uses-vars: 'error'
Doesn't that change React
to createElement
, which isn't the same thing? Or is the default pragma React.createElement
?
I guess pragma here is what imported. Maybe this can conflict with createClass. But it's still deprecated and doesn't matter IMHO. So this way just works.
It's important to note the caveat that it only works when not using anything off of React
except for createElement
- don't forget React.Component
, React.Children
, React.isValidElement
, React.PropTypes
, etc.
Maybe. In my opinion these cases should be processed with flow or typescript. It's just an api, not syntax stuff.
Neither of those things is a part of the language, and "types" is entirely unrelated to the reasons eslint-plugin-react needs to know about the React
and createClass
pragmas (which relate to using alternative renderers to React itself).
Would it make sense to also allow h(...)
as an alternative to React.createElement(...)
? It's a relatively common pattern exposed by preact.
It seems like we’d need a setting to specify “createElement” and whether it should chain it off the pragma or not.
We allow
createClass
to be overridden with a setting - should we allowcreateElement
to be configured as well?If so, any rules referencing
React.createElement
should be sure to use<pragma>.<createElement>