Skip to content

feat: allow duplicated keys behind an option#300

Merged
fisker merged 2 commits into
prettier:mainfrom
kovsu:allow-duplicated-keys
Dec 3, 2025
Merged

feat: allow duplicated keys behind an option#300
fisker merged 2 commits into
prettier:mainfrom
kovsu:allow-duplicated-keys

Conversation

@kovsu

@kovsu kovsu commented Dec 3, 2025

Copy link
Copy Markdown
Contributor

Comment thread src/parse.ts Outdated
@fisker

fisker commented Dec 3, 2025

Copy link
Copy Markdown
Member

Let's write some tests, something like

const tests = [] // From `yaml-test-suite` or write some directly

for (const ... of tests) {
  expect(() => parse(''))....(); // assert error
  expect(() => parse('', {allowDuplicatedKeysInMap: true}))....(); // assert success
}

@fisker fisker changed the title feat: allow duplicated keys feat: allow duplicated keys behind an option Dec 3, 2025
test("duplicate keys should be allowed when `allowDuplicateKeys` is true", () => {
const text = "a: 1\na: 2";
expect(parse(text, { allowDuplicateKeys: true })).toMatchSnapshot();
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think {a:1, a:2} is a different map?

@fisker
fisker merged commit 255b89f into prettier:main Dec 3, 2025
7 of 10 checks passed
@kovsu
kovsu deleted the allow-duplicated-keys branch December 3, 2025 03:06
@fisker

fisker commented Dec 3, 2025

Copy link
Copy Markdown
Member

@fisker

fisker commented Dec 3, 2025

Copy link
Copy Markdown
Member

Changed the name to allowDuplicateKeysInMap 737e2b3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants