Skip to content

fix(sort-keys): fix incorrect result when moving down the block located at the file start#506

Merged
ota-meshi merged 2 commits intoota-meshi:masterfrom
sumimakito:master
Dec 15, 2025
Merged

fix(sort-keys): fix incorrect result when moving down the block located at the file start#506
ota-meshi merged 2 commits intoota-meshi:masterfrom
sumimakito:master

Conversation

@sumimakito
Copy link
Contributor

@sumimakito sumimakito commented Dec 14, 2025

Thank you for building this useful ESLint plugin. ❤️

Issue

When a block that will be moved down due to the sort-keys rule is located at the first line of the input, the fixed result will be incorrect.

Reproduction

https://ota-meshi.github.io/eslint-plugin-yml/playground/#eJyrVkrOT0lVslJKslIwislLtFIwjMlLtlIwVqoFAG+aB7Q=

Input

b: 2
a: 1
c: 3

Expected

a: 1
b: 2
c: 3

Actual

# An empty line (otherwise GitHub will omit the first empty line)
a: 1b: 2
c: 3

While skipping the first line can make sort-keys work correctly, for example,

---
b: 2
a: 1
c: 3

…, it's still an issue when the first line matters and it has to be moved down because of the rule.

@changeset-bot
Copy link

changeset-bot bot commented Dec 14, 2025

🦋 Changeset detected

Latest commit: 7a402b9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-yml Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Dec 14, 2025

@sumimakito sumimakito changed the title fix(sort-keys): fix incorrect result when move down the block located at the file start fix(sort-keys): fix incorrect result when moving down the block located at the file start Dec 14, 2025
Copy link
Owner

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks so much!

@ota-meshi ota-meshi merged commit 736f153 into ota-meshi:master Dec 15, 2025
9 checks passed
@github-actions github-actions bot mentioned this pull request Dec 15, 2025
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