stylelint
stylelint copied to clipboard
Create option to extend rule: font-family-no-duplicate-names
What is the problem you're trying to solve?
Taken from: https://github.com/stylelint/stylelint/issues/7593
Use case: 1. it is way easier to write in our mother language instead of mandatory in english. To train people is also easier. So the CSS files are being written in spanish in this context, and converted to english using build tool like Vite + postCSS. Vite has been improving this area recently, so currently the conversion happens in real-time and it works even in SSR/server. 2. Stylelint can lint CSS files written in spanish, because many of its rules have options to add spanish words that mirror the english ones. However, a few rules consider only hardcoded english values. These rules end up being useless to lint spanish files, unless I also lint the built files and jump back and forth fixing things.
Excellent examples of rules that already exist with options to extend its functioning:
-
"custom-property-pattern"
searches for a regexp in characters with accents : "^([a-zÀ-ÖØ-öø-ÿ][a-z0-9À-ÖØ-öø-ÿ])(--[a-z0-9À-ÖØ-öø-ÿ]+)$" instead of only english characters: "^([a-z][a-z0-9])(--[a-z0-9]+)$" 👍 -
"function-url-scheme-disallowed-list"
searches for spanish functions in the array instead of only english URL scheme: ["file", "archivo"] 👍 -
"property-allowed-list"
searches for spanish properties in the array instead of only english properties: ["border", "borde", "margin", "margen", "padding", "relleno"] 👍 -
"selector-pseudo-element-disallowed-list"
searches for spanish pseudo-elements in the array instead of only english pseudo-elements: ["después", "after", "antes", "before"] 👍
Now let's see the following rule that lacks an option to extend it:
What solution would you like to see?
-
"font-family-no-duplicate-names"
link for fonts only onfont-family
property. 👎 It could have an option to search for spanish properties:
"font-family-no-duplicate-names": [
true,
{
"considerProperty": ["font-family", "fonte-familia"] <== new option suggested
"ignoreFontFamilyNames": [],
"message": "Nombre %s duplicado inesperadamente"
}
],
@darkgreentree Thanks for opening the discussion. This request seems rare and tricky to me, so I am concerned that this addition might make the codebase more complex than necessary or cause other problems.
Related:
- #7664
- #7665