reviewdog / action-stylelint

Run stylelint with reviewdog
https://github.com/marketplace?type=actions&query=reviewdog
MIT License
47 stars 25 forks source link

Stylelint Format Message Text #115

Closed bert-mccutchen closed 9 months ago

bert-mccutchen commented 9 months ago

Fixes https://github.com/reviewdog/action-stylelint/issues/112 ... again

Why?

Turns out that Stylelint doesn't pre-escape strings before they are passed to formatters, which I suppose makes sense. This was causing lots of invalid characters (like newlines) to make its way into the resulting JSON, which was breaking Reviewdog.

I am astounded at how JSON.stringify doesn't automatically escape invalid characters, and that it would rather produce an invalid JSON result.

Also, i'm not sure how this composite action was working before, since it was using the default JSON formatter - which doesn't do anything we needed to do here today. Maybe jq could parse the invalid JSON and then produce a valid result?

What

Added formatMessageText from the Stylelint stringFormatter source.

github-actions[bot] commented 9 months ago

🏷️ [bumpr] Next version:v1.21.0 Changes:v1.20.2...reviewdog:stylelint-format-message-text

bert-mccutchen commented 9 months ago

As a side note from all of this, we should add a more complete test suite that we can run via actions:

  1. Create a test file that breaks each rule for stylelint-config-recommended.
    • Also throw in newlines and special characters throughout.
  2. Check the Reviewdog output for the expected results.
  3. Run this for the following matrix:
    • Stylelint 15 - Node 14, 16, 18, 20
    • Stylelint 16 - Node 18, 20
bert-mccutchen commented 9 months ago

Another thing we should do is create a separation between Stylelint 15 for CommonJS and Stylelint 16+ for ESM. This way we don't have to worry when they drop Stylelint 17 without CommonJS.

github-actions[bot] commented 9 months ago

🚀 [bumpr] Bumped! New version:v1.21.0 Changes:v1.20.2...v1.21.0