Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jsx-pascal-case] Components can with $ or _ #2395

Merged
merged 1 commit into from Aug 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/rules/jsx-pascal-case.js
Expand Up @@ -51,6 +51,7 @@ module.exports = {
return {
JSXOpeningElement(node) {
let name = elementType(node);
if (name.length === 1) return undefined;

// Get namespace if the type is JSXNamespacedName or JSXMemberExpression
if (name.indexOf(':') > -1) {
Expand Down
9 changes: 9 additions & 0 deletions tests/lib/rules/jsx-pascal-case.js
Expand Up @@ -59,6 +59,12 @@ ruleTester.run('jsx-pascal-case', rule, {
}, {
code: '<IGNORED />',
options: [{ignore: ['IGNORED']}]
}, {
code: '<T />'
}, {
code: '<$ />'
}, {
code: '<_ />'
}],

invalid: [{
Expand All @@ -82,5 +88,8 @@ ruleTester.run('jsx-pascal-case', rule, {
code: '<__ />',
options: [{allowAllCaps: true}],
errors: [{message: 'Imported JSX component __ must be in PascalCase or SCREAMING_SNAKE_CASE'}]
}, {
code: '<$a />',
errors: [{message: 'Imported JSX component $a must be in PascalCase'}]
}]
});