Skip to content

Commit

Permalink
Merge pull request #137 from edvardchen/jsx-component-object-member
Browse files Browse the repository at this point in the history
feat: support to filter jsx component named like A.B
  • Loading branch information
edvardchen authored Nov 24, 2024
2 parents beeda15 + 63edc5e commit e875834
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/rules/no-literal-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/rules/no-literal-string/jsx-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const cases = {
code: '<Icon>arrow</Icon>',
options: [{ 'jsx-components': { exclude: ['Icon'] } }],
},
{
code: '<Icon.A>arrow</Icon.A>',
options: [{ 'jsx-components': { exclude: ['Icon.A'] } }],
},
{
code: '<><span>hello</span><p>{i18next.t("KEY")}</p></>',
options: [{ 'jsx-components': { include: ['p'] } }],
Expand Down

0 comments on commit e875834

Please sign in to comment.