stoplightio / spectral

A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI v3.1, v3.0, and v2.0 as well as AsyncAPI v2.x.
https://stoplight.io/spectral
Apache License 2.0
2.37k stars 229 forks source link

Support for Cloudfomration custom tags or disabling default parser #2305

Open p0o opened 1 year ago

p0o commented 1 year ago

User story. As a developer, I can use spectral to lint Cloudformation YAML files (AWS IaC).

Is your feature request related to a problem? Cloudfomration uses custom tags like !Sub or !GetAtt which currently are not supported by default YAML parser and causes spectral to throw errors. It makes it unusable for this use case because enforcing it using CI causes correct Cloudformation templates to fail.

Sample error:

 error  parser                  Unknown tag <!Sub>

Describe the solution you'd like I like to be able to turn off the YAML parser error or be able to add YAML custom tags, through config file.

Additional context These are the current tags (intrinsic functions) AFAIK


        "!And sequence",
        "!If",
        "!If sequence",
        "!Not",
        "!Not sequence",
        "!Equals",
        "!Equals sequence",
        "!Or",
        "!Or sequence",
        "!FindInMap",
        "!FindInMap sequence",
        "!Base64",
        "!Join",
        "!Join sequence",
        "!Cidr",
        "!Ref",
        "!Sub",
        "!Sub sequence",
        "!GetAtt",
        "!GetAZs",
        "!ImportValue",
        "!ImportValue sequence",
        "!Select",
        "!Select sequence",
        "!Split",
        "!Split sequence"```
mnaumanali94 commented 1 year ago

@p0o A concept where there's a file with a list of custom tags that the parser can ignore seems like a good idea. Would you mind contributing on this?

p0o commented 1 year ago

@mnaumanali94 I agree. Contribution on this require changes to @stoplight/yaml package right?