google / google/yamlfmt

Tolerate funny includes

Open
#262 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
1.8k
Forks
75
PR merge metrics
No merged PRs in 30d

Description

We use hpack, which results in having a lot of yaml.

Excerpt of such YAML:

```yaml
<<: !include ../../hpack-common/defaults.yaml

name: some-package
version: 0.1.0.0
license: NONE
author: ""
maintainer: ""

flags:
dev:
description: "some flag"
manual: true
default: false
<<: *defaultflags
```

This yaml is valid in hpack, where it pulls the anchor value from `hpack-common/defaults.yaml`, which contains:

```yaml
<<: !include default-extensions.yaml
<<: !include flags.yaml
<<: !include ghc-options.yaml
```

And then `hpack-common/flags.yaml` contains:

```
_defaultflags: &defaultflags
hie:
description: Generate HIE files
manual: true
default: true
```

This whole thing is valid in the Haskell yaml parser as used by hpack and does merge all of the `<<` together even though my language server does not like it and apparently nor does yamlfmt:

```
$ yamlfmt local-packages/somepackage/package.yaml
encountered the following formatting errors:
local-packages/somepackage/package.yaml: yaml: unknown anchor 'defaultflags' referenced
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.