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

Fix edge cases on jsx-pascal-case #2637

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
46 changes: 39 additions & 7 deletions tests/lib/rules/jsx-pascal-case.js
Expand Up @@ -72,14 +72,34 @@ ruleTester.run('jsx-pascal-case', rule, {
}, {
code: '<qualification.T3StComp0Nent />'
}, {
code: '<Modal:Header />'
}, {
code: '<IGNORED />',
options: [{ignore: ['IGNORED']}]
code: '<__this.TestComponent />'
}, {
code: '<$ />'
}, {
code: '<_ />'
}, {
// The rule must not warn on components with a namespace
// because this pattern is handled by jsx-no-namespace
code: '<svg:path />'
}, {
code: '<ns:testComponent />'
}, {
code: '<Ns:testComponent />'
}, {
code: '<__ns:testComponent />'
}, {
code: '<ns:TestComponent />'
}, {
code: '<Ns:TestComponent />'
}, {
code: '<__ns:TestComponent />'
}, {
code: '<Modal:Header />'
}, {
code: '<layout:Header />'
}, {
code: '<IGNORED />',
options: [{ignore: ['IGNORED']}]
}],

invalid: [{
Expand All @@ -91,6 +111,21 @@ ruleTester.run('jsx-pascal-case', rule, {
}, {
code: '<YMCA />',
errors: [{message: 'Imported JSX component YMCA must be in PascalCase'}]
}, {
code: '<$a />',
errors: [{message: 'Imported JSX component $a must be in PascalCase'}]
}, {
code: '<foo.bar />',
errors: [{message: 'Imported JSX component bar must be in PascalCase'}]
}, {
code: '<object.testComponent />',
errors: [{message: 'Imported JSX component testComponent must be in PascalCase'}]
}, {
code: '<Module.testComponent />',
errors: [{message: 'Imported JSX component testComponent must be in PascalCase'}]
}, {
code: '<__this.testComponent />',
errors: [{message: 'Imported JSX component testComponent must be in PascalCase'}]
}, {
code: '<_TEST_COMPONENT />',
options: [{allowAllCaps: true}],
Expand All @@ -103,8 +138,5 @@ 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'}]
}]
});