Skip to content

Commit

Permalink
Merge pull request #18 from getlang-dev/chores
Browse files Browse the repository at this point in the history
chore: upgrade deps, lint rules
  • Loading branch information
mattfysh authored Sep 24, 2024
2 parents db33ad9 + 9483ffc commit 4c491cb
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected].1/schema.json",
"$schema": "https://unpkg.com/@changesets/[email protected].3/schema.json",
"changelog": ["@changesets/changelog-github", { "repo": "getlang-dev/get" }],
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"updateInternalDependencies": "minor",
"ignore": []
}
3 changes: 2 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
},
"style": {
"noUselessElse": "off",
"noNonNullAssertion": "off"
"noNonNullAssertion": "off",
"useBlockStatements": "error"
}
}
},
Expand Down
Binary file modified bun.lockb
Binary file not shown.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "get",
"license": "Apache-2.0",
"private": true,
"packageManager": "[email protected].27",
"packageManager": "[email protected].29",
"scripts": {
"format": "biome check --write",
"lint": "bun lint:check && bun lint:types && bun lint:unused && bun lint:repo",
Expand All @@ -21,10 +21,10 @@
"@biomejs/biome": "1.8.2",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.8",
"@types/bun": "^1.1.8",
"knip": "^5.30.0",
"@types/bun": "^1.1.10",
"knip": "^5.30.5",
"sherif": "^1.0.0",
"typescript": "^5.5.4"
"typescript": "^5.6.2"
},
"knip": {
"vitest": {},
Expand Down
4 changes: 3 additions & 1 deletion packages/get/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ export async function execute(
let value = await visit(node.context)
const optional = node.typeInfo.type === Type.Maybe
value = optional ? value : assert(value)
if (value instanceof NullSelection) return value
if (value instanceof NullSelection) {
return value
}
context = { value, typeInfo: node.context.typeInfo }
}
return unwrap(context, cb)
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/values/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const toValue = (el: AnyHtmlNode) => {
if (el.nodeType === 2) {
str = el.value
} else if (textContent(el)) {
str = textContent(el)
str = textContent(el).replaceAll(/\s+/g, ' ')
}
return str.trim()
}
4 changes: 3 additions & 1 deletion packages/parser/ast/typeinfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export function tequal(a: TypeInfo, b: TypeInfo): boolean {
} else if (a.type === 'struct' && b.type === 'struct') {
const ax = Object.entries(a.schema)
const bx = Object.entries(b.schema)
if (ax.length !== bx.length) return false
if (ax.length !== bx.length) {
return false
}
return ax.every(([ak, av]) => {
const bv = b.schema[ak]
return bv && tequal(av, bv)
Expand Down
12 changes: 9 additions & 3 deletions packages/parser/desugar/inference/typeinfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ export function inferTypeInfo(): TransformVisitor {

function ctx<C extends CExpr>(cb: (tnode: C, ivisit: Visit) => C) {
return function enter(node: C, visit: Visit): C {
if (!node.context) return cb(node, visit)
if (!node.context) {
return cb(node, visit)
}
const context = visit(node.context)
const itemContext: any = {
...context,
Expand Down Expand Up @@ -133,7 +135,9 @@ export function inferTypeInfo(): TransformVisitor {
enter: ctx((node, visit) => {
const xnode = trace.SliceExpr.enter(node, visit)
let typeInfo: TypeInfo = { type: Type.Value }
if (optional) typeInfo = { type: Type.Maybe, option: typeInfo }
if (optional) {
typeInfo = { type: Type.Maybe, option: typeInfo }
}
return { ...xnode, typeInfo }
}),
},
Expand Down Expand Up @@ -189,7 +193,9 @@ export function inferTypeInfo(): TransformVisitor {
ObjectLiteralExpr: {
enter: ctx((node, visit) => {
const xnode = trace.ObjectLiteralExpr.enter(node, child => {
if (child === node.context) return visit(child)
if (child === node.context) {
return visit(child)
}
const entry = node.entries.find(e => e.value === child)
invariant(
entry,
Expand Down
4 changes: 3 additions & 1 deletion packages/parser/desugar/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import type { TransformVisitor, Visit } from '../visitor/transform.js'

export function traceVisitor(scope: RootScope<Expr>) {
function ctx<C extends CExpr>(node: C, visit: Visit, cb: (tnode: C) => C) {
if (!node.context) return cb(node)
if (!node.context) {
return cb(node)
}
const context = visit(node.context)
scope.pushContext(context)
const xnode = cb({ ...node, context })
Expand Down
4 changes: 3 additions & 1 deletion packages/parser/desugar/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export function selectTypeInfo(
selector: Expr,
): TypeInfo | null {
const sel = render(selector)
if (!sel) return null
if (!sel) {
return null
}
return toPath(sel).reduce<TypeInfo>(
(acc, cur) =>
(acc.type === Type.Struct && acc.schema[cur]) || { type: Type.Value },
Expand Down
7 changes: 5 additions & 2 deletions test/modules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ describe('modules', () => {

test('imports cache', async () => {
const importHook = mock(async (module: string) => {
if (module === 'Top') return `extract \`"top"\``
if (module === 'Mid')
if (module === 'Top') {
return `extract \`"top"\``
}
if (module === 'Mid') {
return `
import Top
set inputA = \`"foo"\`
Expand All @@ -110,6 +112,7 @@ describe('modules', () => {
midValue: \`"mid"\`
}
`
}
throw new Error(`Unexpected import: ${module}`)
})

Expand Down

0 comments on commit 4c491cb

Please sign in to comment.