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

Issue extending web-recommended and configuring http-compressions #905

Closed
molant opened this issue Mar 21, 2018 · 4 comments
Closed

Issue extending web-recommended and configuring http-compressions #905

molant opened this issue Mar 21, 2018 · 4 comments
Assignees

Comments

@molant
Copy link
Member

molant commented Mar 21, 2018

Original report by @jgarber623:

This configuration works, but doesn't include any rule customization:

{
  "extends": [
    "web-recommended"
  ],
  "formatters": [
    "codeframe"
  ],
  "ignoredUrls": [
    {
      "domain": ".*\\.googleapis\\.com/.*",
      "rules": ["*"]
    }
  ]
}

This configuration does not work:

{
  "extends": [
    "web-recommended"
  ],
  "formatters": [
    "codeframe"
  ],
  "rules": {
    "http-compression": ["warning", {
      "html": {
        "brotli": false
      }
    }]
  },
  "ignoredUrls": [
    {
      "domain": ".*\\.googleapis\\.com/.*",
      "rules": ["*"]
    }
  ]
}

The error message shown is "Invalid rule configuration in .sonarwhalrc: http-compression."

My goal is to silence errors/warnings about using Brotli and Zopfli compression.

@molant molant added the support label Mar 21, 2018
@molant molant changed the title Issue extendind web-recommended and configuring http-compressions Issue extending web-recommended and configuring http-compressions Mar 21, 2018
@molant
Copy link
Member Author

molant commented Mar 21, 2018

The following works:

{
  "extends": [
    "web-recommended"
  ],
  "formatters": [
    "codeframe"
  ],
  "rules": {
    "http-compression": "off"
  },
  "ignoredUrls": [
    {
      "domain": ".*\\.googleapis\\.com/.*",
      "rules": ["*"]
    }
  ]
}

so it looks like a problem when merging the rule configurations options with the extends part.

@molant
Copy link
Member Author

molant commented Mar 21, 2018

I've created #907 to fix this issue. If you don't want to wait until things are merged and published on npm you can change html with target in your configuration and it should work.

@alrra alrra closed this as completed in c33c87f Mar 21, 2018
@alrra
Copy link
Contributor

alrra commented Mar 21, 2018

@jgarber623 We published a new version of the http-compression rule. So, the easiest way to get it is to just run npm i @sonarwhal/configuration-web-recommended.

Thanks again for taking the time to let us know!

@jgarber623
Copy link

Thanks, @molant and @alrra! Those updates did the trick.

For future travelers, my updated config works great and now looks like:

{
  "extends": [
    "web-recommended"
  ],
  "formatters": [
    "codeframe"
  ],
  "rules": {
    "http-compression": ["warning", {
      "html": {
        "brotli": false,
        "zopfli": false
      },
      "resource": {
        "brotli": false,
        "zopfli": false
      }
    }]
  },
  "ignoredUrls": [
    {
      "domain": ".*\\.googleapis\\.com/.*",
      "rules": ["*"]
    }
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants