heybourn / headwind

An opinionated Tailwind CSS class sorter built for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=heybourn.headwind
MIT License
1.38k stars 46 forks source link

Modify classRegex to be more configurable #47

Closed notzenox closed 4 years ago

notzenox commented 4 years ago

Before this change, we used a single classRegex string for all possible file types. This change allows more configurability in the form of different classRegexs for different languages. Thanks to this PR using Headwind in a bigger project will be more useful.

Headwind detects the documents languageId and uses it's classRegex config for finding the class strings.

The classRegex config now requires that capture groups contain a class string like class1 class2 class3 instead of one containing a class string with apostrophies and one without. There can be multiple capture groups which can be used for example in React applications where we have both className attributes and CSS-in-JS tw tagged templates.

In this PR when there's no config for some language Headwind just won't parse the file. Should this be the default behaviour? Because it can be easily changed to use a default html config or show a message.

praveenperera commented 4 years ago

I think we should default to HTML config

notzenox commented 4 years ago

Done as requested and also added default configs for css, ts, tsx.

notzenox commented 4 years ago

Fixed typo in css regex.