overlookmotel
d71f0ed2d0
refactor(traverse): inline all passthrough methods ( #5279 )
...
Many methods of `TraverseCtx` just delegate to methods of `TraverseAncestry` or `TraverseScoping`. Mark them all `#[inline]`.
2024-08-28 01:07:11 +00:00
overlookmotel
188ce0766f
refactor(traverse): improve safety via type system ( #5277 )
...
Guard against mistakes in `oxc_traverse` codegen by making it impossible to pop from ancestors stack more times than have pushed.
2024-08-28 01:07:11 +00:00
overlookmotel
0f4a8b39d3
refactor(traverse): add debug asserts for safety invariants ( #5272 )
...
Add `debug_assert!`s for unchecked invariants.
2024-08-28 01:07:11 +00:00
overlookmotel
341e42ac4c
refactor(traverse): make Ancestor an owned type ( #5269 )
...
Make the `Ancestor` type used in `oxc_traverse` an owned type. Instead of `TraverseCtx::parent` returning a `&'t Ancestor<'a>`, it now returns an `Ancestor<'a, 't>`.
This allows `Ancestor` to be `Copy`.
The `'t` lifetime plays the same role in both cases - preventing any `Ancestor` from escaping from the `enter_*` / `exit_*` method in which it's obtained.
Same for the `*Without*` types which are `Ancestor` enum's "payloads". Any AST node references obtained from an `Ancestor` are also constrained by same `'t` lifetime - e.g. `&'t Statement<'a>`.
2024-08-28 01:07:10 +00:00
Kevin Deng 三咲智子
ac8fabd442
chore: fix precommit install hook ( #5271 )
...
Add `-e` for enabling interpretation of backslash escapes.
Before:
```
#!/bin/sh\njust fmt
```
2024-08-28 09:04:29 +08:00
camc314
c8e85323cb
feat(linter/unicorn): add fixer to throw-new-error ( #5275 )
...
got merged into the wrong branch (https://github.com/oxc-project/oxc/pull/5148 ), hence setting to merge when ready (as was already approved)
2024-08-27 20:51:35 +00:00
Kevin Deng 三咲智子
681bd8071a
fix(wasm): reference ast from prettier ( #5268 )
...
regression by cc3332898c
2024-08-27 22:15:26 +08:00
overlookmotel
c23104b2a2
feat(wasm): output symbol IDs in scope tree ( #5266 )
...
`oxc_wasm` include `SymbolId`s in print-out of scopes.
2024-08-27 13:49:44 +00:00
overlookmotel
6a49dc36b2
perf(wasm): generate scope text with visitor ( #5264 )
...
Follow-on after #5232 . `oxc_wasm` build scopes text with a single AST traversal. Previous implementation was O($n^2$).
If we can assume scopes are listed in traversal order, then we could do it a bit more efficiently just from `ScopeTree`, but this approach of using `Visit` will handle out-of-order scope IDs (which you'd get if printing a post-transform `ScopeTree`).
Also reduce creating and discarding `String`s for indentation - reuse a single string instead.
2024-08-27 13:49:42 +00:00
overlookmotel
05d25e2aa3
refactor(semantic): combine add scope methods ( #5262 )
...
#5232 removed `ScopeTree::child_ids`, so it's no longer necessary to have separate `add_scope` and `add_root_scope` methods.
2024-08-27 13:00:21 +00:00
overlookmotel
17d8a88415
fix(wasm): display correct scope IDs ( #5263 )
...
`ScopeId`s were printed incorrectly. `+ 1` used to be correct, but isn't
any more since `ScopeId` became a `NonMaxU32`.
2024-08-27 20:39:07 +08:00
overlookmotel
fdedc0f8b1
refactor(semantic): transform checker: rename SemanticData to Scoping ( #5261 )
...
Pure refactor. Rename type and vars with a more descriptive name.
2024-08-27 11:58:21 +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
Kevin Deng 三咲智子
cc3332898c
perf(wasm): reuse parse result for prettier ( #5254 )
2024-08-27 16:56:18 +08:00
overlookmotel
892a7fab60
refactor(semantic): replace ref syntax ( #5253 )
...
Pure code style refactor. Prefer `if let Some(y) = &x.y` over `if let Some(ref y) = x.y`.
2024-08-27 08:13:14 +00:00
overlookmotel
cbb47252ba
refactor(semantic): add comment to transform checker ( #5250 )
...
Add back a doc comment which was accidentally removed in #5232 .
2024-08-27 07:38:52 +00:00
Boshen
fea2746b73
chore: switch playground to https://github.com/oxc-project/playground ( #5249 )
...
playground app: https://oxc-playground.netlify.app/
2024-08-27 15:14:36 +08:00
Boshen
484f0d7579
fix(wasm): fix broken prettier
2024-08-27 14:25:25 +08:00
Kevin Deng 三咲智子
8b53ef9b27
feat(wasm): add option preserve_parens ( #5237 )
2024-08-27 12:10:08 +08:00
Dunqing
9953fa54a4
fix(linter/no-null): incorrect fixer for NullLiteral within ReturnStatement ( #5247 )
...
close : #5194
It’s a long time no contributed to Linter, I'd like to try it
2024-08-27 03:51:56 +00:00
Billy Levin
a6e97690a7
feat(linter/jsx-a11y): add label-has-associated-control ( #5163 )
2024-08-26 23:33:55 -04: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
DonIsaac
5a137f0985
feat(span/source-type): add SourceType factory methods ( #5242 )
2024-08-27 01:19:54 +00:00
DonIsaac
94f60e7748
refactor(span/source-type): make SourceType factories const ( #5241 )
...
I found myself wanting this while writing `no-unused-vars` and while using oxc
in some downstream personal projects.
2024-08-27 01:19:53 +00:00
DonIsaac
f5e05db302
feat(span/source-type): impl Display and Error for UnknownExtension ( #5240 )
2024-08-27 01:19:52 +00:00
DonIsaac
a6bb3b1b98
fix(span/source-type): consider .cjs and .cts files as ModuleKind::Script ( #5239 )
...
- fix: `SourceType::from_path` considers `.cjs` and `.cts` as modules, not scripts
- docs: improve rusdoc for `SourceType::from_path`
- test: add unit tests for `SourceType::from_path`
2024-08-27 01:19:52 +00:00
Kevin Deng 三咲智子
1af7f04a36
feat(wasm): output panic info to console ( #5238 )
...
Playground Preview:
<img width="1769" alt="image"
src="https://github.com/user-attachments/assets/12143fb5-f6a6-48bc-8dee-cf85b6c52392 ">
2024-08-27 09:12:15 +08:00
Kevin Deng 三咲智子
30ecbf649b
refactor(wasm): combine into a options ( #5235 )
2024-08-27 09:11:30 +08:00
Kevin Deng 三咲智子
167f7e452d
fix(wasm): set both scope and symbol ( #5236 )
2024-08-27 09:10:41 +08:00
camc314
b39544e0f2
fix(linter/jest): fixer for prefer-jest-mocked creates invalid LHS expressions ( #5243 )
...
closes #5228
interestingly `eslint-plugin-jest` reports an error on this code, it also immedietly fixes it.
however fixing here is not good as it results in invalid code.
should fix https://github.com/oxc-project/oxlint-ecosystem-ci/actions/runs/10518058484/job/29247525457
2024-08-27 00:42:01 +00:00
camc314
9f772c9872
fix(linter) bug in fixer for func-names when function name is shadowed ( #5231 )
...
closes #5229
2024-08-26 14:32:42 +00:00
overlookmotel
bc59dd2b29
refactor(parser): improve example for byte_search! macro usage ( #5234 )
...
It's more efficient when reading 2 bytes to use `read2()` than 2 x `read()` calls. Reflect that in example for using `byte_search!` macro.
2024-08-26 14:22:37 +00:00
overlookmotel
a3ddfdd9d7
refactor(parser): improve lexer pointer maths ( #5233 )
...
Small tweaks to pointer maths in lexer which may result in slightly more compact assembly.
2024-08-26 14:22:36 +00:00
camc314
7ccde4b853
feat(linter/unicorn): add fixer to prefer-date-now ( #5147 )
2024-08-26 14:05:01 +00:00
camc314
a58e44845f
feat(linter/eslint): add fixer to no-var ( #5144 )
2024-08-26 13:59:26 +00:00
Kevin Deng 三咲智子
4641034710
fix(wasm): correct ir type ( #5226 )
...
Fixes type error:
https://github.com/oxc-project/playground/actions/runs/10557625323/job/29245568111?pr=22
2024-08-26 21:41:57 +08:00
Dunqing
49606ef2d8
fix(website): failed to build ( #5230 )
...
https://github.com/oxc-project/oxc/actions/runs/10558055209/job/29246786880
Looks caused by #5213
2024-08-26 19:41:40 +08:00
overlookmotel
12a7607bac
perf(codegen): inline Codegen::print_list ( #5221 )
...
Revert #5192 and add a comment that it's not a perf gain.
This was really surprising to me, but the benchmarks do demonstrate it.
Please see the benchmarks commit-by-commit on this PR. Adding `#[inline]` to the function does give +1% gain, but it's no better than it was before #5192 . So I think preferable to just revert to the simpler original.
I think likely explanation is that the compiler is already performing this optimization itself. And if it does it itself, then it understands the code better, and can then make better decisions about inlining.
https://godbolt.org/z/xzhWWeMoe seems to demonstrate this - there are 2 calls to `Item::gen` in the generated assembly, so it has split the loop into 2.
2024-08-26 10:28:49 +00: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
oxc-bot
2a001a043c
Release oxlint v0.9.0 ( #5219 )
...
## [0.9.0] - 2024-08-26
- 5946748 linter: [**BREAKING**] Parse and display syntax errors for
regular expressions (#5214 ) (Boshen)
- b894d3b linter: [**BREAKING**] Make `no-unused-vars` correctness
(#5081 ) (DonIsaac)
### Features
- 1ce9630 linter/config: Implement FromIterator for LintPluginOptions
(#5102 ) (DonIsaac)
- 34bfaf6 linter/react: Add fixer to `jsx-props-no-spread-multi` (#5145 )
(camc314)
- 982bd6e linter/unicorn: Add fixer to `require-array-join-separator`
(#5152 ) (camc314)
- a6704bd linter/unicorn: Add fixer to `prefer-set-size` (#5149 )
(camc314)
- ac7edcc linter/unicorn: Add fixer to `prefer-array-some` (#5153 )
(camc314)
- 1d01aa3 linter/unicorn: Add partial fixer for `prefer-array-flat`
(#5143 ) (camc314)
- 22d57f9 linter/unicorn: Add fixer to `prefer-string-slice` (#5150 )
(Cameron)
- 2fe4415 linter/unicorn: Add fixer to `no-redundant-roles` (#5146 )
(Cameron)
- d35c6f5 linter/unicorn: Add fixer to `prefer-regexp-test` (#5151 )
(Cameron)
- 27db769 linter/unicorn: Add fixer to `text-encoding-identifier-case`
(#5154 ) (Cameron)
- f7958c4 linter/unicorn: Add prefer-structured-clone (#5095 ) (Jelle van
der Waa)
- 004ffa0 linter/vitest: Implement `prefer-each` (#5203 ) (dalaoshu)
### Bug Fixes
- aaaf26c linter: Error in fixer for prefer-to-have-length (#5197 )
(dalaoshu)
- 1f5b6b6 linter: Bug in fixer for prefer-to-have-length (#5164 )
(dalaoshu)
- 7eb052e linter: `no-hex-escape` fixer removing regex flags (#5137 )
(Cameron)
- 76c66b4 linter/max-lines: Point span to end of file for disable
directive to work (#5117 ) (Boshen)
- 8ff6f2c linter/no-unused-vars: Panic on UsingDeclarations (#5206 )
(DonIsaac)
- d29042e linter/no-unused-vars: Function expression in implicit arrow
function return (#5155 ) (DonIsaac)
- 36e4a28 linter/no-unused-vars: Panic in variable declarator usage
checks (#5160 ) (DonIsaac)
- ba62a71 linter/react: Fixed false positive with missing key inside
React.Children.toArray() for fragments (#5133 ) (Earl Chase)
- fd1031a linter/unicorn: Breaking fixer in case statements for
`no-null` (#5176 ) (DonIsaac)
- 7b86ed6 linter/unicorn: Handle type casts and parens in `no-null`
(#5175 ) (Don Isaac)
- b629e16 linter/unicorn: Improve diagnostic message for `no-null`
(#5172 ) (DonIsaac)
### Performance
- ce454cf Use simdutf8 to validate UTF-8 when reading files (#5196 )
(dalaoshu)
### Refactor
- 543cad6 codegen: Remove some pub APIs (Boshen)
- 0d3661a linter: Remove meaningless `span0` (#5209 ) (dalaoshu)
- 2a91ef1 linter: `eslint/no_redeclare` rule use `run_on_symbol` not
`run_once` (#5201 ) (overlookmotel)
- 33599b0 linter: Split options into multiple files (#5101 ) (DonIsaac)
- 7ab6152 linter/unicorn: Clean up `no-null` (#5174 ) (DonIsaac)
### Testing
- a877e5a linter/no-unused-vars: Ensure type annotations on property
accessors are considered used (#5183 ) (DonIsaac)
- 7886618 linter/unicorn: Add fixer tests for `no-null` (#5173 )
(DonIsaac)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-08-26 16:50:15 +08:00
overlookmotel
d4c3778e02
refactor(codegen): rename vars ( #5222 )
...
Rename function params in default methods of `Codegen`. Makes no material difference, just nicer hints in IDE.
2024-08-26 08:40:50 +00:00
renovate[bot]
8109ed046d
chore(deps): update website npm packages ( #5220 )
...
[](https://renovatebot.com )
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@codemirror/view](https://togithub.com/codemirror/view ) | [`6.32.0`
->
`6.33.0`](https://renovatebot.com/diffs/npm/@codemirror%2fview/6.32.0/6.33.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/ )
|
| [vite](https://vitejs.dev )
([source](https://togithub.com/vitejs/vite/tree/HEAD/packages/vite )) |
[`5.4.1` -> `5.4.2`](https://renovatebot.com/diffs/npm/vite/5.4.1/5.4.2 )
|
[](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>codemirror/view (@​codemirror/view)</summary>
###
[`v6.33.0`](https://togithub.com/codemirror/view/blob/HEAD/CHANGELOG.md#6330-2024-08-24 )
[Compare
Source](https://togithub.com/codemirror/view/compare/6.32.0...6.33.0 )
##### Bug fixes
Make it easier to move the pointer over a hover tooltip with an arrow by
not closing the tooltip when the pointer is moving over the gap for the
arrow.
##### New features
The new `EditorView.clipboardInputFilter` and `clipboardOutputFilter`
facets allow you to register filter functions that change text taken
from or sent to the clipboard.
</details>
<details>
<summary>vitejs/vite (vite)</summary>
###
[`v5.4.2`](https://togithub.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small542-2024-08-20-small )
[Compare
Source](https://togithub.com/vitejs/vite/compare/v5.4.1...v5.4.2 )
- chore: remove stale TODOs
([#​17866](https://togithub.com/vitejs/vite/issues/17866 ))
([e012f29](e012f296df )),
closes [#​17866](https://togithub.com/vitejs/vite/issues/17866 )
- refactor: remove redundant prepend/strip base
([#​17887](https://togithub.com/vitejs/vite/issues/17887 ))
([3b8f03d](3b8f03d789 )),
closes [#​17887](https://togithub.com/vitejs/vite/issues/17887 )
- fix: resolve relative URL generated by `renderBuiltUrl` passed to
module preload
([#​16084](https://togithub.com/vitejs/vite/issues/16084 ))
([fac3a8e](fac3a8ed68 )),
closes [#​16084](https://togithub.com/vitejs/vite/issues/16084 )
- feat: support originalFilename
([#​17867](https://togithub.com/vitejs/vite/issues/17867 ))
([7d8c0e2](7d8c0e2dcb )),
closes [#​17867](https://togithub.com/vitejs/vite/issues/17867 )
</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-26 08:26:46 +00:00
leaysgur
46b641b75d
feat(regular_expression): Validate max quantifier value ( #5218 )
...
I've never seen but `/a{9007199254740991}/` is valid and this is the maximum value for quantifier.
\+ left comment about #5210 experiment.
2024-08-26 07:11:04 +00:00
Kevin Deng 三咲智子
b39c0d6122
refactor(wasm): add source_type for parser, replace class options with plain object ( #5217 )
...
- Feat: add `source_type` to `ParserOptions`
- Refactor: use plain objects for options instead of `new
OxcRunOptions()` and `new OxcParserOptions()`, allowing easier
serialization.
2024-08-26 15:08:35 +08:00
renovate[bot]
b4fc521087
chore(deps): update dependency @types/node to v22.5.0 ( #5216 )
...
[](https://renovatebot.com )
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[@types/node](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node )
([source](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node ))
| [`22.4.0` ->
`22.5.0`](https://renovatebot.com/diffs/npm/@types%2fnode/22.4.0/22.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/ )
|
---
### 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-26 05:35:01 +00:00
Boshen
5946748ca6
feat(linter)!: parse and display syntax errors for regular expressions ( #5214 )
...
cc @leaysgur shipping to production!
This is marked as breaking change because there may be false positives.
2024-08-26 05:23:45 +00:00