brackt/.opencode/plugins/oxlint.ts

21 lines
514 B
TypeScript
Raw Normal View History

export const OxlintPlugin = async ({ $ }: { $: any }) => {
return {
"file.edited": async ({ filePath }: { filePath: string }) => {
if (
!filePath.endsWith(".ts") &&
!filePath.endsWith(".tsx") &&
!filePath.endsWith(".js") &&
!filePath.endsWith(".jsx")
) {
return
}
try {
await $`npm run lint:path -- ${filePath}`.quiet()
} catch (e: any) {
throw new Error(`oxlint found issues in ${filePath}:\n${e}`)
}
},
}
}