Skip to content


enforce consistent spacing after the # in a comment

  • ⚙️ This rule is included in "plugin:yml/standard".
  • 🔧 The --fix option on the command line can automatically fix some of the problems reported by this rule.

📖 Rule Details

This rule will enforce consistency of spacing after the start of a comment #. It also provides several exceptions for various documentation styles.

Now loading...

ESLint core spaced-comment rule don't work well in YAML. Turn off that rule in YAML files and use yml/spaced-comment rule.
Use the overrides setting to apply these only to YAML files:

module.exports = {
  overrides: [
      files: ["*.yaml", "*.yml"],
      parser: "yaml-eslint-parser",
      rules: {
        "spaced-comment": ["off"],
        "yml/spaced-comment": ["error"],

🔧 Options

  - error
  - always # or "never"
  - exceptions: []
    markers: []
  • First option
    • "always" ... the # must be followed by at least one whitespace.
    • "never" ... should be no whitespace following.
  • Second option
    • "exceptions" ... It is an array of string patterns which are considered exceptions to the rule. The rule will not warn when the pattern starts from the beginning of the comment and repeats until the end of the line. Please note that exceptions are ignored if the first argument is "never".
    • "markers" ... It is an array of string patterns which are considered markers for docblock-style comments. The "markers" array will apply regardless of the value of the first argument, e.g. "always" or "never".

See also here.

🚀 Version

This rule was introduced in eslint-plugin-yml v0.1.0

🔍 Implementation

Taken with ❤️ from ESLint core