Commit graph

1796 commits

Author SHA1 Message Date
Boshen
eacde0553e chore(coverage): proposal-json-modules to stage 4 (#6380) 2024-10-09 03:09:35 +00:00
DonIsaac
834ee2aa6c fix(semantic): TSConditionalType scope enter/exit locations (#6351)
Fixes the same problem as #6270, but uses `#[scope(enter_before)]` and `#[scope(exit_after)]` to correct scope entry/exit locations.
2024-10-09 01:34:46 +00:00
DonIsaac
d9718adc8d feat(ast_tools): support #[scope(exit_before)] (#6350)
Closes #6311.

Adds support for `#[scope(exit_before)]`, which is the opposite of `#[scope(enter_before)]`
2024-10-09 01:34:44 +00:00
DonIsaac
6e3224d5fa feat(linter): configure by category in config files (#6120)
> closes #5454

Adds a `categories` property to config files, where each key is a `RuleCategory` and each value is `"allow"/"off"`, `"warn"`, or `"deny"/"error"`.

Note that this change won't come into effect until after #6088 is merged.
2024-10-08 22:19:07 +00:00
Boshen
f0a97811e4 chore(deps): update pnpm to v9.12.1 (#6365) 2024-10-08 14:54:27 +00:00
DonIsaac
01b878ecdb feat(parser)!: use BindingIdentifier for namespace declaration names (#6003)
Use `BindingIdentifier` instead of `IdentifierName` so that AST visitors can access the bound symbol id for the namespace's name. This makes namespace consistent with other named declarations, such as `Class`, `Function`, and `TSInterfaceDeclaration`.

We should consider modifying `TSModuleDeclarationName::StringLiteral(...)` to also store a `symbol_id`, since one gets bound in semantic for it as well.
2024-10-08 08:39:31 +00:00
DonIsaac
3b53dd4deb refactor(parser): provide better error messages for const modifiers on class elements (#6353)
Quality-of-life improvement for invalid `const` modifiers on class elements. Instead of panicking, the parser will eat `const` and report it as an error.

```ts
class C {
  static const H = 1;
}
```
2024-10-08 08:23:32 +00:00
DonIsaac
6159560170 fix(parser): string ImportSpecifiers for type imports (#6352)
Fixes a parse failure on imports like this:
```ts
import { type "<A>" as typeA } from "./arbitraryModuleNamespaceIdentifiers_module";
```
2024-10-08 08:17:30 +00:00
overlookmotel
4fd89e8eed test(transformer): fix indentation in transformer test fixtures (#6346)
Unimportant nit. Fix whitespace in the transformer test fixtures.
2024-10-08 01:32:07 +00:00
overlookmotel
cf20f3a89d feat(transformer): exponentiation transform: support private fields (#6345)
Babel doesn't support private fields in this transform, but there's no reason not to. So we can.
2024-10-08 01:32:06 +00:00
overlookmotel
4aa4e6bec0 refactor(transformer): exponentiation transform: do not wrap in SequenceExpression if not needed (#6343)
`left **= right` is transformed to `left = Math.pow(left, right)`. There is no need to wrap it in a `SequenceExpression`.
2024-10-08 01:32:05 +00:00
7086cmd
f9ae70c74a feat(minifier): minify basic arithmetic calculations. (#6280)
It uses to_string to check which is shorter, which is extremely tough. Waiting for further refactor.
2024-10-07 10:41:06 +00:00
overlookmotel
2bcd12a868 fix(transformer): exponentiation transform: fix reference flags (#6330) 2024-10-07 10:35:34 +00:00
overlookmotel
28cbfa7c64 fix(transformer): exponentiation transform: fix temp var names (#6329)
Fix one case that I missed in #6318.
2024-10-07 09:00:35 +00:00
camchenry
4008afe512 feat(minifier): fold array and object constructors (#6257)
This will fold expressions like `new Object()` to `{}`, and `new Array()` to `[]`. Based on the closure compiler tests: b7e380b632/test/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntaxTest.java (L78).

This is outside my usual area, so feedback is welcome.

NOTE: this was previously a full stack of PRs, but Graphite decided to stop working completely for some reason and only gave me this error when I submitted a PR:
```
ERROR: Failed to submit PR for 10-02-feat_minifier_fold_single_arg_new_array_expressions:
{}
```
so I decided to just completely remake this stack and submit as 1 PR.
2024-10-07 06:02:07 +00:00
overlookmotel
3a4bcc77fc fix(transformer): exponentiation transform: fix temp var names (#6318)
Make naming of temp vars follow Babel. It wasn't apparent that our version of this transform was behaving differently from Babel because the Babel plugin has very few tests. The added tests replicate Babel's output.
2024-10-06 23:08:10 +00:00
overlookmotel
ccb7bdcc56 fix(transformer): exponentiation transform: do not replace object when private property (#6313)
Fix exponentiation operator transform to bail out early if a private class property.

We can't transform this:

```js
class C {
    #p;
    method() {
        this.#p **= 2;
    }
}
```

But we should at least leave it alone. Previously `get_obj_ref` called `ast.move_expression(expr)` on the member expression's object before bailing out, so example above was transformed to:

```js
class C {
    #p;
    method() {
        null.#p **= 2; // <-- `null`
    }
}
```

This PR makes it spot this case early and bail out *before* calling `ast.move_expression(expr)`.
2024-10-06 23:08:08 +00:00
Boshen
020bb80b65 refactor(codegen)!: change to CodegenReturn::code and CodegenReturn::map (#6310) 2024-10-06 05:05:47 +00:00
overlookmotel
bd81c5134c fix(transformer): exponentiation transform: fix duplicate symbols (#6300)
Identifier was being cloned unnecessarily, creating an extra symbol.
2024-10-06 00:51:28 +00:00
Boshen
8729755baa feat(oxc,napi/transform): napi/transform use oxc compiler pipeline (#6298)
part of #6156
2024-10-05 16:35:09 +00:00
overlookmotel
409dffc8ab refactor(traverse)!: generate_uid return a BoundIdentifier (#6294)
Closes #5020.

`TraverseCtx::generate_uid` and associated methods return a `BoundIdentifier`, containing both symbol ID and name. This reduces boilerplate code for the caller and avoids and unnecessary lookup to get the name.

Also add a couple of helper methods to `BoundIdentifier` to reduce boilerplate further.
2024-10-05 16:00:50 +00:00
overlookmotel
06797b6900 fix(transformer): logical assignment operator transform: fix reference IDs (#6289) 2024-10-05 14:48:37 +00:00
overlookmotel
e19deaa102 ci(transformer): move post-transform checker to tasks crate (#6288)
Move post-transform checker into a `tasks` crate. It doesn't feel like it belongs in `oxc_semantic`. It also feels like too heavy a lump of code to put in `tasks/common`.
2024-10-05 14:48:37 +00:00
overlookmotel
0f5afd7ede test(transformer): transform checker output symbol name for mismatches (#6286)
Transform checker include symbol names in output for symbol mismatches. This is rather more helpful for locating bugs than just `SymbolId(3)`.
2024-10-05 14:42:06 +00:00
7086cmd
37cbabbac4 fix(minifier): should not handle the strict operation for bool comparison. (#6261) 2024-10-03 12:16:10 +00:00
leaysgur
5a73a663dc refactor(regular_expression)!: Simplify public APIs (#6262)
This PR makes 2 changes to improve the existing API that are not very useful.

- Remove `(Literal)Parser` and `FlagsParser` and their ASTs
- Add `with_flags(flags_text)` helper to `ParserOptions`

Here are the details.

> Remove `(Literal)Parser` and `FlagsParser` and their ASTs

Previously, the `oxc_regular_expression` crate exposed 3 parsers.

- `(Literal)Parser`: assumes `/pattern/flags` format
- `PatternParser`: assumes `pattern` part only
- `FlagsParser`: assumes `flags` part only

However, it turns out that in actual usecases, only the `PatternParser` is actually sufficient, as the pattern and flags are validated and sliced in advance on the `oxc_parser` side.

The current usecase for `(Literal)Parser` is mostly for internal testing.

There were also some misuses of `(Literal)Parser` that restore `format!("/{pattern}/{flags}")` back and use `(Literal)Parser`.

Therefore, only `PatternParser` is now published, and unnecessary ASTs have been removed.
(This also obsoletes #5592 .)

> Added `with_flags(flags_text)` helper to `ParserOptions`

Strictly speaking, there was a subtle difference between the "flag" strings that users were aware of and the "mode" recognised by the parser.

Therefore, it was a common mistake to forget to enable `unicode_mode` when using the `v` flag.

With this helper, crate users no longer need to distinguish between flags and modes.
2024-10-03 02:47:08 +00:00
overlookmotel
4f6bc79734 refactor(transformer)!: remove source_type param from Transformer::new (#6251)
Closes #6248.
2024-10-03 00:21:01 +00:00
7086cmd
23b646484c feat(minifier): fold true / false comparison. (#6225)
Input:
```js
a == false
```
Previous:
```js
a == !1
```
Current:
```js
a == 0
```

Only handle it when it is non-plus, non-relation binary expressions. Align with [Closure Compiler](https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520SIMPLE_OPTIMIZATIONS%250A%252F%252F%2520%2540output_file_name%2520default.js%250A%252F%252F%2520%2540formatting%2520pretty_print%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250Ax%2520%253C%253C%2520true%253B%250A%250Ax%2520%252B%2520true%253B%250A%250Ax%2520-%2520true%253B%250A%250Ax%2520%257C%2520true%253B%250A%250Ax%2520%2525%2520true%253B%250A%250Ay%2520!%253D%2520false%253B%250A%250Af()%2520%253D%253D%2520false%253B%250A%250Ax%2520instanceof%2520true%250A%250Ax%2520**%2520true%250A%250Ax%2520%2526%2520true%250A%250Ax%2520%255E%2520false%250A%250Ax%2520%253D%253D%2520(x%2520instanceof%2520false)%250A%250Ax%2520instanceof%2520(x%2520%253C%253C%2520true)%250A%250Ax%2520%253D%253D%2520fake(false)).
2024-10-02 13:37:17 +00:00
7086cmd
585ccdad8c feat(minifier): support subtraction assignment. (#6214)
Due to the potential for string concatenation when using the `+=` operator, we should only handle the scenario when using the `-=` operator.
2024-10-02 01:42:56 +00:00
overlookmotel
911e4e58ab ci(minifier): minifier benchmark measure only the minifier itself (#6222)
Minifier benchmark currently includes the time to run parser and semantic as well as the minifier itself. Similar to transformer benchmark, only measure the minifier itself in the benchmark.

This will give us a clearer picture of performance changes, and should also reduce variance in the benchmarks.
2024-10-01 17:43:39 +00:00
7086cmd
cca0034e8b feat(minifier): handle positive NaN and Infinity. (#6207)
`+NaN` -> `NaN`, `+Infinity` -> `Infinity`.
2024-10-01 10:12:19 +00:00
overlookmotel
900cb46f6c refactor(transformer): convert ModuleImports into common transform (#6186)
An alternative version of #6177.

Convert `ModuleImports` into a common transform. Works much as before, but it inserts `import` / `require` statements by passing them to `TopLevelStatements` common transform, so they get inserted in one go with any other inserted top-level statements. This avoids shuffling up the `Vec<Statement>` multiple times, which can be slow with large files.

`VarDeclarations` also inserts any declarations via `TopLevelStatements` but runs after `ModuleImports`, so can control whether a `var` statement is inserted before or after `import` statements by inserting it via `VarDeclarations` (to appear after `import` statements) or directly into `TopLevelStatements` (to appear before `import` statements). Insertion order is not actually important, but allows us to match Babel's output and pass its tests.
2024-10-01 07:40:17 +00:00
Boshen
51a78d5946
feat(napi/transform): rename all mention of React to Jsx; remove mention of Binding (#6198)
This does not alter field names nor file names.

part of #6156
2024-10-01 11:52:50 +08:00
dalaoshu
705051560e
feat(rulegen): add diagnostic for rule template (#6187)
When writing new rules, it is always inevitable to add `diagnostic`.
Perhaps we can preset it in the `template`.

In addition, guide users to view relevant documents.
2024-10-01 11:04:50 +08:00
overlookmotel
21b08ba141 refactor(transformer): shared VarDeclarations (#6170)
First step towards #5049.

Various transforms need to add a `var` statement at top of enclosing statement block.

e.g.:

```js
// Input
a ??= b;
```

```js
// Output
var _a;
(_a = a) !== null && _a !== void 0 ? _a : (a = b);
```

Each of these transforms previously maintained it's own stack and added `var` statements individually.

Share this functionality in a "common" utility transform which maintains a single stack to serve them all.
2024-09-30 03:53:00 +00:00
renovate[bot]
646cd1d1ab
chore(deps): update npm packages (#6164)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [express](http://expressjs.com/)
([source](https://redirect.github.com/expressjs/express)) | [`4.19.2` ->
`4.21.0`](https://renovatebot.com/diffs/npm/express/4.19.2/4.21.0) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/express/4.21.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/express/4.21.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/express/4.19.2/4.21.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/express/4.19.2/4.21.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| [pnpm](https://pnpm.io)
([source](https://redirect.github.com/pnpm/pnpm)) | [`9.9.0` ->
`9.11.0`](https://renovatebot.com/diffs/npm/pnpm/9.9.0/9.11.0) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/pnpm/9.11.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/pnpm/9.11.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/pnpm/9.9.0/9.11.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/pnpm/9.9.0/9.11.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>expressjs/express (express)</summary>

###
[`v4.21.0`](https://redirect.github.com/expressjs/express/releases/tag/4.21.0)

[Compare
Source](https://redirect.github.com/expressjs/express/compare/4.20.0...4.21.0)

#### What's Changed

- Deprecate `"back"` magic string in redirects by
[@&#8203;blakeembrey](https://redirect.github.com/blakeembrey) in
[https://github.com/expressjs/express/pull/5935](https://redirect.github.com/expressjs/express/pull/5935)
- finalhandler@1.3.1 by
[@&#8203;wesleytodd](https://redirect.github.com/wesleytodd) in
[https://github.com/expressjs/express/pull/5954](https://redirect.github.com/expressjs/express/pull/5954)
- fix(deps): serve-static@1.16.2 by
[@&#8203;wesleytodd](https://redirect.github.com/wesleytodd) in
[https://github.com/expressjs/express/pull/5951](https://redirect.github.com/expressjs/express/pull/5951)
- Upgraded dependency qs to 6.13.0 to match qs in body-parser by
[@&#8203;agadzinski93](https://redirect.github.com/agadzinski93) in
[https://github.com/expressjs/express/pull/5946](https://redirect.github.com/expressjs/express/pull/5946)

#### New Contributors

- [@&#8203;agadzinski93](https://redirect.github.com/agadzinski93) made
their first contribution in
[https://github.com/expressjs/express/pull/5946](https://redirect.github.com/expressjs/express/pull/5946)

**Full Changelog**:
https://github.com/expressjs/express/compare/4.20.0...4.21.0

###
[`v4.20.0`](https://redirect.github.com/expressjs/express/blob/HEAD/History.md#4200--2024-09-10)

[Compare
Source](https://redirect.github.com/expressjs/express/compare/4.19.2...4.20.0)

\==========

-   deps: serve-static@0.16.0
    -   Remove link renderization in html while redirecting
-   deps: send@0.19.0
    -   Remove link renderization in html while redirecting
-   deps: body-parser@0.6.0
    -   add `depth` option to customize the depth level in the parser
- IMPORTANT: The default `depth` level for parsing URL-encoded data is
now `32` (previously was `Infinity`)
-   Remove link renderization in html while using `res.redirect`
-   deps: path-to-regexp@0.1.10
- Adds support for named matching groups in the routes using a regex
- Adds backtracking protection to parameters without regexes defined
-   deps: encodeurl@~2.0.0
- Removes encoding of `\`, `|`, and `^` to align better with URL spec
- Deprecate passing `options.maxAge` and `options.expires` to
`res.clearCookie`
- Will be ignored in v5, clearCookie will set a cookie with an expires
in the past to instruct clients to delete the cookie

</details>

<details>
<summary>pnpm/pnpm (pnpm)</summary>

###
[`v9.11.0`](https://redirect.github.com/pnpm/pnpm/compare/v9.10.0...v9.11.0)

[Compare
Source](https://redirect.github.com/pnpm/pnpm/compare/v9.10.0...v9.11.0)

###
[`v9.10.0`](https://redirect.github.com/pnpm/pnpm/releases/tag/v9.10.0):
pnpm 9.10

[Compare
Source](https://redirect.github.com/pnpm/pnpm/compare/v9.9.0...v9.10.0)

#### Minor Changes

- Support for a new CLI flag, `--exclude-peers`, added to the `list` and
`why` commands. When `--exclude-peers` is used, peer dependencies are
not printed in the results, but dependencies of peer dependencies are
still scanned
[#&#8203;8506](https://redirect.github.com/pnpm/pnpm/pull/8506).
- Added a new setting to `package.json` at
`pnpm.auditConfig.ignoreGhsas` for ignoring vulnerabilities by their
GHSA code
[#&#8203;6838](https://redirect.github.com/pnpm/pnpm/issues/6838).

    For instance:

    ```json
    {
      "pnpm": {
        "auditConfig": {
          "ignoreGhsas": [
            "GHSA-42xw-2xvc-qx8m",
            "GHSA-4w2v-q235-vp99",
            "GHSA-cph5-m8f7-6c5x",
            "GHSA-vh95-rmgr-6w4m"
          ]
        }
      }
    }
    ```

#### Patch Changes

-   Throw an exception if pnpm switches to the same version of itself.
-   Reduce memory usage during peer dependencies resolution.

#### Platinum Sponsors

<table>
  <tbody>
    <tr>
      <td align="center" valign="middle">
<a href="https://bit.dev/?utm_source=pnpm&utm_medium=release_notes"
target="_blank"><img src="https://pnpm.io/img/users/bit.svg"
width="80"></a>
      </td>
      <td align="center" valign="middle">
<a href="https://figma.com/?utm_source=pnpm&utm_medium=release_notes"
target="_blank"><img src="https://pnpm.io/img/users/figma.svg"
width="80"></a>
      </td>
    </tr>
  </tbody>
</table>

#### Gold Sponsors

<table>
  <tbody>
    <tr>
      <td align="center" valign="middle">
<a href="https://discord.com/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/discord.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/discord_light.svg" />
<img src="https://pnpm.io/img/users/discord.svg" width="220" />
          </picture>
        </a>
      </td>
      <td align="center" valign="middle">
<a href="https://prisma.io/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/prisma.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/prisma_light.svg" />
<img src="https://pnpm.io/img/users/prisma.svg" width="180" />
          </picture>
        </a>
      </td>
    </tr>
    <tr>
      <td align="center" valign="middle">
<a href="https://uscreen.de/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/uscreen.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/uscreen_light.svg" />
<img src="https://pnpm.io/img/users/uscreen.svg" width="180" />
          </picture>
        </a>
      </td>
      <td align="center" valign="middle">
<a
href="https://www.jetbrains.com/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/jetbrains.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/jetbrains.svg" />
<img src="https://pnpm.io/img/users/jetbrains.svg" width="180" />
          </picture>
        </a>
      </td>
    </tr>
    <tr>
      <td align="center" valign="middle">
<a href="https://nx.dev/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/nx.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/nx_light.svg" />
            <img src="https://pnpm.io/img/users/nx.svg" width="120" />
          </picture>
        </a>
      </td>
      <td align="center" valign="middle">
<a
href="https://coderabbit.ai/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/coderabbit.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/coderabbit_light.svg" />
<img src="https://pnpm.io/img/users/coderabbit.svg" width="220" />
          </picture>
        </a>
      </td>
    </tr>
  </tbody>
</table>

#### Our Silver Sponsors

<table>
  <tbody>
    <tr>
      <td align="center" valign="middle">
<a
href="https://leniolabs.com/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <img src="https://pnpm.io/img/users/leniolabs.jpg" width="80">
        </a>
      </td>
      <td align="center" valign="middle">
<a href="https://vercel.com/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/vercel.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/vercel_light.svg" />
<img src="https://pnpm.io/img/users/vercel.svg" width="180" />
          </picture>
        </a>
      </td>
    </tr>
    <tr>
      <td align="center" valign="middle">
<a href="https://depot.dev/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/depot.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/depot_light.svg" />
<img src="https://pnpm.io/img/users/depot.svg" width="200" />
          </picture>
        </a>
      </td>
      <td align="center" valign="middle">
<a href="https://moonrepo.dev/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/moonrepo.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/moonrepo_light.svg" />
<img src="https://pnpm.io/img/users/moonrepo.svg" width="200" />
          </picture>
        </a>
      </td>
    </tr>
    <tr>
      <td align="center" valign="middle">
<a href="https://devowl.io/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/devowlio.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/devowlio.svg" />
<img src="https://pnpm.io/img/users/devowlio.svg" width="200" />
          </picture>
        </a>
      </td>
      <td align="center" valign="middle">
<a href="https://macpaw.com/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/macpaw.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/macpaw_light.svg" />
<img src="https://pnpm.io/img/users/macpaw.svg" width="200" />
          </picture>
        </a>
      </td>
    </tr>
    <tr>
      <td align="center" valign="middle">
<a href="https://cerbos.dev/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/cerbos.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/cerbos_light.svg" />
<img src="https://pnpm.io/img/users/cerbos.svg" width="180" />
          </picture>
        </a>
      </td>
    </tr>
  </tbody>
</table>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 10am on monday" in timezone
Asia/Shanghai, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

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

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config
help](https://redirect.github.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- 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:eyJjcmVhdGVkSW5WZXIiOiIzOC45Ny4wIiwidXBkYXRlZEluVmVyIjoiMzguOTcuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-29 09:48:23 +00:00
Dunqing
bfd19882b0 fix(transformer/react): should not collect use-hooks if it's a nested member expression (#6143)
close: #6139

I still remember this logic and I call `get_first_object` for it intentionally 🥲
2024-09-28 14:38:14 +00:00
DonIsaac
b1af73db81 fix(semantic): do not create a global symbol for declare global {} (#6040)
Re-creation of #6004 to unblock it from down-stack PRs. @Boshen has already reviewed the previous PR and determined this to be correct behavior.
2024-09-25 08:46:00 +00:00
DonIsaac
f866781f49 feat(semantic): check for type annotations on left side of for..in and for..of iterators (#6043) 2024-09-25 02:51:17 +00:00
DonIsaac
8b2e9aa744 feat(semantic): check for JSDoc types in TS type annotations (#6042)
Closes #5982
2024-09-25 02:35:59 +00:00
Cam McHenry
65d8f9e8fe
perf(linter, ast-tools, coverage): Use FxHashSet instead of std::collections::HashSet (#6001) 2024-09-24 19:29:08 +08:00
Boshen
28da77195b feat(transformer): do not transform ** with bigint literals (#6023)
part of #5822

They will produce runtime errors.
2024-09-24 10:33:02 +00:00
Boshen
0658576718 fix(paresr): do not report missing initializer error in ambient context (#6020)
closes #5958
2024-09-24 09:04:09 +00:00
Boshen
c8682e9fcb fix(semantic,codegen,transformer): handle definite ! operator in variable declarator (#6019)
closes #5999
2024-09-24 08:32:05 +00:00
Boshen
5c323a2105 feat(minifier): loop compressor passes (#6013) 2024-09-24 03:09:35 +00:00
camchenry
02d5637dbc perf(ast-tools): use FxHashMap over std::collections::HashMap (#5997) 2024-09-23 18:28:54 +00:00
camchenry
b240b42eb9 fix(rulegen): handle raw string literals correctly (#5991)
Currently, we are not handling raw string literals correctly and just translating them as normal Rust string literals, which causes compile errors and also misses some cases. This PR updates it so that we detect usage of `String.raw` and translate it as a Rust raw string literal.

Before:

<img width="867" alt="Screenshot 2024-09-23 at 10 02 21 AM" src="https://github.com/user-attachments/assets/7c042537-d6c2-4141-a119-0ed846bce59d">

After:

<img width="832" alt="Screenshot 2024-09-23 at 10 01 27 AM" src="https://github.com/user-attachments/assets/759f6647-a675-42eb-b39d-c0e88f689536">
2024-09-23 16:24:19 +00:00
Boshen
0a2f68756f refactor(minifier): move dce conditional expression to RemoveDeadCode (#5971)
This is aligned to closure compiler
2024-09-23 10:22:00 +00:00
DonIsaac
d24985ed51 feat(linter): add oxc-security/api-keys (#5906)
## What This PR does
Adds a new `oxc-security/api-key` rule that scans for hard-coded API keys.

It is broken up into "secret rules", where each one is responsible for finding a different kind of key. It is architecturally identical to how lint rules themselves. This PR also includes the first of these rules, for AWS access key IDs.

Logic and rules are based on [keyhunter](https://github.com/Donisaac/keyhunter). I've licensed that repo under GNU GPLv3, but it's my code and I can do what I want with it 😈 (read: I'm fine with it being MIT for oxc).

This PR is a complete feature in its own right, but does not represent the end of this work. See https://github.com/oxc-project/backlog/issues/116 to track overall progress.
2024-09-22 22:39:56 +00:00
DonIsaac
74d8714d5a feat(semantic): add help message for invalid let x?: number (#5969) 2024-09-22 15:59:49 +00:00
Boshen
612f638bcd
chore: change just c to run cargo conformance 2024-09-22 23:50:30 +08:00
DonIsaac
f1551d64bc fix(semantic): ? on variable declaration type annotations is a syntax error (#5956)
Closes #5955
2024-09-22 00:01:47 +00:00
Dunqing
4a62703d88 feat(isolated-declarations): handle export in the namespace correctly (#5950)
Previous I didn't follow the behavior of `TypeScript` to handle `export` in `namespace` as I thought no one used this
2024-09-21 16:39:58 +00:00
Alexander S.
463c24e5ec
fix(prettier): handle TSTypeLiteral as an object (#5946)
- [x] semi is optional with the right configuration
2024-09-21 23:27:12 +08:00
Boshen
f4aefb57d8 fix(codegen): print let[0] as (let)[0] (#5947) 2024-09-21 15:09:55 +00:00
overlookmotel
4e9e838838 fix(transformer): fix arrow function transform (#5933)
Fix arrow function transform's treatment of `this` within classes.
2024-09-21 07:48:18 +00:00
Boshen
12d4888120 chore(prettier): remove incorrect comment printing logic (#5889)
Remove the previous incorrect implementation, cc @leaysgur
2024-09-21 04:45:18 +00:00
overlookmotel
15743344b1 test(transformer): add test for arrow function transform (#5932)
Add test for `this` in nested block inside arrow function.
2024-09-21 00:53:43 +00:00
Boshen
d901772daa feat(codegen): implement minify number from terser (#5929) 2024-09-20 14:42:28 +00:00
Boshen
6757c5829f
chore(transform_conformance): remove unused snapshots/typescript.snap.md
closes #5922
2024-09-20 22:41:41 +08:00
overlookmotel
b80a9eec7f refactor(ast_tools): shorten code (#5915)
#5904 reduced the generated code for `Visit` trait. Shorten the codegen a little after that change.
2024-09-20 14:15:11 +00:00
overlookmotel
eadffb900e test(conformance): move conformance snapshots into separate directory (#5924) 2024-09-20 12:30:39 +00:00
DonIsaac
ba7b01fbdf refactor(linter): Add LinterBuilder (#5714)
This will replace `OxlintOptions` in an upstream PR. This also adds `plugins` to
`Oxlintrc`. This field gets respected by the builder, but not by
`OxlintOptions`.
2024-09-20 11:58:37 +00:00
overlookmotel
8ade793dfe test(prettier): move prettier conformance snapshots into separate directory (#5921) 2024-09-20 11:34:13 +00:00
overlookmotel
bd318b1eec test(transformer): join paths in cross-platform compatible way (#5920) 2024-09-20 11:30:12 +00:00
overlookmotel
7d32d2086c
test(transformer): update transform conformance README (#5919)
Add reference to our additional tests + tidy up capitalization.
2024-09-20 11:46:44 +01:00
overlookmotel
9dac6dfb23 test(transformer): move transformer conformance snapshots into separate directory (#5917)
Move snapshots for transform conformance into a `snapshots` sub-folder.
2024-09-20 10:25:17 +00:00
camchenry
f4fac0f488 refactor(ast): remove .iter() where not needed (#5904)
this is just an experiment, I noticed while profiling these code paths came up a number of times:
<img width="1077" alt="Screenshot 2024-09-19 at 8 32 51 PM" src="https://github.com/user-attachments/assets/d0f4d703-c456-4344-8f57-81f0b3f491a0">
2024-09-20 02:41:49 +00:00
Alexander S.
65c337a071
feat(prettier): improve ts compatibility (#5900) 2024-09-20 10:40:31 +08:00
overlookmotel
4d5c4f6cad fix(transformer): fix reference flags in logical assignment operator transform (#5903) 2024-09-20 01:26:55 +00:00
overlookmotel
d335a6760e fix(transformer): fix references in logical assignment operator transform (#5896)
Re-use existing reference, rather than creating a new one.
2024-09-20 01:26:53 +00:00
overlookmotel
cab441c572 test(transformer): fix JSX test options (#5895)
Fix a test by setting correct options.
2024-09-20 01:26:52 +00:00
overlookmotel
9758c1a5cc fix(transformer): JSX source: add var _jsxFileName statement (#5894)
Fix JSX source transform when run alone without main JSX transform.

The added test case is same as one of Babel's exec test cases, but the exec test fails due to `transformAsync` not being present.
2024-09-20 01:26:52 +00:00
Boshen
84a5816d03
feat(isolated_declarations): add stripInternal (#5878)
closes #3906
closes #5687
closes #3958

---------

Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-09-19 23:14:47 +08:00
Boshen
db4f16a98f refactor(semantic): call with_trivias before build_with_jsdoc (#5875) 2024-09-19 04:12:57 +00:00
Alexander S.
4e37d18b2e
feat(prettier): start supporting tsx syntax (#5866)
Look at first: #5864 

the only merge conflict for this PR should then be the ts snap file. 
If you want, you can also skip the other PR and merge this one directly
:)
2024-09-19 09:40:07 +08:00
overlookmotel
0c8733df23 test(transformer): clean up identation in test fixtures (#5863)
Not sure how added up with mix of tabs and spaces.
2024-09-18 15:19:59 +00:00
overlookmotel
c96b712f6b refactor(syntax)!: remove SymbolFlags::ArrowFunction (#5857)
`SymbolFlags::ArrowFunction` is an oddity, as whether a symbol is an arrow function is not statically knowable. In the following cases, `f` symbol did not have `ArrowFunction` flag set:

```js
const {f} = {f: () => {}};
```

```js
let f = 123;
f = () => {};
```

`SymbolFlags::ArrowFunction` is therefore not particularly useful, and possibly misleading. Having it complicates the transformer, and it's not used anywhere in Oxc.

This PR removes it.
2024-09-18 14:03:03 +00:00
overlookmotel
2e93548816 ci(transformer): enable arrow function transform in transformer benchmark (#5851) 2024-09-18 11:08:27 +00:00
overlookmotel
ef8dcc9d4d test(transformer): more tests for arrow function transform (#5849) 2024-09-18 09:46:58 +00:00
overlookmotel
49ee1dcff2 fix(transformer): arrow function transform handle this in arrow function in class static block (#5848)
Class static blocks also hold a `this` binding.
2024-09-18 09:46:57 +00:00
Alexander S.
31da9bce3f
feat(prettier): class improvements part 2 (#5838) 2024-09-18 11:07:51 +08:00
Alexander S.
c6d97e9366
feat(prettier): improve ts class output (#5835)
please look first at  #5834 :)
2024-09-17 17:33:35 -04:00
Alexander S.
6d9ccdda92
feat(prettier): support TSMappedType (#5834) 2024-09-17 16:25:51 -04:00
Boshen
5901d2a0f1 fix(codegen): various spacing issues (#5820) 2024-09-17 09:03:28 +00:00
Alexander S.
18e4ac22ad
feat(prettier): improve TSInterfaceDeclaration (#5817)
last one for today :)

---------

Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-09-17 14:41:33 +08:00
DonIsaac
a438743191 refactor(linter): move OxlintConfig to Oxlintrc (#5707) 2024-09-17 05:15:37 +00:00
Alexander S.
b5ac5a6bf0
feat(prettier): support TSModuleDeclaration (#5813)
Goal of this PR is to resolve this test:
aa3853b776/tests/format/typescript/interface/separator.ts
2024-09-16 16:39:42 -04:00
Alexander S.
8b1485bb00
feat(prettier): improve ClassMemberish with print_class_property (#5811) 2024-09-16 13:32:20 -04:00
Alexander S.
01f8c1bca8
feat(prettier): support TSIntersectionType and TSUnionType (#5794) 2024-09-16 13:09:30 -04:00
Alexander S.
52c64093f9
feat(prettier): support typescript enums (#5790)
The last failed test is only because of the comments. the oxc prettier
output is:

```
enum Direction {
  Up = 1,
  Down,
  Left,
  Right,
}

enum FileAccess {
  None,
  Read = // constant members
  1 << 1,
  Write = 1 << 2,
  ReadWrite = Read | Write,
  G = // computed member
  "123".length,
}

enum Empty {}

const enum Enum {
  A = 1,
  B = A * 2,
}
```
Expected output:
aa3853b776/tests/format/typescript/enum/__snapshots__/format.test.js.snap (L91-L99)

Hope you can tell more why this happens :)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-09-16 11:58:04 +08:00
Boshen
213dbc04ff chore(transform_conformance): do not print comments yet (#5788) 2024-09-15 15:48:58 +00:00
Boshen
512be65fa7 refactor(coverage): remove sourcemap snapshot (#5782) 2024-09-15 08:56:54 +00:00
overlookmotel
3230ae5842 feat(semantic): add SemanticBuilder::with_excess_capacity (#5762)
Add `SemanticBuilder::with_excess_capacity` method to request that `SemanticBuilder` over-allocate space in `Semantic`'s `Vec`s.

Use this method to reserve 200% extra capacity for transformer to create more scopes, symbols and references.

200% is an unscientific guess of how much extra capacity is required. Obviously it depends on what transforms are enabled and content of the source code.
2024-09-14 15:02:16 +00:00
Dunqing
36e698b411 perf(transformer): call transform_jsx in exit_expression rather than enter_expression (#5751)
### Difference

In `enter_expression`: Recursive transform JSX
In `exit_expression`: Deep first transform

After the change,  `transform_jsx` still has a lot of room for improvement.
2024-09-13 17:58:41 +00:00
Dunqing
3cc38dfc05 fix(transformer/react): react refresh panics when encounter use hook (#5768)
close: #5766

I even forgot that React has a `use` hook in the latest version
2024-09-13 16:17:33 +00:00
Dunqing
77d9170f84 fix(transformer/react): isStaticChildren should be false when there is only one child (#5745)
We found a warning report [here](206df66e70/packages/react/src/jsx/ReactJSXElement.js (L614-L632)). It caused by we transform incorrectly
2024-09-13 13:20:59 +00:00
Dunqing
c9fea5dd16 chore(tasks/transformer_conformance): remove an ignored test that has passed (#5750) 2024-09-13 09:03:48 +00:00
Boshen
6bc13f6cd4 feat(minifier): add MinimizeConditions pass (#5747)
I expect small performance regression.

But managed to improve the following case from react.developmement.js

```
oxc  main ❯ diff before.js after.js
670c670
< 		if (!(dispatcher !== null)) throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.");
---
> 		if (dispatcher === null) throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.");
```
2024-09-13 08:31:45 +00:00
overlookmotel
3ce8546393 ci(benchmarks): NeverGrowInPlaceAllocator not pub (#5727)
Global allocator used in benchmarks `NeverGrowInPlaceAllocator` doesn't need to be `pub`.
2024-09-12 12:58:13 +00:00
Boshen
748e6f80fe
chore(minsize): update minsize.snap 2024-09-12 19:02:46 +08:00
Boshen
945d2744ae
chore(linter: fix snapshot 2024-09-11 21:07:23 +08:00
dalaoshu
d18c896a2c
perf(rust): use cow_utils instead (#5664)
Related to #5586 and #5662

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-09-11 18:39:30 +08:00
heygsc
5482e73189
feat(prettier): add assignment/sequence (#5694)
test:
https://github.com/prettier/prettier/blob/main/tests/format/js/assignment/sequence.js


snap:https://github.com/prettier/prettier/blob/main/tests/format/js/assignment/__snapshots__/format.test.js.snap#L870-L888

code:
https://github.com/prettier/prettier/blob/main/src/language-js/needs-parens.js#L790-L796
2024-09-11 18:19:09 +08:00
Dunqing
a1afd48c68 fix(transformer/react): incorrect scope_id for var hoisted in fast refresh plugin (#5695)
Fix the last one semantic error in the fast react plugin
2024-09-11 09:02:29 +00:00
Dunqing
f2f5e5aaf5 fix(transformer/react): missing scope_id for function in fast refresh plugin (#5693)
Fix semantic error in the fast react plugin
2024-09-11 09:02:28 +00:00
Dunqing
a891c31889 fix(transformer/react): refresh plugin has incorrect reference flags (#5656)
As you see the diff
2024-09-11 07:57:17 +00:00
Dunqing
ffbc4625b4 chore(transformer): treat all React Refresh tests as ESM syntax (#5644)
related: #5612
2024-09-11 07:57:17 +00:00
Dunqing
3e8b96f165 fix(transformer/react): the refresh plugin cannot handle member expressions with React hooks (#5655)
The previous implementation doesn't handle nested StaticMemberExpression. For example: `A.B.C.useHook`.
2024-09-11 07:57:16 +00:00
Dunqing
7b543dffd9 feat(transformer/react): handle refresh_sig and refresh_reg options correctly (#5638)
In previous implementations, even if pass `import.meta.xxxx` into these options this plugin still treats them as `IdentifierReference`
2024-09-11 07:57:15 +00:00
Dunqing
3bf6aaf06a fix(transformer/react): support emit_full_signatures option in refresh plugin (#5629) 2024-09-11 07:57:14 +00:00
Dunqing
36d864a0c3 fix(transformer/react): don't transform if the variable does not have a value reference (#5528)
close: #4746

Solved the last two tests, but it's a coincidence. I've added a test to cover it.
2024-09-11 07:10:55 +00:00
leaysgur
304ce25446 fix(regular_expression): Keep LegacyOctalEscape raw digits for to_string (#5692)
Fixes #5690

- Update `CharacterKind` enum from `Octal` to `Octal1`, `Octal2` and `Octal3`
- Stylistic refactoring for `impl Display`
2024-09-11 07:07:00 +00:00
DonIsaac
9e9435f03b refactor(linter): add LintFilter (#5685)
Re-creation of #5329
2024-09-11 03:19:04 +00:00
Boshen
2016bae98c feat(coverage): add regular expression idempotency test (#5676)
closes #5634
2024-09-11 02:07:42 +00:00
Boshen
f9e3a41dd2 fix(semantic): bind SymbolId to function name in if (foo) function id() {} (#5673) 2024-09-10 11:05:26 +00:00
DonIsaac
5ae9b48509 refactor(linter): start internal/external split of OxlintOptions (#5659)
re-creation of #5141
2024-09-10 03:19:04 +00:00
leaysgur
0511d55aa8 fix(regular_expression): Report more MayContainStrings error in (nested)class (#5661)
Fixes #5632
2024-09-10 01:55:51 +00:00
IWANABETHATGUY
e38114b825
fix(ast_tools): fix ast-tool panic (#5641)
`just ast` panic due to
553262842c,
change the filename to makesure `ast_tool` still working
1. crates/oxc_span/src/source_type/types.rs is removed in
553262842c
2024-09-09 17:57:20 +08:00
DonIsaac
20d006838e refactor(oxlint): move cli-related exports to cli module (#5139) 2024-09-08 15:29:37 +00:00
Boshen
f49e6ebd41 fix(span): treat .js as module file (reverts the previous breaking change) (#5612)
As it turns out it's not ideal to treat `.js` as `script` in today's world anymore.

This makes https://github.com/oxc-project/oxlint-ecosystem-ci pass again.
2024-09-08 15:14:04 +00:00
Boshen
4a8aec1605 feat(span)!: change SourceType::js to SourceType::cjs and SourceType::mjs (#5606) 2024-09-08 14:11:02 +00:00
Boshen
63a830e08c
chore(dprint): format toml files (#5599)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-09-08 14:26:16 +08:00
Boshen
d00a1f6511
chore: use dprint to format js, json and markdown 2024-09-08 13:24:58 +08:00
Boshen
919d17fc5c fix(transform_conformance): only print semantic mismatch errors when output is correct (#5589)
closes #5166

Had to rerun for mismatch errors :-/
2024-09-07 16:32:53 +00:00
Boshen
1bc08e296e fix(coverage): parse babel unambiguously (#5579) 2024-09-07 10:49:00 +00:00
Boshen
43933912ce fix(coverage): parse typescript unambiguously (#5575) 2024-09-07 10:48:59 +00:00
Boshen
603817bef9 feat(oxc)!: add SourceType::Unambiguous; parse .js as unambiguous (#5557)
See https://babel.dev/docs/options#misc-options for background on `unambiguous`

Once `SourceType::Unambiguous` is parsed, it will correctly set the returned `Program::source_type` to either `module` or `script`.
2024-09-07 10:48:58 +00:00
rzvxa
c78a8507d1 refactor(ast_tools): only use type names to ignore fields in the DeriveContentHash. (#5573)
related to https://github.com/oxc-project/backlog/issues/107
2024-09-07 09:57:25 +00:00
rzvxa
db55fb0fce fix(ast_tools, ci): watch tasks/ast_tools instead of tasks/ast_codegen. (#5576)
I was so confused as to why the `AST Changes` step wasn't running at times. Turns out we weren't watching it at all😅

This means for a duration of time we weren't running the `AST Changes` step on PRs that edited only `ast_tools` that didn't update any side-effects.
2024-09-07 09:41:18 +00:00
rzvxa
7a6b64c3f0 refactor(ast_tools): remove unsafe code from logger. (#5574)
https://github.com/oxc-project/oxc/pull/5519#discussion_r1747097404
2024-09-07 09:03:26 +00:00
Boshen
f7912ad6c0
chore: remove unused pnpm-lock.yaml 2024-09-07 13:11:34 +08:00
overlookmotel
505d06446b fix(transformer): JSX transform delete references for JSXClosingElements (#5560)
JSX transform delete old references which were used in `JSXClosingElement` before transformation.
2024-09-07 03:51:36 +00:00
Boshen
28b934ca74 fix(coverage): apply always_strict to test262 and typescript per the specifcation (#5555)
This also removes the confusing `SourceType::always_strict` field.

I hacked it with `SourceType::always_strict`, but what we actually want is add `'use strict'`.

This is technically a breaking change but I don't expect anyone using this outside of oxc.

The snapshot has a large diff due to every single line shifting by 1 row :-/
2024-09-06 17:14:01 +00:00
Boshen
b06052501a refactor(semantic)!: remove source_type argument from SemanticBuilder::new (#5553)
Realized we can get the source type from the AST.

The next PR will introduce `unambiguous` to `SourceType` and directly set `Program::source_type` to either `script` or `module`.
2024-09-06 16:40:10 +00:00
Boshen
d62defb42d fix(codegen): do not print trailing commas for ArrayExpression (#5551)
closes #5532
2024-09-06 16:35:10 +00:00
overlookmotel
14ee086182 refactor(ast): inline AstKind::as_* methods (#5547)
One would hope compiler will inline these trivial methods anyway, but mark them `#[inline]` to make sure.
2024-09-06 14:31:17 +00:00
overlookmotel
dc924892cc test: add trailing line breaks to conformance fixtures (#5541)
Continuation of #5537. Ensure all conformance fixture files have a trailing line break.
2024-09-06 12:55:17 +00:00
overlookmotel
694f032a3d style: add trailing line breaks to package.json files (#5542)
For consistency with our `.editorconfig`.
2024-09-06 12:43:44 +00:00
overlookmotel
87a79d9cd0 test(transformer): add trailing line breaks to conformance fixtures (#5537)
Currently whether conformance fixture files have trailing line breaks is inconsistent - some have them, some don't. Make all of them have a trailing line break.
2024-09-06 12:02:46 +00:00
overlookmotel
e18c2edfcb test(transformer): move RegExp transform conformance tests (#5536)
Rename transform conformance RegExp test fixtures folder from "esbuild-tests" to "regexp", to reflect that not all these tests are copied from ESBuild.
2024-09-06 12:02:45 +00:00
overlookmotel
d1ece197c4 fix(transformer): RegExp transform handle Term::Quantifier (#5501)
`Term::Quantifier` contains a nested `Term` so we need to recurse into that `Term` to check if it contains any unsupported syntax.
2024-09-06 11:51:35 +00:00
Dunqing
7a797ac635 fix(semantic): incorrect reference when MemberExpression used in TSPropertySignature (#5525)
close: https://github.com/oxc-project/oxc/issues/5435#issuecomment-2333032168
2024-09-06 06:24:45 +00:00
rzvxa
b4f75967bd refactor(ast_tools): add some minimal logging. (#5519) 2024-09-06 06:19:50 +00:00
Boshen
1bed5ce2a5 chore: run cargo +nightly fmt to sort imports (#5503)
They are never going to be stable are they ... cedf7a4daa/.rustfmt.toml (L8-L16)
2024-09-06 04:04:26 +00:00
Boshen
32d4bbb519
feat(transformer): add TransformOptions::enable_all method (#5495)
Make it **really** explicit about which transformer options are being
turned on. I also need this in monitor-oxc.
2024-09-06 12:04:06 +08:00
rzvxa
10e8984d93 ci: fix paths in the .generated_ast_watch_list.yml. (#5520) 2024-09-06 03:23:26 +00:00
Boshen
c3cfbfb480 chore: clippy::allow_attributes (#5521)
https://blog.rust-lang.org/2024/09/05/Rust-1.81.0.html#expectlint

https://rust-lang.github.io/rust-clippy/master/index.html#/allow_attributes
2024-09-06 03:07:02 +00:00
IWANABETHATGUY
b96bea4f0d fix: add back lifetime (#5507)
closed #5506
2024-09-05 17:47:58 +00:00
IWANABETHATGUY
cedf7a4daa feat(xtask): impl as_ast_kind method for each variant (#5491) 2024-09-05 16:17:08 +00:00
overlookmotel
2060efc801 fix(transformer): RegExp transform don't transform all RegExps (#5486)
Previously `RegExp` transform would transform every `RegExp`, even if it had no unsupported flags/patterns.
2024-09-05 13:50:21 +00:00
Dunqing
c59d8b3c9b feat(transformer): support all /regex/ to new RegExp transforms (#5387)
related: #4754

The implementation port from [esbuild](332727499e/internal/js_parser/js_parser.go (L12820-L12840)). And cover all babel's regexp plugins

---

## The following description was generated by `Graphite` 😋

### TL;DR

Added support for transforming various RegExp features to ensure compatibility with older JavaScript environments.

### What changed?

- Implemented a new `RegExp` transformer to handle unsupported RegExp literal features
- Added options to control different RegExp transformations (e.g., sticky flag, unicode flag, dot-all flag, etc.)
- Updated the transformer to convert unsupported RegExp literals into `new RegExp()` constructor calls
- Added test cases for different RegExp transformations
- Integrated the new RegExp transformer into the existing transformation pipeline

### How to test?

1. Run the existing test suite to ensure no regressions
2. Execute the new RegExp-specific tests in the `tasks/transform_conformance/tests/esbuild-tests/test/fixtures/regexp/` directory
3. Try transforming code with various RegExp features using different target environments to verify correct transformations
2024-09-05 11:04:45 +00:00
rzvxa
ccc8a27e4f refactor(ast, ast_tools): use full method path for generated derives trait calls. (#5462)
As of now if we remove the implementation of a trait for a type and implement the method on that type directly it wouldn't break while it isn't the original trait anymore so that method might do something entirely different.
This change is more explicit on trait calls so we hit compile errors on these kinds of changes.
2024-09-05 05:36:50 +00:00
rzvxa
90facd3657 feat(ast): add ContentHash trait; remove noop Hash implementation from Span (#5451)
closes #5283

Also removes the noop Hash implementation on `Span` in favor of a real implementation.
2024-09-05 07:20:04 +03:30
overlookmotel
cba93f52d0 feat(ast)!: add ThisExpression variants to JSXElementName and JSXMemberExpressionObject (#5466)
Close #5352.

Add to AST:

* `JSXElementName::ThisExpression` (`<this>`)
* `JSXMemberExpressionObject::ThisExpression` (`<this.foo>`, `<this.foo.bar>`)
2024-09-05 02:06:20 +00:00
Dunqing
d8b9909bd8 fix(semantic): IdentifierReference within TSPropertySignature cannot reference type-only import binding (#5441)
close: #5435

The behavior of `IdentifierReference` in `TSPropertySignature` is the same as in `TSTypeQuery`, both allow only reference value bindings and type-only import bindings.

I still use `ReferenceFlags::TSTypeQuery` here because I want to avoid producing many changes unrelated to the bug in this PR. I will refactor it in the follow-up PR soon
2024-09-05 01:50:18 +00:00
DonIsaac
0f50b1ed6d feat(semantic): check for initializers in ambient VariableDeclarations (#5463) 2024-09-05 01:33:11 +00:00
DonIsaac
62f7fff88f feat(semantic): check for non-declared, non-abstract object accessors without bodies (#5461) 2024-09-05 01:33:10 +00:00
DonIsaac
540714393a feat(semantic): check for non-declared, non-abstract class accessors without bodies (#5460)
This should be causing more negative tests to fail than it actually is. This is
because our typescript coverage tests use the "declarations" option to change
the source type to `.d.ts`, which is incorrect. This setting enables `.d.ts`
emits, it does not mean that input files should be treated as `.d.ts`
themselves.
2024-09-05 01:33:09 +00:00
DonIsaac
052e94c94e feat(semantic): check for parameter properties in constructor overloads (#5459)
Adds checks for
```
A parameter property is only allowed in a constructor implementation.ts(2369)
```
2024-09-05 01:33:07 +00:00
Boshen
9c937e06e8 fix(benchmark): do not measure initialization of transformer options (#5442)
relates #5267
2024-09-04 14:52:21 +00:00
Boshen
10279f55d9 feat(parser): add syntax error for hyphen in JSXMemberExpression <Foo.bar-baz /> (#5440)
closes #5355
2024-09-04 14:09:06 +00:00
overlookmotel
d9d7e7c596 refactor(ast): remove IdentifierName from TSThisParameter (#5327)
`TSThisParameter` does not need to include an `IdentifierName` which is always "this". Just storing the `Span` is sufficient.
2024-09-04 12:46:53 +00:00
rzvxa
23285f431d feat(ast): add ContentEq trait. (#5427)
Part of #5283
2024-09-04 11:53:50 +00:00
Dunqing
0617249716 fix(transformer/nullish-coalescing-operator): incorrect reference flags (#5408)
Fixes an obvious problem
2024-09-03 15:29:07 +00:00
overlookmotel
cfe54974f1 fix(transformer): do not create double reference in JSX transform (#5414)
Follow on after #5358. Don't create a new `IdentifierReference` with a new `ReferenceId` when we already have one which is correctly resolved.
2024-09-03 15:06:07 +00:00
overlookmotel
b9ef357868 test(transformer): add tests for nested JSX this member expressions in arrow function transform (#5413)
Follow-up after #5356. Handle nested JSX member expressions with `this` as base object in arrow functions transform (e.g. `<this.foo.bar />`).
2024-09-03 15:06:06 +00:00
Dunqing
0eb32a6770 fix(traverse): invalid variable name generated by generate_uid_based_on_node (#5407)
close: #5371
2024-09-03 12:13:30 +00:00
dalaoshu
4473779074
feat(linter/node): implement no-exports-assign (#5370) 2024-09-03 07:53:14 -04:00
Boshen
0a5780d328
ci: fix broken benchmark (#5424) 2024-09-03 18:21:39 +08:00
rzvxa
59abf27d95 feat(ast, parser): add oxc_regular_expression types to the parser and AST. (#5256)
closes #5060
2024-09-03 02:36:37 +00:00
rzvxa
68a1c01f4e feat(ast_tools): add dedicated Derive trait. (#5278)
In an effort toward the implementation of #5256, this PR allows us to have a separately generated "derive" file for each crate.
This also eliminates a bunch of boilerplate when writing new "derive" generators and generally makes it more approachable.
2024-09-03 02:36:36 +00:00
Dunqing
0abfc5049f feat(transformer/typescript): support rewrite_import_extensions option (#5399)
close: #5395

Babel only supports `rewrite`, we also support `remove`
2024-09-03 01:57:42 +00:00
overlookmotel
be4642fc02 feat(semantic): transform checker check child scope IDs (#5410)
Transform checker check child scope IDs. If we have to track child scope IDs, we should make sure they're correct!
2024-09-03 00:57:13 +00:00
Dunqing
1aa49af010 feat(ast)!: remove JSXMemberExpressionObject::Identifier variant (#5358)
close: #5353

`JSXMemberExpressionObject::Identifier` is dead code.
2024-09-02 18:35:39 +00:00
Dunqing
94ff94cd34 fix(transformer/arrow-functions): reaches unreachable when <this.foo> is inside an arrow function (#5356)
Fixes: https://github.com/oxc-project/oxc/issues/5353#issuecomment-2321792915
2024-09-02 18:06:08 +00:00
leaysgur
c7e61a1391 chore(prettier): Update conformance tests to Prettier v3.3.3 (#5394)
- v3.3.3 is latest released version
- Test file name was changed from v3.3.x
  - https://github.com/prettier/prettier/pull/16244
2024-09-02 10:32:17 +00:00
renovate[bot]
8cf9cf9919
chore(deps): update npm packages (#5392)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [axios](https://axios-http.com)
([source](https://togithub.com/axios/axios)) | [`1.7.5` ->
`1.7.7`](https://renovatebot.com/diffs/npm/axios/1.7.5/1.7.7) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/axios/1.7.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/axios/1.7.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/axios/1.7.5/1.7.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/axios/1.7.5/1.7.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| [pnpm](https://pnpm.io) ([source](https://togithub.com/pnpm/pnpm)) |
[`9.8.0` -> `9.9.0`](https://renovatebot.com/diffs/npm/pnpm/9.8.0/9.9.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/pnpm/9.9.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/pnpm/9.9.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/pnpm/9.8.0/9.9.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/pnpm/9.8.0/9.9.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>axios/axios (axios)</summary>

###
[`v1.7.7`](https://togithub.com/axios/axios/blob/HEAD/CHANGELOG.md#177-2024-08-31)

[Compare
Source](https://togithub.com/axios/axios/compare/v1.7.6...v1.7.7)

##### Bug Fixes

- **fetch:** fix stream handling in Safari by fallback to using a stream
reader instead of an async iterator;
([#&#8203;6584](https://togithub.com/axios/axios/issues/6584))
([d198085](d1980854fe))
- **http:** fixed support for IPv6 literal strings in url
([#&#8203;5731](https://togithub.com/axios/axios/issues/5731))
([364993f](364993f0d8))

##### Contributors to this release

- <img
src="https://avatars.githubusercontent.com/u/10539109?v&#x3D;4&amp;s&#x3D;18"
alt="avatar" width="18"/> [Rishi556](https://togithub.com/Rishi556
"+39/-1 (#&#8203;5731 )")
- <img
src="https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;18"
alt="avatar" width="18"/> [Dmitriy
Mozgovoy](https://togithub.com/DigitalBrainJS "+27/-7 (#&#8203;6584 )")

###
[`v1.7.6`](https://togithub.com/axios/axios/blob/HEAD/CHANGELOG.md#176-2024-08-30)

[Compare
Source](https://togithub.com/axios/axios/compare/v1.7.5...v1.7.6)

##### Bug Fixes

- **fetch:** fix content length calculation for FormData payload;
([#&#8203;6524](https://togithub.com/axios/axios/issues/6524))
([085f568](085f56861a))
- **fetch:** optimize signals composing logic;
([#&#8203;6582](https://togithub.com/axios/axios/issues/6582))
([df9889b](df9889b83c))

##### Contributors to this release

- <img
src="https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;18"
alt="avatar" width="18"/> [Dmitriy
Mozgovoy](https://togithub.com/DigitalBrainJS "+98/-46 (#&#8203;6582 )")
- <img
src="https://avatars.githubusercontent.com/u/3534453?v&#x3D;4&amp;s&#x3D;18"
alt="avatar" width="18"/> [Jacques
Germishuys](https://togithub.com/jacquesg "+5/-1 (#&#8203;6524 )")
- <img
src="https://avatars.githubusercontent.com/u/53894505?v&#x3D;4&amp;s&#x3D;18"
alt="avatar" width="18"/> [kuroino721](https://togithub.com/kuroino721
"+3/-1 (#&#8203;6575 )")

</details>

<details>
<summary>pnpm/pnpm (pnpm)</summary>

### [`v9.9.0`](https://togithub.com/pnpm/pnpm/compare/v9.8.0...v9.9.0)

[Compare Source](https://togithub.com/pnpm/pnpm/compare/v9.8.0...v9.9.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 10am on monday" in timezone
Asia/Shanghai, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

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

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- 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:eyJjcmVhdGVkSW5WZXIiOiIzOC41Ni4wIiwidXBkYXRlZEluVmVyIjoiMzguNTYuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-01 19:31:44 +00:00
Dunqing
35f03db464 fix(transformer): ArrowfunctionExpression's expression is true but has more than one body statement (#5366)
close: #5363

We insert the new statement here, but it's broken if it a `() => x;`, we need to transform it to `function () { return x }`

8d565d5b23/crates/oxc_transformer/src/es2020/nullish_coalescing_operator.rs (L59-L76)

I don't where we should put the fallback logic, It's useful for all plugins. We had already done the same thing in the react refresh plugin.

8d565d5b23/crates/oxc_transformer/src/react/refresh.rs (L578-L605)
2024-08-31 14:49:58 +00:00
Boshen
e75e0f1465 chore: update test262 / babel / typescript submodules (#5369)
closes #5215
2024-08-31 12:28:25 +00:00
overlookmotel
8a178075b7 fix(parser): treat JSX element tags starting with _ or $ as IdentifierReferences (#5343)
#5223 added a new variant `JSXElementName::IdentifierReference` for JSX identifiers which are treated as references (e.g. `<Foo>`) as opposed to `JSXElementName::Identifier` which is for lowercase (e.g. `<div>`).

But we were incorrectly categorizing identifiers beginning with `_` or `$` - these should also be treated as references.

(as discussed in https://github.com/oxc-project/oxc/pull/5339#issuecomment-2321037779)
2024-08-30 14:47:06 +00:00
overlookmotel
0de844d23c refactor(transformer): remove unnecessary code from JSX transform (#5339)
Follow-on after #5223.

JSX identifiers which start with a capital letter are now `JSXElementName::IdentifierReference`s, so no need to check for capitalized `JSXElementName::Identifier`s.
2024-08-30 12:17:08 +00:00
Dunqing
32f730085c feat(ast)!: add JSXElementName::IdentifierReference and JSXMemberExpressionObject::IdentifierReference (#5223)
close: #3528

part of #4746
2024-08-30 11:11:04 +00:00
Dunqing
783a31beb6 ci(benchmark/transformer): enable all > es6 plugins (#5324)
There is a bug in the react refresh plugin, I will fix it in follow-up PR and enable the plugin in the benchmark
2024-08-30 09:30:17 +00:00
Boshen
3ae94b8801
refactor(semantic): change build_module_record to accept &Path instead of PathBuf 2024-08-30 12:24:49 +08:00
DonIsaac
cd63336c7e refactor(diagnostic): change how diagnostic codes are rendered (#5317)
Preparation for upstack PRs. Graphical reporter diagnostics look exactly the same. This does, however, change `to_string()` to only show diagnostic messages, and not error codes + messages.
2024-08-29 05:50:03 +00:00
Dunqing
3acb3f6461 fix(transformer/react): mismatch output caused by incorrect transformation ordering (#5255)
close: #4767
2024-08-29 00:38:02 +00:00
DonIsaac
270fc53401 chore(bench): include fixers in linter benchmarks (#5307)
Fixing code is an important part of linter logic. We want to make sure fixers for each rule, and the code responsible for applying those fixes, are included in benchmarks.

As it currently stands, fixer closures are applied regardless of whether the user wants fixers to be applied. However, this is an implementation detail and is subject to change. I  also want to bench the performance of `Fixer`.
2024-08-28 23:19:43 +00:00
magic-akari
08dc0adeab feat(transformer): add object-spread plugin (#3133) 2024-08-28 15:57:20 +00:00
Boshen
8d6b05ca01 fix(transformer): class property with typescript value should not be removed (#5298) 2024-08-28 13:53:41 +00:00
Dunqing
292d162b23 feat(codegen): print missing fields for AccessorProperty (#5291)
Found in https://github.com/oxc-project/monitor-oxc/actions/runs/10592050362/job/29350666018
2024-08-28 08:42:39 +00:00
Dunqing
5754c89b5e fix(transformer/typescript): remove accessibility from AccessorProperty (#5292)
Regression by #5290
2024-08-28 08:42:38 +00:00
Dunqing
550574982f feat(ast): add accessibility field to AccessorProperty (#5290) 2024-08-28 08:42:37 +00:00
Kevin Deng 三咲智子
234a24c14d
fix(ast)!: merge UsingDeclaration into VariableDeclaration (#5270)
relate #2854
2024-08-28 11:26:05 +08:00
leaysgur
15b87adb05 chore(regular_expression): Extract diagnostics (#5287)
- Extract `Diagnostic::error()`s to separate file
- Align error message prefix
2024-08-28 03:19:29 +00:00
Boshen
e6fd52e2a6 fix(parser): change unterminated regex error to be non-recoverable (#5285)
closes #5257
2024-08-28 01:57:31 +00:00
overlookmotel
10861096e0 refactor(semantic): transform checker do not output spans in errors (#5260)
Transform checker don't output spans in errors. They're inaccurate because (a) spans refer to the source text pre-transform, and (b) most errors relate to scopes/symbols/references newly created in transformer, which have no span.
2024-08-27 11:58:21 +00:00
overlookmotel
af5713e411 refactor(semantic): transform checker continue checks if missing IDs (#5259)
Transform checker don't bail out if some IDs missing from AST. Continue to check for other problems.

Also simplify iterating over pairs of IDs.
2024-08-27 11:58:20 +00:00
overlookmotel
943454fa5e refactor(semantic): update transform checker for no conditional scopes (#5252)
All scopes are now unconditional (#5008). Update transform checker to reflect this.
2024-08-27 08:57:15 +00:00
overlookmotel
b479afdafc ci: transformer benchmark measure transformer itself only (#5193)
Transformer benchmark measure only the transformer itself. Parse, generate `Semantic`, and drop `Semantic` outside of the measured section.

This should:

1. Give us greater visibility of how changes to transformer affect its performance.
2. Reduce variance in transformer benchmarks, since they will no longer include the variance introduced by `SemanticBuilder`.

Not ready to merge yet. We should first add an "end to end" benchmark testing the entire compilation process (parse - semantic - transform - minify - codegen).

This PR depends on https://github.com/Boshen/criterion2.rs/pull/49. This PR currently makes Oxc's dependency on `criterion2` a git dependency on that PR's branch. That can be changed once the upstream PR is merged.
2024-08-27 01:53:27 +00:00
Boshen
a17cf33dc3 refactor(semantic): remove ScopeTree::child_ids (#5232)
closes https://github.com/oxc-project/oxc/issues/5244
2024-08-27 01:49:47 +00:00
overlookmotel
7c4f009521
refactor(ci): include drop in semantic benchmark (#5245)
Include dropping `Semantic` in semantic benchmark measure.

If you create a `Semantic`, you have to drop it, so the time it takes to
drop is part of the cost of using this API, and we should be working to
reduce it. Therefore I think it should be included in the benchmark.

It'll be interesting to see what effect a PR like #5232 which removes a
bunch of `Vec`s from `Semantic` has on the drop time.
2024-08-27 09:30:52 +08:00
leaysgur
1686920e23 fix(parser): Span for invalid regex flags (#5225)
### Before
```
  x Flag u is mentioned twice in regular expression literal
   ,-[1:20]
 1 | const a = /\2(.)/uuxig;
   :                    ^
 2 | debugger;
   `----

  x Unexpected flag x in regular expression literal
   ,-[1:21]
 1 | const a = /\2(.)/uuxig;
   :                     ^
 2 | debugger;
   `----
```

### After
```
  x Flag u is mentioned twice in regular expression literal
   ,-[1:19]
 1 | const a = /\2(.)/uuxig;
   :                   ^
 2 | debugger;
   `----

  x Unexpected flag x in regular expression literal
   ,-[1:20]
 1 | const a = /\2(.)/uuxig;
   :                    ^
 2 | debugger;
   `----
```
2024-08-26 10:24:47 +00:00
Boshen
2fbc283e03
chore: bump rustc to v1.80.1 (#5211) 2024-08-26 13:11:29 +08:00
Boshen
293668bebd
chore(tasks): parse regular expression in parser benchmark (#5212) 2024-08-26 13:11:09 +08:00
renovate[bot]
67c7802a58
chore(deps): update dependency axios to v1.7.5 (#5205)
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [axios](https://axios-http.com)
([source](https://togithub.com/axios/axios)) | [`1.7.4` ->
`1.7.5`](https://renovatebot.com/diffs/npm/axios/1.7.4/1.7.5) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/axios/1.7.5?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/axios/1.7.5?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/axios/1.7.4/1.7.5?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/axios/1.7.4/1.7.5?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>axios/axios (axios)</summary>

###
[`v1.7.5`](https://togithub.com/axios/axios/blob/HEAD/CHANGELOG.md#175-2024-08-23)

[Compare
Source](https://togithub.com/axios/axios/compare/v1.7.4...v1.7.5)

##### Bug Fixes

- **adapter:** fix undefined reference to hasBrowserEnv
([#&#8203;6572](https://togithub.com/axios/axios/issues/6572))
([7004707](7004707c41))
- **core:** add the missed implementation of AxiosError#status property;
([#&#8203;6573](https://togithub.com/axios/axios/issues/6573))
([6700a8a](6700a8adac))
- **core:** fix `ReferenceError: navigator is not defined` for custom
environments;
([#&#8203;6567](https://togithub.com/axios/axios/issues/6567))
([fed1a4b](fed1a4b2d7))
- **fetch:** fix credentials handling in Cloudflare workers
([#&#8203;6533](https://togithub.com/axios/axios/issues/6533))
([550d885](550d885eb9))

##### Contributors to this release

- <img
src="https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;18"
alt="avatar" width="18"/> [Dmitriy
Mozgovoy](https://togithub.com/DigitalBrainJS "+187/-83 (#&#8203;6573
#&#8203;6567 #&#8203;6566 #&#8203;6564 #&#8203;6563 #&#8203;6557
#&#8203;6556 #&#8203;6555 #&#8203;6554 #&#8203;6552 )")
- <img
src="https://avatars.githubusercontent.com/u/2495809?v&#x3D;4&amp;s&#x3D;18"
alt="avatar" width="18"/> [Antonin Bas](https://togithub.com/antoninbas
"+6/-6 (#&#8203;6572 )")
- <img
src="https://avatars.githubusercontent.com/u/5406212?v&#x3D;4&amp;s&#x3D;18"
alt="avatar" width="18"/> [Hans Otto
Wirtz](https://togithub.com/hansottowirtz "+4/-1 (#&#8203;6533 )")

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 10am on monday" in timezone
Asia/Shanghai, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, 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://www.mend.io/free-developer-tools/renovate/). View the
[repository job log](https://developer.mend.io/github/oxc-project/oxc).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4yNi4xIiwidXBkYXRlZEluVmVyIjoiMzguMjYuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-25 18:55:22 +00:00
Kevin Deng 三咲智子
bf49f339d0
chore: pin pnpm version & upgrade lockfile version (#5200) 2024-08-25 22:57:33 +08:00
Dunqing
f8bb0222b3 fix(transformer/arrow-functions): remove SymbolFlags::ArrowFunction (#5190)
`ArrowFunction` has been transforming to `FunctionExpression`, So we should remove `SymbolFlags::ArrowFunction`
2024-08-25 10:27:00 +00:00
Dunqing
d9ba5ad022 fix(transformer/arrow-functions): correct scope for _this (#5189)
The `_this` will eventually be inserted into a `Program` or `Function`. So we have to go up to the corresponding `scope_id`
2024-08-25 10:26:59 +00:00
Dunqing
056c6679ec feat(transformer/arrow-functions): the output that uses this inside blocks doesn't match Babel (#5188)
Fixes 666282a13b/crates/oxc_transformer/src/es2015/arrow_functions.rs (L35-L62)
2024-08-25 10:26:57 +00:00
overlookmotel
666282a13b refactor(ci): remove extraneous doc comment (#5185)
Replace doc comment with plain comment.
2024-08-25 07:39:38 +00:00
DonIsaac
7dfd51a62b feat(parser): report class properties that are both definite and optional (#5181) 2024-08-25 01:02:49 +00:00
DonIsaac
a563968386 feat(parser): report errors on optional accessor properties (#5180) 2024-08-25 01:02:49 +00:00
DonIsaac
c2fa72571f feat(ast,parser): parse TSTypeAnnotations on AccessorProperty (#5179)
Closes #5177

While making this, I noticed an uncaught parse error for accessors: accessors cannot be optional. I'll add a fix for this in an up-stack PR.
2024-08-25 01:02:48 +00:00
Boshen
01c0c3e4b2 feat(transformer): add remaining options to transformer options (#5169)
closes #5168
2024-08-24 14:52:03 +00:00
Boshen
c96609151e
fix(coverage): fix cases where source_type is incorrectly set to script 2024-08-24 14:40:05 +08:00
Boshen
e4ca3d3901
chore(coverage): ignore annex-b/disabled tests 2024-08-24 14:20:06 +08:00
Boshen
12c21b2bfd
fix(coverage): do not run generated test cases when filter is applied 2024-08-24 14:03:54 +08:00
overlookmotel
eb71a32ee7 refactor(ci): transform conformance snapshot include when output mismatch (#5135)
Include "Output mismatch" in transform conformance snapshots when a test also fails due to scopes/symbols mismatches.

At present, many of the tests are failing on scopes/symbols mismatches, so it's hard to see from snapshots which also have an output mismatch. In particular, when working to fix scope mismatches, it's hard to notice if changes you make cause the output to be wrong. These extra messages make that visible.
2024-08-24 04:52:14 +00:00
overlookmotel
be42b1c76b fix(ci): transform conformance do not skip any errors (#5134)
Snapshots generated by transform conformance were missing a few errors (e.g. `declarations/const-enum/input.ts` at bottom of diff). Make sure all errors fail the test.
2024-08-24 04:52:11 +00:00
Boshen
d5a494023e refactor(semantic): rewrite handling of label statement errors (#5138)
This reverts the previous changes to handling labels so that all tests can pass.

This passes all false postivies found in `monitor-oxc` (node_modules/flow-parser/flow_parser.js)

As it turns out this requires less code and produces better diagnostics.
2024-08-24 02:37:49 +00:00
overlookmotel
f63b568c48 refactor(ast): remove #[non_exhaustive] attr from AstBuilder (#5130)
Partially revert #4925. That PR's description gave no explanation of why this attribute is desirable.
2024-08-23 23:04:28 +00:00
Dunqing
47e69a8c94 fix(transformer-optional-catch-binding): the unused binding is not in the correct scope (#5066)
Blocked by #5008

In the SemanticBuilder, we insert all CatchClause parameters in the BlockStatement scope, a child-scope of CatchClause

858f510d59/crates/oxc_semantic/src/builder.rs (L709-L718)

So we should do the same thing in this plugin, but because CatchClause has no parameters, SemanticBuilder doesn't create scope for `CatchClause`. This cause we cannot find the `BlockStatement` scope_id.

This PR has changed to the correct logic. Just to wait #5008 solved
2024-08-23 13:02:53 +00:00
overlookmotel
8650d3e773 refactor(ast_tools): remove support for #[scope(if(...))] attr (#5113)
There are no longer any nodes with conditional scopes. Remove support for `#[scope(if(...))]` attr from `ast_tools` - it's no longer needed.
2024-08-23 09:28:17 +00:00
overlookmotel
c100826b42 refactor(semantic)!: always create a scope for for statements (#5110)
Part of #5008. Make scopes for `ForStatement`, `ForInStatement` and `ForOfStatement` unconditional. i.e. always create a scope, even if there is no lexical binding (e.g. `for (i of a) {}`).
2024-08-23 09:28:13 +00:00
overlookmotel
d304d6f973 refactor(semantic)!: always create a scope for CatchClause (#5109)
Part of #5008. Make scope for `CatchClause` unconditional. i.e. always create a scope, even if there is no catch parameter.
2024-08-23 08:30:27 +00:00
overlookmotel
91343913ca fix(semantic): transform checker check unresolved references (#5096)
Transform checker check root unresolved references.

The transform checker is now checking pretty much everything it can.

Only fields of `ScopeTree` and `SymbolTable` that it's *not* checking are those which contain `AstNodeId`s, because transformer does not create node IDs at present:

* `ScopeTree::node_ids`
* `SymbolTable::declarations`
* `Reference::node_id`

Checking also only proceeds in "from AST" direction.

i.e. for each `SymbolId` which appears in the AST, we check everything about that symbol. But we *don't* go through all the "rows" in `SymbolTable` and check if there are any extra symbols in the table which aren't in the AST.

Presumably transformer will leave a lot of old symbols lying around in `SymbolTable` (ditto scopes and references). We'd need to add `ScopeFlags::Deleted`, `SymbolFlags::Deleted` and `ReferenceFlags::Deleted` for the transformer to be able to "delete" existing symbols.
2024-08-23 07:52:30 +00:00
Boshen
56cc4818b5
chore(website): remove textlint annotation
the website no longer uses textlint
2024-08-23 15:50:52 +08:00
overlookmotel
c57e078c71 fix(semantic): transform checker check unbound references (#5093) 2024-08-23 08:37:48 +01:00
Boshen
aa7718ab7b feat(transform_conformance): show printed output alongside with errors (#5105)
closes #5098

```
cargo run -p oxc_transform_conformance -- --filter logical-assignment/arrow-functions-transform/input.js

Input:

var a;
a ||= () => {};
a &&= () => {};
a ??= () => {};

Expected:

var a;
a || (a = () => {});
a && (a = () => {});
a ?? (a = () => {});

Transformed:

var a;
a || (a = () => {});
a && (a = () => {});
a ?? (a = () => {});

Errors:

  x Symbol reference IDs mismatch:
  | after transform: SymbolId(0): [ReferenceId(0), ReferenceId(1),
  | ReferenceId(2), ReferenceId(3), ReferenceId(4), ReferenceId(5),
  | ReferenceId(6), ReferenceId(7), ReferenceId(8)]
  | rebuilt        : SymbolId(0): [ReferenceId(0), ReferenceId(1),
  | ReferenceId(2), ReferenceId(3), ReferenceId(4), ReferenceId(5)]

  x Reference flags mismatch:
  | after transform: ReferenceId(4): ReferenceFlags(Write)
  | rebuilt        : ReferenceId(1): ReferenceFlags(Read | Write)

  x Reference flags mismatch:
  | after transform: ReferenceId(6): ReferenceFlags(Write)
  | rebuilt        : ReferenceId(3): ReferenceFlags(Read | Write)

  x Reference flags mismatch:
  | after transform: ReferenceId(8): ReferenceFlags(Write)
  | rebuilt        : ReferenceId(5): ReferenceFlags(Read | Write)

Passed: true
```
2024-08-23 04:00:45 +00:00
heygsc
ad2be97078
fix(semantic): incorrect semantic check for label has same name (#5041)
fix: #5036

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-08-23 10:36:12 +08:00
overlookmotel
d5de97d6fe fix(semantic): transform checker check reference flags (#5092) 2024-08-23 00:21:21 +00:00
overlookmotel
9da6a21e40 refactor(semantic): rename transform checker output for reference symbol mismatches (#5091) 2024-08-22 23:40:27 +00:00
overlookmotel
90c74ee449 fix(semantic): transform checker check reference symbol IDs (#5090)
Previously was checking that references point to symbols with same name, but not necessarily the same symbol (there could be 2 different symbols with same name).
2024-08-22 23:40:26 +00:00
overlookmotel
a8005b9914 fix(semantic): transform checker check symbol redeclarations (#5089) 2024-08-22 23:40:26 +00:00
overlookmotel
205bff7ea9 fix(semantic): transform checker check symbol references (#5088) 2024-08-22 23:40:25 +00:00
Boshen
4b49cf8ce4 feat(transformer): always pass in symbols and scopes (#5087)
We no longer need to build semantic data inside the transformer.

The caller should be responsible for handling semantic data and its
errors.

The best way to achieve this in via `CompilerInterface`.

closes #3565
2024-08-22 16:06:31 +00:00
overlookmotel
4a57086d79 fix(semantic): transform checker check symbol IDs (#5078) 2024-08-22 15:08:48 +00:00
overlookmotel
ea7d2163e3 fix(semantic): transform checker check symbol spans (#5076) 2024-08-22 15:08:47 +00:00
overlookmotel
1b6b27a6de fix(semantic): transform checker check symbol flags (#5074) 2024-08-22 15:08:45 +00:00
Boshen
6d87b0f1f2 fix(semantic): fix error message for duplicated label (#5071) 2024-08-22 12:30:04 +00:00
Dunqing
3b353321ad fix(transformer/logical-assignment-operators): fix semantic errors (#5047)
Fix semantic error caused by `clone_in` causing `reference_id` to not exist.

In this PR, I try to use `move_expression` as much as possible instead of `expr.clone_in`. But in some cases, we need to reuse the same expression in multiple places. I have added a `clone_expression` to workaround it

I felt a bit painful we missing a [clone_in_scope](https://github.com/oxc-project/oxc/issues/4804) API
2024-08-22 08:41:31 +00:00
Boshen
afe728a73a feat(parser): parse regular expression with regex parser (#4998)
Many false positives and incorrect errors. @leaysgur Enjoy 😁

Run `just conformance` to update the snapshot.
2024-08-22 03:09:55 +00:00
overlookmotel
05fff16d55 fix(semantic): transform checker compare binding symbol IDs (#5057) 2024-08-22 02:34:44 +00:00
overlookmotel
f187b71877 fix(semantic): transform checker compare scope children (#5056) 2024-08-22 02:34:44 +00:00
overlookmotel
b52c6a4269 fix(semantic): transform checker compare scope parents (#5055) 2024-08-22 02:34:43 +00:00
overlookmotel
da64014a6c fix(semantic): transform checker catch more scope flags mismatches (#5054)
There was a bug previously where scope flags were only checked if there was also a bindings mismatch.
2024-08-22 02:34:43 +00:00
overlookmotel
67d1a96391 fix(semantic): transform checker compare scope flags (#5052) 2024-08-22 02:34:41 +00:00
overlookmotel
ee7ac8b0b7 refactor(semantic): store all data in PostTransformChecker in transform checker (#5050)
Pure refactor of transform checker. Store all scope data in `PostTransformChecker` so it doesn't need to be passed around. `SemanticData` contains a full set of all semantic data for semantic pass, so we have 2 instances of it for 1. after transform and 2. rebuilt semantic.
2024-08-21 17:04:48 +00:00
overlookmotel
4e1f4abf89 refactor(semantic): add SemanticIds to transformer checker (#5048)
Transformer checker use `SemanticIds` to store collected IDs. `SemanticIds` only contains the IDs, without the `Vec` of errors which is only used temporarily.
2024-08-21 15:49:07 +00:00
overlookmotel
8cded08eb8 refactor(semantic): rename error labels in transformer checker snapshots (#5044)
Rename labels in transformer checker snapshots "after transform" vs "rebuilt".
2024-08-21 14:33:19 +00:00
overlookmotel
863b9cb921 fix(semantic): transform checker handle conditional scopes (#5040)
Some scopes are conditional e.g. `ForStatement` only gets a scope when initializer has a binding (`for (let i = 0; ...)` vs `for (i = 0; ...)`).

Make transform compare this between post-transform and fresh semantics.
2024-08-21 12:07:14 +00:00
overlookmotel
586e15c814 refactor(semantic): reformat transform checker errors (#5039)
Reformat transform checker error output - shorter and consistent capitalization.
2024-08-21 12:07:11 +00:00
Boshen
1bd9365bd0 fix(coverage): correctly check semantic data after transform (#5035)
closes #4999
2024-08-21 09:35:04 +00:00
overlookmotel
c4c08a7433 refactor(ast)!: rename IdentifierReference::reference_flags field (#5024)
Part of #4991.
2024-08-21 00:19:57 +00:00
overlookmotel
d262a58eb5 refactor(syntax)!: rename ReferenceFlag to ReferenceFlags (#5023)
Part of #4991.
2024-08-21 00:19:56 +00:00
Boshen
b4407c4e9a
refactor(oxc,mangler): oxc crate add mangler; mangler use options API 2024-08-20 22:58:59 +08:00
Boshen
cd9cf5efd8
refactor(oxc): remove remove_whitespace 2024-08-20 18:27:59 +08:00
Boshen
1f6b107339 chore(coverage): ignore test262 stage3 json-modules (#5002)
stage 3 https://github.com/tc39/proposal-json-modules

Ignoring due to https://github.com/tc39/proposal-json-modules/issues/27
2024-08-20 08:50:27 +00:00
Boshen
ce4d4698b4 feat(codegen)!: remove const generic MINIFY (#5001)
This is a premature optimization, makes the code complicated, and bloats the final binary size.

The minify option is moved to `CodegenOptions`
2024-08-20 08:13:27 +00:00
Boshen
b2ff2df5af refactor(parser)!: remove builder pattern from Parser struct (#5000)
part of #4455

use `with_options(ParseOptions { ..ParseOptions::default() })` API instead.
2024-08-20 07:40:25 +00:00
Burlin
f88970bc79
refactor(ast)!: Change order of fields in CallExpression (#4859)
fix: #4821

---------

Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-08-20 09:47:12 +08:00
Dunqing
f51d3f9169 feat(transformer/nullish-coalescing-operator): handles nullish coalescing expression in the FormalParamter (#4975)
### What I did in this PR
1. Replace `self.clone_identifier_reference` with `ctx.clone_identifier.reference`
2. Remove the usage of `ast.copy`
3. Handle below example correctly

### Example

```js
// Input
var foo = object.foo ?? "default";

// Output
var _object$foo;
var foo =
(_object$foo = object.foo) !== null && _object$foo !== void 0
  ? _object$foo
  : "default";
```
2024-08-20 01:06:37 +00:00
Dunqing
f794870dd4 feat(transformer/nullish-coalescing-operator): generate the correct binding name (#4974)
match Babel's [implementation](440fe41333/packages/babel-plugin-transform-nullish-coalescing-operator/src/index.ts (L40))
2024-08-20 01:06:36 +00:00
DonIsaac
7c6bae2d65 feat(website): add link to rule source on docs page (#4995)
![image](https://github.com/user-attachments/assets/70e02c73-5d28-443e-91b0-f32d0623a1ca)
2024-08-19 20:40:14 +00:00
Don Isaac
a0effab160
feat(linter): support more flexible config.globals values (#4990)
Support `"readable", `"writable"`, and boolean values for `GlobalValue`.

I also enhanced the documentation for `OxcGlobals`

## Screenshot
<img width="797" alt="image"
src="https://github.com/user-attachments/assets/8f76de4c-4ae8-44d1-9be1-720fc3c7e0ec">
2024-08-19 16:23:47 -04:00
Don Isaac
4436774e8c
fix(website): sanitize JSON in section docs (#4989) 2024-08-19 16:23:31 -04:00
Boshen
64ace42566 feat(transform_conformance): show transform conformance errors (#4976) 2024-08-19 09:01:34 +00:00
Boshen
4fdf26dac8 refactor(transform_conformance): add driver (#4969) 2024-08-19 07:27:39 +00:00
Boshen
3f6014a042 chore(semantic): add PostTransformChecker (#4967) 2024-08-19 05:38:27 +00:00
DonIsaac
96422b6489 refactor(ast): make AstBuilder non-exhaustive (#4925) 2024-08-19 05:32:30 +00:00
Boshen
6800e694e3
feat(oxc): add Compiler and CompilerInterface (#4954)
This PR adds a full compiler pipeline to the `oxc` crate, to stop us
from implementing the same pipeline over and over again.

relates #4455
2024-08-19 10:20:05 +08:00
renovate[bot]
ef057e7545
chore(deps): update npm packages (#4958)
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [axios](https://axios-http.com)
([source](https://togithub.com/axios/axios)) | [`1.7.3` ->
`1.7.4`](https://renovatebot.com/diffs/npm/axios/1.7.3/1.7.4) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/axios/1.7.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/axios/1.7.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/axios/1.7.3/1.7.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/axios/1.7.3/1.7.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| [pnpm](https://pnpm.io) ([source](https://togithub.com/pnpm/pnpm)) |
[`9.7.0` -> `9.7.1`](https://renovatebot.com/diffs/npm/pnpm/9.7.0/9.7.1)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/pnpm/9.7.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/pnpm/9.7.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/pnpm/9.7.0/9.7.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/pnpm/9.7.0/9.7.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>axios/axios (axios)</summary>

###
[`v1.7.4`](https://togithub.com/axios/axios/blob/HEAD/CHANGELOG.md#174-2024-08-13)

[Compare
Source](https://togithub.com/axios/axios/compare/v1.7.3...v1.7.4)

##### Bug Fixes

- **sec:** CVE-2024-39338
([#&#8203;6539](https://togithub.com/axios/axios/issues/6539))
([#&#8203;6543](https://togithub.com/axios/axios/issues/6543))
([6b6b605](6b6b605eaf))
- **sec:** disregard protocol-relative URL to remediate SSRF
([#&#8203;6539](https://togithub.com/axios/axios/issues/6539))
([07a661a](07a661a2a6))

##### Contributors to this release

- <img
src="https://avatars.githubusercontent.com/u/31389480?v&#x3D;4&amp;s&#x3D;18"
alt="avatar" width="18"/> [Lev
Pachmanov](https://togithub.com/levpachmanov "+47/-11 (#&#8203;6543 )")
- <img
src="https://avatars.githubusercontent.com/u/41283691?v&#x3D;4&amp;s&#x3D;18"
alt="avatar" width="18"/> [Đỗ Trọng Hải](https://togithub.com/hainenber
"+49/-4 (#&#8203;6539 )")

</details>

<details>
<summary>pnpm/pnpm (pnpm)</summary>

### [`v9.7.1`](https://togithub.com/pnpm/pnpm/compare/v9.7.0...v9.7.1)

[Compare Source](https://togithub.com/pnpm/pnpm/compare/v9.7.0...v9.7.1)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 10am on monday" in timezone
Asia/Shanghai, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions) if
that's undesired.

---

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

---

This PR was generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View the
[repository job log](https://developer.mend.io/github/oxc-project/oxc).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4yNi4xIiwidXBkYXRlZEluVmVyIjoiMzguMjYuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-18 23:07:20 +00:00
Boshen
c7a86865f3
fix(coverage): handle transformer errors 2024-08-18 22:19:58 +08:00
Boshen
873d502993
refactor(coverage): use the oxc crate 2024-08-17 22:40:08 +08:00
Boshen
bea76f0f24
fix(coverage): fix babel cases 2024-08-17 11:22:00 +08:00
Boshen
81439403fd chore(coverage): print path relative to snapshot file (#4938)
Ctrl + click in terminal can open the file with this change.

I don't know about vscode, but maybe a plugin can help?

<img width="1399" alt="image" src="https://github.com/user-attachments/assets/9bb4609b-14e9-4df8-b5ee-cb96b72b2f7d">

<img width="1131" alt="image" src="https://github.com/user-attachments/assets/e0293693-f755-4b91-8712-bbd2a0e615cc">
2024-08-17 03:09:25 +00:00
Boshen
7ecf0efd40
chore(coverage): remove arrow functions plugin from semantic check 2024-08-16 19:12:17 +08:00
Boshen
61cdfef5c7
chore(coverage): remove quotes around path from snapshot files
to make it easier to triple click and copy the path
2024-08-16 16:03:50 +08:00
Boshen
c220730779 feat(coverage): check symbols and scopes after transformation (#4917)
closes https://github.com/oxc-project/oxc/issues/4790

@overlookmotel enjoy ... take a look at the snapshots and probably nothing else.

The snapshots are minimal right now, but it's already showing symbols from import specifiers are not being removed. We can iterate on the snapshot representation to aid debugging later.

I'll extend this to `transformer_conformance` and `oxc-monitor` in an up coming PR.
2024-08-16 07:05:11 +00:00
Dunqing
248a757b34 fix(transformer/typescript): typescript syntax within SimpleAssignmentTarget with MemberExpressions is not stripped (#4920)
close: #4870

I added the `move_identifier_reference` and `move_member_expression` methods used to take ownership in `ast_builder_impl`.  This way can let us get rid of `ast.copy`.

Another possible approach is to add `get_expression_owner` to `SimpleAssignmentTarget` and a `get_inner_expression_owner` method to `Expression`. And add an `into_xxxxx` method for `inherit_variants` macro

The implementation looks like this
```rs
let Some(expression) = self.get_expression_owner() else { return; }
match expr.get_inner_expression_owner() {
    Expression::Identifier(ident) => {
        *target = self.ctx.ast.simple_assignment_target_from_identifier_reference(ident);
    }
    inner_expr @ match_member_expression!(Expression) => {
        *target = SimpleAssignmentTarget::from(
            inner_expr.into_member_expression()
        );
    }
    _ => (),
}
```
2024-08-16 05:05:10 +00:00
DonIsaac
80d0d1f0c4 feat(semantic): check for invalid interface heritage clauses (#4928) 2024-08-16 02:30:09 +00:00
Dunqing
f1fcdde593 feat(transformer): support react fast refresh (#4587)
close: #3943

## Further improvements

There is a double visit here. We need to collect all react hooks calling in `Function` and `ArrowFunctionExpression`. If we want to remove this implementation, we may wait for #4188.

d797e595d2/crates/oxc_transformer/src/react/refresh.rs (L744-L947)

## Tests

All tests copy from https://github.com/facebook/react/blob/main/packages/react-refresh/src/__tests__/ReactFresh-test.js

There are still 4 tests that have not been passed

**1. refresh/can-handle-implicit-arrow-returns/input.jsx**

Related to #4767. transform correct, just output doesn't match the expected output

**2. refresh/registers-identifiers-used-in-jsx-at-definition-site/input.jsx**
**3. refresh/registers-identifiers-used-in-react-create-element-at-definition-site/input.jsx**

Blocked by #4746

**4. refresh/supports-typescript-namespace-syntax/input.tsx**

oxc transforms ts to js first, so probably we can ignore this case. If we really want to pass this test, we also need to turn off `TypeScript` plugin.

## What's next?

### Options:

1. Support transform `refresh_reg` and `refresh_sig` options to `MemberExpression`. Currently `import.meta.xxxx` still is an `Identifier`
2. Support `emit_full_signatures` option

### Other
NAPI, testing in `monitor-oxc`, etc..
2024-08-15 16:41:30 +00:00
rzvxa
47c9552ecf docs(ast, ast_macros, ast_tools): better documentation for Ast helper attributes. (#4856) 2024-08-15 11:32:36 +00:00
overlookmotel
90d0b2ba65 refactor(allocator, ast, span, ast_tools): use allocator as var name for Allocator (#4900)
We mostly use `allocator` as var name for an `Allocator`, but in some places used the shorter name `alloc`. Use `allocator` everywhere for consistency.
2024-08-15 10:49:11 +00:00
Dunqing
0d7912217a feat(transformer): support logical-assignment-operators plugin (#4890)
part of #4754

The implementation copy from the original implementation which removed in https://github.com/oxc-project/oxc/pull/2865.
2024-08-15 10:10:36 +00:00
Dunqing
ab1d08ccfb feat(transformer): support optional-catch-binding plugin (#4885)
part of #4754

The implementation copy from the original implementation which removed in https://github.com/oxc-project/oxc/pull/2865.
2024-08-15 10:10:34 +00:00
Dunqing
69da9fda3a feat(transformer): support nullish-coalescing-operator plugin (#4884)
The implementation copy from the original implementation which removed in https://github.com/oxc-project/oxc/pull/2865.
2024-08-15 10:10:33 +00:00
Dunqing
3a66e5843d feat(transformer): support exponentiation operator plugin (#4876)
The implementation copy from the original implementation which removed in https://github.com/oxc-project/oxc/pull/2865.
2024-08-15 10:10:32 +00:00
Boshen
5b14608a95
chore(tasks/website): do not run textlint nor prettier 2024-08-15 14:28:57 +08:00
Boshen
34aa93bda3 feat(coverage): add checker for correctness of semantic data (#4908)
Part of https://github.com/oxc-project/oxc/issues/4790
2024-08-15 04:46:07 +00:00
Boshen
117ae36775 refactor(coverage): add driver struct for adding common checks later (#4893) 2024-08-14 11:11:13 +00:00
Boshen
2afccd75fb
refactor(coverage): move tools into src/tools/ 2024-08-14 15:44:03 +08:00
mysteryven
4d28d037e6 feat(task/website): support render subschemas.all_of (#4800)
To solve unexpected snapshot update in #4742  : https://github.com/oxc-project/oxc/pull/4742/files#diff-4c1a03dc03cfd00f9eaecb5c66b61f4e57272c6262253f0dc82ea1b71223bac2
2024-08-14 06:12:03 +00:00
Boshen
a2269625cc fix(codegen): print TSNonNullExpression (#4869) 2024-08-13 08:47:07 +00:00
rzvxa
8e8fcd0584 refactor(ast_tools): rename oxc_ast_codegen to oxc_ast_tools. (#4846)
This PR renames the `oxc_ast_codegen` crate to `oxc_ast_tools`, It improves the readability and organization of the codebase by giving the crate a name that better reflects its purpose and contents.

It also improves the error message in CI.
2024-08-12 14:33:58 +00:00
Boshen
955a4b4479
docs(oxlint): improve cli doc regarding fix and -D all
closes #3944
2024-08-12 14:58:12 +08:00
renovate[bot]
7027cc7849
chore(deps): update pnpm to v9.7.0 (#4836)
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [pnpm](https://pnpm.io) ([source](https://togithub.com/pnpm/pnpm)) |
[`9.6.0` -> `9.7.0`](https://renovatebot.com/diffs/npm/pnpm/9.6.0/9.7.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/pnpm/9.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/pnpm/9.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/pnpm/9.6.0/9.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/pnpm/9.6.0/9.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>pnpm/pnpm (pnpm)</summary>

### [`v9.7.0`](https://togithub.com/pnpm/pnpm/releases/tag/v9.7.0): pnpm
9.7

[Compare Source](https://togithub.com/pnpm/pnpm/compare/v9.6.0...v9.7.0)

#### Minor Changes

- Added pnpm version management. If the
`manage-package-manager-versions` setting is set to `true`, pnpm will
switch to the version specified in the `packageManager` field of
`package.json` [#&#8203;8363](https://togithub.com/pnpm/pnpm/pull/8363).
This is the same field used by Corepack. Example:

    ```json
    {
      "packageManager": "pnpm@9.3.0"
    }
    ```

- Added the ability to apply patch to all versions
[#&#8203;8337](https://togithub.com/pnpm/pnpm/pull/8337).

If the key of `pnpm.patchedDependencies` is a package name without a
version (e.g. `pkg`), pnpm will attempt to apply the patch to all
versions of the package. Failures will be skipped. If there's only one
version of `pkg` installed, `pnpm patch pkg` and subsequent `pnpm
patch-commit $edit_dir` will create an entry named `pkg` in
`pnpm.patchedDependencies`. And pnpm will attempt to apply this patch to
other versions of `pkg` in the future.

- Change the default edit dir location when running `pnpm patch` from a
temporary directory to `node_modules/.pnpm_patches/pkg[@&#8203;version]`
to allow the code editor to open the edit dir in the same file tree as
the main project
[#&#8203;8379](https://togithub.com/pnpm/pnpm/issues/8379).

- Substitute environment variables in config keys
[#&#8203;6679](https://togithub.com/pnpm/pnpm/issues/6679).

#### Patch Changes

- `pnpm install` should run `node-gyp rebuild` if the project has a
`binding.gyp` file even if the project doesn't have an install script
[#&#8203;8293](https://togithub.com/pnpm/pnpm/issues/8293).
- Print warnings to stderr
[#&#8203;8342](https://togithub.com/pnpm/pnpm/pull/8342).
- Peer dependencies of optional peer dependencies should be
automatically installed
[#&#8203;8323](https://togithub.com/pnpm/pnpm/issues/8323).

#### Platinum Sponsors

<table>
  <tbody>
    <tr>
      <td align="center" valign="middle">
<a href="https://bit.dev/?utm_source=pnpm&utm_medium=release_notes"
target="_blank"><img src="https://pnpm.io/img/users/bit.svg"
width="80"></a>
      </td>
      <td align="center" valign="middle">
<a href="https://figma.com/?utm_source=pnpm&utm_medium=release_notes"
target="_blank"><img src="https://pnpm.io/img/users/figma.svg"
width="80"></a>
      </td>
    </tr>
  </tbody>
</table>

#### Gold Sponsors

<table>
  <tbody>
    <tr>
      <td align="center" valign="middle">
<a href="https://discord.com/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/discord.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/discord_light.svg" />
<img src="https://pnpm.io/img/users/discord.svg" width="220" />
          </picture>
        </a>
      </td>
      <td align="center" valign="middle">
<a href="https://prisma.io/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/prisma.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/prisma_light.svg" />
<img src="https://pnpm.io/img/users/prisma.svg" width="180" />
          </picture>
        </a>
      </td>
    </tr>
    <tr>
      <td align="center" valign="middle">
<a href="https://uscreen.de/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/uscreen.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/uscreen_light.svg" />
<img src="https://pnpm.io/img/users/uscreen.svg" width="180" />
          </picture>
        </a>
      </td>
      <td align="center" valign="middle">
<a
href="https://www.jetbrains.com/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/jetbrains.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/jetbrains.svg" />
<img src="https://pnpm.io/img/users/jetbrains.svg" width="180" />
          </picture>
        </a>
      </td>
    </tr>
    <tr>
      <td align="center" valign="middle">
<a href="https://nx.dev/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/nx.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/nx_light.svg" />
            <img src="https://pnpm.io/img/users/nx.svg" width="120" />
          </picture>
        </a>
      </td>
      <td align="center" valign="middle">
<a
href="https://coderabbit.ai/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/coderabbit.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/coderabbit_light.svg" />
<img src="https://pnpm.io/img/users/coderabbit.svg" width="220" />
          </picture>
        </a>
      </td>
    </tr>
  </tbody>
</table>

#### Our Silver Sponsors

<table>
  <tbody>
    <tr>
      <td align="center" valign="middle">
<a
href="https://leniolabs.com/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <img src="https://pnpm.io/img/users/leniolabs.jpg" width="80">
        </a>
      </td>
      <td align="center" valign="middle">
<a href="https://vercel.com/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/vercel.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/vercel_light.svg" />
<img src="https://pnpm.io/img/users/vercel.svg" width="180" />
          </picture>
        </a>
      </td>
    </tr>
    <tr>
      <td align="center" valign="middle">
<a href="https://depot.dev/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/depot.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/depot_light.svg" />
<img src="https://pnpm.io/img/users/depot.svg" width="200" />
          </picture>
        </a>
      </td>
      <td align="center" valign="middle">
<a href="https://moonrepo.dev/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/moonrepo.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/moonrepo_light.svg" />
<img src="https://pnpm.io/img/users/moonrepo.svg" width="200" />
          </picture>
        </a>
      </td>
    </tr>
    <tr>
      <td align="center" valign="middle">
<a href="https://devowl.io/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/devowlio.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/devowlio.svg" />
<img src="https://pnpm.io/img/users/devowlio.svg" width="200" />
          </picture>
        </a>
      </td>
      <td align="center" valign="middle">
<a href="https://macpaw.com/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/macpaw.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/macpaw_light.svg" />
<img src="https://pnpm.io/img/users/macpaw.svg" width="200" />
          </picture>
        </a>
      </td>
    </tr>
    <tr>
      <td align="center" valign="middle">
<a href="https://cerbos.dev/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
          <picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/cerbos.svg" />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/cerbos_light.svg" />
<img src="https://pnpm.io/img/users/cerbos.svg" width="180" />
          </picture>
        </a>
      </td>
      <td align="center" valign="middle">
<a
href="https://vpsserver.com/en-us/?utm_source=pnpm&utm_medium=release_notes"
target="_blank">
<img src="https://pnpm.io/img/users/vpsserver.svg" width="180" />
        </a>
      </td>
    </tr>
  </tbody>
</table>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 10am on monday" in timezone
Asia/Shanghai, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, 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://www.mend.io/free-developer-tools/renovate/). View the
[repository job log](https://developer.mend.io/github/oxc-project/oxc).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4yMC4xIiwidXBkYXRlZEluVmVyIjoiMzguMjAuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-12 03:22:28 +00:00
Boshen
505d39ba0a
chore: bump deps 2024-08-12 10:12:34 +08:00
Don Isaac
cc922f4c89
feat(vscode): provide config's schema to oxlint config files (#4826)
Updates the VSCode plugin client to automatically provide our
auto-generated
JSON schema to `\.?oxlint(rc)?(\.json)?` files.
2024-08-12 09:15:47 +08:00
overlookmotel
ecfa1247b7 refactor(ast_codegen): add line break to generated code (#4829)
Follow-on after #4819. Style nit. Add a line break after `#![allow(...)]`.
2024-08-11 19:36:24 +00:00
rzvxa
0ea697b4e9 refactor(ast, ast_codegen): CloneIn implementations now initialize semantic related cells with Default value. (#4819)
closes #4809
2024-08-11 19:10:56 +00:00
rzvxa
74af8e230a refactor(ast_codegen): Simplify InnerMarkers. (#4812) 2024-08-11 18:42:54 +00:00
DonIsaac
3d40528588 feat(linter): add fix emoji to rules table and doc pages (#4715)
Rules table:
<img width="898" alt="image" src="https://github.com/user-attachments/assets/353052aa-0af3-4c09-8441-ff79f4561ca0">

Doc pages:
<img width="918" alt="image" src="https://github.com/user-attachments/assets/cb43cb2d-15ff-41e6-8523-145cfbc3f484">
2024-08-10 22:50:47 +00:00
Don Isaac
a266b45167
feat(rulegen): improve examples in documentation (#4815) 2024-08-10 18:48:59 -04:00
Dunqing
62f759c1f2 fix(transformer/typescript): generated assignment for constructor arguments with access modifiers should be injected to the top of the constructor (#4808)
fix: #4789
2024-08-10 11:21:45 +00:00
DonIsaac
8f2a566f9f test(linter): ensure rule docs have valid syntax (#4644)
Adds tests for rule documentation by
1. Compiling doc markdown into HTML, which ensures docs use valid markdown syntax
2. Converts the generated HTML into JSX and parses the results with the parser, ensuring the generated HTML is valid

Has the added benefit of adding a lot of JSX test cases to the parser. I've also fixed all violations for these tests in this PR.
2024-08-10 05:03:09 +00:00
DonIsaac
f62951411d feat(website): auto-generate rule docs pages (#4640)
> AI-generated description because I'm lazy
### TL;DR

This PR introduces the ability to generate documentation for linter rules and adds new methods and metadata for rule fix capabilities.

To see what this looks like, please check out https://github.com/oxc-project/oxc-project.github.io/pull/165.

## Screenshots
Hyperlinks to rule doc pages in auto-generated rules table
<img width="809" alt="image" src="https://github.com/user-attachments/assets/e09eb47d-e86a-4ed1-b1f9-5034f33c71a2">

Example of a docs page
<img width="1273" alt="image" src="https://github.com/user-attachments/assets/78f7e9e6-f4dd-4cc9-aebc-1cdd64b024ec">

### What changed?

- Added `RuleFixMeta` to indicate rule fix capabilities
- Introduced methods `is_none` and `is_pending` in `RuleFixMeta`
- Modified `render_markdown_table` in `RuleTableSection` to accept an optional link prefix
- Created new modules for rule documentation and HTML rendering
- Updated `print_rules` function to generate markdown for rules and detailed documentation pages

### How to test?

Run the `linter-rules` task with appropriate arguments to generate the markdown table and documentation pages.
Verify the generated files for correctness and that all metadata is correctly displayed.

### Why make this change?

To enhance the project documentation and provide clear rule fix capabilities, thereby improving the developer experience and easing the integration process.

---
2024-08-10 00:13:06 +00:00
overlookmotel
92777d0aae refactor(ast_codegen): replace ///@@ with ///@@line_break (#4786)
Follow-on after #4778. `///@@line_break` is more verbose, but it's clearer what it does.
2024-08-09 10:52:22 +00:00
overlookmotel
ec82a79ebe refactor(ast_codegen): trim r# from start of field names (#4785)
Some struct fields are reserved names e.g. `type`. They are written in source as `r#type`. Trim off the `r#` prefix in `FieldDef::name` and add it back when generating output.

Main motivation is to have the unescaped field names in JSON schema.
2024-08-09 10:52:21 +00:00
overlookmotel
31311877f1 refactor(ast_codegen): alter JSON schema format (#4784)
Change the format of schema JSON by altering `serde` attrs.
2024-08-09 10:52:20 +00:00
overlookmotel
c79ca40b77 refactor(ast_codegen): remove excess space from start of doc comments (#4782)
I noticed that in JSON schema the `docs` property contains e.g. `" The name of the identifier being referenced."` (with an excess space on the start). Trim that off.
2024-08-09 10:25:28 +00:00
overlookmotel
d4a3be86ed refactor(ast_codegen): line breaks between types in layout assertions (#4781)
Small style nit. Add line breaks between types in generated layout assertions, to make the file easier to read.
2024-08-09 10:17:21 +00:00
overlookmotel
966fcc925a refactor(ast_codegen): re-order code in fmt module (#4779)
Pure refactor. Just move code which is most used to top of `fmt` module. And rename `pprint` to `pretty_print` to be a little clearer.
2024-08-09 10:01:14 +00:00
overlookmotel
2c1c7050ea refactor(ast_codegen): use doc comments instead of endl! (#4778)
Similar to #4777.

Use `///@@` instead of `endl!();` in AST codegen to create line breaks.

NB: `///@@` needs to be before an item, not after it.
2024-08-09 08:57:18 +00:00
overlookmotel
f418f62e7b refactor(ast_codegen): use doc comments instead of insert! (#4777)
Avoid the `insert!` macro in AST codegen. Use doc comments starting with special symbol `@` instead.

* Before: `insert!("// plain comment");`
* After: `///@ plain comment`
* Or: `//!@ plain comment`

Either `///@` or `//!@` is converted to plain `//` in output.

`//!@` is legal in top-of-file position, which allows us to inline `#![allow(...)]` attributes, which in my opinion makes the generators a bit easier to read.
2024-08-09 08:19:15 +00:00
overlookmotel
c15c931a3f refactor(ast_codegen): move formatting regex definitions (#4775)
Pure refactor. Move the regex definitions used in formatting to next to the `Replacer`s for those regexes.
2024-08-09 07:48:13 +00:00
overlookmotel
dbb5f4c75e refactor(ast_codegen): remove unnecessary imports from generated files (#4774)
#4773 makes types like `Span` importable from `oxc_ast::ast`, so remove the imports from other crates in generated code.

I'm not sure why clippy's `wildcard_imports` rule was not being triggered for `use crate::ast::*;`, but add `#[allow(clippy::wildcard_imports)]` on these statements just to make sure.
2024-08-09 07:48:09 +00:00
rzvxa
fff9da319d fix(ast, ast_codegen): use generate_derive instead of visitable for generating span derives. (#4747)
follow-up to #4735
I was accidentally using the old code to filter the viable target types to derive. It means before this PR we were still using the `#[ast(visit)]` for this purpose.
2024-08-08 17:06:48 +00:00
rzvxa
abe8202ba8 refactor(ast_codegen): declutter the main file. (#4744)
same as #4741
2024-08-08 16:38:13 +00:00
overlookmotel
7345f68d9e refactor(ast_codegen): remove Generator::name and Pass::name methods (#4764)
Remove `Generator::name` and `Pass::name` methods. All impls for these methods return a string identical to the struct name, so can set return value of `Runner::name` in `define_generator!` and `define_pass!` macros instead.
2024-08-08 15:39:10 +00:00
overlookmotel
d32fb6f5c5 refactor(ast_codegen): re-order imports (#4763)
Move imports to top of file in `generators/mod.rs`, just for consistency.
2024-08-08 15:39:09 +00:00
overlookmotel
80046d1144 refactor(ast_codegen): consistent endl! position (#4762)
Pure refactor (style nit). Place `endl!()` macro calls in consistent position throughout codegen.
2024-08-08 15:39:08 +00:00
overlookmotel
2dea0caae0 refactor(ast_codegen): consistent import order (#4761)
Pure refactor. Alter import order in generated code to consistent order - `std`, external crates, `crate`, `super`.
2024-08-08 15:24:45 +00:00
overlookmotel
790c551c5e refactor(ast_codegen): simplify derive_get_span generator (#4757)
Simplify `derive_get_span` generator that was introduced in #4735. No change to functionality, just aiming for greater readability.

In particular:

* Move defining idents/tokens which are specific to `GetSpan` / `GetSpanMut` into those specific generators, rather than branching on `MUT` later on.
* Remove `const MUT` param.
* Remove the confusing pairs of closures and functions both called `derive_enum` / `derive_struct`.
* Inline function which generates the impls - prioritizing readability over DRY code.
2024-08-08 10:47:37 +00:00
heygsc
bd56b6b56b
chore(tasks): change comment fix-dangerous to fix_dangerous (#4756) 2024-08-08 18:42:29 +08:00
dalaoshu
6cf38cb776
chore(tasks): support init vitest lint rule (#4752)
Related to #4656
2024-08-08 16:27:50 +08:00
Boshen
fbfd852cf8 refactor(minifier): add NodeUtil trait for accessing symbols on ast nodes (#4734) 2024-08-08 02:48:25 +00:00
overlookmotel
f36500a2bd refactor(ast_codegen): flatten code (#4743)
A bit of code style simplification after #4731. Remove unnecessary nesting and rename some vars for consistency.
2024-08-07 22:32:07 +00:00
rzvxa
aeed29f248 chore(ci): generate .generated_ast_watch_list.yml (#4737)
closes #4699

I also did some reordering to the code so it is easier to follow.
2024-08-07 22:11:34 +00:00
rzvxa
2218340f2b refactor(ast, ast_codegen): use generate_derive for implementing GetSpan and GetSpanMut traits. (#4735) 2024-08-07 22:07:33 +00:00
rzvxa
579b797cc5 refactor(ast): use type identifier instead of CloneIn::Cloned GAT. (#4738)
After https://github.com/oxc-project/oxc/pull/4731#discussion_r1707526289, I realized that I'm using `Self::Cloned` for enum derives. It was from my earlier attempts to resolve lifetime issues.
2024-08-07 21:23:23 +00:00
rzvxa
ec0b4cbdaa feat(ast_codegen): add derive_clone_in generator. (#4731)
Follow-on after #4276, related to #4284.
2024-08-07 20:29:06 +00:00
rzvxa
2e91ad6c4e feat(ast_codegen): support for generate_derive marker. (#4728)
Follow-on after #4276, related to #4284.
2024-08-07 17:38:13 +00:00
Boshen
94d3c31933 fix(minifier): avoid removing function declaration from KeepVar (#4722) 2024-08-07 05:09:32 +00:00
overlookmotel
06efae6e4c refactor(ast_codegen): reorder imports (#4709)
Pure refactor. Reorder imports to clarify what's an external crate and what's a local module.
2024-08-06 20:38:42 +00:00
overlookmotel
654a6e67fa refactor(ast_codegen): list input files explicitly (#4708)
List inputs to the codegen explicitly. This is less DRY, but I think it has the advantage of being more obvious - for #4704.
2024-08-06 19:14:05 +00:00
overlookmotel
07607d3e94 feat(ast_codegen, span): process Span through ast_codegen (#4703)
Add `#[ast]` attr to `Span`.

Due to how AST codegen works, this necessitates putting the type def in a separate file. https://github.com/oxc-project/oxc/pull/4696#issuecomment-2271781995
2024-08-06 18:22:22 +00:00
rzvxa
125c5fd8ed feat(ast_codegen, span): process SourceType through ast_codegen. (#4696) 2024-08-06 17:42:12 +00:00
rzvxa
82e2f6b924 feat(ast_codegen): process AST-related syntax types. (#4694) 2024-08-06 17:14:35 +00:00
rzvxa
b04dc3d026 refactor(ast_codegen): disallow implicit enum discriminants on #[ast] types. (#4690) 2024-08-06 17:14:33 +00:00
rzvxa
1690a57ed3 refactor(ast_codegen): move away from RType in generators. (#4682)
This PR introduces `EarlyCtx` and `LateCtx` in place of the old `CodegenCtx`, Early passes operate at the AST level while generators and other late passes operate on the schema.

It will also replace the confusing `RType` name with something more idiomatic ~~(open for suggestions, I haven't found a good name yet)~~ I've named it `AstType` and dropped the `R` prefix for `REnum` and `RStruct`.

There are some qualities of life improvements too, Things like `to_type_elide` can be used to simplify the code.

Related to #4442 (and can potentially mark it "close as fixed").
2024-08-06 17:14:31 +00:00
overlookmotel
4797eaaab6 fix(transformer): strip TS statements from for in/of statement bodies (#4686)
Remove TS statements in body of `for of` and `for in` statements, as well as plain `for`.
2024-08-06 13:03:02 +00:00
Boshen
bf48c7f02a fix(minifier): fix keep_var keeping vars from arrow functions (#4680) 2024-08-06 07:04:25 +00:00
overlookmotel
e42ac3a2a0
feat(sourcemap): add ConcatSourceMapBuilder::from_sourcemaps (#4639)
Introduce new method `ConcatSourceMapBuilder::from_sourcemaps`.

Where all the sourcemaps being concatenated exist at time that you
create `ConcatSourceMapBuilder`, it's faster to use `from_sourcemaps`,
because it pre-allocates enough space for the data it will hold and so
avoids memory copying.

Before:

```rs
let mut builder = ConcatSourceMapBuilder::default();
builder.add_sourcemap(&sourcemap1, 0);
builder.add_sourcemap(&sourcemap2, 100);
builder.add_sourcemap(&sourcemap3, 100);
let combined = builder.into_sourcemap();
```

After:

```rs
let builder = ConcatSourceMapBuilder::from_sourcemaps(&[
    (&sourcemap1, 0),
    (&sourcemap2, 100),
    (&sourcemap3, 200),
]);
let combined = builder.into_sourcemap();
```
2024-08-06 14:08:17 +08:00
Boshen
9be29af9d4 fix(minifier): temporarily fix shadowed undefined variable (#4678) 2024-08-06 04:58:39 +00:00
Boshen
0f5e982d19 perf(minifier): only visit arrow expression after dropping console.log (#4677) 2024-08-06 04:20:41 +00:00
Boshen
4a5695416d fix(codegen): print raw if value is number is Infinity (#4676) 2024-08-06 03:24:40 +00:00
Dunqing
3987665490 fix(transformer/typescript): incorrect enum-related symbol_id/reference_id (#4660)
part of #4581
2024-08-06 02:57:19 +00:00
Dunqing
03c643a8af fix(semantic): incorrect scope_id for catch parameter symbols (#4659)
When we move all the bindings in the CatchClause scope to its child scope (BlockStatement), we also need to replace the scope_id in the symbol with the scope_id of the new scope.
2024-08-06 02:57:18 +00:00