Commit graph

4427 commits

Author SHA1 Message Date
Boshen
0deb027e6b
feat(minfier): dce if (xxx) else if (false) { REMOVE } (#4407) 2024-07-22 19:57:35 +08:00
overlookmotel
d79b60afc4 example(semantic): examples print parser errors (#4405)
Examples for `Semantic` print parser errors if parsing fails.
2024-07-22 11:05:03 +00:00
Dunqing
40f93564ac perf(semantic): calculate number of nodes, scopes, symbols, references before visiting AST (#4367)
context: #4328
2024-07-22 10:47:54 +00:00
renovate[bot]
910f2a0a0a
chore(deps): update rust crate handlebars to v6 (#4402)
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [handlebars](https://togithub.com/sunng87/handlebars-rust) |
workspace.dependencies | major | `5.1.2` -> `6.0.0` |

---

### Release Notes

<details>
<summary>sunng87/handlebars-rust (handlebars)</summary>

###
[`v6.0.0`](https://togithub.com/sunng87/handlebars-rust/blob/HEAD/CHANGELOG.md#600---2024-07-20)

[Compare
Source](https://togithub.com/sunng87/handlebars-rust/compare/v5.1.2...v6.0.0)

- \[Fixed] Various indent issue with partials, empty lines and helpers
\[[#&#8203;646](https://togithub.com/sunng87/handlebars-rust/issues/646)]

\[[#&#8203;654](https://togithub.com/sunng87/handlebars-rust/issues/654)]
\[[#&#8203;658](https://togithub.com/sunng87/handlebars-rust/issues/658)]
- \[Fixed] Bug when accessing nested path
\[[#&#8203;651](https://togithub.com/sunng87/handlebars-rust/issues/651)]
- \[Added] New public access to `PathSeg`
\[[#&#8203;656](https://togithub.com/sunng87/handlebars-rust/issues/656)]
- \[Added] New API to set single block params in `BlockContext`
\[[#&#8203;655](https://togithub.com/sunng87/handlebars-rust/issues/655)]
- \[Added] `From<RenderError>` for `RenderErrorReason`
\[[#&#8203;644](https://togithub.com/sunng87/handlebars-rust/issues/644)]
- \[Changed] Add `non_exhaustive` attribute to all public memebers
\[[#&#8203;647](https://togithub.com/sunng87/handlebars-rust/issues/647)]
- \[Changed] `RenderContext` API and improved performance for partial
rendering

\[[#&#8203;661](https://togithub.com/sunng87/handlebars-rust/issues/661)]
\[[#&#8203;662](https://togithub.com/sunng87/handlebars-rust/issues/662)]
- \[Changed] Improved error messsage for template parsing
\[[#&#8203;638](https://togithub.com/sunng87/handlebars-rust/issues/638)]

</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 has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/oxc-project/oxc).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzguMCIsInVwZGF0ZWRJblZlciI6IjM3LjQzOC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-22 05:04:02 +00:00
renovate[bot]
21c7b090dd
chore(deps): update pnpm to v9.6.0 (#4400)
[![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.5.0` -> `9.6.0`](https://renovatebot.com/diffs/npm/pnpm/9.5.0/9.6.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/pnpm/9.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/pnpm/9.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/pnpm/9.5.0/9.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/pnpm/9.5.0/9.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

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

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

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

#### Minor Changes

- Support specifying node version (via `pnpm.executionEnv.nodeVersion`
in `package.json`) for running lifecycle scripts per each package in a
workspace [#&#8203;6720](https://togithub.com/pnpm/pnpm/issues/6720).
- Overrides now support the [`catalogs:`
protocol](https://pnpm.io/catalogs)
[#&#8203;8303](https://togithub.com/pnpm/pnpm/issues/8303).

#### Patch Changes

- The `pnpm deploy` command now supports the [`catalog:`
protocol](https://pnpm.io/catalogs)
[#&#8203;8298](https://togithub.com/pnpm/pnpm/pull/8298).
- The `pnpm outdated` command now supports the [`catalog:`
protocol](https://pnpm.io/catalogs)
[#&#8203;8304](https://togithub.com/pnpm/pnpm/pull/8304).
- Correct the error message when trying to run `pnpm patch` without
`node_modules/.modules.yaml`
[#&#8203;8257](https://togithub.com/pnpm/pnpm/issues/8257).
- Silent reporting fixed with the `pnpm exec` command
[#&#8203;7608](https://togithub.com/pnpm/pnpm/issues/7608).
- Add registries information to the calculation of dlx cache hash
[#&#8203;8299](https://togithub.com/pnpm/pnpm/pull/8299).

#### 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 has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/oxc-project/oxc).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzguMCIsInVwZGF0ZWRJblZlciI6IjM3LjQzOC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-22 02:21:31 +00:00
renovate[bot]
79eb662f3f
chore(deps): update rust crates (#4399)
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[json-strip-comments](https://togithub.com/oxc-project/json-strip-comments)
| workspace.dependencies | patch | `1.0.2` -> `1.0.4` |
| [oxc_resolver](https://togithub.com/oxc-project/oxc-resolver) |
workspace.dependencies | patch | `1.10.0` -> `1.10.2` |
| [similar](https://togithub.com/mitsuhiko/similar) |
workspace.dependencies | minor | `2.5.0` -> `2.6.0` |
| [tokio](https://tokio.rs)
([source](https://togithub.com/tokio-rs/tokio)) | workspace.dependencies
| patch | `1.38.0` -> `1.38.1` |

---

### Release Notes

<details>
<summary>oxc-project/oxc-resolver (oxc_resolver)</summary>

###
[`v1.10.2`](https://togithub.com/oxc-project/oxc-resolver/blob/HEAD/CHANGELOG.md#1102---2024-07-16)

[Compare
Source](https://togithub.com/oxc-project/oxc-resolver/compare/oxc_resolver-v1.10.1...oxc_resolver-v1.10.2)

##### Chore

-   Release FreeBSD

###
[`v1.10.1`](https://togithub.com/oxc-project/oxc-resolver/blob/HEAD/CHANGELOG.md#1101---2024-07-15)

[Compare
Source](https://togithub.com/oxc-project/oxc-resolver/compare/oxc_resolver-v1.10.0...oxc_resolver-v1.10.1)

##### Fixed

- resolve module `ipaddr.js` correctly when `extensionAlias` is provided
([#&#8203;228](https://togithub.com/oxc-project/oxc_resolver/pull/228))

</details>

<details>
<summary>mitsuhiko/similar (similar)</summary>

###
[`v2.6.0`](https://togithub.com/mitsuhiko/similar/blob/HEAD/CHANGELOG.md#260)

[Compare
Source](https://togithub.com/mitsuhiko/similar/compare/2.5.0...2.6.0)

- Bump bstr dependency to 1.5.
[#&#8203;69](https://togithub.com/mitsuhiko/similar/issues/69)

</details>

<details>
<summary>tokio-rs/tokio (tokio)</summary>

###
[`v1.38.1`](https://togithub.com/tokio-rs/tokio/releases/tag/tokio-1.38.1):
Tokio v1.38.1

[Compare
Source](https://togithub.com/tokio-rs/tokio/compare/tokio-1.38.0...tokio-1.38.1)

### 1.38.1 (July 16th, 2024)

This release fixes the bug identified as ([#&#8203;6682]), which caused
timers not
to fire when they should.

##### Fixed

- time: update `wake_up` while holding all the locks of sharded time
wheels ([#&#8203;6683])

[#&#8203;6682]: https://togithub.com/tokio-rs/tokio/pull/6682

[#&#8203;6683]: https://togithub.com/tokio-rs/tokio/pull/6683

</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 has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/oxc-project/oxc).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzguMCIsInVwZGF0ZWRJblZlciI6IjM3LjQzOC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-22 00:05:23 +00:00
DonIsaac
289dc39865 fix(linter): overflow in no-obj-calls (#4397)
Closes #4389
2024-07-21 23:35:47 +00:00
renovate[bot]
c294833b12
chore(deps): update dependency @codemirror/view to v6.28.6 (#4398)
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@codemirror/view](https://togithub.com/codemirror/view) | [`6.28.5`
->
`6.28.6`](https://renovatebot.com/diffs/npm/@codemirror%2fview/6.28.5/6.28.6)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@codemirror%2fview/6.28.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@codemirror%2fview/6.28.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@codemirror%2fview/6.28.5/6.28.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@codemirror%2fview/6.28.5/6.28.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>codemirror/view (@&#8203;codemirror/view)</summary>

###
[`v6.28.6`](https://togithub.com/codemirror/view/blob/HEAD/CHANGELOG.md#6286-2024-07-19)

[Compare
Source](https://togithub.com/codemirror/view/compare/6.28.5...6.28.6)

##### Bug fixes

Fix an issue where the editor got confused about the position of
inserted text when using Chrome's `EditContext` and canceling
transactions for typed text.

</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 has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/oxc-project/oxc).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzguMCIsInVwZGF0ZWRJblZlciI6IjM3LjQzOC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-21 22:54:42 +00:00
overlookmotel
da13d9338f perf(semantic): remove bounds checks on unresolved references stack (#4390)
`SemanticBuilder` keeps a stack of hashmaps to track unresolved references. This stack only grows, never shrinks. Use that invariant to remove bounds checks.
2024-07-21 15:49:52 +00:00
DonIsaac
f7da22da18 perf(linter): disable lint rules by file type (#4380)
### TL;DR

Added a `should_run` function to multiple lint rules to determine if a rule should be executed based on the source type. This change optimizes the linting process by avoiding unnecessary rule checks.

### What changed?

1. **New Method**: Introduced the `should_run` method in the `Rule` trait.
2. **Implementation**: Implemented the `should_run` method for various lint rules, particularly those related to React and TypeScript.
3. **Usage**: Updated the `Linter` to use the `should_run` method to filter rules before execution.
4. **Macro Update**: Modified the `declare_all_lint_rules` macro to incorporate the `should_run` method.

### How to test?

1. Run the linter on a project containing React and TypeScript files.
2. Verify that only relevant rules are executed based on the file type (e.g., JSX rules for React files).

### Why make this change?

This change improves the performance of the linter by ensuring that only applicable rules are run for a given file type, reducing unnecessary computation and potential false positives.

---
2024-07-21 15:22:54 +00:00
Boshen
44a10c4b91 fix(codegen): object shorthand with parens ({x: (x)}) -> ({ x }) (#4391) 2024-07-21 14:04:17 +00:00
overlookmotel
e70c67b2e2 perf(semantic): remove a branch from add_scope (#4384)
Similar to #4361.

`ScopeTree::add_scope` had a branch specifically to handle `Program`. Remove that by inlining the special logic for `Program` into `visit_program`.

Probably won't have much effect on benchmarks as the branch is easy to predict, but still removes a few instructions and makes `add_scope` easier for compiler to inline.
2024-07-21 12:43:34 +00:00
Boshen
97c7678343
ci: fix cargo-bins/cargo-binstall@v1.7.4 2024-07-21 20:42:14 +08:00
overlookmotel
bcd090af98
ci: run conformance with debug assertions (#4386)
Run conformance with debug assertions enabled to ensure `debug_assert!`s
pass.
2024-07-21 20:40:50 +08:00
Boshen
3708fba9e5
ci: use cargo-bins/cargo-binstall@1.7.4 2024-07-21 20:40:14 +08:00
Boshen
44f89e05b8
chore: add .cargo/config.toml to taplo 2024-07-21 20:37:48 +08:00
overlookmotel
402006f28d perf(semantic): simplify logic in enter_scope + leave_scope (#4383)
`SemanticBuilder::enter_scope` contained multiple checks purely to handle when called for `Program` scope (where scope has no parent). This is a very uncommon case as `Program` is visited only once, but these checks run for every scope.

So don't call `enter_scope` from `visit_program`, and inline the special logic for root scope there instead, to simplify `enter_scope`.

A branch in `leave_scope` also gets more predictable (always taken).
2024-07-21 12:33:24 +00:00
overlookmotel
000d083c61 chore: format .cargo/config.toml (#4385)
Fix indentation in `.cargo/config.toml`.
2024-07-21 12:06:19 +00:00
Boshen
3d88f20cbb
fix(codegen): print shorthand for all { x } variants (#4374)
closes #4340
2024-07-21 19:54:21 +08:00
DonIsaac
51f5025c9c feat(linter): add fixer for unicorn/prefer-string-starts-ends-with (#4378)
Part of #4179
2024-07-21 07:20:22 +00:00
DonIsaac
a207923af1 perf: replace some CompactStr usages with Cows (#4377)
Reduce memory allocations in semantic and linter by using `Cow<'a, str>` over `CompactStr`
2024-07-20 19:19:55 +00:00
rzvxa
7a3e92591f refactor(ast_codegen): better visit marker parsing. (#4371)
closes #4281
2024-07-20 17:07:24 +00:00
overlookmotel
d213773e38 refactor(ast): replace serde rename "lowercase" with "camelCase" (#4376)
Replace all `#[serde(rename_all = "lowercase")]` with `#[serde(rename_all = "camelCase")]`, for consistency. In all these cases lowercase and camelcase formatting is the same, so it makes no substantive difference, just better to be consistent.
2024-07-20 16:49:19 +00:00
overlookmotel
abfccbd941 refactor(ast): reduce #[cfg_attr] boilerplate in AST type defs (#4375)
Remove a ton of `#[cfg_attr(feature = "serialize", serde(...))]` boilerplate from AST type definitions.

Before: `#[cfg_attr(feature = "serialize", serde(flatten))]`
After: `#[serde(flatten)]`

This is a reprise of #2669, which was later reverted, but this time doing it using our existing zero-cost `#[ast]` dummy macro attr, so no compile time penalty this time around.

This makes no difference to either runtime or compile time behavior, purely removes the `cfg_attr` boilerplate and makes the code easier to read.
2024-07-20 16:41:16 +00:00
rzvxa
d345b84a72 feat(ast): add #[ast] attribute to non-visited AST types. (#4309)
Mark everything mentioned in https://github.com/oxc-project/oxc/pull/3815#issuecomment-2186736258 as AST.

We now error on the occurrence of non-ast items in the source of truth. It doesn't make sure that all fields and variants are `#[ast]` and therefore `repr_stable` but there are only a handful of non-AST types used here(mainly Atom and Span). Since we don't have access to the external types we can't make sure of it unless we find a way to const assert it.

The best we can do until then is to check all field/variant types to be either `#[ast]` or in a white list. I can add this check to the codegen in an upcoming PR.
2024-07-20 12:22:26 +00:00
rzvxa
5f1c7ecad7 refactor(ast): rename the visited_node marker to ast. (#4289)
closes #4282
I went with `#[ast(visit)]` but we can change it to 2 separate markers as suggested by @overlookmotel in the issue.
2024-07-20 12:02:25 +00:00
DonIsaac
7a75e0f8a7 refactor(linter): use diagnostic codes in lint rules (#4349)
> This PR is (unfortunately) quite large, but all changes are needed in tandem for this to work properly.

## What This PR Does

Updates the linter to populate diagnostics reported by rules with error codes statically derived from `RuleMeta` + `RuleEnum`.

Doing so required changing how we handle vitest rules. I know @mysterven was hoping to refactor that part of the code, and I think this approach is an improvement (but could probably be cleaned up further).

## Changes

### 1. Auto-Populate Error Codes
`LintContext` now sets an error code scope + error code number for diagnostics reported by lint rules. `LintContext` will not clobber existing codes set by rules, allowing for rule-specific override behavior (e.g. to use `eslint-plugin-react-hooks` as an error scope).

In order to accomplish this, I had to update every diagnostic factory for every rule. While doing this I found some incorrect error messages, or messages that could be easily improved. This is where a large majority of the snapshot diffs come from. Additionally, I was able to reduce string allocations from `format!` usages in diagnostic factories, especially within jest rules.

### 2. Framework and Library Detection
This PR adds `FrameworkFlags`, which specify what (if any) set of libraries and frameworks are being used by a project and/or file. They are passed in two ways:

1. `LintOptions` can specify a set of `framework_hints` that apply to the entire target codebase. Right now these are always empty, but I'm thinking in the future we could sniff `package.json`. It may be helpful for enabling/disabling default rules.
2. When `Linter` gets run on a file, framework information is sniffed from the `LintContext`. Right now, we are only checking for `vitest` imports in `ModuleRecord` and test path prefixes from `source_path`. It may be useful to do something similar for React/NextJS rules in the future. I know that [next/no-html-link-for-pages](https://nextjs.org/docs/messages/no-html-link-for-pages) could benefit greatly from this.
2024-07-20 03:35:00 +00:00
Jelle van der Waa
5f1e070c8b
feat(linter/eslint-plugin-unicorn): add fixer for prefer-code-point (#4353) 2024-07-20 10:33:15 +08:00
Jaden Rodriguez
3c0c7093b5
feat(linter): add typescript-eslint/no-extraneous-class (#4357)
Added rule for https://typescript-eslint.io/rules/no-extraneous-class/

Also, I chose to make the match the node against the class and derive
the body from the node, rather than matching against the body and using
the context to go back up to the parent class node as in the original
source.
2024-07-19 15:56:30 -04:00
DonIsaac
ea33f9470b fix: impl PartialEq<str> for CompactStr (#4352)
I need this for another PR that I'm working on, but I think adding this just makes sense.
2024-07-19 16:39:10 +00:00
overlookmotel
5d77b36f24 refactor(semantic): visit_program visit hashbang field (#4370)
The visit was missing previously, though it didn't matter, because semantic doesn't do anything with `Hashbang` anyway. But is needed for #4367.
2024-07-19 16:32:32 +00:00
overlookmotel
f7b9ada372 refactor(semantic): Program visitor leave scope before node (#4369)
Bring the order of calls in `SemanticBuilder::visit_program` into line with `Visit`'s `walk_program`.
2024-07-19 16:32:27 +00:00
overlookmotel
aece1df561 fix(ast): visit Programs hashbang field first (#4368)
Visit `hashbang` before `directives` for `Program`.
2024-07-19 16:27:51 +00:00
Dunqing
6ffce865d1 fix(semantic): align visit_arrow_function_expression field visit order with ast (#4366)
related: #4364
2024-07-19 14:51:59 +00:00
Dunqing
f68b659713 refactor(ast)!: reorder fields of ArrowFunctionExpression (#4364)
Found in #4328
Same as #4248
2024-07-19 14:12:05 +00:00
Boshen
27cbd551fb chore: bump napi to v3 (#4365) 2024-07-19 14:06:33 +00:00
Boshen
557132ffdf
chore(deps): update vscode npm packages (#4363)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-19 21:31:23 +08:00
Boshen
bec03ede98
chore(deps): update website npm packages (#4362)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-19 21:30:21 +08:00
overlookmotel
7469e018b0 perf(semantic): remove branch from Nodes::add_node (#4361)
`AstNodes::add_node` had a branch specifically to handle `Program`. Remove that by inlining the special logic for `Program` into `visit_program`.

Probably won't have much effect on benchmarks as the branch is easy to predict, but still removes a few instructions and makes `add_node` easier for compiler to inline.
2024-07-19 11:34:03 +00:00
overlookmotel
729b288c5d refactor(semantic): shorten code (#4358)
Code style: Remove unnecessary assignments to `_`.
2024-07-19 10:29:27 +00:00
overlookmotel
7eb286413e perf(traverse): speed up finding UID binding name (#4356)
Speed up finding UID var name. Previously iterated through all `SymbolTable::references` and checked each for a string match. Replace that with a single hashmap lookup on `ScopeTree::root_unresolved_references`.
2024-07-19 10:24:01 +00:00
underfin
4cd5df00ea
fix(sourcemap): avoid negative line if token_chunks has same prev_dst_line (#4348) 2024-07-19 18:14:35 +08:00
Dunqing
58f6ec21f3 refactor(ast): enter node before scope (#4347)
close: #4276
2024-07-18 19:18:01 +00:00
Dunqing
59aea73daf refactor(ast): scope is created only if CatchClause has param (#4346)
close: #4345
2024-07-18 19:14:34 +00:00
Dunqing
f8565ae3cd fix(transformer/typescript): unexpectedly removed class binding from ExportNamedDeclaration (#4351)
The original `SymbolFlags` methods were a bit confusing I renamed and re-implemented them.
2024-07-18 16:44:38 +00:00
Boshen
e624dff1d4 fix(codegen,mangler): do not print shorthand for ObjectProperty (#4350)
I'll fix the TODO's later.
2024-07-18 16:26:33 +00:00
DonIsaac
21d0eee182 refactor(semantic): use error codes for ts diagnostics (#4336)
Part of #4333
2024-07-18 16:09:28 +00:00
DonIsaac
a2eabe1f4b refactor(parser): use error codes for ts diagnostics (#4335)
Part of #4333
2024-07-18 16:09:25 +00:00
DonIsaac
6068e6baca feat: add error codes to OxcDiagnostic (#4334)
Part of #4333
2024-07-18 16:09:22 +00:00
github-actions[bot]
7d751898b3
Release crates v0.21.0 (#4344)
## [0.21.0] - 2024-07-18

- d7ab0b8 semantic: [**BREAKING**] Simplify node creation (#4226)
(lucab)

### Features

- af4dc01 ast: Align ts ast scope with typescript (#4253) (Dunqing)
- 83c2c62 codegen: Add option for choosing quotes; remove slow
`choose_quot` method (#4219) (Boshen)
- 5d17675 mangler: Add debug mode (#4314) (Boshen)
- e3e663b mangler: Initialize crate and integrate into minifier (#4197)
(Boshen)
- c818472 minifier: Dce conditional expression `&&` or `||` (#4190)
(Boshen)
- 8a190eb oxc: Export `oxc_mangler` (Boshen)
- 20cdb1f semantic: Align class scope with typescript (#4195) (Dunqing)
- 92ee774 semantic: Add `ScopeFlags::CatchClause` for use in CatchClause
(#4205) (Dunqing)
- 205c259 sourcemap: Support SourceMapBuilder#token_chunks (#4220)
(underfin)
- 7eb960d transformer: Decode xml character entity `&#xhhhh` and
`&#nnnn;` (#4235) (Boshen)

### Bug Fixes

- bf3d8d3 codegen: Print annotation comment inside parens for new and
call expressions (#4290) (Boshen)
- 084ab76 codegen: Use `ryu-js` for f64 to string (Boshen)
- e167ef7 codegen: Print parenthesis properly (#4245) (Boshen)
- c65198f codegen: Choose the right quote for jsx attribute string
(#4236) (Boshen)
- be82c28 codegen: Print `JSXAttributeValue::StringLiteral` directly
(#4231) (Boshen)
- 3df9e69 mangler: No shorthand `BindingProperty`; handle var hoisting
and export variables (#4319) (Boshen)
- f144082 minifier: RemoveDeadCode should visit nested expression
(#4268) (underfin)
- 66b455a oxc_codegen: Avoid print same pure comments multiple time
(#4230) (IWANABETHATGUY)
- 9a87e41 parser: Avoid crashing on invalid const modifier (#4267)
(lucab)
- 641a78b parser: Fix tests for number parsing (#4254) (overlookmotel)
- 9badac0 semantic: Avoid var hosting insert the var variable to the
`CatchClause` scope (#4337) (Dunqing)
- 95e15b6 semantic: Incorrect resolve references for `ExportSpecifier`
(#4320) (Dunqing)
- c362bf7 semantic: Incorrect resolve references for
`TSInterfaceHeritage` (#4311) (Dunqing)
- 351ecf2 semantic: Incorrect resolve references for `TSTypeQuery`
(#4310) (Dunqing)
- 1108f2a semantic: Resolve references to the incorrect symbol (#4280)
(Dunqing)
- 22d56bd semantic: Do not resolve references after `FormalParameters`
in TS type (#4241) (overlookmotel)- 1c117eb Avoid print extra semicolon
after accessor property (#4199) (IWANABETHATGUY)

### Performance

- a8dc4f3 parser: Speed up parsing numbers with `_` separators (#4259)
(overlookmotel)
- b94540d parser: Speed up parsing octal literals (#4258)
(overlookmotel)
- a7b328c parser: Faster parsing decimal numbers (#4257) (overlookmotel)
- f9d3f2e semantic: Inline ast record functions (#4272) (overlookmotel)
- 8fad7db semantic: Reduce `AstNodeId` to `u32` (#4264) (overlookmotel)
- 23743db semantic: Do not record ast nodes for cfg if cfg disabled
(#4263) (overlookmotel)
- da69076 semantic: Reduce overhead of cfg recording ast nodes (#4262)
(overlookmotel)
- cb15303 semantic: Reduce memory copies (#4216) (overlookmotel)
- ef4c1f4 semantic: Reduce lookups (#4214) (overlookmotel)
- f23e54f semantic: Recycle unresolved references hash maps (#4213)
(overlookmotel)
- 2602ce2 semantic: Reuse existing map of unresolved refs (#4206)
(lucab)

### Refactor

- 2c7bb9f ast: Pass final `ScopeFlags` into `visit_function` (#4283)
(overlookmotel)
- 3e099fe ast: Move `enter_scope` after `visit_binding_identifier`
(#4246) (Dunqing)
- aab7aaa ast/visit: Fire node events as the outermost one. (#4203)
(rzvxa)
- d1c4be0 codegen: Clean up annotation_comment (Boshen)
- 06197b8 codegen: Separate tests (Boshen)
- aa22073 codegen: Improve print API (#4196) (Boshen)
- c5731a5 semantic: Remove defunct code setting ScopeFlags twice (#4286)
(overlookmotel)
- 16698bc semantic: Move function/class-specific code into specific
visitors (#4278) (overlookmotel)
- ee16668 semantic: Rename function param (#4277) (overlookmotel)
- 25f0771 semantic: Alter syntax of `control_flow!` macro (#4275)
(overlookmotel)
- 639fd48 semantic: Comment why extra CFG enabled check (#4274)
(overlookmotel)
- c418bf5 semantic: Directly record `current_node_id` when adding a
scope (#4265) (Dunqing)
- ace4f1f semantic: Update the order of `visit_function` and `Visit`
fields in the builder to be consistent (#4248) (Dunqing)
- 8bfeabf semantic: Simplify adding `SymbolFlags::Export` (#4249)
(Dunqing)
- dc2b3c4 semantic: Add strict mode in scope flags for class definitions
(#4156) (Dunqing)
- 81ed588 semantic: Convert scope fields to IndexVecs (#4208) (lucab)
- bbe5ded semantic: Set `current_scope_id` to `scope_id` in
`enter_scope` (#4193) (Dunqing)
- 7f1addd semantic: Correct scope in CatchClause (#4192) (Dunqing)
- fc0b17d syntax: Turn the `AstNodeId::dummy` into a constant field.
(#4308) (rzvxa)
- a197e01 transformer/typescript: Remove unnecessary code (#4321)
(Dunqing)
- 1458d81 visit: Add `#[inline]` to empty functions (#4330)
(overlookmotel)

Co-authored-by: Boshen <Boshen@users.noreply.github.com>
2024-07-18 14:39:07 +08:00