Skip to content

Commit dca72b4

Browse files
committed
chore: add bun + oxc tooling, devShell, and CI
Set up minimal dev environment: - flake.nix devShell (bun, nodejs) with pre-commit hooks for oxlint + oxfmt - package.json with oxlint@1.62.0, oxfmt@0.47.0 and lint/format scripts - .oxfmtrc.json preserves single-quote style - .envrc (use flake) for direnv auto-activation - GitHub Actions: parallel Lint/Format jobs sharing a composite setup action
1 parent e1e79ce commit dca72b4

10 files changed

Lines changed: 350 additions & 2 deletions

File tree

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.github/actions/setup/action.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: Setup
2+
description: Setup Bun and install dependencies
3+
runs:
4+
using: composite
5+
steps:
6+
- uses: oven-sh/setup-bun@v2
7+
with:
8+
bun-version: latest
9+
- run: bun install --frozen-lockfile
10+
shell: bash

.github/workflows/ci.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
lint:
10+
name: Lint
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: ./.github/actions/setup
15+
- run: bun run lint
16+
17+
format:
18+
name: Format
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: ./.github/actions/setup
23+
- run: bun run format

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
*.swp
33
.idea/
44
.vscode/
5+
node_modules/
6+
.direnv/
7+
.pre-commit-config.yaml

.oxfmtrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxfmt/configuration_schema.json",
3+
"singleQuote": true,
4+
"semi": true,
5+
"tabWidth": 2,
6+
"useTabs": false,
7+
"printWidth": 100,
8+
"trailingComma": "all",
9+
"arrowParens": "always",
10+
"endOfLine": "lf"
11+
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Violentmonkey auto-updates from `main` on its own.
1010
Open a script's raw URL in Firefox with Violentmonkey installed — it detects
1111
the `==UserScript==` header and prompts to install.
1212

13-
| Script | Install | Description |
14-
|---|---|---|
13+
| Script | Install | Description |
14+
| ---------------------------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
1515
| `gitlab-mark-viewed.user.js` | [install](https://raw.githubusercontent.com/solcik/userscripts/main/gitlab-mark-viewed.user.js) | Press `v` on a GitLab MR diff to toggle the focused file's "Viewed" checkbox. Matches `gitlab.com` and `git.vs-point.cz`. |
1616

1717
## Authoring

bun.lock

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.lock

Lines changed: 124 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
description = "Userscripts dev environment (bun + oxc)";
3+
4+
inputs = {
5+
unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
6+
systems.url = "github:nix-systems/default";
7+
flake-utils = {
8+
url = "github:numtide/flake-utils";
9+
inputs.systems.follows = "systems";
10+
};
11+
pre-commit-hooks = {
12+
url = "github:cachix/pre-commit-hooks.nix";
13+
inputs.nixpkgs.follows = "unstable";
14+
};
15+
};
16+
17+
outputs = {
18+
unstable,
19+
flake-utils,
20+
pre-commit-hooks,
21+
...
22+
}:
23+
flake-utils.lib.eachDefaultSystem (
24+
system: let
25+
pkgs = unstable.legacyPackages.${system};
26+
pre-commit-check = pre-commit-hooks.lib.${system}.run {
27+
src = ./.;
28+
hooks = {
29+
oxlint = {
30+
enable = true;
31+
name = "oxlint";
32+
entry = "bun run lint";
33+
files = "\\.(js|jsx|ts|tsx)$";
34+
pass_filenames = false;
35+
language = "system";
36+
};
37+
38+
oxfmt = {
39+
enable = true;
40+
name = "oxfmt";
41+
entry = "bun run format";
42+
files = "\\.(js|jsx|ts|tsx|json|jsonc)$";
43+
pass_filenames = false;
44+
language = "system";
45+
};
46+
};
47+
excludes = ["^node_modules/" "^\\.direnv/" "^\\.git/"];
48+
};
49+
in {
50+
checks = {
51+
inherit pre-commit-check;
52+
};
53+
54+
devShells.default = pkgs.mkShell {
55+
packages = with pkgs; [
56+
bun
57+
nodejs_24
58+
];
59+
shellHook = ''
60+
${pre-commit-check.shellHook}
61+
'';
62+
};
63+
}
64+
);
65+
}

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "userscripts",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"lint": "oxlint .",
7+
"lint:fix": "oxlint --fix .",
8+
"format": "oxfmt --check .",
9+
"format:fix": "oxfmt ."
10+
},
11+
"devDependencies": {
12+
"oxfmt": "^0.47.0",
13+
"oxlint": "^1.62.0"
14+
}
15+
}

0 commit comments

Comments
 (0)