-
-
Notifications
You must be signed in to change notification settings - Fork 986
Labels
status: wipis being worked on by someoneis being worked on by someone
Description
Currently, many built-in rules support the message option's function feature:
stylelint/docs/user-guide/configure.md
Lines 114 to 137 in 113888c
| Experimental feature: some rules support message arguments. For example, when configuring the `color-no-hex` rule, the hex color can be used in the message string: | |
| `.stylelintrc.js`: | |
| ```js | |
| { | |
| 'color-no-hex': [true, { | |
| message: (hex) => `Don't use hex colors like "${hex}"`, | |
| }] | |
| } | |
| ``` | |
| `.stylelintrc.json`: | |
| <!-- prettier-ignore --> | |
| ```json | |
| { | |
| "color-no-hex": [true, { | |
| "message": "Don't use hex colors like \"%s\"" | |
| }] | |
| } | |
| ``` | |
| With formats that don't support a function like JSON, you can use a `printf`-like format (e.g., `%s`). On the other hand, with JS format, you can use both a `printf`-like format and a function. |
Rough calculation:
$ git grep -l 'messageArgs: \[' lib/rules/*/index.js | wc -l
92And people have never complained about the feature spec, as I remember.
So, I suggest dropping experimental from this feature and officially publishing it.
Here're tasks:
- Add the function support to all rules except for deprecated ones.
- Fix the test:
stylelint/lib/rules/__tests__/index.test.js
Lines 62 to 63 in 113888c
// NOTE: If all rules support a custom message option, we should remove this `if` statement. if (!jsCode.includes('\tmessageArgs: [')) return;
- Remove the sentence from all the rule README:
The [`message` secondary option](../../../docs/user-guide/configure.md#message) can accept the arguments of this rule.
- Remove "Experimental feature" wording from the doc:
stylelint/docs/user-guide/configure.md
Line 114 in 113888c
Experimental feature: some rules support message arguments. For example, when configuring the `color-no-hex` rule, the hex color can be used in the message string:
Metadata
Metadata
Assignees
Labels
status: wipis being worked on by someoneis being worked on by someone