Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anchors: Add new rule to detect undeclared or duplicated anchors #550

Merged
merged 1 commit into from
Mar 22, 2023

Commits on Mar 19, 2023

  1. anchors: Add new rule to detect undeclared or duplicated anchors

    According to the YAML specification [^1]:
    
    - > It is an error for an alias node to use an anchor that does not
      > previously occur in the document.
    
      The `forbid-undeclared-aliases` option checks that aliases do have a
      matching anchor declared previously in the document. Since this is
      required by the YAML spec, this option is enabled by default.
    
    - > The alias refers to the most recent preceding node having the same
      > anchor.
    
      This means that having a same anchor repeated in a document is
      allowed. However users could want to avoid this, so the new option
      `forbid-duplicated-anchors` allows that. It's disabled by default.
    
    - > It is not an error to specify an anchor that is not used by any
      > alias node.
    
      This means that it's OK to declare anchors but don't have any alias
      referencing them. However users could want to avoid this, so a new
      option (e.g. `forbid-unused-anchors`) could be implemented in the
      future. See #537.
    
    Fixes #395
    Closes #420
    
    [^1]: https://yaml.org/spec/1.2.2/#71-alias-nodes
    adrienverge committed Mar 19, 2023
    Configuration menu
    Copy the full SHA
    9e67d02 View commit details
    Browse the repository at this point in the history