Skip to content

Commit

Permalink
Make log level filters respected in serve/watch mode with VLS.
Browse files Browse the repository at this point in the history
May fix fi3ework#63.
  • Loading branch information
ascott18 authored and fi3ework committed Jan 18, 2022
1 parent 58c1f22 commit 31324d1
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions packages/vite-plugin-checker/src/checkers/vls/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ function suppressConsole() {
}
}

export async function prepareClientConnection(workspaceUri: URI, options: DiagnosticOptions) {
export async function prepareClientConnection(
workspaceUri: URI,
severity: DiagnosticSeverity,
options: DiagnosticOptions
) {
const up = new TestStream()
const down = new TestStream()
const logger = new NullLogger()
Expand All @@ -160,8 +164,7 @@ export async function prepareClientConnection(workspaceUri: URI, options: Diagno
return
}

if (!publishDiagnostics.diagnostics.length) return

publishDiagnostics.diagnostics = filterDiagnostics(publishDiagnostics.diagnostics, severity)
const res = await normalizePublishDiagnosticParams(publishDiagnostics)
const normalized = diagnosticToViteError(res)
consoleLogVls(os.EOL)
Expand Down Expand Up @@ -217,7 +220,7 @@ async function getDiagnostics(
severity: DiagnosticSeverity,
options: DiagnosticOptions
) {
const { clientConnection } = await prepareClientConnection(workspaceUri, options)
const { clientConnection } = await prepareClientConnection(workspaceUri, severity, options)

const files = glob.sync('**/*.vue', { cwd: workspaceUri.fsPath, ignore: ['node_modules/**'] })

Expand Down Expand Up @@ -262,12 +265,7 @@ async function getDiagnostics(
version: DOC_VERSION.init,
})) as Diagnostic[]

/**
* Ignore eslint errors for now
*/
diagnostics = diagnostics
.filter((r) => r.source !== 'eslint-plugin-vue')
.filter((r) => r.severity && r.severity <= severity)
diagnostics = filterDiagnostics(diagnostics, severity)

if (diagnostics.length > 0) {
logChunk +=
Expand Down Expand Up @@ -341,3 +339,12 @@ function mergeDeep<T>(target: T, source: DeepPartial<T> | undefined) {

return target
}

function filterDiagnostics(diagnostics: Diagnostic[], severity: number): Diagnostic[] {
/**
* Ignore eslint errors for now
*/
return diagnostics
.filter((r) => r.source !== 'eslint-plugin-vue')
.filter((r) => r.severity && r.severity <= severity)
}

0 comments on commit 31324d1

Please sign in to comment.