Commit graph

7054 commits

Author SHA1 Message Date
camc314
afe1e9b929 feat(linter): enhance const-comparisons for more cases (#7628) 2024-12-04 02:59:56 +00:00
camc314
b445654fbd refactor(linter): use get_inner_expression in const-comparisons (#7627) 2024-12-04 02:59:55 +00:00
overlookmotel
3b1e63ecab perf(transformer/jsx): no string comparisons generating pragma expression (#7620)
#7553 introduced support for some unusual JSX pragmas e.g. `this.foo` and `import.meta.foo`. We want to support these to pass tests, but they're very unlikely to be used in practice.

Identify these strange patterns when parsing the pragma (which happens only once per file), and encode them as an enum. The removes expensive string comparisons from `Pragma::create_expression` (which is called for every JSX element), and keeps the path for common cases fast.
2024-12-04 02:47:28 +00:00
overlookmotel
8ad52be359 refactor(transformer/jsx): Pragma::parse take a &str (#7619)
`Pragma::parse` take an `Option<&str>` instead of `Option<&String>`. Passing `&String`s to functions is an odd pattern.
2024-12-04 02:47:27 +00:00
overlookmotel
2158c3851b test(transformer/jsx): move tests setup into a macro (#7618)
Follow up after #7553. Move tests setup for JSX pragmas into a macro to prevent tests having access to an owned `TraverseCtx`, for safety.
2024-12-04 02:47:26 +00:00
renovate
25bffa59e5 chore(deps): update crate-ci/typos action to v1.28.2 (#7617)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [crate-ci/typos](https://redirect.github.com/crate-ci/typos) | action | minor | `v1.27.3` -> `v1.28.2` |

---

### Release Notes

<details>
<summary>crate-ci/typos (crate-ci/typos)</summary>

### [`v1.28.2`](https://redirect.github.com/crate-ci/typos/compare/v1.28.1...v1.28.2)

[Compare Source](https://redirect.github.com/crate-ci/typos/compare/v1.28.1...v1.28.2)

### [`v1.28.1`](https://redirect.github.com/crate-ci/typos/releases/tag/v1.28.1)

[Compare Source](https://redirect.github.com/crate-ci/typos/compare/v1.28.0...v1.28.1)

#### \[1.28.1] - 2024-11-26

##### Fixes

-   Add back in `lock` file types accidentally removed in 1.28 (`go.sum`, `requirements.txt`)

### [`v1.28.0`](https://redirect.github.com/crate-ci/typos/releases/tag/v1.28.0)

[Compare Source](https://redirect.github.com/crate-ci/typos/compare/v1.27.3...v1.28.0)

#### \[1.28.0] - 2024-11-25

##### Features

-   Updated the dictionary with the [November 2024](https://redirect.github.com/crate-ci/typos/issues/1139) changes
-   Add many new types and file extensions to the `--type-list`, including ada, alire, bat, candid, carp, cml, devicetree, dita, dockercompose, grpbuild, graphql, hare, lean, meson, prolog, raku, reasonml, rescript, solidity, svelte, usd, v, wgsl

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/oxc-project/oxc).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS40Mi40IiwidXBkYXRlZEluVmVyIjoiMzkuNDIuNCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
2024-12-04 02:39:28 +00:00
camc314
fcc2546f9f fix(linter): move no-unused-expressions from TS to eslint (#7624) 2024-12-04 02:26:47 +00:00
Alexander S.
29db060c78
fix(linter): detect typescript eslint alias rules (#7622)
closes #7233
2024-12-04 10:16:00 +08:00
Boshen
771c698a81
feat(oxc): remove oxc_napi crate (#7634)
napi has a limitation, it cannot feature gate type exposure.

closes #7623
2024-12-04 10:07:32 +08:00
camc314
e824501a21 fix(linter): false positive in exhaustive-deps (#7626) 2024-12-04 01:58:25 +00:00
camc314
8a68ef4c3b fix(linter): update reporting spans for exhaustive-deps (#7625) 2024-12-04 01:58:23 +00:00
camc314
543df6e3a8 fix(linter): fix false positives in exhaustive-deps (#7615)
part of https://github.com/oxc-project/oxc/issues/7246
2024-12-03 23:54:22 +00:00
Boshen
9b803d95d0
chore: bump deps (#7616) 2024-12-04 07:51:53 +08:00
Boshen
b4f3812c4a refactor(oxc_napi): remove source_map - moved to its crate (#7614) 2024-12-03 14:42:34 +00:00
Boshen
adee0d1876
chore(npm/oxc-parser): update README 2024-12-03 22:37:49 +08:00
Boshen
4eb87eadbf feat(linter): RulesOfHooks from nursery to correctness (#7607) 2024-12-03 14:15:43 +00:00
Boshen
bd977cf742 feat(oxc): add oxc_napi crate (#7612) 2024-12-03 14:02:47 +00:00
IWANABETHATGUY
6af8659624 fix(oxc_transformer): correct generate ThisExpr and import.meta in jsx pragma (#7553) 2024-12-03 13:54:15 +00:00
camc314
6dd71c6d05 test(linter): port eslint tests to no-unused-expressions (#7611) 2024-12-03 13:15:49 +00:00
overlookmotel
eb825edee2 fix(transformer/class-properties): replace references to class name with temp var in static prop initializers (#7610)
Similar to #7516. Fix class properties transform to replace references to class name in static prop initializers with temp var.

Input:

```js
class C {
  static getSelf = () => C;
}
const C2 = C;
C = 123;
assert(C2.getSelf() === C);
```

Output:

```js
var _C;
class C {}
_C = C;
_defineProperty(C, "getSelf", () => _C);
const C2 = C;
C = 123;
assert(C2.getSelf() === C);
```

Previously, temp var wasn't used so code was `_defineProperty(C, "getSelf", () => C);`. `C` is altered later by `C = 123`, so `C2.getSelf()` returned `123`, instead of reference to the class.
2024-12-03 12:43:21 +00:00
overlookmotel
7d1c12e5e2 refactor(transformer/class-properties): rename misleadingly-named method (#7609)
This method replaces `this` with class temp var, not reference to class name. Name the method accordingly, and update comments.
2024-12-03 12:43:21 +00:00
overlookmotel
206de912dc feat(semantic): add SymbolTable::add_resolved_reference method (#7608)
Add `SymbolTable::add_resolved_reference` method to add a reference for a symbol.
2024-12-03 12:43:20 +00:00
camc314
e80214c74f fix(linter): fix false positives in rules-of-hooks (#7606)
closes https://github.com/oxc-project/oxc/issues/7572

should remove all false positives from this rule
2024-12-03 12:19:00 +00:00
Boshen
40792b4440 feat(napi/parser): change parse API to accept mandatory filename and optional lang (#7605) 2024-12-03 12:09:48 +00:00
Boshen
348d4f451a feat(sourcemap): move oxc_sourcemap to github.com/oxc-project/oxc-sourcemap (#7604)
It's mostly stable so we can v1.0.0 it.

And we will create cyclic dependency with StringWizard soon.
2024-12-03 11:59:43 +00:00
Boshen
7c62a33a06 feat(napi/parser): return esm info (#7602)
The parser now returns import / export statement information, which can be used for parser plugins.
2024-12-03 11:21:54 +00:00
Yuji Sugiura
521df425de
refactor(prettier): Unified method of Doc generation (#7600)
Before:

- `Doc::Xxx()` + `XXX.with_xxx()`
- `macro!()`
- `p.xxx()`

After:

- `p.xxx()` with `p_vec!` macro
2024-12-03 17:27:55 +08:00
翠 / green
58643529d1
feat(napi/transform): add TransformerOptions::assumptions (#7601)
so that I can use `setPublicClassFields` for #6735 when it's ready.
2024-12-03 17:25:18 +08:00
overlookmotel
802233d151 refactor(transformer/class-properties): remove pointless method (#7592)
#7516 removed the need for a special method to handle `export default class {}`. Delete it.
2024-12-03 07:46:05 +00:00
overlookmotel
0eadd9f6de fix(transformer/class-properties): create temp var for class where required (#7516)
Fix class properties transform to create a temp var for class when it's required.

Input:

```js
class C {
  static getSelf = () => this;
}
const C2 = C;
C = 123;
assert(C2.getSelf() === C);
```

Output:

```js
var _C;
class C {}
_C = C;
_defineProperty(C, "getSelf", () => _C);
const C2 = C;
C = 123;
assert(C2.getSelf() === C);
```

Previously, temp var wasn't used so code was `_defineProperty(C, "getSelf", () => C);`. `C` is altered later by `C = 123`, so `C2.getSelf()` returned `123`, instead of reference to the class.

The logic around when a temp var is required and when it's not, and when/where it's referenced is ridiculously complicated. So add some debug assert mechanisms to double-check the logic.
2024-12-03 07:46:04 +00:00
overlookmotel
a07f278dfd refactor(transformer/class-properties): PrivatePropsStack type (#7589)
Pure refactor. Move all logic and types related to storing details of what private properties classes have into a separate file `private_props.rs`. Introduce a type `PrivatePropsStack` to represent the stack of classes.
2024-12-03 07:46:03 +00:00
overlookmotel
370d4b9176 docs(transformer/class-properties): add missing docs (#7588)
Docs only. Add mention of what `static_prop.rs` does to the main doc comment for the transform.
2024-12-03 07:46:02 +00:00
overlookmotel
7bd6350978 refactor(transformer/class-properties): move creating temp var out of main loop (#7587)
Small optimization. Move code out of the loop which determines if class property transform has nothing to do and can bail out early. This also clears the way for correcting the logic around when temp vars are/aren't created in #7516.
2024-12-03 07:46:01 +00:00
overlookmotel
ebd11fb5e9 refactor(transformer/class-properties): exit transform_class faster if nothing to do (#7586)
Small optimization. Class properties transform doesn't have to do anything if the class has no properties, which will often be the case. Exit sooner in this case.
2024-12-03 07:46:00 +00:00
overlookmotel
dccff38afe refactor(transformer/class-properties): ResolvedPrivateProp type (#7532)
Pure refactor. `lookup_private_property` returns a tuple of 3 items, and future changes will make that 4. That's silly. Create a type `ResolvedPrivateProp` for it to return, so the various parts can have descriptive names.
2024-12-03 07:45:59 +00:00
overlookmotel
367b6c8053 refactor(transformer/class-properties): shortcut_static_class take SymbolId (#7531)
Pure refactor. `shortcut_static_class` method take `SymbolId` of class name, instead of the `&BoundIdentifier`. This change is in preparation for later PRs fixing class properties transform.
2024-12-03 07:45:58 +00:00
overlookmotel
ab1214d33c refactor(transformer/class-properties): rename class_binding (#7533)
Pure refactor. Just rename a variable. `class_binding` is preferable, since this binding isn't always for the class *name*.
2024-12-03 07:45:57 +00:00
翠 / green
71b3437a4c
test(oxc_transformer): define works differently with esbuild (#7593)
See https://github.com/oxc-project/oxc/issues/7594

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-03 15:23:40 +08:00
Boshen
16adaf9afd refactor(napi/parser): clean up code (#7596) 2024-12-03 04:48:51 +00:00
Boshen
943462f22c feat(module_lexer)!: remove oxc_module_lexer (#7595)
This crate will no longer be relevant after we export esm information
directly from the parser.

Besides, `ex-module-lexer`'s output data is too limited for plugin
authors to use.
2024-12-03 04:22:51 +00:00
Kevin Deng 三咲智子
be2293a1b5
fix(napi/transform): respect options.sourcemap for id (#7590)
Don't pass `source_map_path` if `options.sourcemap` is undefined or
false; then, `IsolatedDeclarationsResult.map` should be undefined.

Downstream issue
https://github.com/unplugin/unplugin-isolated-decl/issues/42

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-12-03 11:57:44 +08:00
overlookmotel
b553d6ff9c fix(span): fix clippy warning (#7591)
Fix clippy warning. Only triggers when running clippy in `--release` mode.
2024-12-03 02:18:57 +00:00
Cameron
3dc46a80c9
fix(linter): no-unused-expressions false positive with arrow fn expressions (#7585)
fixes https://github.com/oxc-project/oxc/issues/7584
2024-12-03 09:48:50 +08:00
Alexander S.
810671a4a0
fix(linter): detect vitest jest alias rules (#7567)
closes #7240
2024-12-03 09:46:05 +08:00
Boshen
33e5a49c78 feat(syntax): add statement span to ImportEntry and ExportEntry (#7583) 2024-12-02 14:20:30 +00:00
IWANABETHATGUY
a784a82f4f feat(oxc_transformer): support jsx pragma that are long member expressions (#7538)
related tests:

d34e79e2a9/internal/bundler_tests/bundler_default_test.go (L6188-L6236)
2024-12-02 14:02:38 +00:00
Boshen
f0e7acc68b refactor(syntax): change ModuleRecord::not_esm to has_module_syntax (#7579) 2024-12-02 09:32:57 +00:00
Boshen
18519dea33 refactor(syntax): remove ModuleRecord::export_default (#7578)
This value can be derived.
2024-12-02 09:17:57 +00:00
Boshen
d476660b0b refactor(syntax): remove ModuleRecord::exported_bindings_duplicated because it is a syntax error (#7577) 2024-12-02 08:48:01 +00:00
Boshen
17663f55d3 refactor(syntax): remove ModuleRecord::export_default_duplicated because it is a syntax error (#7576) 2024-12-02 08:19:59 +00:00