64 lines
3.5 KiB
TypeScript
64 lines
3.5 KiB
TypeScript
import { SourceLocation } from '@babel/code-frame';
|
|
import { DiagnosticLevel, DiagnosticToRuntime } from './types.js';
|
|
import { CustomPayload } from 'vite';
|
|
import { Range } from 'vscode-languageclient';
|
|
import { ESLint } from 'eslint';
|
|
import Stylelint__default from 'stylelint';
|
|
import { Diagnostic as Diagnostic$1, PublishDiagnosticsParams } from 'vscode-languageclient/node';
|
|
import { LineAndCharacter, Diagnostic } from 'typescript';
|
|
import 'worker_threads';
|
|
import './checkers/vls/initParams.js';
|
|
import 'vscode-uri';
|
|
import 'vscode-languageserver/node';
|
|
|
|
interface NormalizedDiagnostic {
|
|
/** error message */
|
|
message?: string;
|
|
/** error conclusion */
|
|
conclusion?: string;
|
|
/** error stack */
|
|
stack?: string | string[];
|
|
/** file name */
|
|
id?: string;
|
|
/** checker diagnostic source */
|
|
checker: string;
|
|
/** raw code frame generated by @babel/code-frame */
|
|
codeFrame?: string;
|
|
/** code frame, but striped */
|
|
stripedCodeFrame?: string;
|
|
/** error code location */
|
|
loc?: SourceLocation;
|
|
/** error level */
|
|
level?: DiagnosticLevel;
|
|
}
|
|
declare function filterLogLevel(diagnostics: NormalizedDiagnostic, level?: DiagnosticLevel[]): NormalizedDiagnostic | null;
|
|
declare function filterLogLevel(diagnostics: NormalizedDiagnostic[], level?: DiagnosticLevel[]): NormalizedDiagnostic[];
|
|
declare function diagnosticToTerminalLog(d: NormalizedDiagnostic, name?: 'TypeScript' | 'vue-tsc' | 'VLS' | 'ESLint' | 'Stylelint'): string;
|
|
declare function diagnosticToRuntimeError(d: NormalizedDiagnostic): DiagnosticToRuntime;
|
|
declare function diagnosticToRuntimeError(d: NormalizedDiagnostic[]): DiagnosticToRuntime[];
|
|
declare function toViteCustomPayload(id: string, diagnostics: DiagnosticToRuntime[]): CustomPayload;
|
|
declare function createFrame({ source, location, }: {
|
|
/** file source code */
|
|
source: string;
|
|
location: SourceLocation;
|
|
}): string;
|
|
declare function tsLocationToBabelLocation(tsLoc: Record<'start' | 'end', LineAndCharacter /** 0-based */>): SourceLocation;
|
|
declare function wrapCheckerSummary(checkerName: string, rawSummary: string): string;
|
|
declare function composeCheckerSummary(checkerName: string, errorCount: number, warningCount: number): string;
|
|
declare function normalizeTsDiagnostic(d: Diagnostic): NormalizedDiagnostic;
|
|
declare function normalizeLspDiagnostic({ diagnostic, absFilePath, fileText, }: {
|
|
diagnostic: Diagnostic$1;
|
|
absFilePath: string;
|
|
fileText: string;
|
|
}): NormalizedDiagnostic;
|
|
declare function normalizePublishDiagnosticParams(publishDiagnostics: PublishDiagnosticsParams): Promise<NormalizedDiagnostic[]>;
|
|
declare function uriToAbsPath(documentUri: string): string;
|
|
declare function lspRange2Location(range: Range): SourceLocation;
|
|
declare function normalizeVueTscDiagnostic(d: Diagnostic): NormalizedDiagnostic;
|
|
declare function normalizeEslintDiagnostic(diagnostic: ESLint.LintResult): NormalizedDiagnostic[];
|
|
declare function normalizeStylelintDiagnostic(diagnostic: Stylelint__default.LintResult): NormalizedDiagnostic[];
|
|
declare function ensureCall(callback: CallableFunction): void;
|
|
declare function consoleLog(value: string): void;
|
|
|
|
export { NormalizedDiagnostic, composeCheckerSummary, consoleLog, createFrame, diagnosticToRuntimeError, diagnosticToTerminalLog, ensureCall, filterLogLevel, lspRange2Location, normalizeEslintDiagnostic, normalizeLspDiagnostic, normalizePublishDiagnosticParams, normalizeStylelintDiagnostic, normalizeTsDiagnostic, normalizeVueTscDiagnostic, toViteCustomPayload, tsLocationToBabelLocation, uriToAbsPath, wrapCheckerSummary };
|