feat: Add option to show kebab-case component names #911
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The change replaces
classifyComponents
setting with newcomponentNameStyle
, allowing for additional styles of component names including kebab-case.Also provides somehow standardized approach to transforming component names for display.I had to double check
filter-instances
, but it seem to work alright, as both the filtered value and component names are passed throughclassify
(expect here, but it's dead code, so I left it untouched).I am not particularly proud of
kebabize
function, I tried to keep it close to already existing, similiar functions (classify
andcamelize
), but it turned rather ugly - I'll be glad if you suggest how it could be improved!One other thing worth mention is that I initially considered using enum instead of a string value for
componentNameStyle
value, but since there are no enums currently in the project and similar properties (eg.displayDensity
) uses strings as well, I dropped the idea.Motivation
Inspired by #239, the style guide and my strong preferences towards kebab-case in anything HTML-alike.
Currently present "original" option often leaves us with inconsistencies when using 3rd party libraries which use different casing than the one adopted in the project.
Since there are 2 widely accepted casings, we should be able to coerce to either of them.
Afterthoughts
getComponentDisplayName
could potentially returnAnonymous Component
when the name string is empty.Consider renaming
getComponentDisplayName
tonormalizeComponentName
to match the label?