From 63edc5e5882d0d2abf09e6b126c71bbeba713615 Mon Sep 17 00:00:00 2001 From: Edvard Chen Date: Sun, 24 Nov 2024 21:05:22 +0800 Subject: [PATCH] feat: support to filter jsx component named like A.B closes #135 --- lib/rules/no-literal-string.js | 5 ++++- tests/lib/rules/no-literal-string/jsx-components.js | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/rules/no-literal-string.js b/lib/rules/no-literal-string.js index 30bbb08..c9c48e4 100644 --- a/lib/rules/no-literal-string.js +++ b/lib/rules/no-literal-string.js @@ -203,8 +203,11 @@ module.exports = { // JSXElement(node) { + const fullComponentName = context + .getSourceCode() + .getText(node.openingElement.name); indicatorStack.push( - shouldSkip(options['jsx-components'], node.openingElement.name.name) + shouldSkip(options['jsx-components'], fullComponentName) ); }, 'JSXElement:exit': endIndicator, diff --git a/tests/lib/rules/no-literal-string/jsx-components.js b/tests/lib/rules/no-literal-string/jsx-components.js index 2f98b45..f2a0244 100644 --- a/tests/lib/rules/no-literal-string/jsx-components.js +++ b/tests/lib/rules/no-literal-string/jsx-components.js @@ -8,6 +8,10 @@ const cases = { code: 'arrow', options: [{ 'jsx-components': { exclude: ['Icon'] } }], }, + { + code: 'arrow', + options: [{ 'jsx-components': { exclude: ['Icon.A'] } }], + }, { code: '<>hello

{i18next.t("KEY")}

', options: [{ 'jsx-components': { include: ['p'] } }],