diff options
Diffstat (limited to 'std/encoding/_yaml')
-rw-r--r-- | std/encoding/_yaml/dumper/dumper.ts | 74 | ||||
-rw-r--r-- | std/encoding/_yaml/dumper/dumper_state.ts | 2 | ||||
-rw-r--r-- | std/encoding/_yaml/error.ts | 2 | ||||
-rw-r--r-- | std/encoding/_yaml/example/dump.ts | 2 | ||||
-rw-r--r-- | std/encoding/_yaml/loader/loader.ts | 121 | ||||
-rw-r--r-- | std/encoding/_yaml/loader/loader_state.ts | 2 | ||||
-rw-r--r-- | std/encoding/_yaml/mark.ts | 12 | ||||
-rw-r--r-- | std/encoding/_yaml/parse.ts | 2 | ||||
-rw-r--r-- | std/encoding/_yaml/schema.ts | 6 | ||||
-rw-r--r-- | std/encoding/_yaml/type/float.ts | 2 | ||||
-rw-r--r-- | std/encoding/_yaml/type/timestamp.ts | 24 |
11 files changed, 124 insertions, 125 deletions
diff --git a/std/encoding/_yaml/dumper/dumper.ts b/std/encoding/_yaml/dumper/dumper.ts index 2b23d4758..e1f1a142a 100644 --- a/std/encoding/_yaml/dumper/dumper.ts +++ b/std/encoding/_yaml/dumper/dumper.ts @@ -92,7 +92,7 @@ function encodeHex(character: number): string { length = 8; } else { throw new YAMLError( - "code point within a string may not be greater than 0xFFFFFFFF" + "code point within a string may not be greater than 0xFFFFFFFF", ); } @@ -242,14 +242,13 @@ function chooseScalarStyle( singleLineOnly: boolean, indentPerLevel: number, lineWidth: number, - testAmbiguousType: (...args: Any[]) => Any + testAmbiguousType: (...args: Any[]) => Any, ): number { const shouldTrackWidth = lineWidth !== -1; let hasLineBreak = false, hasFoldableLine = false, // only checked if shouldTrackWidth previousLineBreak = -1, // count the first line correctly - plain = - isPlainSafeFirst(string.charCodeAt(0)) && + plain = isPlainSafeFirst(string.charCodeAt(0)) && !isWhitespace(string.charCodeAt(string.length - 1)); let char: number, i: number; @@ -271,8 +270,7 @@ function chooseScalarStyle( hasLineBreak = true; // Check if any line can be folded. if (shouldTrackWidth) { - hasFoldableLine = - hasFoldableLine || + hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented. (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " "); @@ -284,8 +282,7 @@ function chooseScalarStyle( plain = plain && isPlainSafe(char); } // in case the end is missing a \n - hasFoldableLine = - hasFoldableLine || + hasFoldableLine = hasFoldableLine || (shouldTrackWidth && i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " "); @@ -387,8 +384,7 @@ function foldString(string: string, width: number): string { const prefix = match[1], line = match[2]; moreIndented = line[0] === " "; - result += - prefix + + result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + // eslint-disable-next-line @typescript-eslint/no-use-before-define foldLine(line, width); @@ -412,7 +408,7 @@ function escapeString(string: string): string { if (nextChar >= 0xdc00 && nextChar <= 0xdfff /* low surrogate */) { // Combine the surrogate pair and store it escaped. result += encodeHex( - (char - 0xd800) * 0x400 + nextChar - 0xdc00 + 0x10000 + (char - 0xd800) * 0x400 + nextChar - 0xdc00 + 0x10000, ); // Advance index one extra since we already used that char here. i++; @@ -420,10 +416,9 @@ function escapeString(string: string): string { } } escapeSeq = ESCAPE_SEQUENCES[char]; - result += - !escapeSeq && isPrintable(char) - ? string[i] - : escapeSeq || encodeHex(char); + result += !escapeSeq && isPrintable(char) + ? string[i] + : escapeSeq || encodeHex(char); } return result; @@ -453,7 +448,7 @@ function writeScalar( state: DumperState, string: string, level: number, - iskey: boolean + iskey: boolean, ): void { state.dump = ((): string => { if (string.length === 0) { @@ -476,15 +471,13 @@ function writeScalar( // This behaves better than a constant minimum width which disallows // narrower options, or an indent threshold which causes the width // to suddenly increase. - const lineWidth = - state.lineWidth === -1 - ? -1 - : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); + const lineWidth = state.lineWidth === -1 + ? -1 + : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); // Without knowing if keys are implicit/explicit, // assume implicit for safety. - const singleLineOnly = - iskey || + const singleLineOnly = iskey || // No block styles in flow mode. (state.flowLevel > -1 && level >= state.flowLevel); function testAmbiguity(str: string): boolean { @@ -497,7 +490,7 @@ function writeScalar( singleLineOnly, state.indent, lineWidth, - testAmbiguity + testAmbiguity, ) ) { case STYLE_PLAIN: @@ -505,13 +498,15 @@ function writeScalar( case STYLE_SINGLE: return `'${string.replace(/'/g, "''")}'`; case STYLE_LITERAL: - return `|${blockHeader(string, state.indent)}${dropEndingNewline( - indentString(string, indent) - )}`; + return `|${blockHeader(string, state.indent)}${ + dropEndingNewline(indentString(string, indent)) + }`; case STYLE_FOLDED: - return `>${blockHeader(string, state.indent)}${dropEndingNewline( - indentString(foldString(string, lineWidth), indent) - )}`; + return `>${blockHeader(string, state.indent)}${ + dropEndingNewline( + indentString(foldString(string, lineWidth), indent), + ) + }`; case STYLE_DOUBLE: return `"${escapeString(string)}"`; default: @@ -523,7 +518,7 @@ function writeScalar( function writeFlowSequence( state: DumperState, level: number, - object: Any + object: Any, ): void { let _result = ""; const _tag = state.tag; @@ -545,7 +540,7 @@ function writeBlockSequence( state: DumperState, level: number, object: Any, - compact = false + compact = false, ): void { let _result = ""; const _tag = state.tag; @@ -575,7 +570,7 @@ function writeBlockSequence( function writeFlowMapping( state: DumperState, level: number, - object: Any + object: Any, ): void { let _result = ""; const _tag = state.tag, @@ -624,7 +619,7 @@ function writeBlockMapping( state: DumperState, level: number, object: Any, - compact = false + compact = false, ): void { const _tag = state.tag, objectKeyList = Object.keys(object); @@ -665,8 +660,7 @@ function writeBlockMapping( continue; // Skip this pair because of invalid key. } - explicitPair = - (state.tag !== null && state.tag !== "?") || + explicitPair = (state.tag !== null && state.tag !== "?") || (state.dump && state.dump.length > 1024); if (explicitPair) { @@ -707,7 +701,7 @@ function writeBlockMapping( function detectType( state: DumperState, object: Any, - explicit = false + explicit = false, ): boolean { const typeList = explicit ? state.explicitTypes : state.implicitTypes; @@ -733,11 +727,11 @@ function detectType( } else if (_hasOwnProperty.call(type.represent, style)) { _result = (type.represent as ArrayObject<RepresentFn>)[style]( object, - style + style, ); } else { throw new YAMLError( - `!<${type.tag}> tag resolver accepts not "${style}" style` + `!<${type.tag}> tag resolver accepts not "${style}" style`, ); } @@ -760,7 +754,7 @@ function writeNode( object: Any, block: boolean, compact: boolean, - iskey = false + iskey = false, ): boolean { state.tag = null; state.dump = object; @@ -843,7 +837,7 @@ function writeNode( function inspectNode( object: Any, objects: Any[], - duplicatesIndexes: number[] + duplicatesIndexes: number[], ): void { if (object !== null && typeof object === "object") { const index = objects.indexOf(object); diff --git a/std/encoding/_yaml/dumper/dumper_state.ts b/std/encoding/_yaml/dumper/dumper_state.ts index 2124ecb98..63b04983e 100644 --- a/std/encoding/_yaml/dumper/dumper_state.ts +++ b/std/encoding/_yaml/dumper/dumper_state.ts @@ -12,7 +12,7 @@ const _hasOwnProperty = Object.prototype.hasOwnProperty; function compileStyleMap( schema: Schema, - map?: ArrayObject<StyleVariant> | null + map?: ArrayObject<StyleVariant> | null, ): ArrayObject<StyleVariant> { if (typeof map === "undefined" || map === null) return {}; diff --git a/std/encoding/_yaml/error.ts b/std/encoding/_yaml/error.ts index a96ab11d6..77473fbd8 100644 --- a/std/encoding/_yaml/error.ts +++ b/std/encoding/_yaml/error.ts @@ -8,7 +8,7 @@ import type { Mark } from "./mark.ts"; export class YAMLError extends Error { constructor( message = "(unknown reason)", - protected mark: Mark | string = "" + protected mark: Mark | string = "", ) { super(`${message} ${mark}`); this.name = this.constructor.name; diff --git a/std/encoding/_yaml/example/dump.ts b/std/encoding/_yaml/example/dump.ts index db3647274..bc4684dfe 100644 --- a/std/encoding/_yaml/example/dump.ts +++ b/std/encoding/_yaml/example/dump.ts @@ -18,5 +18,5 @@ console.log( ], }, test: "foobar", - }) + }), ); diff --git a/std/encoding/_yaml/loader/loader.ts b/std/encoding/_yaml/loader/loader.ts index 4ab3e9adc..216e315f2 100644 --- a/std/encoding/_yaml/loader/loader.ts +++ b/std/encoding/_yaml/loader/loader.ts @@ -25,12 +25,14 @@ const CHOMPING_CLIP = 1; const CHOMPING_STRIP = 2; const CHOMPING_KEEP = 3; -const PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; +const PATTERN_NON_PRINTABLE = + /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; const PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; const PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; const PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; /* eslint-disable-next-line max-len */ -const PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; +const PATTERN_TAG_URI = + /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; function _class(obj: unknown): string { return Object.prototype.toString.call(obj); @@ -148,7 +150,7 @@ function charFromCodepoint(c: number): string { // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF return String.fromCharCode( ((c - 0x010000) >> 10) + 0xd800, - ((c - 0x010000) & 0x03ff) + 0xdc00 + ((c - 0x010000) & 0x03ff) + 0xdc00, ); } @@ -167,8 +169,8 @@ function generateError(state: LoaderState, message: string): YAMLError { state.input, state.position, state.line, - state.position - state.lineStart - ) + state.position - state.lineStart, + ), ); } @@ -229,21 +231,21 @@ const directiveHandlers: DirectiveHandlers = { if (!PATTERN_TAG_HANDLE.test(handle)) { return throwError( state, - "ill-formed tag handle (first argument) of the TAG directive" + "ill-formed tag handle (first argument) of the TAG directive", ); } if (_hasOwnProperty.call(state.tagMap, handle)) { return throwError( state, - `there is a previously declared suffix for "${handle}" tag handle` + `there is a previously declared suffix for "${handle}" tag handle`, ); } if (!PATTERN_TAG_URI.test(prefix)) { return throwError( state, - "ill-formed tag prefix (second argument) of the TAG directive" + "ill-formed tag prefix (second argument) of the TAG directive", ); } @@ -258,7 +260,7 @@ function captureSegment( state: LoaderState, start: number, end: number, - checkJson: boolean + checkJson: boolean, ): void { let result: string; if (start < end) { @@ -289,12 +291,12 @@ function mergeMappings( state: LoaderState, destination: ArrayObject, source: ArrayObject, - overridableKeys: ArrayObject<boolean> + overridableKeys: ArrayObject<boolean>, ): void { if (!common.isObject(source)) { return throwError( state, - "cannot merge mappings; the provided source object is unacceptable" + "cannot merge mappings; the provided source object is unacceptable", ); } @@ -316,7 +318,7 @@ function storeMappingPair( keyNode: Any, valueNode: unknown, startLine?: number, - startPos?: number + startPos?: number, ): ArrayObject { // The output is a plain object here, so keys can only be strings. // We need to convert keyNode to a string, but doing so can hang the process @@ -401,7 +403,7 @@ function readLineBreak(state: LoaderState): void { function skipSeparationSpace( state: LoaderState, allowComments: boolean, - checkIndent: number + checkIndent: number, ): number { let lineBreaks = 0, ch = state.input.charCodeAt(state.position); @@ -478,7 +480,7 @@ function writeFoldedLines(state: LoaderState, count: number): void { function readPlainScalar( state: LoaderState, nodeIndent: number, - withinFlowCollection: boolean + withinFlowCollection: boolean, ): boolean { const kind = state.kind; const result = state.result; @@ -587,7 +589,7 @@ function readPlainScalar( function readSingleQuotedScalar( state: LoaderState, - nodeIndent: number + nodeIndent: number, ): boolean { let ch, captureStart, captureEnd; @@ -624,7 +626,7 @@ function readSingleQuotedScalar( ) { return throwError( state, - "unexpected end of the document within a single quoted scalar" + "unexpected end of the document within a single quoted scalar", ); } else { state.position++; @@ -634,13 +636,13 @@ function readSingleQuotedScalar( return throwError( state, - "unexpected end of the stream within a single quoted scalar" + "unexpected end of the stream within a single quoted scalar", ); } function readDoubleQuotedScalar( state: LoaderState, - nodeIndent: number + nodeIndent: number, ): boolean { let ch = state.input.charCodeAt(state.position); @@ -703,7 +705,7 @@ function readDoubleQuotedScalar( ) { return throwError( state, - "unexpected end of the document within a double quoted scalar" + "unexpected end of the document within a double quoted scalar", ); } else { state.position++; @@ -713,7 +715,7 @@ function readDoubleQuotedScalar( return throwError( state, - "unexpected end of the stream within a double quoted scalar" + "unexpected end of the stream within a double quoted scalar", ); } @@ -808,7 +810,7 @@ function readFlowCollection(state: LoaderState, nodeIndent: number): boolean { overridableKeys, keyTag, keyNode, - valueNode + valueNode, ); } else if (isPair) { (result as Array<{}>).push( @@ -818,8 +820,8 @@ function readFlowCollection(state: LoaderState, nodeIndent: number): boolean { overridableKeys, keyTag, keyNode, - valueNode - ) + valueNode, + ), ); } else { (result as ResultType[]).push(keyNode as ResultType); @@ -839,7 +841,7 @@ function readFlowCollection(state: LoaderState, nodeIndent: number): boolean { return throwError( state, - "unexpected end of the stream within a flow collection" + "unexpected end of the stream within a flow collection", ); } @@ -879,7 +881,7 @@ function readBlockScalar(state: LoaderState, nodeIndent: number): boolean { if (tmp === 0) { return throwError( state, - "bad explicit indentation width of a block scalar; it cannot be less than one" + "bad explicit indentation width of a block scalar; it cannot be less than one", ); } else if (!detectedIndent) { textIndent = nodeIndent + tmp - 1; @@ -933,7 +935,7 @@ function readBlockScalar(state: LoaderState, nodeIndent: number): boolean { if (chomping === CHOMPING_KEEP) { state.result += common.repeat( "\n", - didReadContent ? 1 + emptyLines : emptyLines + didReadContent ? 1 + emptyLines : emptyLines, ); } else if (chomping === CHOMPING_CLIP) { if (didReadContent) { @@ -954,7 +956,7 @@ function readBlockScalar(state: LoaderState, nodeIndent: number): boolean { // except for the first content line (cf. Example 8.1) state.result += common.repeat( "\n", - didReadContent ? 1 + emptyLines : emptyLines + didReadContent ? 1 + emptyLines : emptyLines, ); // End of more-indented block. @@ -979,7 +981,7 @@ function readBlockScalar(state: LoaderState, nodeIndent: number): boolean { // Keep all line breaks except the header line break. state.result += common.repeat( "\n", - didReadContent ? 1 + emptyLines : emptyLines + didReadContent ? 1 + emptyLines : emptyLines, ); } @@ -1067,7 +1069,7 @@ function readBlockSequence(state: LoaderState, nodeIndent: number): boolean { function readBlockMapping( state: LoaderState, nodeIndent: number, - flowIndent: number + flowIndent: number, ): boolean { const tag = state.tag, anchor = state.anchor, @@ -1112,7 +1114,7 @@ function readBlockMapping( overridableKeys, keyTag as string, keyNode, - null + null, ); keyTag = keyNode = valueNode = null; } @@ -1127,7 +1129,7 @@ function readBlockMapping( } else { return throwError( state, - "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line" + "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line", ); } @@ -1152,7 +1154,7 @@ function readBlockMapping( if (!isWsOrEol(ch)) { return throwError( state, - "a whitespace character is expected after the key-value separator within a block mapping" + "a whitespace character is expected after the key-value separator within a block mapping", ); } @@ -1163,7 +1165,7 @@ function readBlockMapping( overridableKeys, keyTag as string, keyNode, - null + null, ); keyTag = keyNode = valueNode = null; } @@ -1176,7 +1178,7 @@ function readBlockMapping( } else if (detected) { return throwError( state, - "can not read an implicit mapping pair; a colon is missed" + "can not read an implicit mapping pair; a colon is missed", ); } else { state.tag = tag; @@ -1186,7 +1188,7 @@ function readBlockMapping( } else if (detected) { return throwError( state, - "can not read a block mapping entry; a multiline key may not be an implicit key" + "can not read a block mapping entry; a multiline key may not be an implicit key", ); } else { state.tag = tag; @@ -1221,7 +1223,7 @@ function readBlockMapping( keyNode, valueNode, line, - pos + pos, ); keyTag = keyNode = valueNode = null; } @@ -1249,7 +1251,7 @@ function readBlockMapping( overridableKeys, keyTag as string, keyNode, - null + null, ); } @@ -1306,7 +1308,7 @@ function readTagProperty(state: LoaderState): boolean { } else { return throwError( state, - "unexpected end of the stream within a verbatim tag" + "unexpected end of the stream within a verbatim tag", ); } } else { @@ -1318,7 +1320,7 @@ function readTagProperty(state: LoaderState): boolean { if (!PATTERN_TAG_HANDLE.test(tagHandle)) { return throwError( state, - "named tag handle cannot contain such characters" + "named tag handle cannot contain such characters", ); } @@ -1327,7 +1329,7 @@ function readTagProperty(state: LoaderState): boolean { } else { return throwError( state, - "tag suffix cannot contain exclamation marks" + "tag suffix cannot contain exclamation marks", ); } } @@ -1340,7 +1342,7 @@ function readTagProperty(state: LoaderState): boolean { if (PATTERN_FLOW_INDICATORS.test(tagName)) { return throwError( state, - "tag suffix cannot contain flow indicator characters" + "tag suffix cannot contain flow indicator characters", ); } } @@ -1348,7 +1350,7 @@ function readTagProperty(state: LoaderState): boolean { if (tagName && !PATTERN_TAG_URI.test(tagName)) { return throwError( state, - `tag name cannot contain such characters: ${tagName}` + `tag name cannot contain such characters: ${tagName}`, ); } @@ -1387,7 +1389,7 @@ function readAnchorProperty(state: LoaderState): boolean { if (state.position === position) { return throwError( state, - "name of an anchor node must contain at least one character" + "name of an anchor node must contain at least one character", ); } @@ -1410,7 +1412,7 @@ function readAlias(state: LoaderState): boolean { if (state.position === _position) { return throwError( state, - "name of an alias node must contain at least one character" + "name of an alias node must contain at least one character", ); } @@ -1434,7 +1436,7 @@ function composeNode( parentIndent: number, nodeContext: number, allowToSeek: boolean, - allowCompact: boolean + allowCompact: boolean, ): boolean { let allowBlockScalars: boolean, allowBlockCollections: boolean, @@ -1454,8 +1456,9 @@ function composeNode( state.kind = null; state.result = null; - const allowBlockStyles = (allowBlockScalars = allowBlockCollections = - CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext); + const allowBlockStyles = + (allowBlockScalars = allowBlockCollections = + CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext); if (allowToSeek) { if (skipSeparationSpace(state, true, -1)) { @@ -1495,8 +1498,8 @@ function composeNode( } if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { - const cond = - CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext; + const cond = CONTEXT_FLOW_IN === nodeContext || + CONTEXT_FLOW_OUT === nodeContext; flowIndent = cond ? parentIndent : parentIndent + 1; blockIndent = state.position - state.lineStart; @@ -1522,7 +1525,7 @@ function composeNode( if (state.tag !== null || state.anchor !== null) { return throwError( state, - "alias node should not have Any properties" + "alias node should not have Any properties", ); } } else if ( @@ -1542,8 +1545,8 @@ function composeNode( } else if (indentStatus === 0) { // Special case: block sequences are allowed to have same indentation level as the parent. // http://www.yaml.org/spec/1.2/spec.html#id2799784 - hasContent = - allowBlockCollections && readBlockSequence(state, blockIndent); + hasContent = allowBlockCollections && + readBlockSequence(state, blockIndent); } } @@ -1578,7 +1581,7 @@ function composeNode( if (state.result !== null && type.kind !== state.kind) { return throwError( state, - `unacceptable node kind for !<${state.tag}> tag; it should be "${type.kind}", not "${state.kind}"` + `unacceptable node kind for !<${state.tag}> tag; it should be "${type.kind}", not "${state.kind}"`, ); } @@ -1586,7 +1589,7 @@ function composeNode( // `state.result` updated in resolver if matched return throwError( state, - `cannot resolve a node with !<${state.tag}> explicit tag` + `cannot resolve a node with !<${state.tag}> explicit tag`, ); } else { state.result = type.construct(state.result); @@ -1641,7 +1644,7 @@ function readDocument(state: LoaderState): void { if (directiveName.length < 1) { return throwError( state, - "directive name must not be less than one character in length" + "directive name must not be less than one character in length", ); } @@ -1697,7 +1700,7 @@ function readDocument(state: LoaderState): void { if ( state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test( - state.input.slice(documentStart, state.position) + state.input.slice(documentStart, state.position), ) ) { throwWarning(state, "non-ASCII line breaks are interpreted as content"); @@ -1716,7 +1719,7 @@ function readDocument(state: LoaderState): void { if (state.position < state.length - 1) { return throwError( state, - "end of the stream or a document separator is expected" + "end of the stream or a document separator is expected", ); } else { return; @@ -1767,7 +1770,7 @@ function isCbFunction(fn: unknown): fn is CbFunction { export function loadAll<T extends CbFunction | LoaderStateOptions>( input: string, iteratorOrOption?: T, - options?: LoaderStateOptions + options?: LoaderStateOptions, ): T extends CbFunction ? void : unknown[] { if (!isCbFunction(iteratorOrOption)) { return loadDocuments(input, iteratorOrOption as LoaderStateOptions) as Any; @@ -1792,6 +1795,6 @@ export function load(input: string, options?: LoaderStateOptions): unknown { return documents[0]; } throw new YAMLError( - "expected a single document in the stream, but found more" + "expected a single document in the stream, but found more", ); } diff --git a/std/encoding/_yaml/loader/loader_state.ts b/std/encoding/_yaml/loader/loader_state.ts index 781a4a086..60a7ccabc 100644 --- a/std/encoding/_yaml/loader/loader_state.ts +++ b/std/encoding/_yaml/loader/loader_state.ts @@ -57,7 +57,7 @@ export class LoaderState extends State { legacy = false, json = false, listener = null, - }: LoaderStateOptions + }: LoaderStateOptions, ) { super(schema); this.filename = filename; diff --git a/std/encoding/_yaml/mark.ts b/std/encoding/_yaml/mark.ts index 44cf175a0..35e986cce 100644 --- a/std/encoding/_yaml/mark.ts +++ b/std/encoding/_yaml/mark.ts @@ -11,7 +11,7 @@ export class Mark { public buffer: string, public position: number, public line: number, - public column: number + public column: number, ) {} public getSnippet(indent = 4, maxLength = 75): string | null { @@ -48,10 +48,12 @@ export class Mark { } const snippet = this.buffer.slice(start, end); - return `${repeat(" ", indent)}${head}${snippet}${tail}\n${repeat( - " ", - indent + this.position - start + head.length - )}^`; + return `${repeat(" ", indent)}${head}${snippet}${tail}\n${ + repeat( + " ", + indent + this.position - start + head.length, + ) + }^`; } public toString(compact?: boolean): string { diff --git a/std/encoding/_yaml/parse.ts b/std/encoding/_yaml/parse.ts index 9a6f325f2..05a9b48ac 100644 --- a/std/encoding/_yaml/parse.ts +++ b/std/encoding/_yaml/parse.ts @@ -26,7 +26,7 @@ export function parse(content: string, options?: ParseOptions): unknown { export function parseAll( content: string, iterator?: CbFunction, - options?: ParseOptions + options?: ParseOptions, ): unknown { return loadAll(content, iterator, options); } diff --git a/std/encoding/_yaml/schema.ts b/std/encoding/_yaml/schema.ts index 98b49203c..b955e5df8 100644 --- a/std/encoding/_yaml/schema.ts +++ b/std/encoding/_yaml/schema.ts @@ -10,7 +10,7 @@ import type { ArrayObject, Any } from "./utils.ts"; function compileList( schema: Schema, name: "implicit" | "explicit", - result: Type[] + result: Type[], ): Type[] { const exclude: number[] = []; @@ -78,7 +78,7 @@ export class Schema implements SchemaDefinition { if (type.loadKind && type.loadKind !== "scalar") { throw new YAMLError( // eslint-disable-next-line max-len - "There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported." + "There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.", ); } } @@ -87,7 +87,7 @@ export class Schema implements SchemaDefinition { this.compiledExplicit = compileList(this, "explicit", []); this.compiledTypeMap = compileMap( this.compiledImplicit, - this.compiledExplicit + this.compiledExplicit, ); } diff --git a/std/encoding/_yaml/type/float.ts b/std/encoding/_yaml/type/float.ts index 5ae0689b2..6d59ed9ed 100644 --- a/std/encoding/_yaml/type/float.ts +++ b/std/encoding/_yaml/type/float.ts @@ -17,7 +17,7 @@ const YAML_FLOAT_PATTERN = new RegExp( // .inf "|[-+]?\\.(?:inf|Inf|INF)" + // .nan - "|\\.(?:nan|NaN|NAN))$" + "|\\.(?:nan|NaN|NAN))$", ); function resolveYamlFloat(data: string): boolean { diff --git a/std/encoding/_yaml/type/timestamp.ts b/std/encoding/_yaml/type/timestamp.ts index eb03b3825..231908231 100644 --- a/std/encoding/_yaml/type/timestamp.ts +++ b/std/encoding/_yaml/type/timestamp.ts @@ -7,21 +7,21 @@ import { Type } from "../type.ts"; const YAML_DATE_REGEXP = new RegExp( "^([0-9][0-9][0-9][0-9])" + // [1] year - "-([0-9][0-9])" + // [2] month - "-([0-9][0-9])$" // [3] day + "-([0-9][0-9])" + // [2] month + "-([0-9][0-9])$", // [3] day ); const YAML_TIMESTAMP_REGEXP = new RegExp( "^([0-9][0-9][0-9][0-9])" + // [1] year - "-([0-9][0-9]?)" + // [2] month - "-([0-9][0-9]?)" + // [3] day - "(?:[Tt]|[ \\t]+)" + // ... - "([0-9][0-9]?)" + // [4] hour - ":([0-9][0-9])" + // [5] minute - ":([0-9][0-9])" + // [6] second - "(?:\\.([0-9]*))?" + // [7] fraction - "(?:[ \\t]*(Z|([-+])([0-9][0-9]?)" + // [8] tz [9] tz_sign [10] tz_hour - "(?::([0-9][0-9]))?))?$" // [11] tz_minute + "-([0-9][0-9]?)" + // [2] month + "-([0-9][0-9]?)" + // [3] day + "(?:[Tt]|[ \\t]+)" + // ... + "([0-9][0-9]?)" + // [4] hour + ":([0-9][0-9])" + // [5] minute + ":([0-9][0-9])" + // [6] second + "(?:\\.([0-9]*))?" + // [7] fraction + "(?:[ \\t]*(Z|([-+])([0-9][0-9]?)" + // [8] tz [9] tz_sign [10] tz_hour + "(?::([0-9][0-9]))?))?$", // [11] tz_minute ); function resolveYamlTimestamp(data: string): boolean { @@ -75,7 +75,7 @@ function constructYamlTimestamp(data: string): Date { } const date = new Date( - Date.UTC(year, month, day, hour, minute, second, fraction) + Date.UTC(year, month, day, hour, minute, second, fraction), ); if (delta) date.setTime(date.getTime() - delta); |