diff --git a/js/README.md b/js/README.md index dafc7d71..dee80ddc 100644 --- a/js/README.md +++ b/js/README.md @@ -252,7 +252,17 @@ The Oxigraph bindings are written in Rust using [the Rust WASM toolkit](https:// The [The Rust Wasm Book](https://rustwasm.github.io/docs/book/) is a great tutorial to get started. -To run the tests of the JS bindings written in JS run `npm test`. +To setup a dev environment: +- ensure to have a Rust toolchain with `rustup` and `cargo` installed ([possible instructions](https://www.rust-lang.org/tools/install)). +- install [`wasm-pack`](https://rustwasm.github.io/wasm-pack/): `cargo install wasm-pack` (it is also in some Linux distribution repositories). +- `npm install` to install pure JS dependencies. +- you are good to go! + +Testing and linting: +- Rust code is formatted with [rustfmt](https://github.com/rust-lang/rustfmt) and linted with [clippy](https://github.com/rust-lang/rust-clippy). + You can execute them with `cargo fmt` and `cargo clippy`. +- JS code is formatted and linted with [Biome](https://biomejs.dev/). `npm run fmt` to auto-format and `npm test` to lint and test. +- Tests are written in JavaScript using [Mocha](https://mochajs.org/) in the `test` directory. `npm test` to run them. ## License diff --git a/js/rome.json b/js/biome.json similarity index 77% rename from js/rome.json rename to js/biome.json index 272422a5..72ae2ce8 100644 --- a/js/rome.json +++ b/js/biome.json @@ -1,4 +1,5 @@ { + "$schema": "https://biomejs.dev/schemas/1.0.0/schema.json", "formatter": { "indentStyle": "space", "indentSize": 4, diff --git a/js/package.json b/js/package.json index e8744994..02577037 100644 --- a/js/package.json +++ b/js/package.json @@ -5,11 +5,11 @@ "devDependencies": { "@rdfjs/data-model": "^2.0.1", "mocha": "^10.0.0", - "rome": "^12.0.0" + "@biomejs/biome": "^1.0.0" }, "scripts": { - "fmt": "rome format . --write && rome check . --apply-unsafe", - "test": "rome ci . && wasm-pack build --debug --target nodejs && mocha", + "fmt": "biome format . --write && biome check . --apply-unsafe", + "test": "biome ci . && wasm-pack build --debug --target nodejs && mocha", "build": "rm -rf pkg && wasm-pack build --release --target web --out-name web && mv pkg pkg-web && wasm-pack build --release --target nodejs --out-name node && mv pkg pkg-node && node build_package.js && rm -r pkg-web && rm -r pkg-node", "release": "npm run build && npm publish ./pkg", "pack": "npm run build && npm pack ./pkg" diff --git a/js/test/model.mjs b/js/test/model.mjs index 37f83199..9e816cfe 100644 --- a/js/test/model.mjs +++ b/js/test/model.mjs @@ -1,8 +1,8 @@ /* global describe, it */ +import assert from "assert"; import runTests from "../node_modules/@rdfjs/data-model/test/index.js"; import oxigraph from "../pkg/oxigraph.js"; -import assert from "assert"; runTests({ factory: oxigraph }); diff --git a/js/test/store.mjs b/js/test/store.mjs index ed50cb40..c73560a0 100644 --- a/js/test/store.mjs +++ b/js/test/store.mjs @@ -1,8 +1,8 @@ /* global describe, it */ -import { Store } from "../pkg/oxigraph.js"; -import dataModel from "@rdfjs/data-model"; import assert from "assert"; +import dataModel from "@rdfjs/data-model"; +import { Store } from "../pkg/oxigraph.js"; const ex = dataModel.namedNode("http://example.com"); const triple = dataModel.quad(