Closed hsource closed 1 year ago
Kudos, SonarCloud Quality Gate passed!
0 Bugs
0 Vulnerabilities
0 Security Hotspots
1 Code Smell
No Coverage information
0.0% Duplication
Babel's maintainer here.
I am worried by the usage of @babel/traverse
here:
In #270, Babel is constructing a new scope when it visits a Function () => {}
in the JSXOpeningElement <foo bar={() => {}} />
. It should work if the passed scope
is created by Babel traverse, so that Babel can find all the way up to the program scope. But since we are passing an ESLint scope, it results to an obscure internal Babel error.
This PR looks good to me. If we want to be future-proof, we can get the visitorKeys
of JSXOpeningElement
from context.getSourceCode().visitorKeys
and traverse accordingly.
@Intellicode I think this quick PR should resolve #270, which has seen a lot of activity. Can you help take a look?
Thanks for the fix @hsource, sorry for the late review, life got in the way
Thank you @Intellicode!
I saw your README. I would be happy to take this over and maintain it. I work closely with React Native & the Expo team and would be honored to be passed the torch
Motivation
Fixes #270. babel-traverse expects that it's passed an entire tree that spans to the top of the program. eslint does not guarantee that, which causes crashes when parsing some programs (see #270 for many examples).
Fix
Text
or other allowed components are allowed. Nested text components can safely be used to add inline bold/color/other stylingTesting
Added automated test based on repro case from #270: https://github.com/Intellicode/eslint-plugin-react-native/issues/270#issuecomment-897766305