Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

frw
Copy link

@frw frw commented Jun 15, 2021

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.

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 D:\Dropbox\Projects\Tokuu\Code\packages\app\src\components\products\AddImageButton.tsx:72
    at JSXAttribute (D:\Dropbox\Projects\Tokuu\Code\node_modules\eslint-plugin-react-native\lib\rules\no-single-element-style-arrays.js:40:25)
    at D:\Dropbox\Projects\Tokuu\Code\node_modules\eslint\lib\linter\safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (D:\Dropbox\Projects\Tokuu\Code\node_modules\eslint\lib\linter\safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (D:\Dropbox\Projects\Tokuu\Code\node_modules\eslint\lib\linter\node-event-generator.js:293:26)
    at NodeEventGenerator.applySelectors (D:\Dropbox\Projects\Tokuu\Code\node_modules\eslint\lib\linter\node-event-generator.js:322:22)
    at NodeEventGenerator.enterNode (D:\Dropbox\Projects\Tokuu\Code\node_modules\eslint\lib\linter\node-event-generator.js:336:14)
    at CodePathAnalyzer.enterNode (D:\Dropbox\Projects\Tokuu\Code\node_modules\eslint\lib\linter\code-path-analysis\code-path-analyzer.js:711:23)
    at D:\Dropbox\Projects\Tokuu\Code\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.
@sonarcloud
Copy link

sonarcloud bot commented Jun 15, 2021

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

@frw
Copy link
Author

frw commented Oct 19, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant