stylelint-order icon indicating copy to clipboard operation
stylelint-order copied to clipboard

Ignore the case characters order

Open evanre opened this issue 6 years ago • 3 comments

Hi, I've got a specific problem. I'm trying to implement stylelint into my environment (which is for development newsletters and based on Foundation for Emails). There is specific hacks for developing newsletters for legacy email clients. And one of them is margins support in Outlook. It requires to use a "margin" property with first capital letter. For example - Margin: 0 auto;, so the total style block looks like this:

.publications {
        display: block;
        margin: 0 auto 5px 0;
        Margin: 0 auto 5px 0;
        width: auto;
}

It's necessary to capital "Margin" follows after lower one. But in this case I'm getting alphabetical error. I suppose there is a some regexp that looks like [A-Za-z]. Is there any chance to change this behavior?

Thanks

evanre avatar Jan 12 '19 10:01 evanre

I think this plugin should ignore property case when sorting. I haven't thought about this before, because lower cased properties are kind of default in our industry :)

Your case is totally valid, a plugin should ignore the case of properties.

hudochenkov avatar Jan 13 '19 20:01 hudochenkov

@hudochenkov If change this condition https://github.com/hudochenkov/stylelint-order/blob/a274e7b160a62f72ba105c2e6e02e4a901b9be09/rules/checkAlphabeticalOrder.js#L5 to firstPropData.unprefixedName.toLowerCase() === secondPropData.unprefixedName.toLowerCase() is it will be enough to resolve issue? I tested it and it seems ignoring case without breaking anything.

But if using default stylelint-config-standard, for example, then there are property-case and declaration-block-no-duplicate-properties rules violations. Shoud we or user deal with it?

baradusov avatar Mar 05 '19 08:03 baradusov

@baradusov Thank you for looking into this!

It won't be enough, because later in this file also a check:

https://github.com/hudochenkov/stylelint-order/blob/a274e7b160a62f72ba105c2e6e02e4a901b9be09/rules/checkAlphabeticalOrder.js#L17

Both names should be lowercased before making comparison.

There is also a check for properties-order:

https://github.com/hudochenkov/stylelint-order/blob/a274e7b160a62f72ba105c2e6e02e4a901b9be09/rules/properties-order/checkOrder.js#L14

hudochenkov avatar Mar 05 '19 08:03 hudochenkov