css-in-js icon indicating copy to clipboard operation
css-in-js copied to clipboard

[Feature proposal] Enable extension only on certain file

Open fabioimpe opened this issue 8 years ago • 5 comments

It would be nice to have some configuration parameter which allows to set some activation criteria for the extension.

Scenario: I do not want the style autocomplete in every .js file in my project, I have all the style in separate file, all of them are called somenameStyle.js, in configuration I can set the wildcard "*/*Style.js" to enable the extension only on those files.

Think about it, I love your project ;)

fabioimpe avatar Mar 07 '18 09:03 fabioimpe

Interesting idea! Thanks for sharing!

Which editor do you use?

@ansumanshah maybe we should have issue labels for each editor to make triage easier?

paulmolluzzo avatar Mar 07 '18 15:03 paulmolluzzo

I'm on VS Code. Another criteria could be a comment on top of the file, like flow does. Would be great if in the future will be introduced the .jss file extension, but for now it's just a crazy dream :)

fabioimpe avatar Mar 07 '18 15:03 fabioimpe

So on Atom I believe the autocomplete is limited to when you’re within the scope of a glamorous expression, but I didn’t build that in to the VS Code extension. (I don’t know how. 😅) That might be enough to meet your requirements, unless your "style.js" files are plain objects, then we need to implement your other ideas.

paulmolluzzo avatar Mar 07 '18 15:03 paulmolluzzo

My styles are actually plain object with imports on top in some cases, it’s just to keep them separate from the components

fabioimpe avatar Mar 07 '18 16:03 fabioimpe

My styles are actually plain object with imports on top in some cases, it’s just to keep them separate from the components

In that case, either looking for a comment or testing the filename seems like the only way.

That said, requiring a comment or configuration to activate the plugin seems like an annoying step if you always want autocomplete on. 🤔 I'm not saying we shouldn't or can't have a configurable option, but IMO it should default to being "on" without a config set.

I don't have much time to look into this right now, but if anyone out there wants to open a PR that limits the scope of autocomplete to glamorous expressions like the Atom version does, or implements any of these suggestions @fabioimpe made, PRs are welcome! 🙏

paulmolluzzo avatar Mar 08 '18 16:03 paulmolluzzo