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

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

merged 1 commit into from Aug 31, 2019

Conversation

Haegin
Copy link
Contributor

@Haegin Haegin commented Aug 28, 2019

Fixes #2394.

$ and _ are valid names for components that are neither upper nor lower
case. This change ensures the pascal case rule only applies to the rest
of the component name (if any).

Fixes #2394.

$ and _ are valid names for components that are neither upper nor lower
case. This change ensures the pascal case rule doesn't apply to single letter components
@@ -13,7 +13,7 @@ const jsxUtil = require('../util/jsx');
// Constants
// ------------------------------------------------------------------------------

const PASCAL_CASE_REGEX = /^([A-Z0-9]|[A-Z0-9]+[a-z0-9]+(?:[A-Z0-9]+[a-z0-9]*)*)$/;
const PASCAL_CASE_REGEX = /^([$_A-Z0-9]|[$_]?[A-Z0-9]+[a-z0-9]+(?:[A-Z0-9]+[a-z0-9]*)*)$/;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe instead of this - which could allow much more complex patterns - we just bail out if [...name].length === 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would certainly work for me. Do we still want to disallow a single lowercase letter as the name?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since anything that starts lowercase isn't a custom component, it's an html component, i don't think this rule would warn on it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah cool, in which case I'll make that change. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

react/jsx-pascal-case incorrectly flags $ as not being in pascal case
2 participants