Boshen
70091771b6
test(parser): fix incorrect flow error test
2024-08-28 20:53:32 +08:00
Boshen
fb75d2576b
Revert "fix(parser): Revert "check for @flow with recoverable errors as well" ( #5297 )"
...
This reverts commit d4c06ef093 .
2024-08-28 20:53:13 +08:00
overlookmotel
d4c06ef093
fix(parser): Revert "check for @flow with recoverable errors as well" ( #5297 )
...
e1d8b92080 caused CI to fail. Revert it.
2024-08-28 12:48:37 +00:00
Boshen
e1d8b92080
fix(parser): check for @flow with recoverable errors as well
2024-08-28 19:39:07 +08:00
Boshen
5e27798dc3
chore(parser): parse regular expression in example
2024-08-28 19:32:44 +08:00
overlookmotel
b43a3948a1
refactor(traverse): correct code comments ( #5293 )
...
#5286 changed `TraverseCtx::ancestor` to always return an `Ancestor`. Update doc comments to reflect that.
2024-08-28 10:10:04 +00:00
Dunqing
292d162b23
feat(codegen): print missing fields for AccessorProperty ( #5291 )
...
Found in https://github.com/oxc-project/monitor-oxc/actions/runs/10592050362/job/29350666018
2024-08-28 08:42:39 +00:00
Dunqing
5754c89b5e
fix(transformer/typescript): remove accessibility from AccessorProperty ( #5292 )
...
Regression by #5290
2024-08-28 08:42:38 +00:00
Dunqing
550574982f
feat(ast): add accessibility field to AccessorProperty ( #5290 )
2024-08-28 08:42:37 +00:00
Arian94
76e86f80df
fix(linter): eslint-plugin-unicorn prefer-spread wrong linter suggestion on variables of type string ( #5265 )
...
fixes #5248 .
Similar issue found in here:
https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1147
2024-08-28 09:26:44 +01:00
overlookmotel
582ce9ea65
refactor(traverse)!: TraverseCtx::ancestor return Ancestor::None if out of bounds ( #5286 )
...
This aligns it better with `TraverseCtx::parent` which always returns an `Ancestor`.
2024-08-28 05:26:16 +00:00
Kevin Deng 三咲智子
234a24c14d
fix(ast)!: merge UsingDeclaration into VariableDeclaration ( #5270 )
...
relate #2854
2024-08-28 11:26:05 +08:00
leaysgur
15b87adb05
chore(regular_expression): Extract diagnostics ( #5287 )
...
- Extract `Diagnostic::error()`s to separate file
- Align error message prefix
2024-08-28 03:19:29 +00:00
camc314
d6b84ec44e
fix(linter) bug in fixer for no-null ( #5273 )
...
i tested this in the microsoft/vscode repo and there were no syntax errors after running the fixer 🎉
hopefully this is the last fix.
2024-08-28 02:14:38 +00:00
Boshen
e6fd52e2a6
fix(parser): change unterminated regex error to be non-recoverable ( #5285 )
...
closes #5257
2024-08-28 01:57:31 +00:00
leaysgur
cffce11620
fix(regular_expression): Prevent panic on too large number ( #5282 )
...
Partially close #5257
Use `checked_(mul|add)` to prevent panic.
2024-08-28 01:31:54 +00:00
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