Comparing version 2.0.0 to 2.0.1
@@ -43,8 +43,9 @@ import { Pair } from '../nodes/Pair.js'; | ||
} | ||
if (keyProps.hasNewlineAfterProp || containsNewline(key)) { | ||
onError(key !== null && key !== void 0 ? key : start[start.length - 1], 'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line'); | ||
} | ||
} | ||
else if (((_a = keyProps.found) === null || _a === void 0 ? void 0 : _a.indent) !== bm.indent) | ||
else if (((_a = keyProps.found) === null || _a === void 0 ? void 0 : _a.indent) !== bm.indent) { | ||
onError(offset, 'BAD_INDENT', startColMsg); | ||
if (implicitKey && containsNewline(key)) | ||
onError(key, // checked by containsNewline() | ||
'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line'); | ||
} | ||
// key value | ||
@@ -51,0 +52,0 @@ const keyStart = keyProps.end; |
@@ -8,2 +8,3 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnNewline }) { | ||
let hasNewline = false; | ||
let hasNewlineAfterProp = false; | ||
let reqSpace = false; | ||
@@ -58,2 +59,4 @@ let anchor = null; | ||
hasNewline = true; | ||
if (anchor || tag) | ||
hasNewlineAfterProp = true; | ||
hasSpace = true; | ||
@@ -125,2 +128,3 @@ break; | ||
hasNewline, | ||
hasNewlineAfterProp, | ||
anchor, | ||
@@ -127,0 +131,0 @@ tag, |
@@ -10,3 +10,3 @@ import { tokenType } from './cst.js'; | ||
} | ||
function includesNonEmpty(list) { | ||
function findNonEmptyIndex(list) { | ||
for (let i = 0; i < list.length; ++i) { | ||
@@ -19,6 +19,6 @@ switch (list[i].type) { | ||
default: | ||
return true; | ||
return i; | ||
} | ||
} | ||
return false; | ||
return -1; | ||
} | ||
@@ -348,3 +348,3 @@ function isFlowToken(token) { | ||
last.start.length > 0 && | ||
!includesNonEmpty(last.start) && | ||
findNonEmptyIndex(last.start) === -1 && | ||
(token.indent === 0 || | ||
@@ -397,3 +397,3 @@ last.start.every(st => st.type !== 'comment' || st.indent < token.indent))) { | ||
case 'doc-start': { | ||
if (includesNonEmpty(doc.start)) { | ||
if (findNonEmptyIndex(doc.start) !== -1) { | ||
yield* this.pop(); | ||
@@ -492,13 +492,17 @@ yield* this.step(); | ||
} | ||
else if (it.sep) | ||
else if (it.sep) { | ||
it.sep.push(this.sourceToken); | ||
else | ||
} | ||
else { | ||
it.start.push(this.sourceToken); | ||
} | ||
return; | ||
case 'space': | ||
case 'comment': | ||
if (it.value) | ||
if (it.value) { | ||
map.items.push({ start: [this.sourceToken] }); | ||
else if (it.sep) | ||
} | ||
else if (it.sep) { | ||
it.sep.push(this.sourceToken); | ||
} | ||
else { | ||
@@ -520,5 +524,3 @@ if (this.atIndentedComment(it.start, map.indent)) { | ||
if (this.indent >= map.indent) { | ||
const atNextItem = !this.onKeyLine && | ||
this.indent === map.indent && | ||
(it.sep || includesNonEmpty(it.start)); | ||
const atNextItem = !this.onKeyLine && this.indent === map.indent && it.sep; | ||
// For empty nodes, assign newline-separated not indented empty tokens to following node | ||
@@ -525,0 +527,0 @@ let start = []; |
@@ -45,8 +45,9 @@ 'use strict'; | ||
} | ||
if (keyProps.hasNewlineAfterProp || utilContainsNewline.containsNewline(key)) { | ||
onError(key !== null && key !== void 0 ? key : start[start.length - 1], 'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line'); | ||
} | ||
} | ||
else if (((_a = keyProps.found) === null || _a === void 0 ? void 0 : _a.indent) !== bm.indent) | ||
else if (((_a = keyProps.found) === null || _a === void 0 ? void 0 : _a.indent) !== bm.indent) { | ||
onError(offset, 'BAD_INDENT', startColMsg); | ||
if (implicitKey && utilContainsNewline.containsNewline(key)) | ||
onError(key, // checked by containsNewline() | ||
'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line'); | ||
} | ||
// key value | ||
@@ -53,0 +54,0 @@ const keyStart = keyProps.end; |
@@ -17,2 +17,3 @@ import type { SourceToken, Token } from '../parse/cst.js'; | ||
hasNewline: boolean; | ||
hasNewlineAfterProp: boolean; | ||
anchor: SourceToken | null; | ||
@@ -19,0 +20,0 @@ tag: SourceToken | null; |
@@ -10,2 +10,3 @@ 'use strict'; | ||
let hasNewline = false; | ||
let hasNewlineAfterProp = false; | ||
let reqSpace = false; | ||
@@ -60,2 +61,4 @@ let anchor = null; | ||
hasNewline = true; | ||
if (anchor || tag) | ||
hasNewlineAfterProp = true; | ||
hasSpace = true; | ||
@@ -127,2 +130,3 @@ break; | ||
hasNewline, | ||
hasNewlineAfterProp, | ||
anchor, | ||
@@ -129,0 +133,0 @@ tag, |
@@ -12,3 +12,3 @@ 'use strict'; | ||
} | ||
function includesNonEmpty(list) { | ||
function findNonEmptyIndex(list) { | ||
for (let i = 0; i < list.length; ++i) { | ||
@@ -21,6 +21,6 @@ switch (list[i].type) { | ||
default: | ||
return true; | ||
return i; | ||
} | ||
} | ||
return false; | ||
return -1; | ||
} | ||
@@ -352,3 +352,3 @@ function isFlowToken(token) { | ||
last.start.length > 0 && | ||
!includesNonEmpty(last.start) && | ||
findNonEmptyIndex(last.start) === -1 && | ||
(token.indent === 0 || | ||
@@ -401,3 +401,3 @@ last.start.every(st => st.type !== 'comment' || st.indent < token.indent))) { | ||
case 'doc-start': { | ||
if (includesNonEmpty(doc.start)) { | ||
if (findNonEmptyIndex(doc.start) !== -1) { | ||
yield* this.pop(); | ||
@@ -496,13 +496,17 @@ yield* this.step(); | ||
} | ||
else if (it.sep) | ||
else if (it.sep) { | ||
it.sep.push(this.sourceToken); | ||
else | ||
} | ||
else { | ||
it.start.push(this.sourceToken); | ||
} | ||
return; | ||
case 'space': | ||
case 'comment': | ||
if (it.value) | ||
if (it.value) { | ||
map.items.push({ start: [this.sourceToken] }); | ||
else if (it.sep) | ||
} | ||
else if (it.sep) { | ||
it.sep.push(this.sourceToken); | ||
} | ||
else { | ||
@@ -524,5 +528,3 @@ if (this.atIndentedComment(it.start, map.indent)) { | ||
if (this.indent >= map.indent) { | ||
const atNextItem = !this.onKeyLine && | ||
this.indent === map.indent && | ||
(it.sep || includesNonEmpty(it.start)); | ||
const atNextItem = !this.onKeyLine && this.indent === map.indent && it.sep; | ||
// For empty nodes, assign newline-separated not indented empty tokens to following node | ||
@@ -529,0 +531,0 @@ let start = []; |
{ | ||
"name": "yaml", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"license": "ISC", | ||
@@ -5,0 +5,0 @@ "author": "Eemeli Aro <eemeli@gmail.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
657731
17349