chore: force component and route names to have dashes#467
chore: force component and route names to have dashes#467hansl merged 1 commit intoangular:masterfrom
Conversation
|
Could you add a test 😄 |
250ed62 to
0e103c8
Compare
| this.dynamicPath = parsedPath; | ||
|
|
||
| if (!validateName(parsedPath.name)) { | ||
| throw 'Invalid name. Names must be camelCase or kabob-case'; |
There was a problem hiding this comment.
I should know better than to trust my spelling, ever since 3rd grade when I spelled enough "enuff"
Thanks for catching that @gkalpak!
0e103c8 to
5858a5e
Compare
| this.dynamicPath = parsedPath; | ||
|
|
||
| if (!validateName(parsedPath.name)) { | ||
| throw 'Invalid name. Names must be camelCase or kebab-case'; |
There was a problem hiding this comment.
FWIW, the message might be confusing with single-word names, since toast is technically valid camelCase and kebab-case.
More generally, validateName() isn't strict at all, which means that all sorts of non-camelCase-or-kebab-case names would pass. (But maybe that's intentional.)
There was a problem hiding this comment.
The purpose of this is to enforce the selector to contain a - so I agree, I'll tweak it to show a more useful message to the user.
I'm aware that the names can contain any variety of capital/lower/dash characters, but that is indeed intentional, as long as the name transformation creates a selector with at least 1 dash, then it will satisfy the HTML spec for custom elements.
I'm open to suggestions on the actual error message, I currently have this:
Names must contain a dash either include a dash or multiCase name. (i.e. multiCase -> multi-case)
There was a problem hiding this comment.
I think that's better. "Invalid name" does scare people off.
|
Change the message, then LGTM 👍 |
5858a5e to
cd4dcf0
Compare
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
No description provided.