Skip to content

feat: Support excluding lines #27

Description

@nkakouros

In many yaml-based applications, like Ansible, Github workflows, etc, there are keys like name that make sense to be on top of the rest of the keys in a dict. It would be nice to supply a list of key names and/or an ignore-comment so that these lines are left at the same position after sorting keys. For example:

# Original
version: 1
name: test  # yaml-sort:no-sort
z: 3
a: 1

# Sorted (excluding "name")
a: 1
name: test
version: 1
z: 3

or instead of the no-sort, it could be run as:

yaml-sort --ignore name,some-other

Support for a file-level ignore comment would be nice too so that you can pass all yaml files in your codebase to yaml-sort and have it ignore those with e.g. # yaml-sort:no-sort-file somewhere in them (e.g. at the top).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions