Use this rule to report duplicated anchors and aliases referencing undeclared anchors.
true to avoid aliases that reference an anchor that
hasn't been declared (either not declared at all, or declared later in
the document).true to avoid duplications of a same anchor.true to avoid anchors being declared but
not used anywhere in the YAML document via alias.With anchors: {forbid-undeclared-aliases: true}
the following code snippet would PASS:
---
- &anchor
foo: bar
- *anchor
the following code snippets would FAIL:
---
- &anchor
foo: bar
- *unknown
---
- &anchor
foo: bar
- <<: *unknown
extra: value
With anchors: {forbid-duplicated-anchors: true}
the following code snippet would PASS:
---
- &anchor1 Foo Bar
- &anchor2 [item 1, item 2]
the following code snippet would FAIL:
---
- &anchor Foo Bar
- &anchor [item 1, item 2]
With anchors: {forbid-unused-anchors: true}
the following code snippet would PASS:
---
- &anchor
foo: bar
- *anchor
the following code snippet would FAIL:
---
- &anchor
foo: bar
- items:
- item1
- item2