From 496faa55007778206225cd2b8f5b694180a30f80 Mon Sep 17 00:00:00 2001 From: Frederick Widjaja Date: Tue, 15 Jun 2021 12:15:56 +0700 Subject: [PATCH] Fix null error in no-single-element-style-arrays I'm using the ESLint plugin in VSCode, and when I'm in the middle of typing out my component style (e.g. ``) 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 () 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 () ``` 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. --- lib/rules/no-single-element-style-arrays.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/rules/no-single-element-style-arrays.js b/lib/rules/no-single-element-style-arrays.js index ce43bc9..b1fa87e 100644 --- a/lib/rules/no-single-element-style-arrays.js +++ b/lib/rules/no-single-element-style-arrays.js @@ -37,6 +37,7 @@ module.exports = { return { JSXAttribute(node) { if (node.name.name !== 'style') return; + if (!node.value) return; if (!node.value.expression) return; if (node.value.expression.type !== 'ArrayExpression') return; if (node.value.expression.elements.length === 1) { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy