Commit Graph
21141 Commits
Author SHA1 Message Date
leaysgur 814eaeb2c6 fix(formatter_toml): bump oxc-toml to keep commented inline table (#27782)
https://github.com/oxc-project/oxc-toml/releases/tag/v0.15.1
2026-10-16 04:21:11 +00:00
leaysgur 6fe4c1b911 fix(formatter): treat lone CR in JSX text and argument blank lines (#27780)
Also disables BOM and shebang variants.
2026-10-16 04:04:07 +00:00
leaysgur 78b6f0260c test(formatter_tests): run conformance with CRLF/CR/BOM variants (#27779)
Fixes will land in later PR.
2026-10-16 04:04:07 +00:00
leaysgur 5605362017 fix(oxfmt): validate editorconfig as like oxfmtrc (#27778)
Fixes various bugs.
2026-10-16 04:04:06 +00:00
leaysgur 5b2acb0427 fix(formatter_core): report error position releative to CRLF source (#27777)
e.g. CSS, YAML formatter replace CRLF beforehand, so when reports error, need to restore positon.
2026-10-16 04:04:06 +00:00
leaysgur c78e80edc5 fix(formatter_core): report parse error positions relative to the BOM-headed source (#27776)
We need to shift 3 bytes for BOM to display correct error span.
2026-10-16 04:04:05 +00:00
leaysgur 3a980c922b fix(formatter_toml): handle BOM like other languages (#27775)
Use `split_bom` and restore as like other formatters.
2026-10-16 04:04:05 +00:00
leaysgur 97c9fc4f5e fix(oxfmt): handle BOM in config JSON (#27774)
Fixed config load error when config has BOM.
2026-10-16 04:04:04 +00:00
leaysgur 28eb4a752b fix(oxfmt): print trailing newline for --list-different (#27773)
Fixed that last entry does not have newline, which fails pipe operation.
2026-10-16 04:04:04 +00:00
Yuji Sugiura fddf422904 fix(deps): update rustls to 0.23.46 (#27810)
- Update the locked `rustls` version from 0.23.45 to 0.23.46.
- Address RUSTSEC-2026-0346, RUSTSEC-2026-0347, RUSTSEC-2026-0348, and
RUSTSEC-2026-0349 reported by Security Analysis CI.
-
https://github.com/oxc-project/oxc/actions/runs/38845387708/job/116794625241
2026-10-16 13:01:26 +09:00
Cam McHenry 770ada4baa feat(linter): mark vue 3 rules as recommended (#27717)
<sub>Stack created with <a
href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a
href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
2026-10-15 23:35:40 -04:00
Cam McHenry ba38c1de7b feat(linter): mark react/react-hooks rules as recommended (#27701)
<sub>Stack created with <a
href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a
href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
2026-10-15 23:35:40 -04:00
Cam McHenry d85a3bab3e feat(linter): mark promise rules as recommended (#27693)
Copying recommended state from upstream.

---

<sub>Stack created with <a
href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a
href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
2026-10-15 23:35:40 -04:00
Boshen 566b11b2db docs(security): inherit organization security policy (#27781)
Use the shared organization security policy and GitHub private
vulnerability reporting, replacing the repository-specific policy.

AI-assisted.
2026-10-16 11:09:05 +08:00
leaysgur d2bea21099 fix(formatter): glue comments to an opener in empty for-head slots and array holes (#27737)
Follow up on #27730,
Use the same utils with `for (/*c*/;;)` case.

Also fixed some weird comment printing.
2026-10-16 00:58:42 +00:00
leaysgur 6a95ec188b fix(formatter): keep comment position on holey array (#27730)
Fixes #22799, closes #26376

Fundamentally, the pattern AST side needs to be fixed (https://github.com/oxc-project/backlog/issues/244), but I'll do it while working on another task.
2026-10-16 00:48:56 +00:00
leaysgur 54769daf58 fix(formatter): break after dangling line comment in holey array (#27729)
```js
[
, ,// c
]
```

should be

```js
[
  ,
  ,// c
];
```

Not
```js
[, ,// c]
```
2026-10-16 00:36:35 +00:00
leaysgur 99077ef835 fix(formatter_json): reject unary expressions other than signed numbers (#27728)
Should reject invalid JSON like `{ "foo": -true }`.
2026-10-16 00:36:34 +00:00
leaysgur 22cd4cdaee fix(formatter_json): handle holey array and comments (#27727)
- Prevent panic on `[, /* holey only array with comment */ ]`
- Keep comment position as-is
2026-10-16 00:30:34 +00:00
camc314 2c671979b5 fix(linter/eslint/no-unused-vars): count conditional calls in sequences as uses (#27755)
Calls such as `(x ? a(y) : 0, y)` and `(x && a(y), y)` consume `a` even though their results are discarded. Track that consumption through surrounding expressions, resetting at function boundaries so discarded self-referencing closures remain unused, matching ESLint.

Addresses report 1 (`eslint/no-unused-vars`) in #27746.
2026-10-15 21:07:17 +00:00
camc314 7f22fa0d8c fix(linter/unicorn/prefer-regexp-test): check logical operands in boolean contexts (#27761)
Calls such as `if (a && s.match(/x/))` and `if (s.match(/x/) || a)` were skipped even though their results are only tested for truthiness. Follow `&&`/`||` operands to the enclosing boolean context, matching Unicorn, while preserving value-producing uses and nullish expressions. Add diagnostic and autofix regressions for `.match()` and `.exec()`.

Addresses report 9 (`unicorn/prefer-regexp-test`) in #27746.
2026-10-15 21:01:05 +00:00
camc314 3c44398772 fix(linter/eslint/class-methods-use-this): count this in parameter defaults (#27756)
Methods such as `t(errors = this.errors) { return errors; }` and fields such as `f = (x = this.y) => x` were reported despite using `this` in their defaults. Visit parameters with the existing `ThisFinder` to match ESLint while preserving nested function boundaries.

Addresses report 2 (`eslint/class-methods-use-this`) in #27746.
2026-10-15 20:27:29 +00:00
camc314 d85923f968 fix(linter/eslint/no-param-reassign): report rest parameter writes (#27765)
Report assignments such as `function f(...args) { args = []; }`, matching ESLint. Rest parameters now use the same reference and property checks as regular parameters, with regression coverage for destructuring, nested scopes, and property-ignore options.

Addresses #27746, report 11 (`eslint/no-param-reassign`).
2026-10-15 20:20:18 +00:00
camc314 8ea47bbdb5 fix(linter/unicorn/prefer-type-error): handle parenthesized type checks (#27766)
Unwrap parentheses when identifying type checks so `!(x instanceof Y)` and `!(typeof x === "string")` report `throw new Error(...)` and fix it to `TypeError`, matching Unicorn. Includes regressions for nested conditions and both autofixes.

Addresses report 16 (`unicorn/prefer-type-error`) in #27746.
2026-10-15 20:13:01 +00:00
camc314 e96856cf45 fix(linter/unicorn/catch-error-name): check unused underscore-prefixed names (#27751)
Match Unicorn by exempting only the exact unused name `_`. Unused `_err` and `__` are now reported and renamed in catch clauses and promise rejection handlers. Regression tests preserve the `_` exemption and configured names/ignore patterns.

Addresses report 15 (`unicorn/catch-error-name`) in #27746.
2026-10-15 20:06:05 +00:00
camc314 d8ca3998a7 fix(linter/unicorn/no-array-callback-reference): ignore callback factory calls (#27763)
Match Unicorn by ignoring call expressions passed as callbacks, including `arr.forEach(make(x))` and `arr.map(make(x))`. Suggesting an arrow wrapper would run the factory once per element instead of once per array method call.

Addresses report 4 (`unicorn/no-array-callback-reference`) in #27746.
2026-10-15 19:58:18 +00:00
camc314 1267ab8f6e fix(linter/eslint/max-params): count rest parameters (#27757)
Count rest parameters toward the limit for functions, arrows, and TypeScript function types, matching ESLint. For example, `function f(a, b, c, ...rest) {}` now reports four parameters with the default maximum of three.

Addresses report 12 (`eslint/max-params`) in #27746.
2026-10-15 19:50:50 +00:00
camc314 8f252a2b57 refactor(linter): move inline AST paths into imports (#27738)
Move inline `oxc_ast::…` references into module-level imports throughout `oxc_linter`, reusing existing imports where available. This replaces 133 qualified paths across 56 files without changing lint behavior.

Validated after rebasing with crate-wide tests (1,289 passed), Clippy, and formatting. Three parallel reviewers found no issues in the import refactor.

AI assistance: implemented and reviewed with Codex.
2026-10-15 14:58:58 +00:00
camc314 9ff25c3a14 fix(linter/eslint/no-useless-assignment): report dead stores to function parameters (#27735)
Track function parameter bindings so `function f(p) { p = 5; p = 6; return p; }` reports `p = 5`, matching ESLint. This also covers defaulted, destructured, and rest parameters.

Keep writes during parameter initialization excluded: the CFG does not model skipped defaults or their destructuring evaluation order reliably. Reads in defaults still count as uses.

Fixes #27720
2026-10-15 13:33:08 +00:00
camc314 ee5e730ca9 fix(linter/eslint/no-setter-return): check setters in property descriptors (#27731)
Oxlint currently allows descriptor setters such as `Object.defineProperty(o, "x", { set: value => value })`, while ESLint reports the returned value.

Recognize setters passed to `Object.defineProperty`, `Reflect.defineProperty`, `Object.defineProperties`, and `Object.create`, including concise arrows. Check argument positions and global bindings, preserve nested-function boundaries, and enable the upstream descriptor tests with additional regression coverage.

Addresses report 1 (`eslint/no-setter-return`) in #27710.
2026-10-15 13:11:33 +00:00
Yunus OzenandCameron Clark edbb5eddff fix(linter/eslint/id-length): check destructuring assignment targets (#27724)
`id-length` missed identifiers used as destructuring assignment targets,
including `[q] = values` and `for ([ix, s] of values) {}`. Check array
and object targets, defaults, and rest elements, matching ESLint
10.12.0.

Preserve `properties: "never"` exemptions and report the key when an
explicit object property's key and target share a name, including
parenthesized computed keys. Regression tests cover assignment targets,
exempt reads, and diagnostic locations.

Part of #27710 (report 3).

---------

Co-authored-by: Cameron Clark <cameron.clark@hey.com>
2026-10-15 16:11:21 +03:00
Yunus Ozen 0e40acb4a5 fix(linter/eslint/no-magic-numbers): restrict unary exemptions to numeric signs (#27723) 2026-10-15 13:06:05 +00:00
Yunus Ozen ae7e44be49 fix(linter/eslint/no-div-regex): report quantified leading equals (#27722) 2026-10-15 13:03:26 +00:00
camc314 eb461f8344 fix(linter/unicorn/consistent-function-scoping): count self-referencing variables as captures (#27726)
Treat a function's reference to its own variable binding as a parent-scope capture, matching eslint-plugin-unicorn. For example, a nested `const builder = (...args) => builder.apply(null, args)` was incorrectly reported as movable even though it captures `builder` from the enclosing scope.

Limit the recursion exemption to function-name symbols. Add regression cases for arrow functions, anonymous and named function expressions, parameter defaults, and `var` bindings, while retaining warnings for internal function-name recursion and shadowed parameters.

Addresses report 5 (`unicorn/consistent-function-scoping`) in #27710.
2026-10-15 12:53:36 +00:00
leaysgur 033faa933e refactor(formatter_core): remove Buffer trait (#27716)
Follow up on #27559.

Now `Buffer` trait is not needed, just inline them in `Formatter`.
2026-10-15 05:02:32 +00:00
leaysgur e5fdc9c88e perf(formatter_core): write into one element stack through a concrete Formatter (#27559)
Makes the `Formatter` a concrete type that writes into one element stack, instead of writing through `&mut dyn Buffer` into separate buffers.

### Before

- `Formatter` held a `&mut dyn Buffer`, so every element write was a virtual call.
- There were 4 `Buffer` implementations, one per use:
  - `VecBuffer`: the root document, written directly into the arena.
  - `HeapVecBuffer`: nested staging (`intern`, best fitting variants), a watermarked view of a shared heap vector, copied into the arena one element at a time (`from_iter_in`).
  - `AccumulatorBuffer`: writes into a `ScratchBuffer`'s heap vector (JSX children, assignment left-hand sides).
  - `RemoveSoftLinesBuffer`: a wrapper buffer for `remove_soft_lines`.

### After

- `Formatter { state, start, soft_lines }` is concrete.
  - A write is a `push_fast` that inlines into the builders.
- `FormatState` owns one element stack in the arena:
  - The root formatter writes at the bottom.
  - `into_vec` returns the vector as is, so the document needs no copy (same as `VecBuffer`).
  - Nested formatters write past their parent's elements. They are taken off as one
exactly-sized bulk copy.
- `ScratchBuffer::write(f, |f| ..)` writes past the stack, then moves the elements into its heap vector.
- `remove_soft_lines` is a mode of `Formatter`, kept off the hot path (`#[cold]`).
- Removed: `VecBuffer`, `HeapVecr`, `RemoveSoftLinesBuffer`.
- Entry points change from `VecBuffer::new` / `with_capacity` to `Formatter::new` / `with_capacity` + `into_vec`.
2026-10-15 05:02:32 +00:00
Cam McHenry e71c88ae65 feat(linter): mark node rule as recommended (#27692)
Copying recommended rule state from upstream.

---

<sub>Stack created with <a
href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a
href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
2026-10-15 01:02:15 -04:00
Cam McHenry 7213f61e89 feat(linter): mark nextjs rules as recommended (#27691)
Copying recommended rules from upstream.

---

<sub>Stack created with <a
href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a
href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
2026-10-15 01:02:15 -04:00
Cam McHenry d7c6b26a90 feat(linter): mark jsx-a11y rules as recommended (#27690)
Upstreaming recommended state from the upstream plugin.

---

<sub>Stack created with <a
href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a
href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
2026-10-15 00:45:20 -04:00
Cam McHenry 199dfdc4dd feat(linter): mark jsdoc rules as recommended (#27689)
Marking upstream recommended rules as recommended here.

---

<sub>Stack created with <a
href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a
href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
2026-10-15 00:45:20 -04:00
Cam McHenry 780bff398e feat(linter): mark jest/vitest rules as recommended (#27672)
Copying recommended state from upstream Jest/Vitest plugin.
2026-10-15 00:45:20 -04:00
Cam McHenry 6ae6859ecd feat(linter): mark import rules as recommended (#27671)
Copying recommended state from the upstream plugin.
2026-10-15 00:45:19 -04:00
Armano c5a66191a6 refactor(minifier): move import/export minification to standalone file (#27655)
move import/export merging to standalone file

`minimize_statements` is intended to process nodes that are part of
block like stmts

follow up on:
https://github.com/oxc-project/oxc/pull/25534#discussion_r4145236287
2026-10-15 10:04:27 +08:00
Dunqing b60f8a7c14 fix(coverage): pin the V8 test262 status list to Node's V8 version (#27674)
monitor-oxc's Test262 job fails on every run because `cargo coverage
runtime` no longer matches `runtime.snap`. The runtime suite skips the
cases V8's `test262.status` lists as failing, and it fetches that file
from V8's `main` branch at run time. On 2026-10-09 V8 landed
`03af3c3548` ("[scopes] Reject var arguments in parameter eval") and
removed the 88 `language/eval-code/direct/*declare-arguments*` entries.
Node 26.5 bundles V8 14.6.202, which predates that fix, so those 88
cases now run and fail with `Expected a SyntaxError to be thrown`.

The skip list exists to hide bugs of the engine that executes the cases,
and that engine is Node's V8, not V8 `main`. `main` is wrong in both
directions: it un-skips cases V8 fixed after Node's branch cut, and it
skips 236 entries for test262 files newer than the pinned checkout.

The list is now fetched at the V8 version reported by `node -p
process.versions.v8` (`14.6.202.34`, which V8 tags on GitHub), falling
back to `main` only when that tag does not exist. The gitignored cache
file carries the version in its name so a Node bump cannot serve a stale
list.

With the pinned list the snapshot only changes when the test262 pin or
`.node-version` moves. Regenerated against Node 26.5.0 it adds nothing
and drops: four `delete/super-property-uninitialized-this` cases that V8
fixed upstream after 14.6, the `typeof/symbol.js` timeout, and the two
`bigint-and-number-extremes` minify cases that #27656 fixed (the regular
CI does not run the runtime suite, so that PR could not update the
snapshot):

| skip list | cases | passed | new failures |
| --- | --- | --- | --- |
| V8 `main` today | 18369 | 17307 | 88 |
| V8 `14.6.202.34` | 18277 | 17306 | 0 |

Written with Claude Code; reviewed and tested by me.
2026-10-15 09:43:24 +08:00
Armano 6b5057bb1d feat(minifier): add de morgan optimization for void expressions (#27375)
add missing de morgan law optimizations in context of void expression

`(!a || b === c) && b()` -> `a && b !== c || b()`

limitations: due to how nodes are processed, currently simple rewrites
like `!a || b()` are not rewritten to `a && b()` and follow same
limitations as optimizations of `not unary expression`
2026-10-15 09:38:26 +08:00
overlookmotel db9f3d69f8 ci(lexer): test and lint ARM Neon implementation in CI (#27706)
#27642 added an aarch64 Neon implementation of `classify`. So now we have 3 implementations.

Add a CI job to test and lint the Neon implementation on a Linux aarch64 runner on PRs which touch `oxc_lexer` crate.
2026-10-14 21:59:02 +00:00
overlookmotel a76e5fd80d test(lexer): update just recipes to cover Neon implementation (#27705)
#27642 added an aarch64 Neon implementation of `classify`. So now we have 3 implementations.

Update `just ready-lexer` recipe to test and lint all 3.
2026-10-14 21:59:01 +00:00
overlookmotel 6a9a8f5e15 ci(lexer): report which SIMD/generic implementation used in conformance & benchmarks (#27703)
#27642 added an aarch64 Neon implementation of `classify`. So now we have 2 SIMD implementations. This makes the previous output "Lexer implementation: SIMD" / "Lexer implementation: scalar" ambiguous - which SIMD?

Fix that, and also update some comments to match.
2026-10-14 21:59:01 +00:00
camc314 5c8e731c64 fix(linter/unicorn/catch-error-name): avoid fix symbol name collisions (#27702)
`unicorn/catch-error-name` could rename a parameter to an existing binding, producing invalid syntax or capturing another variable. The fixer now appends underscores until the configured name is available in the parameter's scope and every scope where it is referenced, and avoids capturing unresolved references in its body. Diagnostics show the selected name.

Adds regressions for both reported examples, unused catch parameters, nested references, globals, promise callbacks, configured names, and repeated suffix collisions. Generated names are also accepted when the configured name already ends in an underscore.

Fixes #27700.
2026-10-14 20:44:23 +00:00
camc314 9a424c209e fix(oxlint,oxfmt): correct Node.js TypeScript support range (#27699)
TypeScript config load errors currently advertise `^20.19.0 || >=22.18.0`, even though Node 20 cannot load TypeScript files natively. Remove the Node 20 range from the shared Oxlint/Oxfmt diagnostic and the matching TypeScript plugin documentation, including generated schema, declarations, and website snapshot. Package engine requirements stay the same.

Fixes #27678
2026-10-14 19:45:27 +00:00