component-inspector icon indicating copy to clipboard operation
component-inspector copied to clipboard

Add support for property names that start with an underscore

Open jgornick opened this issue 2 years ago • 2 comments

Currently, if I have a property name that starts with an underscore, it's formatted to camelCase (e.g., _state converts to state). However, if I have a property name of state and another of _state, the output definitions duplicate the "state" property. An expectation here is that the underscore at the beginning of the property name is respected as an individual property.

Just another consideration: In some cases, the use of underscores on interface field names has an implied "private" or "protected" meaning. In recent JS, the # character means "private". I don't know if there's something there with regards to what's included in the definition output.

I will say though, I'm using the underscore to indicate a property specific for Figma usage and not to be exported for a component API.

Great plugin BTW! Thank you!

jgornick avatar Feb 01 '23 22:02 jgornick

ah yes this is great feedback, i have a pretty greedy cleaning regex, should probably add a bit more discretion.

as for the ignoring prefix convo, run the configuration mode for the plugin and you can set a prefix to ignore. it's not currently respected for angular, web components, or json (my bad, should fix), but works for vue and react today.

jake-figma avatar Feb 01 '23 22:02 jake-figma

Thank you for the prompt response and info @jake-figma! I should have RTFM'd a little to know there was already the ignore prop, but new to Figma so didn't really know all that I was looking at 😄

We're just starting to introduce this plugin into our component creation process and I'll see if we can squeeze in some time to provide a fix as well.

jgornick avatar Feb 17 '23 16:02 jgornick