Skip to content

Commit ca30f77

Browse files
HenryBrown0ljharb
authored andcommitted
[Refactor] jsx-props-no-multi-spaces: extract type parameters to var
1 parent aef6e7d commit ca30f77

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
1818
* [Refactor] `propTypes`: extract type params to var ([#3634][] @HenryBrown0)
1919
* [Refactor] [`boolean-prop-naming`]: invert if statement ([#3634][] @HenryBrown0)
2020
* [Refactor] [`function-component-definition`]: exit early if no type params ([#3634][] @HenryBrown0)
21+
* [Refactor] [`jsx-props-no-multi-spaces`]: extract type parameters to var ([#3634][] @HenryBrown0)
2122

2223
[#3638]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3638
2324
[#3634]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3634

lib/rules/jsx-props-no-multi-spaces.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,12 @@ module.exports = {
9898
}
9999

100100
function containsGenericType(node) {
101-
const containsTypeParams = typeof node.typeParameters !== 'undefined';
102-
return containsTypeParams && node.typeParameters.type === 'TSTypeParameterInstantiation';
101+
const nodeTypeParams = node.typeParameters;
102+
if (typeof nodeTypeParams === 'undefined') {
103+
return false;
104+
}
105+
106+
return nodeTypeParams.type === 'TSTypeParameterInstantiation';
103107
}
104108

105109
function getGenericNode(node) {

0 commit comments

Comments
 (0)