21 lines
514 B
TypeScript
21 lines
514 B
TypeScript
|
|
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}`)
|
||
|
|
}
|
||
|
|
},
|
||
|
|
}
|
||
|
|
}
|