ansumanshah / css-in-js

Autocomplete React Native / JS Styles and converting plain CSS to JS styles
https://atom.io/packages/css-in-js
MIT License
208 stars 21 forks source link

[Feature proposal] Enable extension only on certain file #18

Open fabioimpe opened 6 years ago

fabioimpe commented 6 years ago

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 ;)

paulmolluzzo commented 6 years ago

Interesting idea! Thanks for sharing!

Which editor do you use?

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

fabioimpe commented 6 years ago

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 :)

paulmolluzzo commented 6 years ago

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.

fabioimpe commented 6 years ago

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

paulmolluzzo commented 6 years ago

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! 🙏