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

[New] jsx-pascal-case: Support unicode characters #2557

Merged
merged 1 commit into from Feb 14, 2020
Merged

[New] jsx-pascal-case: Support unicode characters #2557

merged 1 commit into from Feb 14, 2020

Conversation

Svish
Copy link
Contributor

@Svish Svish commented Jan 29, 2020

Fixes #1654

Uses the \p Unicode character property matcher, and the tests run fine. πŸ‘

Note

I pulled in the xregexp package to definitely support \p. The tests does seem to work without it, at least it Works On My Machineβ„’, but eslint, or something at least, doesn't seem to like it? πŸ€”

image

@Svish
Copy link
Contributor Author

Svish commented Jan 29, 2020

Can't seem to find any log or anything for why the travis build fails. But I do know there were failing tests in the project even before I started, so that could be one reason. πŸ€”

Tests related to the jsx-pascal-case rule runs fine.

@Svish Svish requested a review from ljharb January 29, 2020 12:50
const PASCAL_CASE_REGEX = /^(.*[.])*([A-Z]|[A-Z]+[a-z0-9]+(?:[A-Z0-9]+[a-z0-9]*)*)$/;
const ALL_CAPS_TAG_REGEX = /^[A-Z0-9]+([A-Z0-9_]*[A-Z0-9]+)?$/;
const PASCAL_CASE_REGEX = XRegExp('^(.*[.])*([\\p{Lu}]|[\\p{Lu}]+[\\p{Ll}0-9]+(?:[\\p{Lu}0-9]+[\\p{Ll}0-9]*)*)$', 'u');
const ALL_CAPS_TAG_REGEX = XRegExp('^[\\p{Lu}0-9]+([\\p{Lu}0-9_]*[\\p{Lu}0-9]+)?$', 'u');
Copy link
Contributor

Choose a reason for hiding this comment

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

Test is failing because you used RegExp u flag but it is not available in node 4. https://node.green/#ES2015-syntax-RegExp--y--and--u--flags

Copy link
Member

Choose a reason for hiding this comment

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

@Svish we'll need to come up with another solution that doesn't rely on unicode mode in regexes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, support unicode characters in a way that doesn't rely on unicode? Guess I'm out and will have to just disable this rule then...

But really, why not just drop support for Node 4 and 5? They're like 4+ years old now. If someone for some reason needs to stick with Node 4 or 5, they can always stick with an eslint-plugin-react version pre Unicode as well?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, you're using XRegExp tho, which shouldn't require native unicode support.

Their age isn't relevant, people still use them; and it's not worth a breaking change for it.

However, it would be fine if the unicode recognition only worked in versions of node that support the u flag - we could detect the support (function hasU() { try { new RegExp('o', 'u'); return true; } catch (e) { return false; } }) and treat the tests differently.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ljharb I don't know how to do that though, so think someone else needs to take over here. Sorry. πŸ˜•

Copy link
Member

Choose a reason for hiding this comment

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

Done.

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.

jsx-pascal-case warns on valid casing when using non-English characters
3 participants