@tsrx/oxc 0.0.0-trusted-publishing-bootstrap → 0.8.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/LICENSE +21 -0
- package/README.md +141 -0
- package/THIRD_PARTY_NOTICES.md +49 -0
- package/bin/oxc-tsrx +2 -0
- package/bin/oxc-tsrx-fmt +2 -0
- package/bin/oxc-tsrx-lint +2 -0
- package/bin/oxc-tsrx-lsp +2 -0
- package/bin/oxfmt +2 -0
- package/bin/oxlint +2 -0
- package/dist/bin/oxc-tsrx-fmt.js +13 -0
- package/dist/bin/oxc-tsrx-lint.js +13 -0
- package/dist/bin/oxc-tsrx-lsp.js +13 -0
- package/dist/bin/oxc-tsrx.js +115 -0
- package/dist/bin/oxfmt.js +24 -0
- package/dist/bin/oxlint.js +33 -0
- package/dist/canonical-command.d.ts +50 -0
- package/dist/canonical-command.js +196 -0
- package/dist/compat.d.ts +149 -0
- package/dist/compat.js +1615 -0
- package/dist/editor-resolution.js +508 -0
- package/dist/format-cli.js +276 -0
- package/dist/format-invocation.js +97 -0
- package/dist/format.d.ts +1 -0
- package/dist/format.js +56 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +16 -0
- package/dist/lint-cli.js +487 -0
- package/dist/lint-invocation.js +192 -0
- package/dist/lint-js-plugins.js +819 -0
- package/dist/lint-plugins-dev.d.ts +1 -0
- package/dist/lint-plugins-dev.js +2 -0
- package/dist/lint-prestart.js +16 -0
- package/dist/lint.d.ts +1 -0
- package/dist/lint.js +2 -0
- package/dist/native-targets.js +76 -0
- package/dist/oxlint-lsp-multiplexer.js +622 -0
- package/dist/package-binary.js +29 -0
- package/dist/parser.d.ts +216 -0
- package/dist/parser.js +557 -0
- package/dist/process.js +88 -0
- package/dist/provider-resolve.d.ts +160 -0
- package/dist/provider-resolve.js +471 -0
- package/dist/providers-report.js +49 -0
- package/dist/runtime.js +323 -0
- package/dist/spawn-command.d.ts +20 -0
- package/dist/spawn-command.js +87 -0
- package/dist/tsrx-core-compat/facade.js +1184 -0
- package/dist/tsrx-core-compat/index.d.ts +6 -0
- package/dist/tsrx-core-compat/index.js +9 -0
- package/dist/tsrx-core-compat/style.js +525 -0
- package/dist/tsrx-core-compat/types/estree.d.ts +20 -0
- package/dist/tsrx-core-compat/types/index.d.ts +50 -0
- package/dist/tsrx-transfer.js +352 -0
- package/package.json +144 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OXC for TSRX contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://compiled.run/oxc-tsrx">
|
|
3
|
+
<img alt="OXC for TSRX" width="600" src="https://raw.githubusercontent.com/tsrx-org/oxc/HEAD/.github/assets/readme-hero.png">
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://www.npmjs.com/package/@tsrx/oxc"><img alt="npm version" src="https://img.shields.io/npm/v/@tsrx/oxc"></a>
|
|
9
|
+
<a href="https://nodejs.org/en/about/previous-releases"><img alt="supported Node.js versions" src="https://img.shields.io/node/v/@tsrx/oxc"></a>
|
|
10
|
+
<a href="https://github.com/tsrx-org/oxc/actions/workflows/ci.yml"><img alt="CI status" src="https://github.com/tsrx-org/oxc/actions/workflows/ci.yml/badge.svg?branch=main"></a>
|
|
11
|
+
<a href="https://discord.gg/HCYpT5QHQR"><img alt="Discord" src="https://img.shields.io/badge/Discord-Join%20the%20community-7289da?logo=discord&logoColor=white"></a>
|
|
12
|
+
<a href="https://github.com/tsrx-org/oxc/blob/HEAD/LICENSE"><img alt="MIT license" src="https://img.shields.io/npm/l/@tsrx/oxc"></a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
The official OXC integration for TSRX. `@tsrx/oxc` gives you three tools for
|
|
16
|
+
`.tsrx` files:
|
|
17
|
+
|
|
18
|
+
- a **linter**, which warns you about likely mistakes before you run your code
|
|
19
|
+
- a **formatter**, which fixes spacing and punctuation so every file matches
|
|
20
|
+
- a **parser**, which reads a file into a form your own tools can work with
|
|
21
|
+
|
|
22
|
+
A `.tsrx` file is TypeScript with HTML-like markup in it, plus blocks like `@if`
|
|
23
|
+
and `@for` for showing something only sometimes, or once per item in a list.
|
|
24
|
+
[OXC](https://oxc.rs) is a set of fast tools for JavaScript and TypeScript,
|
|
25
|
+
written in Rust. This package teaches them to read `.tsrx` too.
|
|
26
|
+
|
|
27
|
+
_OXC for TSRX is the official OXC integration maintained by the TSRX project._
|
|
28
|
+
|
|
29
|
+
[**Docs**](https://compiled.run/oxc-tsrx) · [**Getting started**](https://compiled.run/oxc-tsrx/guide/getting-started) · [**Playground**](https://compiled.run/oxc-tsrx/playground)
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npm install --save-dev @tsrx/oxc
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
That is the whole setup, for the command line and for your editor. You get
|
|
38
|
+
`oxlint` and `oxfmt`, the real [OXC](https://oxc.rs) commands, now able to read
|
|
39
|
+
`.tsrx`, with no config file, no ignore file, and no install script. [Vite+ needs
|
|
40
|
+
one more command](https://compiled.run/oxc-tsrx/guide/getting-started#try-it-with-vite).
|
|
41
|
+
|
|
42
|
+
You do not need Rust installed: the install downloads a ready-built program for
|
|
43
|
+
your machine, one of eight published for macOS, Linux, and Windows. See
|
|
44
|
+
[Platform support](https://compiled.run/oxc-tsrx/reference/platform-support).
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
npx oxlint src/Cart.tsrx # Lint the file.
|
|
50
|
+
npx oxfmt --check src/Cart.tsrx # Show what formatting would change.
|
|
51
|
+
npx oxfmt --write src/Cart.tsrx # Apply it.
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Always give these commands a path. A bare `npx oxlint` also checks
|
|
55
|
+
`node_modules`, and `--fix` (the flag that lets `oxlint` edit your files) will
|
|
56
|
+
rewrite files in there.
|
|
57
|
+
|
|
58
|
+
Your `.js`, `.jsx`, `.ts`, and `.tsx` files go straight to OXC, exactly as they
|
|
59
|
+
would without this package. Only `.tsrx` files do anything TSRX-specific.
|
|
60
|
+
|
|
61
|
+
## What works today
|
|
62
|
+
|
|
63
|
+
These are the TSRX blocks the linter and formatter understand: `@{` blocks,
|
|
64
|
+
`@if` / `@else if` / `@else`, `@for` / `@empty`, `@switch` / `@case` /
|
|
65
|
+
`@default`, `@try` / `@pending` / `@catch`, tags whose name is an expression,
|
|
66
|
+
`<{expression}>`, and plain `<style>` blocks
|
|
67
|
+
([TSRX syntax](https://compiled.run/oxc-tsrx/guide/tsrx-syntax) shows each one). Anything
|
|
68
|
+
outside that list **fails closed**: the command stops and says what it found and
|
|
69
|
+
where, rather than guessing and maybe producing wrong output.
|
|
70
|
+
|
|
71
|
+
**This package compiles nothing.** It never builds or runs your app. Turning
|
|
72
|
+
`.tsrx` into something a browser can run is your framework's TSRX plugin's job,
|
|
73
|
+
such as `@tsrx/vite-plugin-react`. See
|
|
74
|
+
[tsrx.dev/getting-started](https://tsrx.dev/getting-started). Without one, your
|
|
75
|
+
build tool reads `.tsrx` as plain TypeScript and stops at the first `@{`.
|
|
76
|
+
|
|
77
|
+
## In your editor
|
|
78
|
+
|
|
79
|
+
Install the official OXC extension, `oxc.oxc-vscode`. With `@tsrx/oxc` in the
|
|
80
|
+
project there is nothing else to install or configure, and your editor
|
|
81
|
+
underlines the same problems the terminal reports. One catch: the TSRX
|
|
82
|
+
toolchain's own extension owns `.tsrx`, and the OXC extension lists no
|
|
83
|
+
activation event for it, so it does not start on its own. Open any JavaScript,
|
|
84
|
+
TypeScript, or JSON file in the project once, and `.tsrx` works for the rest of
|
|
85
|
+
the session. See the [editor guide](https://compiled.run/oxc-tsrx/integrations/editor).
|
|
86
|
+
|
|
87
|
+
## Using it from your own code
|
|
88
|
+
|
|
89
|
+
```js
|
|
90
|
+
import { parseSync } from "@tsrx/oxc/parser";
|
|
91
|
+
import { defineConfig } from "@tsrx/oxc/lint";
|
|
92
|
+
import { format } from "@tsrx/oxc/format";
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The parser hands back the structure of your file and the formatter hands back
|
|
96
|
+
tidied text, so you can build your own tools on the same reader the commands
|
|
97
|
+
use. [Parsing](https://compiled.run/oxc-tsrx/guide/parsing) has the shape it returns.
|
|
98
|
+
None of these compiles `.tsrx` either; that stays your framework's TSRX
|
|
99
|
+
plugin's job.
|
|
100
|
+
|
|
101
|
+
Framework compilers that currently call `@tsrx/core`'s parser can use the
|
|
102
|
+
compatibility facade from the same package:
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
import { parseModule } from "@tsrx/oxc/tsrx-core-compat";
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
It preserves TypeScript fields and supplies the source locations, directive
|
|
109
|
+
keyword origins, comments, and complete scoped-CSS tree expected by
|
|
110
|
+
`@tsrx/core` consumers.
|
|
111
|
+
|
|
112
|
+
## Your own JavaScript lint plugins
|
|
113
|
+
|
|
114
|
+
A plugin listed in `jsPlugins` runs on `.tsrx` from the `oxlint` command and
|
|
115
|
+
inside your editor, but it sees a translated copy of your file rather than the
|
|
116
|
+
TSRX you wrote, so each `.tsrx` file is read once more. The command and the
|
|
117
|
+
editor both say when they have done that, and
|
|
118
|
+
`settings.oxcTsrx.jsPluginsOnTsrx: false` turns it off.
|
|
119
|
+
|
|
120
|
+
`oxc-tsrx-lint`, the standalone Rust command, has no Node.js to run a plugin in,
|
|
121
|
+
so it refuses `jsPlugins` and names `oxlint` as the command that can.
|
|
122
|
+
`@tsrx/oxc/lint/plugins-dev` is for *writing* a plugin, since it re-exports the
|
|
123
|
+
`RuleTester` from `oxlint`. See [Custom JavaScript
|
|
124
|
+
plugins](https://compiled.run/oxc-tsrx/integrations/custom-js-plugins).
|
|
125
|
+
|
|
126
|
+
## Documentation
|
|
127
|
+
|
|
128
|
+
- [Getting started](https://compiled.run/oxc-tsrx/guide/getting-started): install, first file, first run.
|
|
129
|
+
- [Configuration](https://compiled.run/oxc-tsrx/integrations/configuration): every supported setting.
|
|
130
|
+
- [CLI reference](https://compiled.run/oxc-tsrx/reference/cli): commands, flags, and exit codes.
|
|
131
|
+
- [Platform support](https://compiled.run/oxc-tsrx/reference/platform-support): which of the eight published platforms are tested on every change.
|
|
132
|
+
- [Limitations](https://compiled.run/oxc-tsrx/reference/limitations): what is not claimed yet.
|
|
133
|
+
- [Provider protocol](https://compiled.run/oxc-tsrx/architecture/provider-protocol): the `oxc.provider` block, what reads it today, and how a plain install reaches released hosts.
|
|
134
|
+
|
|
135
|
+
`@tsrx/oxc` is the only package to depend on. The eight `@tsrx/oxc-*`
|
|
136
|
+
packages are platform binaries in `optionalDependencies`, and you never name one
|
|
137
|
+
yourself.
|
|
138
|
+
|
|
139
|
+
## License
|
|
140
|
+
|
|
141
|
+
[MIT](https://github.com/tsrx-org/oxc/blob/HEAD/LICENSE).
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
`oxc-tsrx` is the complete OXC-shaped TSRX parser, linter, formatter, and
|
|
4
|
+
language-server host. It uses canonical OXC Rust crates from commit
|
|
5
|
+
`8e0ed2ebb96137fb1611cdbd5742d5cb46037d40` of
|
|
6
|
+
<https://github.com/oxc-project/oxc>. OXC is licensed under the MIT License.
|
|
7
|
+
|
|
8
|
+
OXC is consumed as an exact-revision Cargo dependency. Its source is not
|
|
9
|
+
copied, vendored, patched, or forked by this project. Target-native packages
|
|
10
|
+
contain the complete generated Rust dependency inventory and byte-exact
|
|
11
|
+
upstream legal files, and each `@oxc-tsrx/native-*` package carries the notices
|
|
12
|
+
for the linked Rust/OXC binary distribution it ships.
|
|
13
|
+
|
|
14
|
+
This package's npm dependencies are:
|
|
15
|
+
|
|
16
|
+
- `@oxc-project/types` 0.140.0, MIT licensed and maintained by the OXC project,
|
|
17
|
+
for the parser declaration surface.
|
|
18
|
+
- `oxlint` 1.74.0, which ordinary linting delegates to unchanged.
|
|
19
|
+
- `oxfmt` 0.59.0, which ordinary formatting delegates to unchanged.
|
|
20
|
+
- `oxlint-tsgolint` 0.24.0, for type-aware linting.
|
|
21
|
+
- `tinyglobby` 0.2.17, MIT licensed, for file discovery.
|
|
22
|
+
|
|
23
|
+
Those packages retain their own license and notice files when installed.
|
|
24
|
+
|
|
25
|
+
The `oxc-tsrx/tsrx-core-compat` export adapts the CSS parser from `@tsrx/core`
|
|
26
|
+
0.1.56, Copyright (c) 2025 Dominic Gannaway. The adapted source is licensed
|
|
27
|
+
under the MIT License:
|
|
28
|
+
|
|
29
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
30
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
31
|
+
in the Software without restriction, including without limitation the rights
|
|
32
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
33
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
34
|
+
furnished to do so, subject to the following conditions:
|
|
35
|
+
|
|
36
|
+
The above copyright notice and this permission notice shall be included in all
|
|
37
|
+
copies or substantial portions of the Software.
|
|
38
|
+
|
|
39
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
40
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
41
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
42
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
43
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
44
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
45
|
+
SOFTWARE.
|
|
46
|
+
|
|
47
|
+
OXC for TSRX is an independent community integration. It is not an official
|
|
48
|
+
OXC project and is not affiliated with or endorsed by VoidZero Inc. or OXC's
|
|
49
|
+
contributors.
|
package/bin/oxc-tsrx
ADDED
package/bin/oxc-tsrx-fmt
ADDED
package/bin/oxc-tsrx-lsp
ADDED
package/bin/oxfmt
ADDED
package/bin/oxlint
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
//#region src/bin/oxc-tsrx-fmt.ts
|
|
3
|
+
try {
|
|
4
|
+
const { resolveNativeCommand, runPassthrough } = await import("../runtime.js");
|
|
5
|
+
const native = resolveNativeCommand("format", process.argv.slice(2));
|
|
6
|
+
const result = await runPassthrough(native.executable, native.args);
|
|
7
|
+
process.exitCode = result.status;
|
|
8
|
+
} catch (error) {
|
|
9
|
+
console.error(`oxc-tsrx-fmt: ${error instanceof Error ? error.message : String(error)}`);
|
|
10
|
+
process.exitCode = 2;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
//#region src/bin/oxc-tsrx-lint.ts
|
|
3
|
+
try {
|
|
4
|
+
const { resolveNativeCommand, runPassthrough } = await import("../runtime.js");
|
|
5
|
+
const native = resolveNativeCommand("lint", process.argv.slice(2));
|
|
6
|
+
const result = await runPassthrough(native.executable, native.args);
|
|
7
|
+
process.exitCode = result.status;
|
|
8
|
+
} catch (error) {
|
|
9
|
+
console.error(`oxc-tsrx-lint: ${error instanceof Error ? error.message : String(error)}`);
|
|
10
|
+
process.exitCode = 2;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
//#region src/bin/oxc-tsrx-lsp.ts
|
|
3
|
+
try {
|
|
4
|
+
const { resolveNativeCommand, runPassthrough } = await import("../runtime.js");
|
|
5
|
+
const native = resolveNativeCommand("server", process.argv.slice(2));
|
|
6
|
+
const result = await runPassthrough(native.executable, native.args);
|
|
7
|
+
process.exitCode = result.status;
|
|
8
|
+
} catch (error) {
|
|
9
|
+
console.error(`oxc-tsrx-lsp: ${error instanceof Error ? error.message : String(error)}`);
|
|
10
|
+
process.exitCode = 2;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
//#region src/bin/oxc-tsrx.ts
|
|
3
|
+
function usage() {
|
|
4
|
+
return `oxc-tsrx
|
|
5
|
+
|
|
6
|
+
Usage:
|
|
7
|
+
oxc-tsrx providers [--project <directory>] [--json]
|
|
8
|
+
oxc-tsrx setup [--project <directory>] [--dry-run] [--write-tsconfig]
|
|
9
|
+
[--workspace-root <directory>] [--json]
|
|
10
|
+
oxc-tsrx status [--project <directory>] [--json]
|
|
11
|
+
oxc-tsrx remove [--project <directory>] [--dry-run] [--json]
|
|
12
|
+
|
|
13
|
+
providers reports the OXC language providers the project root's direct
|
|
14
|
+
dependencies declare through their static oxc.provider metadata. It reads
|
|
15
|
+
package manifests only: it writes nothing, mutates no node_modules directory,
|
|
16
|
+
and imports, requires, or spawns no dependency. It exits non-zero when a
|
|
17
|
+
provider claims a reserved extension or when two providers collide.
|
|
18
|
+
|
|
19
|
+
setup, status, and remove are the temporary compatibility bridge for consumers
|
|
20
|
+
whose resolver is not provider-aware yet. The bridge creates the exact
|
|
21
|
+
oxc-parser, oxlint, and oxfmt package-name facades those consumers need, and one
|
|
22
|
+
fourth slot for the editor. Transitive official packages in those exact slots are
|
|
23
|
+
preserved and restored; direct or unrecognized packages are never replaced.
|
|
24
|
+
|
|
25
|
+
The editor slot is the one thing setup writes outside node_modules. When
|
|
26
|
+
node_modules/.bin/oxlint belongs to another tool, the official OXC extension
|
|
27
|
+
finds that tool and serves no .tsrx diagnostics, so setup merges the single key
|
|
28
|
+
"oxc.path.oxlint" into your .vscode/settings.json. Everything else in that file
|
|
29
|
+
is preserved, an existing "oxc.path.oxlint" is reported rather than overwritten,
|
|
30
|
+
and remove takes back only that key. It never edits package.json, and it never
|
|
31
|
+
edits tsconfig.json unless you ask.
|
|
32
|
+
|
|
33
|
+
VS Code reads .vscode/settings.json only from the folder you open as the
|
|
34
|
+
workspace root, never from a subfolder of it, and setup writes at your project
|
|
35
|
+
root, meaning the nearest package.json. In a monorepo those are different
|
|
36
|
+
folders, so setup and status name every folder above your project root that
|
|
37
|
+
looks like a workspace root, and the file that made each one look like one,
|
|
38
|
+
rather than quietly writing a key nothing reads.
|
|
39
|
+
|
|
40
|
+
--workspace-root <directory> is the only way to write above your project root,
|
|
41
|
+
and it is never implied. The value is written relative to the folder you name.
|
|
42
|
+
Note that a multi-root window resolves a relative "oxc.path.oxlint" against its
|
|
43
|
+
first folder, not against the folder holding the settings file.
|
|
44
|
+
|
|
45
|
+
setup also reports the TSRX editor prerequisites it deliberately does not own:
|
|
46
|
+
@tsrx/typescript-plugin, a framework binding, the tsconfig.json plugins entry,
|
|
47
|
+
and a TypeScript version the plugin supports. It installs none of them.
|
|
48
|
+
|
|
49
|
+
--write-tsconfig is the one exception, and it is opt-in for that reason. It adds
|
|
50
|
+
"plugins": [{ "name": "@tsrx/typescript-plugin" }] under compilerOptions in the
|
|
51
|
+
tsconfig that owns your source, keeping every comment and every other byte in
|
|
52
|
+
the file. A solution-style root is skipped in favour of the referenced project
|
|
53
|
+
that includes your source, and an existing "plugins" list is reported rather
|
|
54
|
+
than appended to. Without the flag, setup only tells you the entry is missing.
|
|
55
|
+
`;
|
|
56
|
+
}
|
|
57
|
+
const HELP_FLAGS = /* @__PURE__ */ new Set(["--help", "-h"]);
|
|
58
|
+
const VERSION_FLAGS = /* @__PURE__ */ new Set(["--version", "-V"]);
|
|
59
|
+
function parseArguments(argv) {
|
|
60
|
+
const [first = "help", ...rest] = argv;
|
|
61
|
+
const options = {
|
|
62
|
+
command: HELP_FLAGS.has(first) ? "help" : VERSION_FLAGS.has(first) ? "version" : first,
|
|
63
|
+
projectRoot: void 0,
|
|
64
|
+
dryRun: false,
|
|
65
|
+
json: false
|
|
66
|
+
};
|
|
67
|
+
for (let index = 0; index < rest.length; index += 1) {
|
|
68
|
+
const argument = rest[index];
|
|
69
|
+
if (argument === "--project") {
|
|
70
|
+
options.projectRoot = rest[++index];
|
|
71
|
+
if (!options.projectRoot) throw new Error("--project requires a directory");
|
|
72
|
+
} else if (argument.startsWith("--project=")) options.projectRoot = argument.slice(10);
|
|
73
|
+
else if (argument === "--dry-run") options.dryRun = true;
|
|
74
|
+
else if (argument === "--write-tsconfig") options.writeTsconfig = true;
|
|
75
|
+
else if (argument === "--workspace-root") {
|
|
76
|
+
options.workspaceRoot = rest[++index];
|
|
77
|
+
if (!options.workspaceRoot) throw new Error("--workspace-root requires a directory");
|
|
78
|
+
} else if (argument.startsWith("--workspace-root=")) {
|
|
79
|
+
options.workspaceRoot = argument.slice(17);
|
|
80
|
+
if (!options.workspaceRoot) throw new Error("--workspace-root requires a directory");
|
|
81
|
+
} else if (argument === "--json") options.json = true;
|
|
82
|
+
else if (HELP_FLAGS.has(argument)) options.command = "help";
|
|
83
|
+
else if (VERSION_FLAGS.has(argument)) options.command = "version";
|
|
84
|
+
else throw new Error(`unknown option: ${argument}`);
|
|
85
|
+
}
|
|
86
|
+
return options;
|
|
87
|
+
}
|
|
88
|
+
function printResult(result, json, format) {
|
|
89
|
+
process.stdout.write(json ? `${JSON.stringify(result, null, 2)}\n` : format(result));
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const options = parseArguments(process.argv.slice(2));
|
|
93
|
+
if (options.command === "help") process.stdout.write(usage());
|
|
94
|
+
else if (options.command === "version") {
|
|
95
|
+
const { createRequire } = await import("node:module");
|
|
96
|
+
const manifest = createRequire(import.meta.url)("../../package.json");
|
|
97
|
+
process.stdout.write(`oxc-tsrx ${manifest.version}\n`);
|
|
98
|
+
} else if (options.command === "providers") {
|
|
99
|
+
const { collectProviderReport, formatProviderReport } = await import("../providers-report.js");
|
|
100
|
+
const report = await collectProviderReport(options);
|
|
101
|
+
process.stdout.write(options.json ? `${JSON.stringify(report, null, 2)}\n` : formatProviderReport(report));
|
|
102
|
+
if (!report.ok) process.exitCode = 1;
|
|
103
|
+
} else {
|
|
104
|
+
const { compatibilityStatus, formatCompatibilityReport, removeCompatibility, setupCompatibility } = await import("../compat.js");
|
|
105
|
+
if (options.command === "setup" || options.command === "activate") printResult(await setupCompatibility(options), options.json, formatCompatibilityReport);
|
|
106
|
+
else if (options.command === "status") printResult(await compatibilityStatus(options), options.json, formatCompatibilityReport);
|
|
107
|
+
else if (options.command === "remove" || options.command === "deactivate") printResult(await removeCompatibility(options), options.json, formatCompatibilityReport);
|
|
108
|
+
else throw new Error(`unknown command: ${options.command}\n\n${usage()}`);
|
|
109
|
+
}
|
|
110
|
+
} catch (error) {
|
|
111
|
+
console.error(`oxc-tsrx: ${error instanceof Error ? error.message : String(error)}`);
|
|
112
|
+
process.exitCode = 2;
|
|
113
|
+
}
|
|
114
|
+
//#endregion
|
|
115
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
//#region src/bin/oxfmt.ts
|
|
3
|
+
try {
|
|
4
|
+
const { decideCanonicalCommand, deferralNotice, runOfficialCommand } = await import("../canonical-command.js");
|
|
5
|
+
const args = process.argv.slice(2);
|
|
6
|
+
const decision = await decideCanonicalCommand("oxfmt");
|
|
7
|
+
if (decision.owner === "project") {
|
|
8
|
+
const notice = deferralNotice(decision, args);
|
|
9
|
+
if (notice !== null) console.error(notice);
|
|
10
|
+
await runOfficialCommand(decision);
|
|
11
|
+
} else {
|
|
12
|
+
const { canRunCanonicalOxfmt, importDeclaredPackageBinary } = await import("../format-invocation.js");
|
|
13
|
+
if (canRunCanonicalOxfmt(args)) await importDeclaredPackageBinary("oxfmt-current", "oxfmt", import.meta.url);
|
|
14
|
+
else {
|
|
15
|
+
const { runCli } = await import("../format-cli.js");
|
|
16
|
+
process.exitCode = await runCli(args);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error(`oxfmt (oxc-tsrx): ${error instanceof Error ? error.message : String(error)}`);
|
|
21
|
+
process.exitCode = 2;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
//#region src/bin/oxlint.ts
|
|
3
|
+
try {
|
|
4
|
+
const { enableCompileCache } = await import("node:module");
|
|
5
|
+
enableCompileCache?.();
|
|
6
|
+
} catch {}
|
|
7
|
+
try {
|
|
8
|
+
const { decideCanonicalCommand, deferralNotice, runOfficialCommand } = await import("../canonical-command.js");
|
|
9
|
+
const args = process.argv.slice(2);
|
|
10
|
+
const decision = await decideCanonicalCommand("oxlint");
|
|
11
|
+
if (decision.owner === "project") {
|
|
12
|
+
const notice = deferralNotice(decision, args);
|
|
13
|
+
if (notice !== null) console.error(notice);
|
|
14
|
+
await runOfficialCommand(decision);
|
|
15
|
+
} else if (args.some((argument) => argument.split("=", 1)[0] === "--lsp")) {
|
|
16
|
+
const { runOxlintLspMultiplexer } = await import("../oxlint-lsp-multiplexer.js");
|
|
17
|
+
process.exitCode = await runOxlintLspMultiplexer(args);
|
|
18
|
+
} else {
|
|
19
|
+
const { canRunCanonicalOxlint, importDeclaredPackageBinary, planCanonicalOxlintComposition } = await import("../lint-invocation.js");
|
|
20
|
+
if (canRunCanonicalOxlint(args)) await importDeclaredPackageBinary("oxlint-current", "oxlint", import.meta.url);
|
|
21
|
+
else {
|
|
22
|
+
const plan = Boolean(process.env.VP_VERSION || process.env.VP_COMMAND || process.env.NODE_PACKAGE_MANAGER === "vite-plus") ? null : planCanonicalOxlintComposition(args);
|
|
23
|
+
const prestart = plan === null ? Promise.resolve(null) : import("../lint-prestart.js").then(({ startCanonicalOxlint }) => startCanonicalOxlint(plan.args));
|
|
24
|
+
const [{ runCli }, prestartedUpstream] = await Promise.all([import("../lint-cli.js"), prestart]);
|
|
25
|
+
process.exitCode = await runCli(args, { prestartedUpstream });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error(`oxlint (oxc-tsrx): ${error instanceof Error ? error.message : String(error)}`);
|
|
30
|
+
process.exitCode = 2;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export type OxcTsrxCanonicalCommand = "oxlint" | "oxfmt";
|
|
2
|
+
|
|
3
|
+
export interface OxcTsrxCanonicalDecisionKept {
|
|
4
|
+
readonly command: OxcTsrxCanonicalCommand;
|
|
5
|
+
readonly owner: "@tsrx/oxc";
|
|
6
|
+
readonly reason: "no-project-manifest" | "not-directly-declared" | "compatibility-facade";
|
|
7
|
+
readonly projectRoot: string | null;
|
|
8
|
+
readonly officialRoot?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface OxcTsrxCanonicalDecisionDeferred {
|
|
12
|
+
readonly command: OxcTsrxCanonicalCommand;
|
|
13
|
+
readonly owner: "project";
|
|
14
|
+
readonly reason: string;
|
|
15
|
+
readonly projectRoot: string;
|
|
16
|
+
readonly officialRoot: string;
|
|
17
|
+
readonly officialVersion: string | null;
|
|
18
|
+
readonly binPath: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type OxcTsrxCanonicalDecision =
|
|
22
|
+
| OxcTsrxCanonicalDecisionKept
|
|
23
|
+
| OxcTsrxCanonicalDecisionDeferred;
|
|
24
|
+
|
|
25
|
+
export interface OxcTsrxCanonicalOptions {
|
|
26
|
+
readonly cwd?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export declare function decideCanonicalCommand(
|
|
30
|
+
command: OxcTsrxCanonicalCommand,
|
|
31
|
+
options?: OxcTsrxCanonicalOptions,
|
|
32
|
+
): Promise<OxcTsrxCanonicalDecision>;
|
|
33
|
+
|
|
34
|
+
export declare function providedArguments(args: readonly string[]): string[];
|
|
35
|
+
|
|
36
|
+
export declare function usesNodeInterpreter(path: string): Promise<boolean>;
|
|
37
|
+
|
|
38
|
+
export declare function deferralNotice(
|
|
39
|
+
decision: OxcTsrxCanonicalDecision,
|
|
40
|
+
args: readonly string[],
|
|
41
|
+
): string | null;
|
|
42
|
+
|
|
43
|
+
export interface OxcTsrxRunOfficialOptions {
|
|
44
|
+
readonly spawn?: typeof import("node:child_process").spawn;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export declare function runOfficialCommand(
|
|
48
|
+
decision: OxcTsrxCanonicalDecisionDeferred,
|
|
49
|
+
options?: OxcTsrxRunOfficialOptions,
|
|
50
|
+
): Promise<void>;
|