Skip to content

Commit e4f963a

Browse files
committed
style: Apply updated Prettier rules
1 parent cdc032e commit e4f963a

File tree

13 files changed

+59
-50
lines changed

13 files changed

+59
-50
lines changed

docs/06_custom_tags.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,16 @@ class YAMLError extends YAMLMap {
118118
name === 'EvalError'
119119
? EvalError
120120
: name === 'RangeError'
121-
? RangeError
122-
: name === 'ReferenceError'
123-
? ReferenceError
124-
: name === 'SyntaxError'
125-
? SyntaxError
126-
: name === 'TypeError'
127-
? TypeError
128-
: name === 'URIError'
129-
? URIError
130-
: Error
121+
? RangeError
122+
: name === 'ReferenceError'
123+
? ReferenceError
124+
: name === 'SyntaxError'
125+
? SyntaxError
126+
: name === 'TypeError'
127+
? TypeError
128+
: name === 'URIError'
129+
? URIError
130+
: Error
131131
if (Cls.name !== name) {
132132
Object.defineProperty(er, 'name', {
133133
value: name,

src/compose/compose-collection.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ function resolveCollection(
2828
token.type === 'block-map'
2929
? resolveBlockMap(CN, ctx, token, onError, tag)
3030
: token.type === 'block-seq'
31-
? resolveBlockSeq(CN, ctx, token, onError, tag)
32-
: resolveFlowCollection(CN, ctx, token, onError, tag)
31+
? resolveBlockSeq(CN, ctx, token, onError, tag)
32+
: resolveFlowCollection(CN, ctx, token, onError, tag)
3333

3434
const Coll = coll.constructor as typeof YAMLMap | typeof YAMLSeq
3535

@@ -60,10 +60,10 @@ export function composeCollection(
6060
token.type === 'block-map'
6161
? 'map'
6262
: token.type === 'block-seq'
63-
? 'seq'
64-
: token.start.source === '{'
65-
? 'map'
66-
: 'seq'
63+
? 'seq'
64+
: token.start.source === '{'
65+
? 'map'
66+
: 'seq'
6767

6868
// shortcut: check if it's a generic YAMLMap or YAMLSeq
6969
// before jumping into the custom tag logic.

src/compose/compose-scalar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export function composeScalar(
2828
tagToken && tagName
2929
? findScalarTagByName(ctx.schema, value, tagName, tagToken, onError)
3030
: token.type === 'scalar'
31-
? findScalarTagByTest(ctx, value, token, onError)
32-
: ctx.schema[SCALAR]
31+
? findScalarTagByTest(ctx, value, token, onError)
32+
: ctx.schema[SCALAR]
3333

3434
let scalar: Scalar
3535
try {

src/compose/resolve-flow-collection.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,15 @@ export function resolveFlowCollection(
169169
const valueNode = value
170170
? composeNode(ctx, value, valueProps, onError)
171171
: valueProps.found
172-
? composeEmptyNode(ctx, valueProps.end, sep, null, valueProps, onError)
173-
: null
172+
? composeEmptyNode(
173+
ctx,
174+
valueProps.end,
175+
sep,
176+
null,
177+
valueProps,
178+
onError
179+
)
180+
: null
174181
if (valueNode) {
175182
if (isBlock(value)) onError(valueNode.range, 'BLOCK_IN_FLOW', blockMsg)
176183
} else if (valueProps.comment) {

src/doc/createNode.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ export function createNode(
8989
value instanceof Map
9090
? schema[MAP]
9191
: Symbol.iterator in Object(value)
92-
? schema[SEQ]
93-
: schema[MAP]
92+
? schema[SEQ]
93+
: schema[MAP]
9494
}
9595
if (onTagObj) {
9696
onTagObj(tagObj)
@@ -100,8 +100,8 @@ export function createNode(
100100
const node = tagObj?.createNode
101101
? tagObj.createNode(ctx.schema, value, ctx)
102102
: typeof tagObj?.nodeClass?.from === 'function'
103-
? tagObj.nodeClass.from(ctx.schema, value, ctx)
104-
: new Scalar(value)
103+
? tagObj.nodeClass.from(ctx.schema, value, ctx)
104+
: new Scalar(value)
105105
if (tagName) node.tag = tagName
106106
else if (!tagObj.default) node.tag = tagObj.tag
107107

src/nodes/Node.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ export type NodeType<T> = T extends
2626
| undefined
2727
? Scalar<T>
2828
: T extends Date
29-
? Scalar<string | Date>
30-
: T extends Array<any>
31-
? YAMLSeq<NodeType<T[number]>>
32-
: T extends { [key: string]: any }
33-
? YAMLMap<NodeType<keyof T>, NodeType<T[keyof T]>>
34-
: T extends { [key: number]: any } // Merge with previous once supported in all TS versions
35-
? YAMLMap<NodeType<keyof T>, NodeType<T[keyof T]>>
36-
: Node
29+
? Scalar<string | Date>
30+
: T extends Array<any>
31+
? YAMLSeq<NodeType<T[number]>>
32+
: T extends { [key: string]: any }
33+
? YAMLMap<NodeType<keyof T>, NodeType<T[keyof T]>>
34+
: T extends { [key: number]: any } // Merge with previous once supported in all TS versions
35+
? YAMLMap<NodeType<keyof T>, NodeType<T[keyof T]>>
36+
: Node
3737

3838
export type ParsedNode =
3939
| Alias.Parsed

src/schema/Schema.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ export class Schema {
3636
this.compat = Array.isArray(compat)
3737
? getTags(compat, 'compat')
3838
: compat
39-
? getTags(null, compat)
40-
: null
39+
? getTags(null, compat)
40+
: null
4141
this.merge = !!merge
4242
this.name = (typeof schema === 'string' && schema) || 'core'
4343
this.knownTags = resolveKnownTags ? coreKnownTags : {}
@@ -53,8 +53,8 @@ export class Schema {
5353
typeof sortMapEntries === 'function'
5454
? sortMapEntries
5555
: sortMapEntries === true
56-
? sortMapEntriesByKey
57-
: null
56+
? sortMapEntriesByKey
57+
: null
5858
}
5959

6060
clone(): Schema {

src/schema/core/float.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export const floatNaN: ScalarTag = {
1111
str.slice(-3).toLowerCase() === 'nan'
1212
? NaN
1313
: str[0] === '-'
14-
? Number.NEGATIVE_INFINITY
15-
: Number.POSITIVE_INFINITY,
14+
? Number.NEGATIVE_INFINITY
15+
: Number.POSITIVE_INFINITY,
1616
stringify: stringifyNumber
1717
}
1818

src/schema/yaml-1.1/float.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export const floatNaN: ScalarTag = {
1111
str.slice(-3).toLowerCase() === 'nan'
1212
? NaN
1313
: str[0] === '-'
14-
? Number.NEGATIVE_INFINITY
15-
: Number.POSITIVE_INFINITY,
14+
? Number.NEGATIVE_INFINITY
15+
: Number.POSITIVE_INFINITY,
1616
stringify: stringifyNumber
1717
}
1818

src/stringify/stringify.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ export function stringify(
165165
typeof tagObj.stringify === 'function'
166166
? tagObj.stringify(node as Scalar, ctx, onComment, onChompKeep)
167167
: isScalar(node)
168-
? stringifyString(node, ctx, onComment, onChompKeep)
169-
: node.toString(ctx, onComment, onChompKeep)
168+
? stringifyString(node, ctx, onComment, onChompKeep)
169+
: node.toString(ctx, onComment, onChompKeep)
170170
if (!props) return str
171171
return isScalar(node) || str[0] === '{' || str[0] === '['
172172
? `${props} ${str}`

0 commit comments

Comments
 (0)