UNPKG

@biomejs/js-api

Version:

JavaScript APIs for the Biome package

106 lines 3.45 kB
import type { FixFileMode, Module, OpenProjectResult, ProjectKey } from "./wasm"; export interface FormatContentDebugOptions extends FormatContentOptions { /** * If `true`, you'll be able to inspect the IR of the formatter */ debug: boolean; } export interface FormatContentOptions { /** * A virtual path of the file. You should add the extension, so Biome knows * how to parse the content */ filePath: string; /** * The range where to format the content */ range?: [number, number]; } export interface FormatResult<Diagnostic> { /** * The new formatted content */ content: string; /** * A series of errors encountered while executing an operation */ diagnostics: Diagnostic[]; } export interface FormatDebugResult<Diagnostic> extends FormatResult<Diagnostic> { /** * The IR emitted by the formatter */ ir: string; } export interface LintContentOptions { /** * A virtual path of the file. You should add the extension, so Biome knows * how to parse the content */ filePath: string; fixFileMode?: FixFileMode; } export interface LintResult<Diagnostic> { content: string; diagnostics: Diagnostic[]; } export interface PrintDiagnosticsOptions { /** * The name of the file to print diagnostics for */ filePath: string; /** * The content of the file the diagnostics were emitted for */ fileSource: string; /** * Whether to print the diagnostics in verbose mode */ verbose?: boolean; } export declare class BiomeCommon<Configuration, Diagnostic> { private readonly module; private readonly workspace; constructor(module: Module<Configuration, Diagnostic>); /** * Stop this instance of Biome * * After calling `shutdown()` on this object, it should be considered * unusable as calling any method on it will fail */ shutdown(): void; /** * Allows to apply a custom configuration. * * If fails when the configuration is incorrect. * * @param projectKey The identifier of the project * @param configuration */ applyConfiguration(projectKey: ProjectKey, configuration: Configuration): void; /** * Open a possible workspace project folder. Returns the key of said project. Use this key when you want to switch to different projects. * * @param [path] */ openProject(path?: string): OpenProjectResult; private withFile; formatContent(projectKey: ProjectKey, content: string, options: FormatContentOptions): FormatResult<Diagnostic>; formatContent(projectKey: ProjectKey, content: string, options: FormatContentDebugOptions): FormatDebugResult<Diagnostic>; /** * Lint the content of a file. * * @param projectKey The identifier of the project * @param content The content to lint * @param options Options needed when linting some content */ lintContent(projectKey: ProjectKey, content: string, { filePath, fixFileMode }: LintContentOptions): LintResult<Diagnostic>; /** * Print a list of diagnostics to an HTML string. * * @param diagnostics The list of diagnostics to print * @param options Options needed for printing the diagnostics */ printDiagnostics(diagnostics: Diagnostic[], options: PrintDiagnosticsOptions): string; } //# sourceMappingURL=common.d.ts.map