Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow plugins to bail out of custom message and do it themselfs with substitutions #5170

Closed
AndyOGo opened this issue Feb 25, 2021 · 7 comments
Labels
status: needs discussion triage needs further discussion

Comments

@AndyOGo
Copy link
Contributor

AndyOGo commented Feb 25, 2021

What is the problem you're trying to solve?

My plugin provides a custom message with substituted interpolations.
Unfortunately they are overruled by stylelint's message option introduced with #672

Support for substitutions has never been added and the request for it got closed #836

Seem that it is ignored because of this general solution, so I deleted the customMessages entry for my rule, like:

delete result.stylelint.customMessages[ruleName];

What solution would you like to see?

Well, some official way of saying, hey stylelint this plugin is handling the message option by itself.

Original issue in my plugin: AndyOGo/stylelint-declaration-strict-value#142

@jeddy3
Copy link
Member

jeddy3 commented Feb 25, 2021

@AndyOGo Thanks for the request.

Labelling as a discussion for now. Ideally, we would provide a common way for using interpolated values in custom messages that all plugins can use, but in the meantime, an official flag may by the best option.

Support for substitutions has never been added and the request for it got closed #836

It picked up again in #4117, but the issue has stalled.

@SalimBensiali
Copy link

I would love the ability to supplement the default message with extra info and recommendation. We have RTL aware Sass variables that we want developers to use instead of margin-left, border-left-color etc. And a custom message currently lacks the ability to preserve the existing message. Something with string interpolation or an additional_message option would be grand.

I would love to be able to do the following for example

{
  "rules": {
    "property-disallowed-list": [
      "/left|right$/",
      {
        "message": "${original_message}. Use the \"$start-direction\" & \"$end-direction\" SASS variables instead of \"left\" & \"right\".",
      }
    ]
  }
}

or

{
  "rules": {
    "property-disallowed-list": [
      "/left|right$/",
      {
        "additional_message": "Use the \"$start-direction\" & \"$end-direction\" SASS variables instead of \"left\" & \"right\".",
      }
    ]
  }
}

@SalimBensiali
Copy link

@jeddy3 Is there anything I can help with on this one? I would be keen to contribute, or is this needing internal discussion first?

Thanks.

@jeddy3
Copy link
Member

jeddy3 commented Apr 20, 2021

@SalimBensiali Thanks for offering to contribute. The original interpolated custom messages issue (#4117) stalled, but a proof-of-concept pull request showing how this might work would be a good start in getting it going again. It is probably worth seeing if this problem has been solved in other tools, and applying their approach here in stylelint.

@SalimBensiali
Copy link

Thanks @jeddy3. I will do some research and raise a POC PR afterwards.

@Mouvedia
Copy link
Contributor

@ybiquitous is this achievable since #6312 merge?

@ybiquitous
Copy link
Member

Yes, let's close this. The functional message support should resolve this issue.

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}"`,
}]
}
```

@ybiquitous ybiquitous closed this as not planned Won't fix, can't repro, duplicate, stale Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs discussion triage needs further discussion
Development

No branches or pull requests

5 participants