Skip to content

Commit

Permalink
jsx-pascal-case: Handle single character namespaced component
Browse files Browse the repository at this point in the history
  • Loading branch information
daviferreira committed Sep 10, 2020
1 parent 9a569f7 commit 98e9a3e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rules/jsx-pascal-case.js
Expand Up @@ -97,7 +97,6 @@ module.exports = {
if (isCompatTag) return undefined;

let name = elementType(node);
if (name.length === 1) return undefined;

// Get JSXIdentifier if the type is JSXNamespacedName or JSXMemberExpression
if (name.lastIndexOf(':') > -1) {
Expand All @@ -106,6 +105,8 @@ module.exports = {
name = name.substring(name.lastIndexOf('.') + 1);
}

if (name.length === 1) return undefined;

const isPascalCase = testPascalCase(name);
const isAllowedAllCaps = allowAllCaps && testAllCaps(name);
const isIgnored = ignore.indexOf(name) !== -1;
Expand Down
2 changes: 2 additions & 0 deletions tests/lib/rules/jsx-pascal-case.js
Expand Up @@ -82,6 +82,8 @@ ruleTester.run('jsx-pascal-case', rule, {
code: '<_ />'
}, {
code: '<H1>Hello!</H1>'
}, {
code: '<Typography.P />'
}],

invalid: [{
Expand Down

0 comments on commit 98e9a3e

Please sign in to comment.