Revamping to matrix style

This commit is contained in:
2026-02-16 16:37:35 -05:00
parent 71852ec99a
commit 9d0e3938e4
14958 changed files with 2089572 additions and 114 deletions

View File

@@ -0,0 +1,24 @@
import { Diagnostic, DiagnosticSeverity, Range } from 'vscode-languageserver-types';
import { isMap, isSeq, visit } from 'yaml';
export class YAMLStyleValidator {
constructor(settings) {
this.forbidMapping = settings.flowMapping === 'forbid';
this.forbidSequence = settings.flowSequence === 'forbid';
}
validate(document, yamlDoc) {
const result = [];
visit(yamlDoc.internalDocument, (key, node) => {
if (this.forbidMapping && isMap(node) && node.srcToken?.type === 'flow-collection') {
result.push(Diagnostic.create(this.getRangeOf(document, node.srcToken), 'Flow style mapping is forbidden', DiagnosticSeverity.Error, 'flowMap'));
}
if (this.forbidSequence && isSeq(node) && node.srcToken?.type === 'flow-collection') {
result.push(Diagnostic.create(this.getRangeOf(document, node.srcToken), 'Flow style sequence is forbidden', DiagnosticSeverity.Error, 'flowSeq'));
}
});
return result;
}
getRangeOf(document, node) {
return Range.create(document.positionAt(node.start.offset), document.positionAt(node.end.pop().offset));
}
}
//# sourceMappingURL=yaml-style.js.map