Commit Graph

13 Commits

Author SHA1 Message Date
camc314 af0f2af93f chore(lint): enable ban-ts-comment rule and fix ts-ignore usages (#16799)
follow on from https://github.com/oxc-project/oxc/pull/16796
2025-12-13 16:19:48 +00:00
Boshen 523a30a016 style(all): apply oxfmt default options (#16091)
Embrace the defaults!

---------

Co-authored-by: Yuji Sugiura <y.sugiura.0316@gmail.com>
2025-11-25 15:56:24 +09:00
leaysgur a8e5181ab7 chore(infra): dogfooding oxfmt (#14979)
Fixes #14803

- Added `oxfmt` and `oxfmtrc.jsonc`
- Remove `dprint` plugin and useless ignore paths
- Apply `dprint` again
- Apply `oxfmt`
2025-10-28 01:16:46 +00:00
overlookmotel bb040bc2d5 refactor(parser, linter): replace .mjs files with .js (#14045)
Now that `apps/oxlint` and `napi/parser` are both ESM packages (#13723 and #14042), we can use `.js` file extensions for all ESM files, rather than the mix of `.js` and `.mjs` file we had previously.

It's less confusing having to remember what's `.js` and what's `.mjs`, and avoids ugly workarounds like #14038 (`.d.mts`??).
2025-09-23 14:47:40 +00:00
overlookmotel ac3e9e966a refactor(napi/parser): move JS code into src-js directory (#13899)
Pure refactor. Root of `napi/parser` was getting really crowded with tons of files, and I'm about to add a load more for the ESTree walker.

Move JS source files into a `src-js` directory, like in `apps/oxlint`, so that the root of the package is just config files and scripts.
2025-09-19 08:46:42 +00:00
Boshen 4577b71ec8 feat(napi/parser)!: change oxc-parser to ESM (#13432)
closes #13329
2025-09-08 10:53:05 +00:00
overlookmotel 5baa4f1467 refactor(napi/parser): fix lint errors (#13185)
Same as #13184.

#13173 enabled Oxlint for all the repo, but we currently skip `napi` directory.

Fix all errors that Oxlint flags in `napi/parser`.

We currently can't turn on Oxlint for the directory, because `oxlint-disable` comments don't work for type-aware rules, but we should be able to once that's fixed.
2025-08-18 22:14:15 +00:00
overlookmotel cf0e18ae6d fix(napi/parser): NodeArray allow setting large integer properties (#11883)
Integers `>= 4294967295` are treated as string properties, not numerical array indexes. Make `NodeArray` behave the same as `Array` for such properties, and allow user to set them.
2025-06-24 15:35:07 +00:00
overlookmotel fb02e6c9d0 perf(napi/parser): lazy deser: speed up creating NodeArrays (#11869)
`NodeArray` store length as an internal property, rather then creating an underlying `Array` with that length. This is much faster when the array is large.

Produces an 18x speed-up in getting `program.body` for `cal.com.tsx` benchmark fixture, because it has 3942 statements.
2025-06-23 17:21:22 +00:00
overlookmotel 6848b242f3 test(napi/parser): lazy deser: tests for introspection of NodeArrays (#11702)
Add tests for results of `Object.keys`, `Object.getOwnPropertyDescriptors`, and other introspection methods on `NodeArray`s.
2025-06-14 12:16:24 +00:00
overlookmotel dfdebc27e3 feat(napi/parser): lazy deserializer NodeArray slice method (#11680)
Implement an optimized `slice` method for `NodeArray` in lazy-deserialized AST. It returns a another `NodeArray`, instead of a plain `Array`, and doesn't deserialize any of the contents.
2025-06-13 18:31:18 +00:00
overlookmotel 60f754e37c perf(napi/parser): lazily deserialize Vecs (#11678)
Lazy deserialization return `NodeArray`s which deserialize their contents lazily, instead of plain JS arrays.

`program.body.find(stmt => stmt.type === 'ImportDeclaration')` now only deserializes the nodes up until first `ImportDeclaration`, rather than deserializing every statement in the program into an array, and then searching it. Similarly getting `program.body.length` does not deserialize any nodes, and all other array methods are similarly optimized.

Also provide an optimized iterator for the common case of:

```js
for (const stmt of program.body) {
  doStuff(stmt);
}
```
2025-06-13 16:45:15 +00:00
overlookmotel 931fc739c3 fix(napi/parser): cache nodes in lazy deserialization (#11637)
In lazy-deserialized AST, cache node objects, so accessing the same field twice returns the same object. Previously `assert(binaryExpression.left == binaryExpression.left)` would fail, as each access returned a new object.

`pos` (i.e. memory address) is used as the cache key, with 2 exceptions: `RegExp` and `Program`.

`RegExp` doesn't have a `span: Span` field, so its first field `RegExpPattern` has the same memory address as the `RegExp`. So `pos` would not be a unique key.

```rs
pub struct RegExp<'a> {
    pub pattern: RegExpPattern<'a>,
    pub flags: RegExpFlags,
}

pub struct RegExpPattern<'a> {
    pub text: Atom<'a>,
    pub pattern: Option<Box<'a, Pattern<'a>>>,
}
```

The codegen identifies these cases, and applies a workaround - `pos + 1` is used as the cache key instead of `pos`, so the parent and child have different cache keys.
2025-06-12 14:26:06 +00:00