Cameron
07076d9765
feat(linter) improve prefer-string-starts-ends-with rule ( #3176 )
...
basically:
`^#/i.test(hex)` is the same as `/^#/.test(hex)`
so, in this case the `i` flag does nothing and we can safely ignore it
inspired by https://x.com/the_moisrex/status/1787444601571221892
---
This could potentially lead a new `oxc` rule called
`no_useless_case_insensitive_regex_flag` that reports if you have a
regex with the `i` flag with no ascii alphabetic chars.
2024-05-06 23:52:19 +08:00
Boshen
cb2e651eea
feat(linter): eslint-plugin-next/no-duplicate-head ( #3174 )
...
closes #2438
2024-05-06 19:43:38 +08:00
Boshen
d91b688f3a
chore(rulegen): default rule to nursery
2024-05-06 17:17:36 +08:00
Boshen
8fbba03afd
ci: reduce the total number of linter benchmarks ( #3172 )
...
closes #2981
2024-05-06 12:54:50 +08:00
Boshen
a84454cf87
refactor(linter): clean up prefer_node_protocol and move to restriction ( #3171 )
...
closes #3161
2024-05-06 12:43:24 +08:00
renovate[bot]
e6027beec3
chore(deps): lock file maintenance ( #3163 )
...
[](https://renovatebot.com )
This PR contains the following updates:
| Update | Change |
|---|---|
| lockFileMaintenance | All locks refreshed |
🔧 This Pull Request updates lock files to use the latest dependency
versions.
---
### Configuration
📅 **Schedule**: Branch creation - "before 4am on monday" in timezone
Asia/Shanghai, Automerge - At any time (no schedule defined).
🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.
♻ **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:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNDAuMTAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4zNDAuMTAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbXX0=-->
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-06 12:34:01 +08:00
overlookmotel
be87ca8419
feat(transform): oxc_traverse crate ( #3169 )
...
First part of #3152 .
This adds a crate `oxc_traverse`, but doesn't connect it up to the
transformer or anything else yet.
I think we could merge this now - as it doesn't affect any code that's
in use - and then iterate on it to add scopes before using it in
transformer. Please see
https://github.com/oxc-project/oxc/pull/3152#issuecomment-2094965406 for
the broader picture.
2024-05-06 09:37:04 +08:00
renovate[bot]
0ceeec8cbe
chore(deps): lock file maintenance website npm packages ( #3166 )
...
[](https://renovatebot.com )
This PR contains the following updates:
| Package | Type | Update | Change | Age | Adoption | Passing |
Confidence |
|---|---|---|---|---|---|---|---|
| | | lockFileMaintenance | All locks refreshed | | | | |
|
[@codemirror/autocomplete](https://togithub.com/codemirror/autocomplete )
| dependencies | minor | [`6.15.0` ->
`6.16.0`](https://renovatebot.com/diffs/npm/@codemirror%2fautocomplete/6.15.0/6.16.0 )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
| [@codemirror/commands](https://togithub.com/codemirror/commands ) |
dependencies | minor | [`6.3.3` ->
`6.5.0`](https://renovatebot.com/diffs/npm/@codemirror%2fcommands/6.3.3/6.5.0 )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
| [@codemirror/lint](https://togithub.com/codemirror/lint ) |
dependencies | minor | [`6.5.0` ->
`6.7.0`](https://renovatebot.com/diffs/npm/@codemirror%2flint/6.5.0/6.7.0 )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
| [@codemirror/view](https://togithub.com/codemirror/view ) |
dependencies | patch | [`6.26.0` ->
`6.26.3`](https://renovatebot.com/diffs/npm/@codemirror%2fview/6.26.0/6.26.3 )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
| [pnpm](https://pnpm.io ) ([source](https://togithub.com/pnpm/pnpm )) |
packageManager | patch | [`9.0.4` ->
`9.0.6`](https://renovatebot.com/diffs/npm/pnpm/9.0.4/9.0.6 ) |
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
| [vite](https://vitejs.dev )
([source](https://togithub.com/vitejs/vite/tree/HEAD/packages/vite )) |
devDependencies | patch | [`5.2.6` ->
`5.2.11`](https://renovatebot.com/diffs/npm/vite/5.2.6/5.2.11 ) |
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
🔧 This Pull Request updates lock files to use the latest dependency
versions.
---
### Release Notes
<details>
<summary>codemirror/autocomplete
(@​codemirror/autocomplete)</summary>
###
[`v6.16.0`](https://togithub.com/codemirror/autocomplete/blob/HEAD/CHANGELOG.md#6160-2024-04-12 )
[Compare
Source](https://togithub.com/codemirror/autocomplete/compare/6.15.0...6.16.0 )
##### New features
The new `activateOnCompletion` option allows autocompletion to be
configured to chain completion activation for some types of completions.
</details>
<details>
<summary>codemirror/commands (@​codemirror/commands)</summary>
###
[`v6.5.0`](https://togithub.com/codemirror/commands/blob/HEAD/CHANGELOG.md#650-2024-04-19 )
[Compare
Source](https://togithub.com/codemirror/commands/compare/6.4.0...6.5.0 )
##### New features
The `insertNewlineKeepIndent` command inserts a newline along with the
same indentation as the line before.
###
[`v6.4.0`](https://togithub.com/codemirror/commands/blob/HEAD/CHANGELOG.md#640-2024-04-17 )
[Compare
Source](https://togithub.com/codemirror/commands/compare/6.3.3...6.4.0 )
##### Bug fixes
Fix an issue where `deleteLine` sometimes leaves the cursor on the wrong
line.
##### New features
The new `deleteCharBackwardStrict` command just deletes a character,
without further smart behavior around indentation.
</details>
<details>
<summary>codemirror/lint (@​codemirror/lint)</summary>
###
[`v6.7.0`](https://togithub.com/codemirror/lint/blob/HEAD/CHANGELOG.md#670-2024-04-30 )
[Compare
Source](https://togithub.com/codemirror/lint/compare/6.6.0...6.7.0 )
##### New features
The `renderMessage` function is now called with the editor view as first
argument.
###
[`v6.6.0`](https://togithub.com/codemirror/lint/blob/HEAD/CHANGELOG.md#660-2024-04-29 )
[Compare
Source](https://togithub.com/codemirror/lint/compare/6.5.0...6.6.0 )
##### New features
The new `hideOn` configuration option can be used to control in what
circumstances lint tooltips get hidden by state changes.
</details>
<details>
<summary>codemirror/view (@​codemirror/view)</summary>
###
[`v6.26.3`](https://togithub.com/codemirror/view/blob/HEAD/CHANGELOG.md#6263-2024-04-12 )
[Compare
Source](https://togithub.com/codemirror/view/compare/6.26.2...6.26.3 )
##### Bug fixes
Fix an issue where dispatching an update to an editor before it measured
itself for the first time could cause the scroll position to incorrectly
move.
Fix a crash when multiple tooltips with arrows are shown.
###
[`v6.26.2`](https://togithub.com/codemirror/view/blob/HEAD/CHANGELOG.md#6262-2024-04-09 )
[Compare
Source](https://togithub.com/codemirror/view/compare/6.26.1...6.26.2 )
##### Bug fixes
Improve behavior of `scrollPastEnd` in a scaled editor.
When available, use `Selection.getComposedRanges` on Safari to find the
selection inside a shadow DOM.
Remove the workaround that avoided inappropriate styling on composed
text after a decoration again, since it breaks the stock Android virtual
keyboard.
###
[`v6.26.1`](https://togithub.com/codemirror/view/blob/HEAD/CHANGELOG.md#6261-2024-03-28 )
[Compare
Source](https://togithub.com/codemirror/view/compare/6.26.0...6.26.1 )
##### Bug fixes
Fix the editor getting stuck in composition when Safari fails to fire a
compositionend event for a dead key composition.
Fix an issue where, with IME systems that kept the cursor at the start
of the composed text, the editor misidentified the target node and
disrupted composition.
Fix a bug where in a line-wrapped editor, with some content, the initial
scroll position would be off from the top of the document.
</details>
<details>
<summary>pnpm/pnpm (pnpm)</summary>
### [`v9.0.6`](https://togithub.com/pnpm/pnpm/compare/v9.0.5...v9.0.6 )
[Compare Source](https://togithub.com/pnpm/pnpm/compare/v9.0.5...v9.0.6 )
### [`v9.0.5`](https://togithub.com/pnpm/pnpm/compare/v9.0.4...v9.0.5 )
[Compare Source](https://togithub.com/pnpm/pnpm/compare/v9.0.4...v9.0.5 )
</details>
<details>
<summary>vitejs/vite (vite)</summary>
###
[`v5.2.11`](https://togithub.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small5211-2024-05-02-small )
[Compare
Source](https://togithub.com/vitejs/vite/compare/v5.2.10...v5.2.11 )
- feat: improve dynamic import variable failure error message
([#​16519](https://togithub.com/vitejs/vite/issues/16519 ))
([f8feeea](https://togithub.com/vitejs/vite/commit/f8feeea )), closes
[#​16519](https://togithub.com/vitejs/vite/issues/16519 )
- fix: dynamic-import-vars plugin normalize path issue
([#​16518](https://togithub.com/vitejs/vite/issues/16518 ))
([f71ba5b](https://togithub.com/vitejs/vite/commit/f71ba5b )), closes
[#​16518](https://togithub.com/vitejs/vite/issues/16518 )
- fix: scripts and styles were missing from built HTML on Windows
([#​16421](https://togithub.com/vitejs/vite/issues/16421 ))
([0e93f58](https://togithub.com/vitejs/vite/commit/0e93f58 )), closes
[#​16421](https://togithub.com/vitejs/vite/issues/16421 )
- fix(deps): update all non-major dependencies
([#​16488](https://togithub.com/vitejs/vite/issues/16488 ))
([2d50be2](https://togithub.com/vitejs/vite/commit/2d50be2 )), closes
[#​16488](https://togithub.com/vitejs/vite/issues/16488 )
- fix(deps): update all non-major dependencies
([#​16549](https://togithub.com/vitejs/vite/issues/16549 ))
([2d6a13b](https://togithub.com/vitejs/vite/commit/2d6a13b )), closes
[#​16549](https://togithub.com/vitejs/vite/issues/16549 )
- fix(dev): watch publicDir explicitly to include it outside the root
([#​16502](https://togithub.com/vitejs/vite/issues/16502 ))
([4d83eb5](https://togithub.com/vitejs/vite/commit/4d83eb5 )), closes
[#​16502](https://togithub.com/vitejs/vite/issues/16502 )
- fix(preload): skip preload for non-static urls
([#​16556](https://togithub.com/vitejs/vite/issues/16556 ))
([bb79c9b](https://togithub.com/vitejs/vite/commit/bb79c9b )), closes
[#​16556](https://togithub.com/vitejs/vite/issues/16556 )
- fix(ssr): handle class declaration and expression name scoping
([#​16569](https://togithub.com/vitejs/vite/issues/16569 ))
([c071eb3](https://togithub.com/vitejs/vite/commit/c071eb3 )), closes
[#​16569](https://togithub.com/vitejs/vite/issues/16569 )
- fix(ssr): handle function expression name scoping
([#​16563](https://togithub.com/vitejs/vite/issues/16563 ))
([02db947](https://togithub.com/vitejs/vite/commit/02db947 )), closes
[#​16563](https://togithub.com/vitejs/vite/issues/16563 )
###
[`v5.2.10`](https://togithub.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small5210-2024-04-20-small )
[Compare
Source](https://togithub.com/vitejs/vite/compare/v5.2.9...v5.2.10 )
- revert: perf: use workspace root for fs cache
([#​15712](https://togithub.com/vitejs/vite/issues/15712 ))
([#​16476](https://togithub.com/vitejs/vite/issues/16476 ))
([77e7359](https://togithub.com/vitejs/vite/commit/77e7359 )), closes
[#​15712](https://togithub.com/vitejs/vite/issues/15712 )
[#​16476](https://togithub.com/vitejs/vite/issues/16476 )
- fix: add base to virtual html
([#​16442](https://togithub.com/vitejs/vite/issues/16442 ))
([721f94d](https://togithub.com/vitejs/vite/commit/721f94d )), closes
[#​16442](https://togithub.com/vitejs/vite/issues/16442 )
- fix: adjust esm syntax judgment logic
([#​16436](https://togithub.com/vitejs/vite/issues/16436 ))
([af72eab](https://togithub.com/vitejs/vite/commit/af72eab )), closes
[#​16436](https://togithub.com/vitejs/vite/issues/16436 )
- fix: don't add outDirs to watch.ignored if emptyOutDir is false
([#​16453](https://togithub.com/vitejs/vite/issues/16453 ))
([6a127d6](https://togithub.com/vitejs/vite/commit/6a127d6 )), closes
[#​16453](https://togithub.com/vitejs/vite/issues/16453 )
- fix(cspNonce): don't overwrite existing nonce values
([#​16415](https://togithub.com/vitejs/vite/issues/16415 ))
([b872635](https://togithub.com/vitejs/vite/commit/b872635 )), closes
[#​16415](https://togithub.com/vitejs/vite/issues/16415 )
- feat: show warning if root is in build.outDir
([#​16454](https://togithub.com/vitejs/vite/issues/16454 ))
([11444dc](https://togithub.com/vitejs/vite/commit/11444dc )), closes
[#​16454](https://togithub.com/vitejs/vite/issues/16454 )
- feat: write cspNonce to style tags
([#​16419](https://togithub.com/vitejs/vite/issues/16419 ))
([8e54bbd](https://togithub.com/vitejs/vite/commit/8e54bbd )), closes
[#​16419](https://togithub.com/vitejs/vite/issues/16419 )
- chore(deps): update dependency eslint-plugin-n to v17
([#​16381](https://togithub.com/vitejs/vite/issues/16381 ))
([6cccef7](https://togithub.com/vitejs/vite/commit/6cccef7 )), closes
[#​16381](https://togithub.com/vitejs/vite/issues/16381 )
###
[`v5.2.9`](https://togithub.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small529-2024-04-15-small )
[Compare
Source](https://togithub.com/vitejs/vite/compare/v5.2.8...v5.2.9 )
- fix: `fsp.rm` removing files does not take effect
([#​16032](https://togithub.com/vitejs/vite/issues/16032 ))
([b05c405](https://togithub.com/vitejs/vite/commit/b05c405 )), closes
[#​16032](https://togithub.com/vitejs/vite/issues/16032 )
- fix: fix accumulated stacks in error overlay
([#​16393](https://togithub.com/vitejs/vite/issues/16393 ))
([102c2fd](https://togithub.com/vitejs/vite/commit/102c2fd )), closes
[#​16393](https://togithub.com/vitejs/vite/issues/16393 )
- fix(deps): update all non-major dependencies
([#​16376](https://togithub.com/vitejs/vite/issues/16376 ))
([58a2938](https://togithub.com/vitejs/vite/commit/58a2938 )), closes
[#​16376](https://togithub.com/vitejs/vite/issues/16376 )
- chore: update region comment
([#​16380](https://togithub.com/vitejs/vite/issues/16380 ))
([77562c3](https://togithub.com/vitejs/vite/commit/77562c3 )), closes
[#​16380](https://togithub.com/vitejs/vite/issues/16380 )
- perf: reduce size of injected \__vite\_\_mapDeps code
([#​16184](https://togithub.com/vitejs/vite/issues/16184 ))
([c0ec6be](https://togithub.com/vitejs/vite/commit/c0ec6be )), closes
[#​16184](https://togithub.com/vitejs/vite/issues/16184 )
- perf(css): only replace empty chunk if imported
([#​16349](https://togithub.com/vitejs/vite/issues/16349 ))
([e2658ad](https://togithub.com/vitejs/vite/commit/e2658ad )), closes
[#​16349](https://togithub.com/vitejs/vite/issues/16349 )
###
[`v5.2.8`](https://togithub.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small528-2024-04-03-small )
[Compare
Source](https://togithub.com/vitejs/vite/compare/v5.2.7...v5.2.8 )
- fix: csp nonce injection when no closing tag
([#​16281](https://togithub.com/vitejs/vite/issues/16281 ))
([#​16282](https://togithub.com/vitejs/vite/issues/16282 ))
([3c85c6b](https://togithub.com/vitejs/vite/commit/3c85c6b )), closes
[#​16281](https://togithub.com/vitejs/vite/issues/16281 )
[#​16282](https://togithub.com/vitejs/vite/issues/16282 )
- fix: do not access document in `/@​vite/client` when not defined
([#​16318](https://togithub.com/vitejs/vite/issues/16318 ))
([646319c](https://togithub.com/vitejs/vite/commit/646319c )), closes
[#​16318](https://togithub.com/vitejs/vite/issues/16318 )
- fix: fix sourcemap when using object as `define` value
([#​15805](https://togithub.com/vitejs/vite/issues/15805 ))
([445c4f2](https://togithub.com/vitejs/vite/commit/445c4f2 )), closes
[#​15805](https://togithub.com/vitejs/vite/issues/15805 )
- fix(css): unknown file error happened with lightningcss
([#​16306](https://togithub.com/vitejs/vite/issues/16306 ))
([01af308](https://togithub.com/vitejs/vite/commit/01af308 )), closes
[#​16306](https://togithub.com/vitejs/vite/issues/16306 )
- fix(hmr): multiple updates happened when invalidate is called while
multiple tabs open
([#​16307](https://togithub.com/vitejs/vite/issues/16307 ))
([21cc10b](https://togithub.com/vitejs/vite/commit/21cc10b )), closes
[#​16307](https://togithub.com/vitejs/vite/issues/16307 )
- fix(scanner): duplicate modules for same id if glob is used in
html-like types
([#​16305](https://togithub.com/vitejs/vite/issues/16305 ))
([eca68fa](https://togithub.com/vitejs/vite/commit/eca68fa )), closes
[#​16305](https://togithub.com/vitejs/vite/issues/16305 )
- chore(deps): update all non-major dependencies
([#​16325](https://togithub.com/vitejs/vite/issues/16325 ))
([a78e265](https://togithub.com/vitejs/vite/commit/a78e265 )), closes
[#​16325](https://togithub.com/vitejs/vite/issues/16325 )
- refactor: use types from sass instead of
[@​types/sass](https://togithub.com/types/sass )
([#​16340](https://togithub.com/vitejs/vite/issues/16340 ))
([4581e83](https://togithub.com/vitejs/vite/commit/4581e83 )), closes
[#​16340](https://togithub.com/vitejs/vite/issues/16340 )
###
[`v5.2.7`](https://togithub.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small527-2024-03-29-small )
[Compare
Source](https://togithub.com/vitejs/vite/compare/v5.2.6...v5.2.7 )
- chore: deprecate splitVendorChunkPlugin
([#​16274](https://togithub.com/vitejs/vite/issues/16274 ))
([45a06da](https://togithub.com/vitejs/vite/commit/45a06da )), closes
[#​16274](https://togithub.com/vitejs/vite/issues/16274 )
- fix: skip injecting `__vite__mapDeps` when it's not used
([#​16271](https://togithub.com/vitejs/vite/issues/16271 ))
([890538a](https://togithub.com/vitejs/vite/commit/890538a )), closes
[#​16271](https://togithub.com/vitejs/vite/issues/16271 )
- fix(deps): update all non-major dependencies
([#​16258](https://togithub.com/vitejs/vite/issues/16258 ))
([7caef42](https://togithub.com/vitejs/vite/commit/7caef42 )), closes
[#​16258](https://togithub.com/vitejs/vite/issues/16258 )
- fix(hmr): don't mutate module graph when collecting modules
([#​16302](https://togithub.com/vitejs/vite/issues/16302 ))
([dfffea1](https://togithub.com/vitejs/vite/commit/dfffea1 )), closes
[#​16302](https://togithub.com/vitejs/vite/issues/16302 )
- fix(hmr): trigger hmr for missing file import errored module after
file creation
([#​16303](https://togithub.com/vitejs/vite/issues/16303 ))
([ffedc06](https://togithub.com/vitejs/vite/commit/ffedc06 )), closes
[#​16303](https://togithub.com/vitejs/vite/issues/16303 )
- fix(sourcemap): don't warn even if the sourcesContent is an empty
string ([#​16273](https://togithub.com/vitejs/vite/issues/16273 ))
([24e376a](https://togithub.com/vitejs/vite/commit/24e376a )), closes
[#​16273](https://togithub.com/vitejs/vite/issues/16273 )
- feat(hmr): reload when HTML file is created/deleted
([#​16288](https://togithub.com/vitejs/vite/issues/16288 ))
([1f53796](https://togithub.com/vitejs/vite/commit/1f53796 )), closes
[#​16288](https://togithub.com/vitejs/vite/issues/16288 )
</details>
---
### Configuration
📅 **Schedule**: Branch creation - "before 4am on monday" in timezone
Asia/Shanghai, Automerge - At any time (no schedule defined).
🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.
♻ **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:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNDAuMTAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4zNDAuMTAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbXX0=-->
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-06 09:35:15 +08:00
renovate[bot]
46b4f4fd31
chore(deps): lock file maintenance rust crates ( #3164 )
...
[](https://renovatebot.com )
This PR contains the following updates:
| Package | Type | Update | Change |
|---|---|---|---|
| | | lockFileMaintenance | All locks refreshed |
| [base64](https://togithub.com/marshallpierce/rust-base64 ) |
workspace.dependencies | patch | `0.22.0` -> `0.22.1` |
| [bpaf](https://togithub.com/pacak/bpaf ) | workspace.dependencies |
patch | `0.9.11` -> `0.9.12` |
| [flate2](https://togithub.com/rust-lang/flate2-rs ) |
workspace.dependencies | patch | `1.0.29` -> `1.0.30` |
| [num-traits](https://togithub.com/rust-num/num-traits ) |
workspace.dependencies | patch | `0.2.18` -> `0.2.19` |
| [serde](https://serde.rs )
([source](https://togithub.com/serde-rs/serde )) | workspace.dependencies
| patch | `1.0.199` -> `1.0.200` |
🔧 This Pull Request updates lock files to use the latest dependency
versions.
---
### Release Notes
<details>
<summary>marshallpierce/rust-base64 (base64)</summary>
###
[`v0.22.1`](https://togithub.com/marshallpierce/rust-base64/blob/HEAD/RELEASE-NOTES.md#0221 )
[Compare
Source](https://togithub.com/marshallpierce/rust-base64/compare/v0.22.0...v0.22.1 )
- Correct the symbols used for the predefined `alphabet::BIN_HEX`.
</details>
<details>
<summary>pacak/bpaf (bpaf)</summary>
###
[`v0.9.12`](https://togithub.com/pacak/bpaf/blob/HEAD/Changelog.md#bpaf-0912---2024-04-29 )
[Compare
Source](https://togithub.com/pacak/bpaf/compare/v0.9.11...v0.9.12 )
- better error messages
</details>
<details>
<summary>rust-lang/flate2-rs (flate2)</summary>
###
[`v1.0.30`](https://togithub.com/rust-lang/flate2-rs/releases/tag/1.0.30 ):
- docs.rs pages should build again
[Compare
Source](https://togithub.com/rust-lang/flate2-rs/compare/1.0.29...1.0.30 )
#### What's Changed
- Fix typos by [@​striezel](https://togithub.com/striezel ) in
[https://github.com/rust-lang/flate2-rs/pull/406 ](https://togithub.com/rust-lang/flate2-rs/pull/406 )
- Update actions/checkout in GitHub Actions workflows to v4 by
[@​striezel](https://togithub.com/striezel ) in
[https://github.com/rust-lang/flate2-rs/pull/407 ](https://togithub.com/rust-lang/flate2-rs/pull/407 )
- fix CI - `--all-features` wasn't tested and didn't work with arrival
of `zlib-rs` by [@​Byron](https://togithub.com/Byron ) in
[https://github.com/rust-lang/flate2-rs/pull/405 ](https://togithub.com/rust-lang/flate2-rs/pull/405 )
#### New Contributors
- [@​striezel](https://togithub.com/striezel ) made their first
contribution in
[https://github.com/rust-lang/flate2-rs/pull/406 ](https://togithub.com/rust-lang/flate2-rs/pull/406 )
**Full Changelog**:
https://github.com/rust-lang/flate2-rs/compare/1.0.29...1.0.30
</details>
<details>
<summary>rust-num/num-traits (num-traits)</summary>
###
[`v0.2.19`](https://togithub.com/rust-num/num-traits/blob/HEAD/RELEASES.md#Release-0219-2024-05-03 )
[Compare
Source](https://togithub.com/rust-num/num-traits/compare/num-traits-0.2.18...num-traits-0.2.19 )
- [Upgrade to 2021 edition, **MSRV 1.60**][310]
- [The new `Float::clamp` limits values by minimum and maximum][305]
**Contributors**: [@​cuviper](https://togithub.com/cuviper ),
[@​michaelciraci](https://togithub.com/michaelciraci )
[305]: https://togithub.com/rust-num/num-traits/pull/305
[310]: https://togithub.com/rust-num/num-traits/pull/310
</details>
<details>
<summary>serde-rs/serde (serde)</summary>
###
[`v1.0.200`](https://togithub.com/serde-rs/serde/releases/tag/v1.0.200 )
[Compare
Source](https://togithub.com/serde-rs/serde/compare/v1.0.199...v1.0.200 )
- Fix formatting of "invalid type" and "invalid value" deserialization
error messages containing NaN or infinite floats
([#​2733](https://togithub.com/serde-rs/serde/issues/2733 ), thanks
[@​jamessan](https://togithub.com/jamessan ))
</details>
---
### Configuration
📅 **Schedule**: Branch creation - "before 4am on monday" in timezone
Asia/Shanghai, Automerge - At any time (no schedule defined).
🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.
♻ **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:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNDAuMTAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4zNDAuMTAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbXX0=-->
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-06 09:33:57 +08:00
renovate[bot]
166bc315d9
chore(deps): lock file maintenance vscode npm packages ( #3165 )
...
[](https://renovatebot.com )
This PR contains the following updates:
| Package | Type | Update | Change | Age | Adoption | Passing |
Confidence |
|---|---|---|---|---|---|---|---|
| | | lockFileMaintenance | All locks refreshed | | | | |
|
[@types/node](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node )
([source](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node ))
| devDependencies | patch | [`20.12.7` ->
`20.12.8`](https://renovatebot.com/diffs/npm/@types%2fnode/20.12.7/20.12.8 )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
| [@vscode/vsce](https://code.visualstudio.com )
([source](https://togithub.com/Microsoft/vsce )) | devDependencies |
patch | [`2.26.0` ->
`2.26.1`](https://renovatebot.com/diffs/npm/@vscode%2fvsce/2.26.0/2.26.1 )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
🔧 This Pull Request updates lock files to use the latest dependency
versions.
---
### Release Notes
<details>
<summary>Microsoft/vsce (@​vscode/vsce)</summary>
###
[`v2.26.1`](https://togithub.com/microsoft/vscode-vsce/releases/tag/v2.26.1 )
[Compare
Source](https://togithub.com/Microsoft/vsce/compare/v2.26.0...v2.26.1 )
#### Changes:
##### Feature Requests:
- [#​971](https://togithub.com/Microsoft/vsce/issues/971 ):
Validate nls strings on publish
##### Others:
- [#​974](https://togithub.com/Microsoft/vsce/issues/974 ):
Validate NLS strings
- [#​973](https://togithub.com/Microsoft/vsce/issues/973 ): Fix
nodejs breaking change CVE-2024-27980
This list of changes was [auto
generated](https://dev.azure.com/monacotools/Monaco/\_build/results?buildId=271623\&view=logs ).
</details>
---
### Configuration
📅 **Schedule**: Branch creation - "before 4am on monday" in timezone
Asia/Shanghai, Automerge - At any time (no schedule defined).
🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.
♻ **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:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNDAuMTAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4zNDAuMTAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbXX0=-->
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-06 09:33:25 +08:00
renovate[bot]
e5c08163af
chore(deps): update dependency tar to v7.1.0 ( #3162 )
...
[](https://renovatebot.com )
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [tar](https://togithub.com/isaacs/node-tar ) | [`7.0.1` ->
`7.1.0`](https://renovatebot.com/diffs/npm/tar/7.0.1/7.1.0 ) |
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
---
### Release Notes
<details>
<summary>isaacs/node-tar (tar)</summary>
###
[`v7.1.0`](https://togithub.com/isaacs/node-tar/compare/v7.0.1...v7.1.0 )
[Compare
Source](https://togithub.com/isaacs/node-tar/compare/v7.0.1...v7.1.0 )
</details>
---
### Configuration
📅 **Schedule**: Branch creation - "before 8am on monday" in timezone
Asia/Shanghai, Automerge - At any time (no schedule defined).
🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.
♻ **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:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNDAuMTAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4zNDAuMTAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbXX0=-->
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-06 09:33:06 +08:00
Dunqing
f88f330426
feat(linter/import): improve multiple exports error message ( #3160 )
...
https://github.com/oxc-project/oxc/issues/3157#issuecomment-2094113518
2024-05-04 22:14:26 +08:00
Boshen
a7940868c6
Release oxlint and vscode extension v0.3.2
2024-05-04 21:08:49 +08:00
Boshen
d78edb1eb5
chore(linter): move more import plugin rules out of nursery
2024-05-04 19:07:25 +08:00
Dunqing
6f5df113af
feat(linter/import): move some rules out of nursery ( #2841 )
...
### Correctness
- named
- export
- default
- namespace
- no-unresolved
The above rules will prevent bugs or broken, so I changed these to
correctness
### Suspicious
- no-duplicates
- no-named-as-default-member
- no-named-as-default
I'm still not sure whether the `no-unresolved` rule should be changed to
`correctness`. Because I found that the rule reported a lot in the
AFFiNE. But in fact, they are all correct reports
---------
Co-authored-by: Boshen <boshenc@gmail.com>
2024-05-04 18:51:26 +08:00
Boshen
fde7d65992
fix(linter): handle named export default in import-plugin/named ( #3158 )
2024-05-04 17:40:56 +08:00
Boshen
b1bddacd09
fix(linter): fix hang if a file fails to parse while using --import-plugin
2024-05-04 17:16:43 +08:00
Boshen
222030c4c5
refactor(linter): render --rules in a table
2024-05-04 15:31:20 +08:00
Boshen
bf932be94f
chore(README): add sponsors
2024-05-04 10:57:53 +08:00
Boshen
cf2db1ef3a
ci: fix broken cargo bloat command
2024-05-04 00:03:21 +08:00
Wang Wenzhe
32df6d779c
feat(linter/tree-shaking): support While/Switch/Yield Statement ( #3155 )
...
All test cases passed now. There are something remain. I'll change the category when it's ready.
- [ ] Port [`isPureFuncion`](96f0d1c825/src/utils/helpers.ts (L53-L67) ), [pure-function](198432ecc9/src/utils/pure-functions.ts )
- [ ] Support [options](463fa1f0be/src/rules/no-side-effects-in-initialization.ts (L1130-L1138) )
- [ ] Clean TODO
- [ ] Add more support of operator computation. [The original version](463fa1f0be/src/rules/no-side-effects-in-initialization.ts (L139-L210) ) is straightforward benefit of JS. We only [support Number](f91a063616/crates/oxc_linter/src/utils/tree_shaking.rs (L194) ) now.
2024-05-03 23:21:28 +08:00
Wang Wenzhe
8290421e72
feat(linter/tree-shaking): support SequenceExpression ( #3154 )
2024-05-03 23:19:36 +08:00
Wang Wenzhe
5c21b7f843
feat(linter/tree-shaking): support UnaryExpression ( #3153 )
2024-05-03 23:17:15 +08:00
renovate[bot]
56a0db8621
chore(deps): update dependency rust to v1.78.0 ( #3151 )
2024-05-03 00:01:42 +08:00
Yuji Sugiura
5a1d63afed
feat(linter/jsdoc): Implement require-yields rule ( #3150 )
...
Part of #1170
>
https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-yields.md
With:
- Fix typo of JSDocPluginSettings
- Update utils/jsdoc
2024-05-02 22:49:19 +08:00
Yuji Sugiura
d7a8345e4c
feat(linter/jsdoc): Support settings.ignore(Private|Internal) ( #3147 )
...
>
https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/settings.md#user-content-settings-allow-tags-private-or-internal-to-disable-rules-for-that-comment-block
...and fixed the issue that intended initial settings values are not
used in some cases.
2024-05-01 19:48:28 +08:00
Wang Wenzhe
8cdd5b0fd8
feat(linter/tree_shaking): support LogicExpression and MemberExpression ( #3148 )
...
MemberExpression's message is not accurate, I will update later.
2024-05-01 19:46:40 +08:00
kaykdm
80cf0b2b2e
feat(linter): @typescript-eslint/prefer-literal-enum-member ( #3134 )
...
Related issue: https://github.com/oxc-project/oxc/issues/2180
original implementation
- code: https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/rules/prefer-literal-enum-member.ts
- test: https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/tests/rules/prefer-literal-enum-member.test.ts
- doc: https://typescript-eslint.io/rules/prefer-literal-enum-member/
2024-05-01 11:17:46 +08:00
Dunqing
a52e321b25
feat(transformer/jsx-source): get the correct lineNumber and columnNumber from the span. ( #3142 )
2024-05-01 00:30:47 +00:00
Boshen
bdae6b0e4e
chore(npm/oxc-parser): document parseOptions
...
closes #3114
2024-04-30 23:11:31 +08:00
Boshen
f5dccc96fd
refactor(coverage): avoid an String::from_utf8 over head during serialization ( #3145 )
2024-04-30 23:11:22 +08:00
Boshen
67225a8091
refactor(coverage): replace yaml parsing with saphyr ( #3144 )
...
closes #3128
Profiling `cargo run -p oxc_coverage -- parser` no longer shows a
bottleneck in yaml parsing
2024-04-30 22:49:39 +08:00
Dunqing
be8fabedab
feat(transformer/react): enable jsx plugin when development is true ( #3141 )
2024-04-30 15:48:17 +08:00
Boshen
a63a45d5b2
refactor(transformer): remove the requirement of Semantic ( #3140 )
...
It seems like we need to rebuild the scopes and symbols while
traversing. We can't utilize the scopes and symbols built by semantic
because they are immutable.
2024-04-30 12:48:21 +08:00
Wang Wenzhe
733361822e
feat(linter/tree-shaking): support JSX ( #3139 )
2024-04-30 11:25:39 +08:00
Wang Wenzhe
16a31e95b8
feat(linter/tree-shaking): support import statement ( #3138 )
2024-04-30 11:23:23 +08:00
Boshen
d76507699d
chore(transform_conformance): skip transform-destructuring ( #3136 )
2024-04-30 00:09:22 +08:00
Boshen
5a3f8a5811
feat(transform_conformance): handle parse error ( #3135 )
2024-04-30 00:07:53 +08:00
Dunqing
b5894964d1
fix(transformer/arrow-functions): should not transform this in class ( #3129 )
2024-04-29 13:44:10 +00:00
Boshen
f1ccbd4856
feat(syntax): add ToJsInt32 trait for f64 ( #3132 )
2024-04-29 21:13:04 +08:00
Boshen
870d11f1bb
feat(syntax): add ToJsString trait for f64 ( #3131 )
2024-04-29 21:00:04 +08:00
Boshen
a8af5de8f5
refactor(syntax): move number related functions to number module ( #3130 )
2024-04-29 18:54:35 +08:00
Dunqing
843318cdbe
refactor(transformer/typescript): reimplementation of Enum conversion based on Babel ( #3102 )
...
The remaining test cases will perform better with a scope
implementation, and while we can implement them without the scope, it
still requires us to do what the scope did.
---------
Co-authored-by: Boshen <boshenc@gmail.com>
2024-04-29 16:26:22 +08:00
Dunqing
905ee3fef1
feat(transformer): add arrow-functions plugin ( #3083 )
...
close : #2983
2024-04-29 08:04:01 +00:00
renovate[bot]
6fd6170154
chore(deps): lock file maintenance rust crates ( #3125 )
2024-04-29 06:00:15 +00:00
Boshen
ae6561308c
refactor(syntax): use FxHashMap for ModuleRecord::request_modules ( #3124 )
...
closes #3121
The ordering is not important here.
2024-04-29 03:37:34 +00:00
renovate[bot]
14e4c58540
chore(deps): update pnpm to v9.0.6 ( #3123 )
...
[](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.0.5` -> `9.0.6`](https://renovatebot.com/diffs/npm/pnpm/9.0.5/9.0.6 )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
---
### Release Notes
<details>
<summary>pnpm/pnpm (pnpm)</summary>
### [`v9.0.6`](https://togithub.com/pnpm/pnpm/compare/v9.0.5...v9.0.6 )
[Compare Source](https://togithub.com/pnpm/pnpm/compare/v9.0.5...v9.0.6 )
</details>
---
### Configuration
📅 **Schedule**: Branch creation - "before 8am on monday" in timezone
Asia/Shanghai, Automerge - At any time (no schedule defined).
🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.
♻ **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:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMjEuMiIsInVwZGF0ZWRJblZlciI6IjM3LjMyMS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-29 09:37:30 +08:00
overlookmotel
514228ad42
deps(allocator): disable serde dep by default ( #3120 )
...
`oxc_allocator` currently depends on `serde`, although it's generally
not required.
This PR puts the dependency behind a feature `serialize`.
NB: `serde` is needed for the crate's tests, but this can be enabled by
adding it to `dev-dependencies` and putting the impls behind
`#[cfg(any(feature = "serialize", test))]`.
2024-04-28 22:17:32 +08:00
Wang Wenzhe
8f31ad618e
chore(linter/tree-shaking): uncomment function and identifier test cases ( #3119 )
2024-04-28 22:05:33 +08:00
overlookmotel
7e1fe36c68
refactor(ast): squash nested enums ( #3115 )
...
OK, this is a big one...
I have done this as part of work on Traversable AST, but I believe it
has wider benefits, so thought better to spin it off into its own PR.
## What this PR does
This PR squashes all nested AST enum types (#2685 ).
e.g.: Previously:
```rs
pub enum Statement<'a> {
BlockStatement(Box<'a, BlockStatement<'a>>),
/* ...other Statement variants... */
Declaration(Declaration<'a>),
}
pub enum Declaration<'a> {
VariableDeclaration(Box<'a, VariableDeclaration<'a>>),
/* ...other Declaration variants... */
}
```
After this PR:
```rs
#[repr(C, u8)]
pub enum Statement<'a> {
BlockStatement(Box<'a, BlockStatement<'a>>) = 0,
/* ...other Statement variants... */
VariableDeclaration(Box<'a, VariableDeclaration<'a>>) = 32,
/* ...other Declaration variants... */
}
#[repr(C, u8)]
pub enum Declaration<'a> {
VariableDeclaration(Box<'a, VariableDeclaration<'a>>) = 32,
/* ...other Declaration variants... */
}
```
All `Declaration`'s variants are combined into `Statement`, but
`Declaration` type still exists.
As both types are `#[repr(C, u8)]`, and the discriminants are aligned, a
`Declaration` can be transmuted to a `Statement` at zero cost.
This is the same thing as #2847 , but here applied to *all* nested enums
in the AST, and with improved helper methods.
No enums increase in size, and a few get smaller. Indirection is reduced
for some types (this removes multiple levels of boxing).
## Why?
1. It is a prerequisite for Traversable AST (#2987 ).
2. It would help a lot with AST Transfer (#2409 ) - it solves the only
remaining blocker for this.
3. It is a step closer to making the whole AST `#[repr(C)]`.
## Why is it a good thing for the AST to be `#[repr(C)]`?
Oxc's direction appears to be increasingly to build up control over the
fundamental primitives we use, in order to unlock performance and
features. We have our own allocator, our own custom implementations for
`Box` and `Vec`, our own `IndexVec` (TBC). The AST is the central
building block of Oxc, and taking control of its memory layout feels
like a step in this same direction.
Oxc has a major advantage over other similar libraries in that it keeps
all the AST data in an arena. This opens the door to treating the AST
either as Rust types or as *pure data* (just bytes). That data can be
moved around and manipulated beyond what Rust natively allows.
However, to enable that, the types need to be well-specified, with
completely stable layouts. `#[repr(C)]` is the only tool Rust provides
to do this.
Once the types are `#[repr(C)]`, various features become possible:
1. Cheap transfer of the AST across boundaries without ser/deser - the
property used by AST Transfer.
2. Having multiple versions of the AST (standard, read-only,
traversable), and these AST representations can be converted to one
other at zero cost via transmute - the property used by Traversable AST
scheme.
3. Caching AST data on disk (#3079 ) or transferring across network.
4. Stuff we haven't thought of yet!
Allowing the AST to be treated as pure data will likely unlock other
"next level" features further down the track (caching for "edge
bundling" comes to mind).
## The problem with `#[repr(C)]`
It's not *required* to squash nested enums to make the AST `#[repr(C)]`.
But the problem with `#[repr(C)]` is that it disables some compiler
optimizations. Without `#[repr(C)]`, the compiler squashes enums itself
in some cases (which is how `Statement` is currently 16 bytes). But
making the types `#[repr(C)]` as they are currently disables this
optimization.
So this PR essentially makes explicit what the compiler is already doing
- and in fact goes a bit further with the optimization than the compiler
is able to, in squashing 3 or 4 layers of nested enums (the compiler
only does up to 2 layers).
## Implementation
One enum "inheriting" variants from another is implemented with
`inherit_variants!` macro.
```rs
inherit_variants! {
#[repr(C, u8)]
pub enum Statement<'a> {
BlockStatement(Box<'a, BlockStatement<'a>>),
/* ...other Statement variants... */
// `Declaration` variants added here by `inherit_variants!` macro
@inherit Declaration
// `ModuleDeclaration` variants added here by `inherit_variants!` macro
@inherit ModuleDeclaration
}
}
```
The macro is *fairly* lightweight, and I think the above is quite easy
to understand. No proc macros.
The macro also implements utility methods for converting between enums
e.g. `Statement::as_declaration`. These methods are all zero-cost
(essentially transmutes).
New patterns for dealing with nested enums are introduced:
Creation:
```rs
// Old
let stmt = Statement::Declaration(Declaration::VariableDeclaration(var_decl));
// New
let stmt = Statement::VariableDeclaration(var_decl);
```
Conversion:
```rs
// Old
let stmt = Statement::Declaration(decl);
// New
let stmt = Statement::from(decl);
```
Testing:
```rs
// Old
if matches!(stmt, Statement::Declaration(_)) { }
if matches!(stmt, Statement::ModuleDeclaration(m) if m.is_import()) { }
// New
if stmt.is_declaration() { }
if matches!(stmt, Statement::ImportDeclaration(_)) { }
```
Branching:
```rs
// Old
if let Statement::Declaration(decl) = &stmt { decl.do_stuff() };
// New
if let Some(decl) = stmt.as_declaration() { decl.do_stuff() };
```
Matching:
```rs
// Old
match stmt {
Statement::Declaration(decl) => visitor.visit(decl),
}
// New (exhaustive match)
match stmt {
match_declaration!(Statement) => visitor.visit(stmt.to_declaration()),
}
// New (alternative)
match stmt {
_ if stmt.is_declaration() => visitor.visit(stmt.to_declaration()),
}
```
New syntax has pluses and minuses vs the old. `match` syntax is worse,
but when working with a deeply nested enum, the code is much nicer -
it's shorter and easier to read.
This PR removes 200 lines from the linter with changes like this:
https://github.com/oxc-project/oxc/pull/3115/files#diff-dc417ff57352da6727a760ec6dee22de6816f8231fb69dbef1bf05d478699103L92-R95
```diff
- let AssignmentTarget::SimpleAssignmentTarget(simple_assignment_target) =
- &assignment_expr.left
- else {
- return;
- };
- let SimpleAssignmentTarget::AssignmentTargetIdentifier(ident) =
- simple_assignment_target
+ let AssignmentTarget::AssignmentTargetIdentifier(ident) = &assignment_expr.left
else {
return;
};
```
2024-04-28 20:40:37 +08:00