-
-
Notifications
You must be signed in to change notification settings - Fork 425
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 #331 - Invalid characters in component name #332
Conversation
This pull request is automatically deployed with Now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your method is the good one, thanks for your contribution!
packages/core/src/state.js
Outdated
pascalCase: true, | ||
}) | ||
const pascalCaseFileName = camelcase( | ||
path.parse(state.filePath).name.replace(/[^a-zA-Z0-9_-]/g, ''), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please extract the RegExp in a constant outside the function (it is faster).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Codecov Report
@@ Coverage Diff @@
## master #332 +/- ##
==========================================
+ Coverage 85% 85.03% +0.03%
==========================================
Files 30 30
Lines 480 481 +1
Branches 134 134
==========================================
+ Hits 408 409 +1
Misses 60 60
Partials 12 12
Continue to review full report at Codecov.
|
1 similar comment
Codecov Report
@@ Coverage Diff @@
## master #332 +/- ##
==========================================
+ Coverage 85% 85.03% +0.03%
==========================================
Files 30 30
Lines 480 481 +1
Branches 134 134
==========================================
+ Hits 408 409 +1
Misses 60 60
Partials 12 12
Continue to review full report at Codecov.
|
Summary
fixes #331 - Filenames may contain invalid characters for javascript variable names, so they need to be removed.
Test plan
Add a few tests to check that the characters are removed.
@neoziro There a few ways to handle this, but I'm not sure which way is preferred.
a-zA-Z0-9_-
)With option 1 we may run into more characters later that need to be added. Option 2 might have the issue of a filename with only invalid characters, or characters that are actually valid but are removed anyways (unicode).