NiklasPor / prettier-plugin-organize-attributes

Organize your HTML attributes automatically with Prettier ๐Ÿงผ
MIT License
197 stars 12 forks source link

Add attributeIgnoreCase parameter #5

Closed nickbullock closed 2 years ago

nickbullock commented 2 years ago

Hi, thanks for this package!

Closes #6

What I want to achieve: I'm an Angular developer and I'm trying to sort attributes in our application. One of the groups that I want to create is a group called VENDOR_DIRECTIVES. What it includes: in Angular (and in Vue I believe) you can use directives to modify nodes somehow. There is a lot of directives provided by the community and for Angular is Material library and CDK toolkit. An example of usage of such directives:

<my-component
myInput <-- not a directive
cdkScrollable <-- a directive
></my-component

To correctly describe group for inputs but ignoring cdk* directives I use the following group:

"^((?!(cdk)[A-Z])[a-z])"

but since all regexps before this pr are case insensitive it becomes

/^((?!(cdk)[A-Z])[a-z])/i

and this is not what was expected, because it actually matches the same as /cdk.*/. So I introduced an option to control ignoreCase from outside and added tests for it.

NiklasPor commented 2 years ago

Hey, first of all, thanks for your contribution ๐Ÿš€ I really like the idea of being able to modify the casing behavior. The main goal here was to have stuff like CLASS also work, but I see where you're coming from. I'm fine with merging this, but I'll probably modify the existing regexes to not break with upper / lowercasing.

NiklasPor commented 2 years ago

Also please revert the fdescribe change ๐Ÿ‘