You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add editor SDK support for oxc (oxfmt & oxlint) (#7078)
## What's the problem this PR addresses?
Add editor SDK support for oxc. This should enable optional editor
integration with both oxfmt and oxlint.
## How did you fix it?
Added oxlint, oxfmt and oxlint-tsgolint as supported integration and
documented it.
Oxlint and oxlint-tsgolint addition is a bit hacky and I don't know
whether this is the right direction or not. Rationale can be read from
the comment there.
Loader option added to sdk setupEnv to prevent oxfmt tinypool from being
broken due to failing to resolve tinypool/dist/process.js.
I haven't tried this with vim yet since I don't use it so if anyone
would kindly help test whether this will work on vim or not, thanks!
### oxlint type-aware feature (tsgolint)
The biggest challenge here is the type-aware feature (tsgolint) support.
The rust side of oxlint spawn tsgolint a bit different from how the
oxlint itself is spawned:
https://github.com/oxc-project/oxc/blob/d3dcf5bc9718ebb4839be27062b5d82da2118e2e/crates/oxc_linter/src/tsgolint.rs#L265-L270
Instead of using js entrypoint, it directly spawn executable so the
wrapper approach is not directly applicable here. Luckily, there are
some strategies that the oxc_linter uses to resolve tsgolint:
- via PATH
- via node_modules search
- direct path via OXLINT_TSGOLINT_PATH (which is what oxc.path.tsgolint
does basically)
The only realistic strategy is to use PATH. For the sdks, it will
generate a windows executable shim (cmd) that will basically just spawn
tsgolint.js, else should fallback to tsgolint.
Be noted however that this will not fix fundamental issue with
typescript-go module resolution, which requires this to be merged first:
- microsoft/typescript-go#1966
This PR just enable the usage of tsgo regardless of whether it can
resolve with pnp or not in the type-checking.
### Reference
Coc config:
https://github.com/oxc-project/coc-oxc/blob/7a7f0d8f503d5cdb65da37232da6b865f159b42a/src/common.ts#L27-L36
Vscode oxc binary resolution reference:
https://github.com/oxc-project/oxc-vscode/blob/main/client/findBinary.ts
Oxlint-tsgolint executable resolution:
https://github.com/oxc-project/oxc/blob/d3dcf5bc9718ebb4839be27062b5d82da2118e2e/crates/oxc_linter/src/tsgolint.rs#L1164-L1225
## Checklist
- [x] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).
- [x] I have set the packages that need to be released for my changes to
be effective.
- [x] I will check that all automated PR checks pass before the PR gets
reviewed.
0 commit comments