eslint-plugin-react-native icon indicating copy to clipboard operation
eslint-plugin-react-native copied to clipboard

Fix null error in no-single-element-style-arrays

Open frw opened this issue 3 years ago • 2 comments

I'm using the ESLint plugin in VSCode, and when I'm in the middle of typing out my component style (e.g. <View style>) in VSCode, I'm getting the following error:

TypeError: Cannot read property 'expression' of null
Occurred while linting root\src\Component.tsx:72
    at JSXAttribute (root\node_modules\eslint-plugin-react-native\lib\rules\no-single-element-style-arrays.js:40:25)
    at root\node_modules\eslint\lib\linter\safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (root\node_modules\eslint\lib\linter\safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (root\node_modules\eslint\lib\linter\node-event-generator.js:293:26)
    at NodeEventGenerator.applySelectors (root\node_modules\eslint\lib\linter\node-event-generator.js:322:22)
    at NodeEventGenerator.enterNode (root\node_modules\eslint\lib\linter\node-event-generator.js:336:14)
    at CodePathAnalyzer.enterNode (root\node_modules\eslint\lib\linter\code-path-analysis\code-path-analyzer.js:711:23)
    at root\node_modules\eslint\lib\linter\linter.js:954:32
    at Array.forEach (<anonymous>)

Although a style attribute with no value is technically not valid, no-single-element-style-arrays should silently ignore this and not throw an error.

frw avatar Jun 15 '21 05:06 frw

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

sonarqubecloud[bot] avatar Jun 15 '21 05:06 sonarqubecloud[bot]

Hi @Intellicode, could you take a quick look at this?

frw avatar Oct 19 '21 05:10 frw