summaryrefslogtreecommitdiff
path: root/node_modules/yaml/browser/dist/compose
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/yaml/browser/dist/compose')
-rw-r--r--node_modules/yaml/browser/dist/compose/compose-collection.js18
-rw-r--r--node_modules/yaml/browser/dist/compose/compose-doc.js1
-rw-r--r--node_modules/yaml/browser/dist/compose/compose-node.js2
-rw-r--r--node_modules/yaml/browser/dist/compose/compose-scalar.js2
-rw-r--r--node_modules/yaml/browser/dist/compose/resolve-block-map.js4
-rw-r--r--node_modules/yaml/browser/dist/compose/resolve-block-scalar.js8
-rw-r--r--node_modules/yaml/browser/dist/compose/resolve-block-seq.js1
-rw-r--r--node_modules/yaml/browser/dist/compose/resolve-flow-collection.js2
-rw-r--r--node_modules/yaml/browser/dist/compose/resolve-props.js34
9 files changed, 54 insertions, 18 deletions
diff --git a/node_modules/yaml/browser/dist/compose/compose-collection.js b/node_modules/yaml/browser/dist/compose/compose-collection.js
index 8d4507f3..b80fba27 100644
--- a/node_modules/yaml/browser/dist/compose/compose-collection.js
+++ b/node_modules/yaml/browser/dist/compose/compose-collection.js
@@ -23,10 +23,23 @@ function resolveCollection(CN, ctx, token, onError, tagName, tag) {
coll.tag = tagName;
return coll;
}
-function composeCollection(CN, ctx, token, tagToken, onError) {
+function composeCollection(CN, ctx, token, props, onError) {
+ const tagToken = props.tag;
const tagName = !tagToken
? null
: ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg));
+ if (token.type === 'block-seq') {
+ const { anchor, newlineAfterProp: nl } = props;
+ const lastProp = anchor && tagToken
+ ? anchor.offset > tagToken.offset
+ ? anchor
+ : tagToken
+ : (anchor ?? tagToken);
+ if (lastProp && (!nl || nl.offset < lastProp.offset)) {
+ const message = 'Missing newline after block sequence props';
+ onError(lastProp, 'MISSING_CHAR', message);
+ }
+ }
const expType = token.type === 'block-map'
? 'map'
: token.type === 'block-seq'
@@ -40,8 +53,7 @@ function composeCollection(CN, ctx, token, tagToken, onError) {
!tagName ||
tagName === '!' ||
(tagName === YAMLMap.tagName && expType === 'map') ||
- (tagName === YAMLSeq.tagName && expType === 'seq') ||
- !expType) {
+ (tagName === YAMLSeq.tagName && expType === 'seq')) {
return resolveCollection(CN, ctx, token, onError, tagName);
}
let tag = ctx.schema.tags.find(t => t.tag === tagName && t.collection === expType);
diff --git a/node_modules/yaml/browser/dist/compose/compose-doc.js b/node_modules/yaml/browser/dist/compose/compose-doc.js
index d36c380b..95f97246 100644
--- a/node_modules/yaml/browser/dist/compose/compose-doc.js
+++ b/node_modules/yaml/browser/dist/compose/compose-doc.js
@@ -17,6 +17,7 @@ function composeDoc(options, directives, { offset, start, value, end }, onError)
next: value ?? end?.[0],
offset,
onError,
+ parentIndent: 0,
startOnNewline: true
});
if (props.found) {
diff --git a/node_modules/yaml/browser/dist/compose/compose-node.js b/node_modules/yaml/browser/dist/compose/compose-node.js
index 39d98e36..611c4a55 100644
--- a/node_modules/yaml/browser/dist/compose/compose-node.js
+++ b/node_modules/yaml/browser/dist/compose/compose-node.js
@@ -26,7 +26,7 @@ function composeNode(ctx, token, props, onError) {
case 'block-map':
case 'block-seq':
case 'flow-collection':
- node = composeCollection(CN, ctx, token, tag, onError);
+ node = composeCollection(CN, ctx, token, props, onError);
if (anchor)
node.anchor = anchor.source.substring(1);
break;
diff --git a/node_modules/yaml/browser/dist/compose/compose-scalar.js b/node_modules/yaml/browser/dist/compose/compose-scalar.js
index fb4447d8..98e8cd03 100644
--- a/node_modules/yaml/browser/dist/compose/compose-scalar.js
+++ b/node_modules/yaml/browser/dist/compose/compose-scalar.js
@@ -5,7 +5,7 @@ import { resolveFlowScalar } from './resolve-flow-scalar.js';
function composeScalar(ctx, token, tagToken, onError) {
const { value, type, comment, range } = token.type === 'block-scalar'
- ? resolveBlockScalar(token, ctx.options.strict, onError)
+ ? resolveBlockScalar(ctx, token, onError)
: resolveFlowScalar(token, ctx.options.strict, onError);
const tagName = tagToken
? ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg))
diff --git a/node_modules/yaml/browser/dist/compose/resolve-block-map.js b/node_modules/yaml/browser/dist/compose/resolve-block-map.js
index 679b3dee..1413a880 100644
--- a/node_modules/yaml/browser/dist/compose/resolve-block-map.js
+++ b/node_modules/yaml/browser/dist/compose/resolve-block-map.js
@@ -21,6 +21,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, ta
next: key ?? sep?.[0],
offset,
onError,
+ parentIndent: bm.indent,
startOnNewline: true
});
const implicitKey = !keyProps.found;
@@ -41,7 +42,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, ta
}
continue;
}
- if (keyProps.hasNewlineAfterProp || containsNewline(key)) {
+ if (keyProps.newlineAfterProp || containsNewline(key)) {
onError(key ?? start[start.length - 1], 'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line');
}
}
@@ -63,6 +64,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, ta
next: value,
offset: keyNode.range[2],
onError,
+ parentIndent: bm.indent,
startOnNewline: !key || key.type === 'block-scalar'
});
offset = valueProps.end;
diff --git a/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js b/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js
index 592d8075..9b7b7b55 100644
--- a/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js
+++ b/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js
@@ -1,8 +1,8 @@
import { Scalar } from '../nodes/Scalar.js';
-function resolveBlockScalar(scalar, strict, onError) {
+function resolveBlockScalar(ctx, scalar, onError) {
const start = scalar.offset;
- const header = parseBlockScalarHeader(scalar, strict, onError);
+ const header = parseBlockScalarHeader(scalar, ctx.options.strict, onError);
if (!header)
return { value: '', type: null, comment: '', range: [start, start, start] };
const type = header.mode === '>' ? Scalar.BLOCK_FOLDED : Scalar.BLOCK_LITERAL;
@@ -44,6 +44,10 @@ function resolveBlockScalar(scalar, strict, onError) {
if (header.indent === 0)
trimIndent = indent.length;
contentStart = i;
+ if (trimIndent === 0 && !ctx.atRoot) {
+ const message = 'Block scalar values in collections must be indented';
+ onError(offset, 'BAD_INDENT', message);
+ }
break;
}
offset += indent.length + content.length + 1;
diff --git a/node_modules/yaml/browser/dist/compose/resolve-block-seq.js b/node_modules/yaml/browser/dist/compose/resolve-block-seq.js
index 3241ca79..9e69e09d 100644
--- a/node_modules/yaml/browser/dist/compose/resolve-block-seq.js
+++ b/node_modules/yaml/browser/dist/compose/resolve-block-seq.js
@@ -15,6 +15,7 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError, ta
next: value,
offset,
onError,
+ parentIndent: bs.indent,
startOnNewline: true
});
if (!props.found) {
diff --git a/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js b/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js
index fdf929a0..bbf18a82 100644
--- a/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js
+++ b/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js
@@ -28,6 +28,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
next: key ?? sep?.[0],
offset,
onError,
+ parentIndent: fc.indent,
startOnNewline: false
});
if (!props.found) {
@@ -109,6 +110,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
next: value,
offset: keyNode.range[2],
onError,
+ parentIndent: fc.indent,
startOnNewline: false
});
if (valueProps.found) {
diff --git a/node_modules/yaml/browser/dist/compose/resolve-props.js b/node_modules/yaml/browser/dist/compose/resolve-props.js
index ab30f56f..dd6ce6cc 100644
--- a/node_modules/yaml/browser/dist/compose/resolve-props.js
+++ b/node_modules/yaml/browser/dist/compose/resolve-props.js
@@ -1,14 +1,15 @@
-function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnNewline }) {
+function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIndent, startOnNewline }) {
let spaceBefore = false;
let atNewline = startOnNewline;
let hasSpace = startOnNewline;
let comment = '';
let commentSep = '';
let hasNewline = false;
- let hasNewlineAfterProp = false;
let reqSpace = false;
+ let tab = null;
let anchor = null;
let tag = null;
+ let newlineAfterProp = null;
let comma = null;
let found = null;
let start = null;
@@ -20,16 +21,22 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
onError(token.offset, 'MISSING_CHAR', 'Tags and anchors must be separated from the next token by white space');
reqSpace = false;
}
+ if (tab) {
+ if (atNewline && token.type !== 'comment' && token.type !== 'newline') {
+ onError(tab, 'TAB_AS_INDENT', 'Tabs are not allowed as indentation');
+ }
+ tab = null;
+ }
switch (token.type) {
case 'space':
// At the doc level, tabs at line start may be parsed
// as leading white space rather than indentation.
// In a flow collection, only the parser handles indent.
if (!flow &&
- atNewline &&
- indicator !== 'doc-start' &&
- token.source[0] === '\t')
- onError(token, 'TAB_AS_INDENT', 'Tabs are not allowed as indentation');
+ (indicator !== 'doc-start' || next?.type !== 'flow-collection') &&
+ token.source.includes('\t')) {
+ tab = token;
+ }
hasSpace = true;
break;
case 'comment': {
@@ -56,7 +63,7 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
atNewline = true;
hasNewline = true;
if (anchor || tag)
- hasNewlineAfterProp = true;
+ newlineAfterProp = token;
hasSpace = true;
break;
case 'anchor':
@@ -89,7 +96,8 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
if (found)
onError(token, 'UNEXPECTED_TOKEN', `Unexpected ${token.source} in ${flow ?? 'collection'}`);
found = token;
- atNewline = false;
+ atNewline =
+ indicator === 'seq-item-ind' || indicator === 'explicit-key-ind';
hasSpace = false;
break;
case 'comma':
@@ -115,17 +123,23 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
next.type !== 'space' &&
next.type !== 'newline' &&
next.type !== 'comma' &&
- (next.type !== 'scalar' || next.source !== ''))
+ (next.type !== 'scalar' || next.source !== '')) {
onError(next.offset, 'MISSING_CHAR', 'Tags and anchors must be separated from the next token by white space');
+ }
+ if (tab &&
+ ((atNewline && tab.indent <= parentIndent) ||
+ next?.type === 'block-map' ||
+ next?.type === 'block-seq'))
+ onError(tab, 'TAB_AS_INDENT', 'Tabs are not allowed as indentation');
return {
comma,
found,
spaceBefore,
comment,
hasNewline,
- hasNewlineAfterProp,
anchor,
tag,
+ newlineAfterProp,
end,
start: start ?? end
};