@biomejs/js-api
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -1,4 +0,4 @@ | ||
import type { Diagnostic, PartialConfiguration, PullDiagnosticsResult } from "@biomejs/wasm-nodejs"; | ||
import type { Diagnostic, FixFileMode, PartialConfiguration } from "@biomejs/wasm-nodejs"; | ||
import { Distribution } from "./wasm"; | ||
export declare type Configuration = PartialConfiguration; | ||
export type Configuration = PartialConfiguration; | ||
export type { Diagnostic }; | ||
@@ -45,3 +45,8 @@ export { Distribution }; | ||
filePath: string; | ||
fixFileMode?: FixFileMode; | ||
} | ||
export interface LintResult { | ||
content: string; | ||
diagnostics: Diagnostic[]; | ||
} | ||
export interface BiomeCreate { | ||
@@ -97,3 +102,3 @@ distribution: Distribution; | ||
*/ | ||
lintContent(content: string, options: LintContentOptions): PullDiagnosticsResult; | ||
lintContent(content: string, { filePath, fixFileMode }: LintContentOptions): LintResult; | ||
/** | ||
@@ -100,0 +105,0 @@ * Print a list of diagnostics to an HTML string. |
@@ -129,5 +129,17 @@ "use strict"; | ||
*/ | ||
lintContent(content, options) { | ||
return this.withFile(options.filePath, content, (path) => { | ||
return this.workspace.pullDiagnostics({ | ||
lintContent(content, { filePath, fixFileMode }) { | ||
const maybeFixedContent = fixFileMode | ||
? this.withFile(filePath, content, (path) => { | ||
let code = content; | ||
const result = this.workspace.fixFile({ | ||
path, | ||
fix_file_mode: fixFileMode, | ||
should_format: false, | ||
}); | ||
code = result.code; | ||
return code; | ||
}) | ||
: content; | ||
return this.withFile(filePath, maybeFixedContent, (path) => { | ||
const { diagnostics } = this.workspace.pullDiagnostics({ | ||
path, | ||
@@ -137,2 +149,6 @@ categories: ["Syntax", "Lint"], | ||
}); | ||
return { | ||
content: maybeFixedContent, | ||
diagnostics, | ||
}; | ||
}); | ||
@@ -139,0 +155,0 @@ } |
@@ -1,5 +0,5 @@ | ||
export declare type WasmBundler = typeof import("@biomejs/wasm-bundler"); | ||
export declare type WasmNodejs = typeof import("@biomejs/wasm-nodejs"); | ||
export declare type WasmWeb = typeof import("@biomejs/wasm-web"); | ||
export declare type WasmModule = WasmBundler | WasmNodejs | WasmWeb; | ||
export type WasmBundler = typeof import("@biomejs/wasm-bundler"); | ||
export type WasmNodejs = typeof import("@biomejs/wasm-nodejs"); | ||
export type WasmWeb = typeof import("@biomejs/wasm-web"); | ||
export type WasmModule = WasmBundler | WasmNodejs | WasmWeb; | ||
/** | ||
@@ -6,0 +6,0 @@ * What kind of client Biome should use to communicate with the binary |
@@ -44,3 +44,3 @@ "use strict"; | ||
Distribution[Distribution["WEB"] = 2] = "WEB"; | ||
})(Distribution = exports.Distribution || (exports.Distribution = {})); | ||
})(Distribution || (exports.Distribution = Distribution = {})); | ||
const isInitialized = { | ||
@@ -47,0 +47,0 @@ [Distribution.BUNDLER]: false, |
{ | ||
"name": "@biomejs/js-api", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "JavaScript APIs for the Biome package", | ||
"scripts": { | ||
"tsc": "tsc --noEmit", | ||
"format": "cargo biome-cli-dev format ./ --write", | ||
"format": "cargo biome-cli-dev format --write .", | ||
"ci": "cargo biome-cli-dev ci ./src && tsc --noEmit", | ||
"check": "pnpm biome:check && tsc --noEmit", | ||
"biome:check": "cargo biome-cli-dev check ./", | ||
"check:apply": "cargo biome-cli-dev check ./ --apply-unsafe", | ||
"biome:check": "cargo biome-cli-dev check .", | ||
"check:apply": "cargo biome-cli-dev check --apply-unsafe .", | ||
"build:wasm-dev": "pnpm run \"/^build:wasm-.+-dev$/\"", | ||
"build:wasm": "pnpm run \"/^build:wasm-.+(?<!dev)$/\"", | ||
"build:wasm-bundler-dev": "wasm-pack build --out-dir ../../packages/@biomejs/wasm-bundler --target bundler --dev --scope biomedev ../../../crates/biome_wasm", | ||
@@ -19,4 +21,4 @@ "build:wasm-bundler": "wasm-pack build --out-dir ../../packages/@biomejs/wasm-bundler --target bundler --release --scope biomedev ../../../crates/biome_wasm", | ||
"test": "vitest", | ||
"test:ci": "vitest --run", | ||
"build": "tsc " | ||
"test:ci": "vitest run", | ||
"build": "tsc" | ||
}, | ||
@@ -43,13 +45,13 @@ "files": [ | ||
"devDependencies": { | ||
"typescript": "^4.8.2", | ||
"vitest": "^1.3.0", | ||
"vite": "^5.1.3", | ||
"@biomejs/wasm-bundler": "../wasm-bundler", | ||
"@biomejs/wasm-nodejs": "../wasm-nodejs", | ||
"@biomejs/wasm-web": "../wasm-web" | ||
"@biomejs/wasm-bundler": "link:../wasm-bundler", | ||
"@biomejs/wasm-nodejs": "link:../wasm-nodejs", | ||
"@biomejs/wasm-web": "link:../wasm-web", | ||
"typescript": "^5.4.2", | ||
"vite": "^5.1.6", | ||
"vitest": "^1.3.1" | ||
}, | ||
"peerDependencies": { | ||
"@biomejs/wasm-bundler": "^1.5.3", | ||
"@biomejs/wasm-nodejs": "^1.5.3", | ||
"@biomejs/wasm-web": "^1.5.3" | ||
"@biomejs/wasm-bundler": "^1.6.1", | ||
"@biomejs/wasm-nodejs": "^1.6.1", | ||
"@biomejs/wasm-web": "^1.6.1" | ||
}, | ||
@@ -56,0 +58,0 @@ "peerDependenciesMeta": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
39155
428