@rrlab/oxc-plugin 0.1.1 → 0.1.2-git-c5c6e0f.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 +27 -7
- package/dist/index.d.mts +9 -3
- package/dist/index.mjs +22 -14
- package/package.json +3 -3
- package/src/index.ts +18 -17
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @rrlab/oxc-plugin
|
|
2
2
|
|
|
3
|
-
[oxc](https://oxc.rs) plugin for [`@rrlab/cli`](https://npmjs.com/package/@rrlab/cli). Provides `lint` (oxlint)
|
|
3
|
+
[oxc](https://oxc.rs) plugin for [`@rrlab/cli`](https://npmjs.com/package/@rrlab/cli). Provides `lint` (oxlint), `format` (oxfmt), and `tsc` (oxlint type-aware) capabilities.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -8,17 +8,37 @@
|
|
|
8
8
|
rr plugins add oxc
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
Installs `@rrlab/oxc-plugin` and adds `oxlint`, `oxfmt`, and `oxlint-tsgolint`
|
|
11
|
+
Installs `@rrlab/oxc-plugin` and adds `oxlint`, `oxfmt`, and `oxlint-tsgolint` 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
12
|
|
|
13
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
14
|
|
|
15
15
|
## What it provides
|
|
16
16
|
|
|
17
|
-
| Capability | Surface |
|
|
18
|
-
|
|
19
|
-
| `lint` | `rr lint`, `rr lint doctor` |
|
|
20
|
-
| `format` | `rr format`, `rr format doctor` |
|
|
21
|
-
| `
|
|
17
|
+
| Capability | Surface | Underlying command |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| `lint` | `rr lint`, `rr lint doctor` | `oxlint --check` / `--fix` |
|
|
20
|
+
| `format` | `rr format`, `rr format doctor` | `oxfmt --check` / `--fix` |
|
|
21
|
+
| `tsc` | `rr tsc`, `rr tsc doctor` | `oxlint --type-aware --type-check` (via `oxlint-tsgolint`) |
|
|
22
|
+
| `jsc` (composed) | `rr jsc` (synthesised lint + format) | |
|
|
23
|
+
|
|
24
|
+
## Picking only some capabilities
|
|
25
|
+
|
|
26
|
+
Pass `only` to mix oxc with another plugin. Example: biome for lint+format, oxc just for the type-aware checks:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import biome from "@rrlab/biome-plugin";
|
|
30
|
+
import oxc from "@rrlab/oxc-plugin";
|
|
31
|
+
import { defineConfig } from "@rrlab/cli/config";
|
|
32
|
+
|
|
33
|
+
export default defineConfig({
|
|
34
|
+
plugins: [
|
|
35
|
+
biome({ only: ["lint", "format"] }),
|
|
36
|
+
oxc({ only: ["tsc"] }),
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The `only` array is typed against the kinds *this* plugin provides (`"lint" | "format" | "tsc"` for oxc), so typos like `oxc({ only: ["pack"] })` are caught at compile time.
|
|
22
42
|
|
|
23
43
|
## Removal
|
|
24
44
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormatOptions, Formatter, InstallContext, InstallResult, LintOptions, Linter, ToolService, UninstallContext, UninstallResult } from "@rrlab/cli/plugin";
|
|
1
|
+
import { FormatOptions, Formatter, InstallContext, InstallResult, LintOptions, Linter, ToolService, TypeCheckOptions, TypeChecker, UninstallContext, UninstallResult } from "@rrlab/cli/plugin";
|
|
2
2
|
import { ShellService } from "@vlandoss/clibuddy";
|
|
3
3
|
|
|
4
4
|
//#region src/tool-versions.d.ts
|
|
@@ -26,8 +26,14 @@ declare class OxfmtService extends ToolService implements Formatter {
|
|
|
26
26
|
constructor(shellService: ShellService);
|
|
27
27
|
format(options: FormatOptions): Promise<void>;
|
|
28
28
|
}
|
|
29
|
+
declare class OxlintTypeCheckService extends ToolService implements TypeChecker {
|
|
30
|
+
constructor(shellService: ShellService);
|
|
31
|
+
check(options?: TypeCheckOptions): Promise<void>;
|
|
32
|
+
}
|
|
29
33
|
declare function install(_ctx: InstallContext): Promise<InstallResult>;
|
|
30
34
|
declare function uninstall(_ctx: UninstallContext): Promise<UninstallResult>;
|
|
31
|
-
declare const oxc: (options
|
|
35
|
+
declare const oxc: (options?: {
|
|
36
|
+
only?: readonly ("lint" | "format" | "tsc")[] | undefined;
|
|
37
|
+
} | undefined) => import("@rrlab/cli/plugin").Plugin;
|
|
32
38
|
//#endregion
|
|
33
|
-
export { OxfmtService, OxlintService, TOOL_VERSIONS, oxc as default, install, uninstall };
|
|
39
|
+
export { OxfmtService, OxlintService, OxlintTypeCheckService, TOOL_VERSIONS, oxc as default, install, uninstall };
|
package/dist/index.mjs
CHANGED
|
@@ -47,6 +47,22 @@ var OxfmtService = class extends ToolService {
|
|
|
47
47
|
await this.exec(["--no-error-on-unmatched-pattern", options.fix ? "--fix" : "--check"]);
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
+
var OxlintTypeCheckService = class extends ToolService {
|
|
51
|
+
constructor(shellService) {
|
|
52
|
+
super({
|
|
53
|
+
pkg: "oxlint",
|
|
54
|
+
ui: UI_LINT,
|
|
55
|
+
shellService,
|
|
56
|
+
from: FROM
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async check(options = {}) {
|
|
60
|
+
await this.exec(["--type-aware", "--type-check"], {
|
|
61
|
+
cwd: options.cwd,
|
|
62
|
+
verbose: !options.cwd
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
50
66
|
async function install(_ctx) {
|
|
51
67
|
return { devDependencies: {
|
|
52
68
|
oxlint: TOOL_VERSIONS.oxlint.install,
|
|
@@ -66,19 +82,11 @@ const oxc = definePlugin(() => ({
|
|
|
66
82
|
apiVersion: 1,
|
|
67
83
|
install,
|
|
68
84
|
uninstall,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
}
|
|
85
|
+
capabilities: ({ shell }) => ({
|
|
86
|
+
lint: new OxlintService(shell),
|
|
87
|
+
format: new OxfmtService(shell),
|
|
88
|
+
tsc: new OxlintTypeCheckService(shell)
|
|
89
|
+
})
|
|
82
90
|
}));
|
|
83
91
|
//#endregion
|
|
84
|
-
export { OxfmtService, OxlintService, TOOL_VERSIONS, oxc as default, install, uninstall };
|
|
92
|
+
export { OxfmtService, OxlintService, OxlintTypeCheckService, TOOL_VERSIONS, oxc as default, install, uninstall };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rrlab/oxc-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2-git-c5c6e0f.0",
|
|
4
4
|
"description": "oxc plugin for @rrlab/cli — provides lint (oxlint) and format (oxfmt) capabilities.",
|
|
5
5
|
"homepage": "https://github.com/variableland/dx/tree/main/run-run/oxc-plugin#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"oxfmt": ">=0.30.0",
|
|
40
40
|
"oxlint": ">=1.0.0",
|
|
41
41
|
"oxlint-tsgolint": ">=0.15.0",
|
|
42
|
-
"@rrlab/cli": "0.0.
|
|
42
|
+
"@rrlab/cli": "0.0.4-git-c5c6e0f.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependenciesMeta": {
|
|
45
45
|
"oxlint-tsgolint": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"oxfmt": "0.35.0",
|
|
51
51
|
"oxlint": "1.50.0",
|
|
52
52
|
"oxlint-tsgolint": "0.15.0",
|
|
53
|
-
"@rrlab/cli": "0.0.
|
|
53
|
+
"@rrlab/cli": "0.0.4-git-c5c6e0f.0",
|
|
54
54
|
"@rrlab/tsdown-config": "^0.1.0"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
type Linter,
|
|
8
8
|
type LintOptions,
|
|
9
9
|
ToolService,
|
|
10
|
+
type TypeChecker,
|
|
11
|
+
type TypeCheckOptions,
|
|
10
12
|
type UninstallContext,
|
|
11
13
|
type UninstallResult,
|
|
12
14
|
} from "@rrlab/cli/plugin";
|
|
@@ -40,6 +42,16 @@ export class OxfmtService extends ToolService implements Formatter {
|
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
|
|
45
|
+
export class OxlintTypeCheckService extends ToolService implements TypeChecker {
|
|
46
|
+
constructor(shellService: ShellService) {
|
|
47
|
+
super({ pkg: "oxlint", ui: UI_LINT, shellService, from: FROM });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async check(options: TypeCheckOptions = {}): Promise<void> {
|
|
51
|
+
await this.exec(["--type-aware", "--type-check"], { cwd: options.cwd, verbose: !options.cwd });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
43
55
|
export async function install(_ctx: InstallContext): Promise<InstallResult> {
|
|
44
56
|
return {
|
|
45
57
|
devDependencies: {
|
|
@@ -54,27 +66,16 @@ export async function uninstall(_ctx: UninstallContext): Promise<UninstallResult
|
|
|
54
66
|
return { removeDependencies: ["oxlint", "oxfmt", "oxlint-tsgolint"] };
|
|
55
67
|
}
|
|
56
68
|
|
|
57
|
-
const oxc = definePlugin
|
|
69
|
+
const oxc = definePlugin(() => ({
|
|
58
70
|
name: "oxc",
|
|
59
71
|
apiVersion: 1,
|
|
60
72
|
install,
|
|
61
73
|
uninstall,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
},
|
|
74
|
+
capabilities: ({ shell }) => ({
|
|
75
|
+
lint: new OxlintService(shell),
|
|
76
|
+
format: new OxfmtService(shell),
|
|
77
|
+
tsc: new OxlintTypeCheckService(shell),
|
|
78
|
+
}),
|
|
78
79
|
}));
|
|
79
80
|
|
|
80
81
|
export default oxc;
|