From 5baa3e0fb7cf4e7602c48e8dd2ac0ed0091f03cf Mon Sep 17 00:00:00 2001 From: Chiawen Chen Date: Thu, 6 Oct 2022 17:20:32 +0800 Subject: [PATCH] [Perf] component detection: improve performance by optimizing getId --- CHANGELOG.md | 2 ++ lib/util/Components.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d39be4a9df..f5975115a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange ### Changed * [Docs] [`no-unknown-property`]: fix typo in link ([#3445][] @denkristoffer) +* [Perf] component detection: improve performance by optimizing getId ([#3451][] @golopot) +[#3451]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3451 [#3448]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3448 [#3445]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3445 [#3436]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3436 diff --git a/lib/util/Components.js b/lib/util/Components.js index 7b931c2234..b112923f63 100644 --- a/lib/util/Components.js +++ b/lib/util/Components.js @@ -21,7 +21,7 @@ const isFirstLetterCapitalized = require('./isFirstLetterCapitalized'); const isDestructuredFromPragmaImport = require('./isDestructuredFromPragmaImport'); function getId(node) { - return node && node.range.join(':'); + return node ? `${node.range[0]}:${node.range[1]}` : ''; } function usedPropTypesAreEquivalent(propA, propB) {