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

Merge keys shouldn’t be supported by default #646

Open
remcohaszing opened this issue Nov 16, 2021 · 2 comments
Open

Merge keys shouldn’t be supported by default #646

remcohaszing opened this issue Nov 16, 2021 · 2 comments
Labels

Comments

@remcohaszing
Copy link

Support for merge keys was removed in YAML 1.2. However, this is still supported in js-yaml.

See changes in version 1.2

Since js-yaml aims to be YAML 1.2 compatible, it should treat << as a regular key.

Given the following script:

const yaml = require('js-yaml');

console.dir(yaml.load(`
foo: &foo
  f: oo

bar:
 <<: *foo
`))

Expected output:

{ foo: { f: 'oo' }, bar: { '<<': { f: 'oo' } } }

Actual output:

{ foo: { f: 'oo' }, bar: { f: 'oo' } }

I realize many people expect this to work the way as it does now, so a fix should be considered carefully, possibly in a major version release.

@perlpunk
Copy link

I would recommend to make this feature an option instead of removing it completely.
There's nothing in 1.2 that can replace this feature, and if an app clearly documents that this is supported in its YAML files, then it should be fine to use.
Ideally it should be off by default, but that could break stuff of course.

@remcohaszing remcohaszing changed the title Merge keys shouldn’t be supported Merge keys shouldn’t be supported by default Nov 16, 2021
@puzrin puzrin added the spec 1.2 label May 9, 2022
@yuriy-yarosh
Copy link

yuriy-yarosh commented Jan 3, 2024

There are a lot of projects which could benefit from anchor merging.
Where do I sign to make it optional, as well ?

Mentioned about yarn previously, and here #561 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants