Skip to content

no-duplicate-anchors

GitHub ActionsYAMLsuspiciousno fixdefault: warnyaml/yamllint

Reports an anchor name that is defined again in the same document, on the second &name.

An alias refers to the latest definition above it, so after a repeated anchor the same *name can mean two different nodes depending on its place, which is easy to misread.

To fix, give the second anchor another name.

Reported
- &a 1
- &a 2
github-actions:
lint:
rules:
no-duplicate-anchors: warn # off, warn (default), error
yaml:
lint:
rules:
no-duplicate-anchors: warn # off, warn (default), error

Enabled by the presets: yaml/yamllint.

Suppress one line with sudsy-disable-next-line no-duplicate-anchors in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
yamllint anchors.forbid-duplicated-anchors full