From ca30f77196d410c7cdb1e4fe11f11bfffb46c84f Mon Sep 17 00:00:00 2001 From: HenryBrown0 <26250092+HenryBrown0@users.noreply.github.com> Date: Sun, 24 Sep 2023 13:42:03 +0100 Subject: [PATCH] [Refactor] `jsx-props-no-multi-spaces`: extract type parameters to var --- CHANGELOG.md | 1 + lib/rules/jsx-props-no-multi-spaces.js | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e048ec074..5ff0e08075 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange * [Refactor] `propTypes`: extract type params to var ([#3634][] @HenryBrown0) * [Refactor] [`boolean-prop-naming`]: invert if statement ([#3634][] @HenryBrown0) * [Refactor] [`function-component-definition`]: exit early if no type params ([#3634][] @HenryBrown0) +* [Refactor] [`jsx-props-no-multi-spaces`]: extract type parameters to var ([#3634][] @HenryBrown0) [#3638]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3638 [#3634]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3634 diff --git a/lib/rules/jsx-props-no-multi-spaces.js b/lib/rules/jsx-props-no-multi-spaces.js index b0d34d59dd..b9cabafe32 100644 --- a/lib/rules/jsx-props-no-multi-spaces.js +++ b/lib/rules/jsx-props-no-multi-spaces.js @@ -98,8 +98,12 @@ module.exports = { } function containsGenericType(node) { - const containsTypeParams = typeof node.typeParameters !== 'undefined'; - return containsTypeParams && node.typeParameters.type === 'TSTypeParameterInstantiation'; + const nodeTypeParams = node.typeParameters; + if (typeof nodeTypeParams === 'undefined') { + return false; + } + + return nodeTypeParams.type === 'TSTypeParameterInstantiation'; } function getGenericNode(node) {