Skip to content

Commit

Permalink
chore: code style
Browse files Browse the repository at this point in the history
Updates from PR review
  • Loading branch information
isaacs committed Apr 29, 2023
1 parent 8dffda2 commit bfca91f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
7 changes: 2 additions & 5 deletions src/compose/compose-collection.ts
Expand Up @@ -38,10 +38,8 @@ function resolveCollection(
if (tagName === '!' || tagName === Coll.tagName) {
coll.tag = Coll.tagName
return coll
} else if (tagName) {
coll.tag = tagName
}

if (tagName) coll.tag = tagName
return coll
}

Expand All @@ -58,7 +56,6 @@ export function composeCollection(
onError(tagToken, 'TAG_RESOLVE_FAILED', msg)
)

let coll: YAMLMap.Parsed | YAMLSeq.Parsed
let expType: 'map' | 'seq' | undefined =

Check warning on line 59 in src/compose/compose-collection.ts

View workflow job for this annotation

GitHub Actions / lint

'expType' is never reassigned. Use 'const' instead
token.type === 'block-map'
? 'map'
Expand Down Expand Up @@ -133,7 +130,7 @@ export function composeCollection(
}
}

coll = resolveCollection(CN, ctx, token, onError, tagName, tag)
const coll = resolveCollection(CN, ctx, token, onError, tagName, tag)

const res =
tag.resolve?.(
Expand Down
10 changes: 4 additions & 6 deletions src/compose/resolve-flow-collection.ts
Expand Up @@ -24,12 +24,10 @@ export function resolveFlowCollection(
) {
const isMap = fc.start.source === '{'
const fcName = isMap ? 'flow map' : 'flow sequence'
let NodeClass = tag?.nodeClass
const MapClass = NodeClass || YAMLMap
const SeqClass = NodeClass || YAMLSeq
const coll = isMap
? (new MapClass(ctx.schema) as YAMLMap.Parsed)
: (new SeqClass(ctx.schema) as YAMLSeq.Parsed)
let NodeClass = (tag?.nodeClass ?? (isMap ? YAMLMap : YAMLSeq)) as {

Check warning on line 27 in src/compose/resolve-flow-collection.ts

View workflow job for this annotation

GitHub Actions / lint

'NodeClass' is never reassigned. Use 'const' instead
new (ctx: ComposeContext['schema']): YAMLMap.Parsed | YAMLSeq.Parsed
}
const coll = new NodeClass(ctx.schema)
coll.flow = true
const atRoot = ctx.atRoot
if (atRoot) ctx.atRoot = false
Expand Down
2 changes: 1 addition & 1 deletion src/schema/yaml-1.1/timestamp.ts
Expand Up @@ -47,7 +47,7 @@ function stringifySexagesimal(node: Scalar) {
return (
sign +
parts
.map(n => String(n).padStart(2, '0')) //(n < 10 ? '0' + String(n) : String(n)))
.map(n => String(n).padStart(2, '0'))
.join(':')
.replace(/000000\d*$/, '') // % 60 may introduce error
)
Expand Down

0 comments on commit bfca91f

Please sign in to comment.