Ruff WASM
⚠️ WARNING: This API is experimental and may change at any time
Docs | Playground
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();
const workspace = new Workspace({
'line-length': 88,
'indent-width': 4,
format: {
'indent-style': 'space',
'quote-style': 'double',
},
lint: {
select: [
'E4',
'E7',
'E9',
'F'
],
},
});
const diagnostics: Diagnostic[] = workspace.check(exampleDocument);
const formatted = workspace.format(exampleDocument);
0.6.1
This is a hotfix release to address an issue with ruff-pre-commit
. In v0.6,
Ruff changed its behavior to lint and format Jupyter notebooks by default;
however, due to an oversight, these files were still excluded by default if
Ruff was run via pre-commit, leading to inconsistent behavior.
This has now been fixed.
Preview features
- [
fastapi
] Implement fast-api-unused-path-parameter
(FAST003
) (#12638)
Rule changes
- [
pylint
] Rename too-many-positional
to too-many-positional-arguments
(R0917
) (#12905)
Server
- Fix crash when applying "fix-all" code-action to notebook cells (#12929)
Other changes
- [
flake8-naming
]: Respect import conventions (N817
) (#12922)