Skip to content

Stabilise functional support for message option #6966

@ybiquitous

Description

@ybiquitous

Currently, many built-in rules support the message option's function feature:

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
      92

And 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:
  • Remove the sentence from all the rule README:
  • Remove "Experimental feature" wording from the doc:

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: wipis being worked on by someone

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions