This repository has been archived by the owner on Sep 30, 2020. It is now read-only.
feat: add liferay-portal/no-react-dom-render rule #71
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Just for fun, I made this one pretty comprehensive (but not exhaustive) in terms of finding bindings to the "react-dom"
render()
function. I took the simple approach of remembering imports as I see them, and checkingCallExpression
nodes along the way to see if they correspond to an import. This is in contrast to the alternative approach which would be to scan the entire input accumulating imports and then checkingCallExpressions
at the very end.Three reasons for this:
import
statements usually go at the top of the file, so we will probably always see them first.const
semantics, and so are affected by the temporal dead zone, which makes it even less likely that they'd be used before we've seen them (you could still use them inside a lazily-executed function, but I think the odds of that are vanishingly small).Possible add-on to consider:
ReactDOM.render
insidetest/**/*.js
directories?