diff --git a/packages/vite-plugin-checker/src/checkers/biome/cli.ts b/packages/vite-plugin-checker/src/checkers/biome/cli.ts index 419330c8..8e5da888 100644 --- a/packages/vite-plugin-checker/src/checkers/biome/cli.ts +++ b/packages/vite-plugin-checker/src/checkers/biome/cli.ts @@ -40,7 +40,7 @@ function parseBiomeOutput(output: string) { const diagnostics: NormalizedDiagnostic[] = parsed.diagnostics.map((d) => { const loc = { - file: d.location.path || '', + file: d.location.path?.file || '', start: getLineAndColumn(d.location.sourceCode, d.location.span?.[0]), end: getLineAndColumn(d.location.sourceCode, d.location.span?.[1]), } diff --git a/playground/biome-default/__tests__/__snapshots__/test.spec.ts.snap b/playground/biome-default/__tests__/__snapshots__/test.spec.ts.snap index 389236f0..6f8016b3 100644 --- a/playground/biome-default/__tests__/__snapshots__/test.spec.ts.snap +++ b/playground/biome-default/__tests__/__snapshots__/test.spec.ts.snap @@ -27,7 +27,7 @@ exports[`biome > serve > get initial error and subsequent error 2`] = ` ] `; -exports[`biome > serve > get initial error and subsequent error 3`] = `"[{"checkerId":"Biome","frame":" 1 | const a = 'hello'/n > 2 | var b = 'world'/n | ^^^^^^^^^^^^^^^/n 3 | const c = '!'/n 4 | var d = a + b + c/n 5 |","id":"/playground-temp/biome-default/src/index.js","level":1,"loc":{"column":1,"file":"/playground-temp/biome-default/src/index.js","line":2},"message":"[lint/style/noVar] Use let or const instead of var.","stack":""},{"checkerId":"Biome","frame":" 2 | var b = 'world'/n 3 | const c = '!'/n > 4 | var d = a + b + c/n | ^^^^^^^^^^^^^^^^^/n 5 |","id":"/playground-temp/biome-default/src/index.js","level":1,"loc":{"column":1,"file":"/playground-temp/biome-default/src/index.js","line":4},"message":"[lint/style/noVar] Use let or const instead of var.","stack":""},{"checkerId":"Biome","frame":" 2 | const b = 'world'/n 3 | const c = '!'/n > 4 | var d = a + b + c/n | ^^^^^^^^^^^^^^^^^/n 5 |","id":"/playground-temp/biome-default/src/index.js","level":1,"loc":{"column":1,"file":"/playground-temp/biome-default/src/index.js","line":4},"message":"[lint/style/noVar] Use let or const instead of var.","stack":""}]"`; +exports[`biome > serve > get initial error and subsequent error 3`] = `"[{"checkerId":"Biome","frame":" 2 | const b = 'world'/n 3 | const c = '!'/n > 4 | var d = a + b + c/n | ^^^^^^^^^^^^^^^^^/n 5 |","id":"/playground-temp/biome-default/src/index.js","level":1,"loc":{"column":1,"file":"/playground-temp/biome-default/src/index.js","line":4},"message":"[lint/style/noVar] Use let or const instead of var.","stack":""}]"`; exports[`biome > serve > get initial error and subsequent error 4`] = ` [ diff --git a/playground/biome-default/__tests__/test.spec.ts b/playground/biome-default/__tests__/test.spec.ts index abe6c97c..df9b81b6 100644 --- a/playground/biome-default/__tests__/test.spec.ts +++ b/playground/biome-default/__tests__/test.spec.ts @@ -7,6 +7,7 @@ import { isBuild, isServe, log, + resetDiagnostics, resetReceivedLog, sleepForEdit, sleepForServerReady, @@ -22,6 +23,7 @@ describe('biome', () => { console.log('-- edit error file --') resetReceivedLog() + resetDiagnostics() editFile('src/index.js', (code) => code.replace(`var b = 'world'`, `const b = 'world'`)) await sleepForEdit() expect(stringify(diagnostics)).toMatchSnapshot()