0.7.2 • Published 8 months ago
@astral-sh/ruff-wasm-web v0.7.2
Ruff WASM
⚠️ WARNING: This API is experimental and may change at any time
An extremely fast Python linter and code formatter, written in Rust.
This is a WASM version of the Ruff API which can be used to lint/format Python in a browser environment.
There are multiple versions for the different wasm-pack targets. See here for more info on targets.
Usage
This example uses the wasm-pack web target and is known to work with Vite.
import init, { Workspace, type Diagnostic } from '@astral-sh/ruff-api';
const exampleDocument = `print('hello'); print("world")`
await init(); // Initializes WASM module
// These are default settings just to illustrate configuring Ruff
// Settings info: https://docs.astral.sh/ruff/settings
const workspace = new Workspace({
'line-length': 88,
'indent-width': 4,
format: {
'indent-style': 'space',
'quote-style': 'double',
},
lint: {
select: [
'E4',
'E7',
'E9',
'F'
],
},
});
// Will contain 1 diagnostic code for E702: Multiple statements on one line
const diagnostics: Diagnostic[] = workspace.check(exampleDocument);
const formatted = workspace.format(exampleDocument);
0.7.2
8 months ago
0.7.1
9 months ago
0.7.0
9 months ago
0.6.9
9 months ago
0.6.8
10 months ago
0.6.7
10 months ago
0.6.6
10 months ago
0.6.3
10 months ago
0.6.5
10 months ago
0.6.4
10 months ago
0.6.2
11 months ago
0.6.1
11 months ago
0.6.0
11 months ago
0.5.7
11 months ago
0.5.6
11 months ago
0.5.5
12 months ago
0.5.4
12 months ago
0.5.3
12 months ago