Use this rule to control the number of spaces after hyphens (-).

Parameters

max-spaces-after
Defines the maximal number of spaces allowed after hyphens. Set to a negative integer if you want to allow any number of spaces. Cannot be set to 0.
min-spaces-after
Defines the minimal number of spaces allowed after hyphens. Set to a negative integer if you want to allow any number of spaces. When set to a positive value, cannot be greater than max-spaces-after.
check-scalars
YAMLLint will consider "-xx" as a scalar. However you may consider that, in your context, such a syntax is a typo and is actually a sequence and as a consequence there should be a space after the hyphen. As this is not a standard behaviour, you explicitly need to enable this control by setting the option check-scalars to true. Use with caution as all scalars will be checked and non-solvable false positive might be identified. Has no effect when set to true but min-spaces-after is disabled (< 0).

Examples

With max-spaces-after = 1 the following code snippet would PASS:

    - first list:
        - a
        - b
    - - 1
      - 2
      - 3

the following code snippets would FAIL:

    -  first list:
         - a
         - b

With max-spaces-after = 3 the following code snippet would PASS:

    -   key
    -  key2
    - key42

the following code snippet would FAIL:

    -    key
    -   key2
    -  key42

With hyphens: {min-spaces-after: 3} the following code snippet would PASS:

    list:
    -   key
    -    key2
    -     key42
    -foo:  # starter of a new sequence named "-foo"; without the colon, a syntax error will be raised.

the following code snippet would FAIL:

    -  key
    -   key2
    -  key42

With hyphens: {min-spaces-after: 3, check-scalars: true} the following code snippet would PASS:

    list:
    -   key
    -    key2
    -     key42
    key: -value

the following code snippet would FAIL:

    ---
    -item

or

    sequence:
      -key  # Mind the spaces before the hyphen to enforce the sequence and avoid a syntax error