Commit graph

3087 commits

Author SHA1 Message Date
underfin
b199cb89a2
feat: add oxc sourcemap crate (#2825)
The sourcemap implement port from
[rust-sourcemap](https://github.com/getsentry/rust-sourcemap), but has
some different with it.

- Encode sourcemap at parallel, including quote `sourceContent` and
encode token to `vlq` mappings.
- Avoid `Sourcemap` some methods overhead, like `SourceMap::tokens()`
caused extra overhead at common cases. Here using `SourceViewToken` to
instead of it.
2024-03-28 19:36:38 +08:00
Dunqing
2c6bfa3dde
feat(linter/import) check type import in no_duplicates (#2777)
Grouping unmergeable imports to determine if they are duplicates
2024-03-28 17:13:25 +08:00
Dunqing
920d1be286
feat(linter/import) check module import in no_duplicates (#2771)
We should use `requested_modules` instead of `loaded_modules` because
`loaded_modules` only contains successfully resolved modules.
2024-03-28 15:25:10 +08:00
Dunqing
d63807e703
feat(linter): fallback to the default tsconfig path (#2842)
Users usually do not need to manually set the tsconfig path, as it is
usually located in cwd/tsconfig.json.
2024-03-28 15:23:12 +08:00
Dunqing
ab7d7dcbe8
feat(linter/import) support allow_computed option in namespace (#2840) 2024-03-28 14:49:39 +08:00
Dunqing
40f4c1fafd
feat(linter/import) check deep namespace in namespace rule (#2805) 2024-03-28 14:47:36 +08:00
Wang Wenzhe
0cae373672
feat(linter/tree-shaking): pass CallExpression cases (#2839) 2024-03-28 09:48:41 +08:00
Dunqing
ec05a41525
chore: update transformer snapshots (#2838) 2024-03-27 15:02:09 +08:00
Dunqing
d67100730b
feat(tasks/transforme_conformance): support for testing oxc's test cases (#2835)
Related to:
https://github.com/oxc-project/oxc/pull/2822#issuecomment-2021802212

Although `babel` has a lot of test cases, we still need to add edge
cases that `babel` doesn't have.

This PR will allow us to add out test cases to
`/root/oxc/tasks/transform_conformance/tests`. The directory structure
is consistent with `babel`

For example
```shell
# cd /root/oxc/tasks/transform_conformance/tests
- babel-transform-plugin–optional-catch-binding
   - test
       - fixtures
           - your tests # add test cases here
```
2024-03-27 14:14:15 +08:00
Dunqing
947a9f05e8
fix(semantic): missing SymbolFlags::Export when identifier used in ExportDefaultDeclaration (#2837) 2024-03-27 14:13:25 +08:00
Ali Rezvani
528744ca0a
fix(transformer): optional-catch-binding unused variable side effect (#2822)
Before this PR for this given case:

```javascript
const _unused = "It's a lie, They gonna use me:(";
try {
    throw 0;
} catch {
  console.log(_unused);
}
```

We would've generated this:

```javascript
const _unused = "It's a lie, They gonna use me:(";
try {
    throw 0;
} catch (_unused) {
  console.log(_unused);
}
```

This is incorrect, This PR aims to use the `CreateVars` trait in order
to ensure the variable uniqueness.

Now it would output this:

```javascript
const _unused = "It's a lie, They gonna use me:(";
try {
    throw 0;
} catch (_unused2) {
  console.log(_unused);
}
```
2024-03-27 13:53:02 +08:00
Ali Rezvani
b76b02d019
fix(parser): add support for empty module declaration (#2834)
Should be merged after #2829, Tried a few times to get it done with
graphite stacking but found no success. I guess it either doesn't work
with forks or It is just a skill issue since I'm not familiar with it.

closes: #2829
closes: #2830

---------

Co-authored-by: Dmytro Maretskyi <maretskii@gmail.com>
2024-03-27 13:48:03 +08:00
cinchen
f6391f9b43
feat(linter): eslint-plugin-jest/prefer-comparison-matcher (#2806)
Rule Detail:
[link](https://github.com/jest-community/eslint-plugin-jest/blob/main/src/rules/prefer-comparison-matcher.ts)

---------

Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-03-27 12:17:36 +08:00
renovate[bot]
8c6936ab74
chore(deps): lock file maintenance rust crates (#2827) 2024-03-26 16:04:53 +00:00
Boshen
95fc28168c
chore: apply cargo autoinherit (#2826)
See https://github.com/mainmatter/cargo-autoinherit
2024-03-26 23:57:50 +08:00
overlookmotel
881329dc1a
chore: remove cargo-machete package metadata (#2824)
`cargo-machete` has been replaced with `cargo-shear`, so the package
metadata for `cargo-machete` is no longer required.
2024-03-26 22:40:49 +08:00
Wang Wenzhe
3897cf4118
chore(eslint/tree-shaking): add NoEffect explicitly (#2823) 2024-03-26 21:32:29 +08:00
Wang Wenzhe
fa39fa87b3
feat(linter/tree-shaking): check CallExpression when called (#2809) 2024-03-26 21:24:04 +08:00
Ali Rezvani
fe12617315
refactor(transformer): pass options via context. (#2794)
With this PR all transformers would get their `AstBuilder` and options
via `TransformerCtx`.
2024-03-26 21:21:31 +08:00
Boshen
75edb49c43
chore: add CHANGELOG.md 2024-03-26 21:03:22 +08:00
cinchen
f131442bbf
feat(linter): eslint-plugin-jest/no-untyped-mock-factory (#2807)
Rule Detail:
[link](https://github.com/jest-community/eslint-plugin-jest/blob/main/src/rules/no-untyped-mock-factory.ts)

---------

Co-authored-by: wenzhe <mysteryven@gmail.com>
Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-03-26 20:05:36 +08:00
Yuji Sugiura
df744b205a
feat(semantic/jsdoc): Add Span for JSDoc, JSDocTag (#2815) 2024-03-26 18:40:31 +08:00
Boshen
c5ccd5e7a1
ci: add release-plz 2024-03-26 18:18:16 +08:00
Ali Rezvani
243131d7a4
feat(transformer): numeric separator plugin. (#2795)
[es2021 numeric
separator](https://babeljs.io/docs/babel-plugin-transform-numeric-separator)
2024-03-26 18:15:12 +08:00
Ali Rezvani
56493bd02b
feat(transformer): add transform literal for numeric literals. (#2797)
[es2015 transform
literals](https://babeljs.io/docs/babel-plugin-transform-literals)

---------

Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-03-26 16:27:32 +08:00
Ali Rezvani
3d0ea545ca
chore: using numeric value for profile.dev.debug. (#2820)
Change the `profile.dev.debug` value from `limited` to `1` which is the
same thing according to
[this](https://doc.rust-lang.org/cargo/reference/profiles.html#debug).

For some reason, the numeric value was failing when running the codspeed
benchmark.

------

#### Edit:

it was resulting in the following error:

```
   failed to parse manifest at `/home/runner/work/oxc/oxc/Cargo.toml`
```

Related to #2812
2024-03-26 16:15:34 +08:00
Dunqing
224299fe5c
ci: ci should run when clone-submodules/action.yml changes (#2816)
When we change `clone-submodules/action.yml`, the snapshot will probably be updated as well, so I'd run ci to make sure the snapshot is correct.
2024-03-26 11:58:55 +08:00
Dunqing
220f722f19
chore: update snapshots (#2817)
Babel repo is updated in #2813 and #2814
2024-03-26 11:53:26 +08:00
Ali Rezvani
dcbbda3b2d
ci: update babel version (#2814)
In my privius PR I changed this version in justfile It seems like the
version used in CI is different from justfile.
2024-03-26 10:13:34 +08:00
Ali Rezvani
f9d6f33a80
ci(coverage): update babel version. (#2813)
This PR updates the babel submodule in the justfile to take advantage of
[this PR](https://github.com/babel/babel/pull/16381). Related to #2795
and #2797.
2024-03-26 09:42:19 +08:00
Boshen
66117b10aa
ci: cargo doc --no-deps 2024-03-26 01:56:16 +08:00
Boshen
33eca79440
chore: try speeding up compilation by setting debug = "limited" for [profile.dev] (#2812) 2024-03-26 01:55:46 +08:00
Boshen
c92e0ff892
ci: force install Rust minimal profile 2024-03-26 01:38:15 +08:00
Boshen
06a81409f1
ci: actions/checkout@v4 -> taiki-e/checkout-action@v1 (#2811)
This does not depend on node.js, and sets persist-credentials to false
2024-03-26 01:24:51 +08:00
Ali Rezvani
fc3878350f
refactor(ast): add walk_mut functions (#2776)
* move `visit` and `visit_mut` modules to a super module called `visit`
* add `walk_mut` module containing walk functions
* update `enter_node` and `leave_node` events to not pass a reference in the `VisitMut` trait
* add `AstType`, a non-referencing version of `AstKind` to use with `VisitMut` trait
* update the `VisitMut` trait's usages.
2024-03-25 20:40:13 +03:30
Boshen
e32a3b3783
ci: use cargo-shear (#2810) 2024-03-26 00:43:10 +08:00
Dunqing
68e011c479
fix(tasks/transform-conformance) when the output file does not exist, the output content should be empty (#2808)
https://github.com/oxc-project/oxc/pull/2795#issuecomment-2018018675
2024-03-25 23:28:00 +08:00
renovate[bot]
3d761f17c2
chore(deps): lock file maintenance rust crates (#2804) 2024-03-25 17:24:30 +08:00
Boshen
9057ebea95
chore: enable renovate "lockFileMaintenance" 2024-03-25 11:00:28 +08:00
Ali Rezvani
198eea0bce
refactor(ast): add walk functions to Visit trait. (#2791)
closes #2442
2024-03-25 10:44:29 +08:00
Dunqing
b28b61774b
fix(semantic): incorrect ExportEntry span for ExportAllDeclaration in ModuleRecord (#2793)
Now the span is ExportAllDeclaration's span
2024-03-25 10:32:02 +08:00
renovate[bot]
525031b7a2
chore(deps): update rust crates (#2802) 2024-03-25 09:47:26 +08:00
renovate[bot]
2500947114
chore(deps): update dependency vite to v5.2.6 (#2801) 2024-03-25 04:52:45 +08:00
renovate[bot]
890144f464
chore(deps): update dependency express to v4.19.1 (#2800) 2024-03-24 20:51:37 +00:00
Dunqing
398a0346b3
feat(transformer/typescript): remove verbatim_module_syntax option (#2796)
Remove `verbatim_module_syntax` option, Because Babel's
[onlyRemoveTypeImports](https://babeljs.io/docs/babel-plugin-transform-typescript#onlyremovetypeimports)
option same behavior with `verbatim_module_syntax` , You can see
https://github.com/babel/babel/issues/15493#issuecomment-1466453493
2024-03-25 04:51:23 +08:00
Dunqing
b6e493bd78
fix(semantic): ModuleRecord's indirect_export_entires missing reexported imports (#2792)
local_name has `name` and `span`. We can't directly compare
ExportEntry's local_name and ImportEntry's local_name. because the span
is never equal.
2024-03-25 04:50:04 +08:00
renovate[bot]
7b6a4d0690
chore(deps): update vscode npm packages (#2799) 2024-03-25 04:47:59 +08:00
renovate[bot]
36e63142d5
chore(deps): update dependency tar to v6.2.1 (#2798) 2024-03-25 04:45:54 +08:00
Ali Rezvani
813226b648
refactor(ast): get rid of unsafe transmutation in VisitMut trait. (#2764)
This will close #2745,

In this PR I attempt to fix this issue using a combination of ideas
discussed in the issue mentioned above, I've created this early draft so
people can pitch in if there is something I should consider doing.

The first goal of this PR is to resolve the issue with the possible
illegal references, As a result of my approach it would also end up with
a bunch of walk_* and walk_*_mut functions to help with the abstraction.
I want to eliminate enter_node and leave_node functions, but I still
haven't started working on it since I first want to familiarize myself
with all of its usage throughout the project. I'm hesitating to do it at
the moment, When we want to do this it would require quite a bit of
refactoring so we should make sure it is probably going to work and end
up being a better implementation.
2024-03-23 13:48:30 +00:00
underfin
d9b77d853b
refactor(sourcemap): change sourcemap name to take a reference (#2779) 2024-03-23 21:40:05 +08:00