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

Add support for custom class regex #7

Closed SaschaDens closed 4 years ago

SaschaDens commented 4 years ago

This feature request is created for the open issue #4 and allows user to configure a custom regex based on the user requirements.

The default regex \bclass(?:Name)*\s*=\s*([\"\']([_a-zA-Z0-9\s\-\:]+)[\"\']) matches the following patterns

In case a capturing group is used in the regex the user needs to ensure that the group is non-capturing or else a weird behaviour can occur.

This is related to the following snippet: https://github.com/heybourn/headwind/blob/d77b0fbabd0554ab67871f4bdac2ffd6f5844c45/src/extension.ts#L20-L21

heybourn commented 4 years ago

I've merged, but compiling throws the following error:

Argument of type 'RegExp | undefined' is not assignable to parameter of type 'string'.

Mind taking a look into this and submitting a PR with a fix? @SaschaDens

SaschaDens commented 4 years ago

Sure, will look into it.