Search code examples
node.jsstylelint

PostCSS stylelint cannot set `comment-no-empty`?


PostCSS stylelint cannot set comment-no-empty?

In .stylelintrc.json I have:

{
  "extends": "stylelint-config-recommended-scss",
}

When I run this, I get an Unexpected empty comment error that I want disabled.

However, stylelint-config-recommended-scss.js already has this rule disabled:

rules: {
  'annotation-no-unknown': null,
  'at-rule-no-unknown': null,
  'comment-no-empty': null,
}

And adding it to .stylelintrc.json doesn't work either.

{
  "extends": "stylelint-config-recommended-scss",
  "rules": {
    "comment-no-empty": null
  }
}

Am I missing something? Thanks :)


Solution

  • The stylelint-config-recommended-scss config replaces the built-in comment-no-empty rule with its own scss/comment-no-empty one.

    The scss/comment-no-empty can detect both // and /* */ empty comments.

    To disable the rule, you can turn it off in your config:

    {
      "extends": "stylelint-config-recommended-scss",
      "rules": {
        "scss/comment-no-empty": null
      }
    }
    

    Note that the rule is prefixed with scss, the name of the SCSS plugin.

    (In your config, you're trying to turn off the already turned-off built-in rule.)