diff --git a/src/rules/yaml-key-sort.ts b/src/rules/yaml-key-sort.ts index f86b95e9..e3536de1 100644 --- a/src/rules/yaml-key-sort.ts +++ b/src/rules/yaml-key-sort.ts @@ -63,6 +63,10 @@ export default class YamlKeySort extends RuleBuilder { const doc = parseYAML(yamlText); const startingPriorityKeys = getEmptyDocument(doc); + if (doc.contents == null) { + return text; + } + let remainingKeys = this.getYAMLKeysSorted(yamlKeys, doc, startingPriorityKeys); const sortOrder = options.yamlSortOrderForOtherKeys;