@rrlab/oxc-plugin 0.0.1-git-06ed46c.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -0
- package/dist/index.d.mts +33 -0
- package/dist/index.mjs +84 -0
- package/package.json +60 -0
- package/src/index.ts +80 -0
- package/src/tool-versions.ts +5 -0
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# @rrlab/oxc-plugin
|
|
2
|
+
|
|
3
|
+
[oxc](https://oxc.rs) plugin for [`@rrlab/cli`](https://npmjs.com/package/@rrlab/cli). Provides `lint` (oxlint) and `format` (oxfmt) capabilities.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
rr plugins add oxc
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Installs `@rrlab/oxc-plugin` and adds `oxlint`, `oxfmt`, and `oxlint-tsgolint` (optional) as `devDependencies`. No config file is scaffolded — oxlint and oxfmt work with sensible defaults and the projects that need to customise add their own `oxlintrc.json` / `.oxfmtrc` on demand.
|
|
12
|
+
|
|
13
|
+
For `rr jsc` (lint + format together), the kernel composes oxlint + oxfmt automatically when both capabilities are present and no plugin provides `jsc` directly.
|
|
14
|
+
|
|
15
|
+
## What it provides
|
|
16
|
+
|
|
17
|
+
| Capability | Surface |
|
|
18
|
+
|---|---|
|
|
19
|
+
| `lint` | `rr lint`, `rr lint doctor` |
|
|
20
|
+
| `format` | `rr format`, `rr format doctor` |
|
|
21
|
+
| `jsc` (composed) | `rr jsc` (synthesised lint + format) |
|
|
22
|
+
|
|
23
|
+
## Removal
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
rr plugins remove oxc
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Removes `oxlint`, `oxfmt`, and `oxlint-tsgolint` from `package.json` and drops the `oxc()` entry from `run-run.config.{ts,mts}`. Tool config files (`oxlintrc.json`, `.oxfmtrc`) — if any — are left alone, they belong to the user.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { FormatOptions, Formatter, InstallContext, InstallResult, LintOptions, Linter, ToolService, UninstallContext, UninstallResult } from "@rrlab/cli/plugin";
|
|
2
|
+
import { ShellService } from "@vlandoss/clibuddy";
|
|
3
|
+
|
|
4
|
+
//#region src/tool-versions.d.ts
|
|
5
|
+
declare const TOOL_VERSIONS: {
|
|
6
|
+
readonly oxlint: {
|
|
7
|
+
readonly install: "^1.0.0";
|
|
8
|
+
readonly peer: ">=1.0.0";
|
|
9
|
+
};
|
|
10
|
+
readonly oxfmt: {
|
|
11
|
+
readonly install: "^0.30.0";
|
|
12
|
+
readonly peer: ">=0.30.0";
|
|
13
|
+
};
|
|
14
|
+
readonly "oxlint-tsgolint": {
|
|
15
|
+
readonly install: "^0.15.0";
|
|
16
|
+
readonly peer: ">=0.15.0";
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/index.d.ts
|
|
21
|
+
declare class OxlintService extends ToolService implements Linter {
|
|
22
|
+
constructor(shellService: ShellService);
|
|
23
|
+
lint(options: LintOptions): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
declare class OxfmtService extends ToolService implements Formatter {
|
|
26
|
+
constructor(shellService: ShellService);
|
|
27
|
+
format(options: FormatOptions): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
declare function install(_ctx: InstallContext): Promise<InstallResult>;
|
|
30
|
+
declare function uninstall(_ctx: UninstallContext): Promise<UninstallResult>;
|
|
31
|
+
declare const oxc: (options: void) => import("@rrlab/cli/plugin").Plugin;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { OxfmtService, OxlintService, TOOL_VERSIONS, oxc as default, install, uninstall };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ToolService, definePlugin } from "@rrlab/cli/plugin";
|
|
2
|
+
import { colorize } from "@vlandoss/clibuddy";
|
|
3
|
+
//#region src/tool-versions.ts
|
|
4
|
+
const TOOL_VERSIONS = {
|
|
5
|
+
oxlint: {
|
|
6
|
+
install: "^1.0.0",
|
|
7
|
+
peer: ">=1.0.0"
|
|
8
|
+
},
|
|
9
|
+
oxfmt: {
|
|
10
|
+
install: "^0.30.0",
|
|
11
|
+
peer: ">=0.30.0"
|
|
12
|
+
},
|
|
13
|
+
"oxlint-tsgolint": {
|
|
14
|
+
install: "^0.15.0",
|
|
15
|
+
peer: ">=0.15.0"
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/index.ts
|
|
20
|
+
const FROM = import.meta.url;
|
|
21
|
+
const oxColor = colorize("#32F3E9");
|
|
22
|
+
const UI_LINT = oxColor("oxlint");
|
|
23
|
+
const UI_FMT = oxColor("oxfmt");
|
|
24
|
+
var OxlintService = class extends ToolService {
|
|
25
|
+
constructor(shellService) {
|
|
26
|
+
super({
|
|
27
|
+
pkg: "oxlint",
|
|
28
|
+
ui: UI_LINT,
|
|
29
|
+
shellService,
|
|
30
|
+
from: FROM
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
async lint(options) {
|
|
34
|
+
await this.exec(["--report-unused-disable-directives", options.fix ? "--fix" : "--check"]);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var OxfmtService = class extends ToolService {
|
|
38
|
+
constructor(shellService) {
|
|
39
|
+
super({
|
|
40
|
+
pkg: "oxfmt",
|
|
41
|
+
ui: UI_FMT,
|
|
42
|
+
shellService,
|
|
43
|
+
from: FROM
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
async format(options) {
|
|
47
|
+
await this.exec(["--no-error-on-unmatched-pattern", options.fix ? "--fix" : "--check"]);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
async function install(_ctx) {
|
|
51
|
+
return { devDependencies: {
|
|
52
|
+
oxlint: TOOL_VERSIONS.oxlint.install,
|
|
53
|
+
oxfmt: TOOL_VERSIONS.oxfmt.install,
|
|
54
|
+
"oxlint-tsgolint": TOOL_VERSIONS["oxlint-tsgolint"].install
|
|
55
|
+
} };
|
|
56
|
+
}
|
|
57
|
+
async function uninstall(_ctx) {
|
|
58
|
+
return { removeDependencies: [
|
|
59
|
+
"oxlint",
|
|
60
|
+
"oxfmt",
|
|
61
|
+
"oxlint-tsgolint"
|
|
62
|
+
] };
|
|
63
|
+
}
|
|
64
|
+
const oxc = definePlugin(() => ({
|
|
65
|
+
name: "oxc",
|
|
66
|
+
apiVersion: 1,
|
|
67
|
+
install,
|
|
68
|
+
uninstall,
|
|
69
|
+
async setup({ shell }) {
|
|
70
|
+
const lintSvc = new OxlintService(shell);
|
|
71
|
+
const fmtSvc = new OxfmtService(shell);
|
|
72
|
+
try {
|
|
73
|
+
await Promise.all([lintSvc.getBinDir(), fmtSvc.getBinDir()]);
|
|
74
|
+
} catch (_err) {
|
|
75
|
+
throw new Error("@rrlab/oxc-plugin requires oxlint and oxfmt to be installed in the host project. Run: rr plugins add oxc (or: pnpm add -D oxlint oxfmt)");
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
lint: lintSvc,
|
|
79
|
+
format: fmtSvc
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}));
|
|
83
|
+
//#endregion
|
|
84
|
+
export { OxfmtService, OxlintService, TOOL_VERSIONS, oxc as default, install, uninstall };
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rrlab/oxc-plugin",
|
|
3
|
+
"version": "0.0.1-git-06ed46c.0",
|
|
4
|
+
"description": "oxc plugin for @rrlab/cli — provides lint (oxlint) and format (oxfmt) capabilities.",
|
|
5
|
+
"homepage": "https://github.com/variableland/dx/tree/main/run-run/oxc-plugin#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/variableland/dx/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/variableland/dx.git",
|
|
12
|
+
"directory": "run-run/oxc-plugin"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": "rcrd <rcrd@variable.land>",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.mts",
|
|
20
|
+
"default": "./dist/index.mjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"src",
|
|
26
|
+
"!src/**/__tests__",
|
|
27
|
+
"!src/**/*.test.*"
|
|
28
|
+
],
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=20.0.0"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@vlandoss/clibuddy": "0.6.1"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"oxfmt": ">=0.30.0",
|
|
40
|
+
"oxlint": ">=1.0.0",
|
|
41
|
+
"oxlint-tsgolint": ">=0.15.0",
|
|
42
|
+
"@rrlab/cli": "0.0.2-git-06ed46c.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependenciesMeta": {
|
|
45
|
+
"oxlint-tsgolint": {
|
|
46
|
+
"optional": true
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"oxfmt": "0.35.0",
|
|
51
|
+
"oxlint": "1.50.0",
|
|
52
|
+
"oxlint-tsgolint": "0.15.0",
|
|
53
|
+
"@rrlab/cli": "0.0.2-git-06ed46c.0",
|
|
54
|
+
"@rrlab/tsdown-config": "^0.0.1-git-06ed46c.0"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsdown",
|
|
58
|
+
"test": "vitest run"
|
|
59
|
+
}
|
|
60
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import {
|
|
2
|
+
definePlugin,
|
|
3
|
+
type FormatOptions,
|
|
4
|
+
type Formatter,
|
|
5
|
+
type InstallContext,
|
|
6
|
+
type InstallResult,
|
|
7
|
+
type Linter,
|
|
8
|
+
type LintOptions,
|
|
9
|
+
ToolService,
|
|
10
|
+
type UninstallContext,
|
|
11
|
+
type UninstallResult,
|
|
12
|
+
} from "@rrlab/cli/plugin";
|
|
13
|
+
import { colorize, type ShellService } from "@vlandoss/clibuddy";
|
|
14
|
+
import { TOOL_VERSIONS } from "./tool-versions.ts";
|
|
15
|
+
|
|
16
|
+
export { TOOL_VERSIONS } from "./tool-versions.ts";
|
|
17
|
+
|
|
18
|
+
const FROM = import.meta.url;
|
|
19
|
+
const oxColor = colorize("#32F3E9");
|
|
20
|
+
const UI_LINT = oxColor("oxlint");
|
|
21
|
+
const UI_FMT = oxColor("oxfmt");
|
|
22
|
+
|
|
23
|
+
export class OxlintService extends ToolService implements Linter {
|
|
24
|
+
constructor(shellService: ShellService) {
|
|
25
|
+
super({ pkg: "oxlint", ui: UI_LINT, shellService, from: FROM });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async lint(options: LintOptions) {
|
|
29
|
+
await this.exec(["--report-unused-disable-directives", options.fix ? "--fix" : "--check"]);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class OxfmtService extends ToolService implements Formatter {
|
|
34
|
+
constructor(shellService: ShellService) {
|
|
35
|
+
super({ pkg: "oxfmt", ui: UI_FMT, shellService, from: FROM });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async format(options: FormatOptions) {
|
|
39
|
+
await this.exec(["--no-error-on-unmatched-pattern", options.fix ? "--fix" : "--check"]);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function install(_ctx: InstallContext): Promise<InstallResult> {
|
|
44
|
+
return {
|
|
45
|
+
devDependencies: {
|
|
46
|
+
oxlint: TOOL_VERSIONS.oxlint.install,
|
|
47
|
+
oxfmt: TOOL_VERSIONS.oxfmt.install,
|
|
48
|
+
"oxlint-tsgolint": TOOL_VERSIONS["oxlint-tsgolint"].install,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export async function uninstall(_ctx: UninstallContext): Promise<UninstallResult> {
|
|
54
|
+
return { removeDependencies: ["oxlint", "oxfmt", "oxlint-tsgolint"] };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const oxc = definePlugin<void>(() => ({
|
|
58
|
+
name: "oxc",
|
|
59
|
+
apiVersion: 1,
|
|
60
|
+
install,
|
|
61
|
+
uninstall,
|
|
62
|
+
async setup({ shell }) {
|
|
63
|
+
const lintSvc = new OxlintService(shell);
|
|
64
|
+
const fmtSvc = new OxfmtService(shell);
|
|
65
|
+
try {
|
|
66
|
+
await Promise.all([lintSvc.getBinDir(), fmtSvc.getBinDir()]);
|
|
67
|
+
} catch (_err) {
|
|
68
|
+
throw new Error(
|
|
69
|
+
"@rrlab/oxc-plugin requires oxlint and oxfmt to be installed in the host project. " +
|
|
70
|
+
"Run: rr plugins add oxc (or: pnpm add -D oxlint oxfmt)",
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
lint: lintSvc,
|
|
75
|
+
format: fmtSvc,
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
}));
|
|
79
|
+
|
|
80
|
+
export default oxc;
|