Commit Graph

9 Commits

Author SHA1 Message Date
overlookmotel 09a4057f14 refactor(linter/plugins, napi/parser): remove pattern of destructuring globals at top level (#18455)
Pure refactor.

Remove a few remaining instances of the pattern where we destructure global objects at top level e.g. `const { isArray } = Array;`.

In Oxlint, TSDown plugin already performs this optimization. In `napi/parser`, we intend to build the package with TSDown, and we'll apply the same optimization in build process then too.
2026-01-23 14:28:18 +00:00
camc314 5d211a8c69 refactor(napi/parser): move generated JS into src-js (#16957)
moves the generated code into src-js to keep the same pattern as oxlint
2025-12-17 11:43:42 +00:00
camc314 2acd66ed42 style(all): enable eslint/curly lint rule (#16753)
built on https://github.com/oxc-project/oxc/pull/16749, we can use the linter to be consistent here
2025-12-11 14:49: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
camc314 1cc7ee92b0 chore(parser): enable oxlint (#14571) 2025-10-14 13:25:29 +00:00
overlookmotel 52f35c6dcd refactor(napi/parser, linter/plugins): rename types.js to type_ids.js (#14384)
Pure refactor. Just rename generated `types.js` files to `type_ids.js`. This name better describes what the files contain, and it avoids naming clash with `types.d.ts` in `apps/oxlint/src-js/generated`.
2025-10-06 18:55:15 +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 56a385fe94 feat(napi/parser): add AST walker (#13930)
Add an AST visitor to `oxc-parser`.

```js
import { parseSync, Visitor } from 'oxc-parser';

const { program } = parseSync('test.js', 'let x = { y: z };');

const idents = [];
const visitor = new Visitor({
  Identifier(node) {
    idents.push(node.name);
  }
});

visitor.visit(program);

// Logs [ 'x', 'y', 'z' ]
console.log(idents);
```

Primarily we need a visitor for Oxlint plugins, but it's easier to develop and test in `oxc-parser`, so I thought I'd add it there first. Oxlint build process will copy the generated files for tree-walking from `napi/parser` dir, as it does with other files.

Notes:

* The `walk.mjs` file is large, so it's lazy-loaded only when user first constructs a `Visitor`. Adding `Visitor` to the package will not affect start-up time where user only uses `parseSync` etc.
* TS type definition for `Visitor` and the visitor object it takes are provided.
* Visitor supports enter and exit visitors e.g. `Program` and `Program:exit`.
* `src-js/visit/visitor.mjs` is copied from `apps/oxlint` with only minor modifications, and conversion from TS to JS. It'd be better if we only had this impl in one place, but that would require converting `oxc-parser` to TS and building with TSDown, like `oxlint` is. Leaving that for later - #13935.
2025-09-22 11:08:46 +00:00