Boshen
28b934ca74
fix(coverage): apply always_strict to test262 and typescript per the specifcation ( #5555 )
...
This also removes the confusing `SourceType::always_strict` field.
I hacked it with `SourceType::always_strict`, but what we actually want is add `'use strict'`.
This is technically a breaking change but I don't expect anyone using this outside of oxc.
The snapshot has a large diff due to every single line shifting by 1 row :-/
2024-09-06 17:14:01 +00:00
Boshen
b06052501a
refactor(semantic)!: remove source_type argument from SemanticBuilder::new ( #5553 )
...
Realized we can get the source type from the AST.
The next PR will introduce `unambiguous` to `SourceType` and directly set `Program::source_type` to either `script` or `module`.
2024-09-06 16:40:10 +00:00
Boshen
d62defb42d
fix(codegen): do not print trailing commas for ArrayExpression ( #5551 )
...
closes #5532
2024-09-06 16:35:10 +00:00
overlookmotel
14ee086182
refactor(ast): inline AstKind::as_* methods ( #5547 )
...
One would hope compiler will inline these trivial methods anyway, but mark them `#[inline]` to make sure.
2024-09-06 14:31:17 +00:00
overlookmotel
dc924892cc
test: add trailing line breaks to conformance fixtures ( #5541 )
...
Continuation of #5537 . Ensure all conformance fixture files have a trailing line break.
2024-09-06 12:55:17 +00:00
overlookmotel
694f032a3d
style: add trailing line breaks to package.json files ( #5542 )
...
For consistency with our `.editorconfig`.
2024-09-06 12:43:44 +00:00
overlookmotel
87a79d9cd0
test(transformer): add trailing line breaks to conformance fixtures ( #5537 )
...
Currently whether conformance fixture files have trailing line breaks is inconsistent - some have them, some don't. Make all of them have a trailing line break.
2024-09-06 12:02:46 +00:00
overlookmotel
e18c2edfcb
test(transformer): move RegExp transform conformance tests ( #5536 )
...
Rename transform conformance RegExp test fixtures folder from "esbuild-tests" to "regexp", to reflect that not all these tests are copied from ESBuild.
2024-09-06 12:02:45 +00:00
overlookmotel
d1ece197c4
fix(transformer): RegExp transform handle Term::Quantifier ( #5501 )
...
`Term::Quantifier` contains a nested `Term` so we need to recurse into that `Term` to check if it contains any unsupported syntax.
2024-09-06 11:51:35 +00:00
Dunqing
7a797ac635
fix(semantic): incorrect reference when MemberExpression used in TSPropertySignature ( #5525 )
...
close: https://github.com/oxc-project/oxc/issues/5435#issuecomment-2333032168
2024-09-06 06:24:45 +00:00
rzvxa
b4f75967bd
refactor(ast_tools): add some minimal logging. ( #5519 )
2024-09-06 06:19:50 +00:00
Boshen
1bed5ce2a5
chore: run cargo +nightly fmt to sort imports ( #5503 )
...
They are never going to be stable are they ... cedf7a4daa/.rustfmt.toml (L8-L16)
2024-09-06 04:04:26 +00:00
Boshen
32d4bbb519
feat(transformer): add TransformOptions::enable_all method ( #5495 )
...
Make it **really** explicit about which transformer options are being
turned on. I also need this in monitor-oxc.
2024-09-06 12:04:06 +08:00
rzvxa
10e8984d93
ci: fix paths in the .generated_ast_watch_list.yml. ( #5520 )
2024-09-06 03:23:26 +00:00
Boshen
c3cfbfb480
chore: clippy::allow_attributes ( #5521 )
...
https://blog.rust-lang.org/2024/09/05/Rust-1.81.0.html#expectlint
https://rust-lang.github.io/rust-clippy/master/index.html#/allow_attributes
2024-09-06 03:07:02 +00:00
IWANABETHATGUY
b96bea4f0d
fix: add back lifetime ( #5507 )
...
closed #5506
2024-09-05 17:47:58 +00:00
IWANABETHATGUY
cedf7a4daa
feat(xtask): impl as_ast_kind method for each variant ( #5491 )
2024-09-05 16:17:08 +00:00
overlookmotel
2060efc801
fix(transformer): RegExp transform don't transform all RegExps ( #5486 )
...
Previously `RegExp` transform would transform every `RegExp`, even if it had no unsupported flags/patterns.
2024-09-05 13:50:21 +00:00
Dunqing
c59d8b3c9b
feat(transformer): support all /regex/ to new RegExp transforms ( #5387 )
...
related: #4754
The implementation port from [esbuild](332727499e/internal/js_parser/js_parser.go (L12820-L12840) ). And cover all babel's regexp plugins
---
## The following description was generated by `Graphite` 😋
### TL;DR
Added support for transforming various RegExp features to ensure compatibility with older JavaScript environments.
### What changed?
- Implemented a new `RegExp` transformer to handle unsupported RegExp literal features
- Added options to control different RegExp transformations (e.g., sticky flag, unicode flag, dot-all flag, etc.)
- Updated the transformer to convert unsupported RegExp literals into `new RegExp()` constructor calls
- Added test cases for different RegExp transformations
- Integrated the new RegExp transformer into the existing transformation pipeline
### How to test?
1. Run the existing test suite to ensure no regressions
2. Execute the new RegExp-specific tests in the `tasks/transform_conformance/tests/esbuild-tests/test/fixtures/regexp/` directory
3. Try transforming code with various RegExp features using different target environments to verify correct transformations
2024-09-05 11:04:45 +00:00
rzvxa
ccc8a27e4f
refactor(ast, ast_tools): use full method path for generated derives trait calls. ( #5462 )
...
As of now if we remove the implementation of a trait for a type and implement the method on that type directly it wouldn't break while it isn't the original trait anymore so that method might do something entirely different.
This change is more explicit on trait calls so we hit compile errors on these kinds of changes.
2024-09-05 05:36:50 +00:00
rzvxa
90facd3657
feat(ast): add ContentHash trait; remove noop Hash implementation from Span ( #5451 )
...
closes #5283
Also removes the noop Hash implementation on `Span` in favor of a real implementation.
2024-09-05 07:20:04 +03:30
overlookmotel
cba93f52d0
feat(ast)!: add ThisExpression variants to JSXElementName and JSXMemberExpressionObject ( #5466 )
...
Close #5352 .
Add to AST:
* `JSXElementName::ThisExpression` (`<this>`)
* `JSXMemberExpressionObject::ThisExpression` (`<this.foo>`, `<this.foo.bar>`)
2024-09-05 02:06:20 +00:00
Dunqing
d8b9909bd8
fix(semantic): IdentifierReference within TSPropertySignature cannot reference type-only import binding ( #5441 )
...
close : #5435
The behavior of `IdentifierReference` in `TSPropertySignature` is the same as in `TSTypeQuery`, both allow only reference value bindings and type-only import bindings.
I still use `ReferenceFlags::TSTypeQuery` here because I want to avoid producing many changes unrelated to the bug in this PR. I will refactor it in the follow-up PR soon
2024-09-05 01:50:18 +00:00
DonIsaac
0f50b1ed6d
feat(semantic): check for initializers in ambient VariableDeclarations ( #5463 )
2024-09-05 01:33:11 +00:00
DonIsaac
62f7fff88f
feat(semantic): check for non-declared, non-abstract object accessors without bodies ( #5461 )
2024-09-05 01:33:10 +00:00
DonIsaac
540714393a
feat(semantic): check for non-declared, non-abstract class accessors without bodies ( #5460 )
...
This should be causing more negative tests to fail than it actually is. This is
because our typescript coverage tests use the "declarations" option to change
the source type to `.d.ts`, which is incorrect. This setting enables `.d.ts`
emits, it does not mean that input files should be treated as `.d.ts`
themselves.
2024-09-05 01:33:09 +00:00
DonIsaac
052e94c94e
feat(semantic): check for parameter properties in constructor overloads ( #5459 )
...
Adds checks for
```
A parameter property is only allowed in a constructor implementation.ts(2369)
```
2024-09-05 01:33:07 +00:00
Boshen
9c937e06e8
fix(benchmark): do not measure initialization of transformer options ( #5442 )
...
relates #5267
2024-09-04 14:52:21 +00:00
Boshen
10279f55d9
feat(parser): add syntax error for hyphen in JSXMemberExpression <Foo.bar-baz /> ( #5440 )
...
closes #5355
2024-09-04 14:09:06 +00:00
overlookmotel
d9d7e7c596
refactor(ast): remove IdentifierName from TSThisParameter ( #5327 )
...
`TSThisParameter` does not need to include an `IdentifierName` which is always "this". Just storing the `Span` is sufficient.
2024-09-04 12:46:53 +00:00
rzvxa
23285f431d
feat(ast): add ContentEq trait. ( #5427 )
...
Part of #5283
2024-09-04 11:53:50 +00:00
Dunqing
0617249716
fix(transformer/nullish-coalescing-operator): incorrect reference flags ( #5408 )
...
Fixes an obvious problem
2024-09-03 15:29:07 +00:00
overlookmotel
cfe54974f1
fix(transformer): do not create double reference in JSX transform ( #5414 )
...
Follow on after #5358 . Don't create a new `IdentifierReference` with a new `ReferenceId` when we already have one which is correctly resolved.
2024-09-03 15:06:07 +00:00
overlookmotel
b9ef357868
test(transformer): add tests for nested JSX this member expressions in arrow function transform ( #5413 )
...
Follow-up after #5356 . Handle nested JSX member expressions with `this` as base object in arrow functions transform (e.g. `<this.foo.bar />`).
2024-09-03 15:06:06 +00:00
Dunqing
0eb32a6770
fix(traverse): invalid variable name generated by generate_uid_based_on_node ( #5407 )
...
close : #5371
2024-09-03 12:13:30 +00:00
dalaoshu
4473779074
feat(linter/node): implement no-exports-assign ( #5370 )
2024-09-03 07:53:14 -04:00
Boshen
0a5780d328
ci: fix broken benchmark ( #5424 )
2024-09-03 18:21:39 +08:00
rzvxa
59abf27d95
feat(ast, parser): add oxc_regular_expression types to the parser and AST. ( #5256 )
...
closes #5060
2024-09-03 02:36:37 +00:00
rzvxa
68a1c01f4e
feat(ast_tools): add dedicated Derive trait. ( #5278 )
...
In an effort toward the implementation of #5256 , this PR allows us to have a separately generated "derive" file for each crate.
This also eliminates a bunch of boilerplate when writing new "derive" generators and generally makes it more approachable.
2024-09-03 02:36:36 +00:00
Dunqing
0abfc5049f
feat(transformer/typescript): support rewrite_import_extensions option ( #5399 )
...
close : #5395
Babel only supports `rewrite`, we also support `remove`
2024-09-03 01:57:42 +00:00
overlookmotel
be4642fc02
feat(semantic): transform checker check child scope IDs ( #5410 )
...
Transform checker check child scope IDs. If we have to track child scope IDs, we should make sure they're correct!
2024-09-03 00:57:13 +00:00
Dunqing
1aa49af010
feat(ast)!: remove JSXMemberExpressionObject::Identifier variant ( #5358 )
...
close : #5353
`JSXMemberExpressionObject::Identifier` is dead code.
2024-09-02 18:35:39 +00:00
Dunqing
94ff94cd34
fix(transformer/arrow-functions): reaches unreachable when <this.foo> is inside an arrow function ( #5356 )
...
Fixes: https://github.com/oxc-project/oxc/issues/5353#issuecomment-2321792915
2024-09-02 18:06:08 +00:00
leaysgur
c7e61a1391
chore(prettier): Update conformance tests to Prettier v3.3.3 ( #5394 )
...
- v3.3.3 is latest released version
- Test file name was changed from v3.3.x
- https://github.com/prettier/prettier/pull/16244
2024-09-02 10:32:17 +00:00
renovate[bot]
8cf9cf9919
chore(deps): update npm packages ( #5392 )
...
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [axios](https://axios-http.com )
([source](https://togithub.com/axios/axios )) | [`1.7.5` ->
`1.7.7`](https://renovatebot.com/diffs/npm/axios/1.7.5/1.7.7 ) |
[](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 )) |
[`9.8.0` -> `9.9.0`](https://renovatebot.com/diffs/npm/pnpm/9.8.0/9.9.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>axios/axios (axios)</summary>
###
[`v1.7.7`](https://togithub.com/axios/axios/blob/HEAD/CHANGELOG.md#177-2024-08-31 )
[Compare
Source](https://togithub.com/axios/axios/compare/v1.7.6...v1.7.7 )
##### Bug Fixes
- **fetch:** fix stream handling in Safari by fallback to using a stream
reader instead of an async iterator;
([#​6584](https://togithub.com/axios/axios/issues/6584 ))
([d198085](d1980854fe ))
- **http:** fixed support for IPv6 literal strings in url
([#​5731](https://togithub.com/axios/axios/issues/5731 ))
([364993f](364993f0d8 ))
##### Contributors to this release
- <img
src="https://avatars.githubusercontent.com/u/10539109?v=4&s=18 "
alt="avatar" width="18"/> [Rishi556](https://togithub.com/Rishi556
"+39/-1 (#​5731 )")
- <img
src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18 "
alt="avatar" width="18"/> [Dmitriy
Mozgovoy](https://togithub.com/DigitalBrainJS "+27/-7 (#​6584 )")
###
[`v1.7.6`](https://togithub.com/axios/axios/blob/HEAD/CHANGELOG.md#176-2024-08-30 )
[Compare
Source](https://togithub.com/axios/axios/compare/v1.7.5...v1.7.6 )
##### Bug Fixes
- **fetch:** fix content length calculation for FormData payload;
([#​6524](https://togithub.com/axios/axios/issues/6524 ))
([085f568](085f56861a ))
- **fetch:** optimize signals composing logic;
([#​6582](https://togithub.com/axios/axios/issues/6582 ))
([df9889b](df9889b83c ))
##### Contributors to this release
- <img
src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18 "
alt="avatar" width="18"/> [Dmitriy
Mozgovoy](https://togithub.com/DigitalBrainJS "+98/-46 (#​6582 )")
- <img
src="https://avatars.githubusercontent.com/u/3534453?v=4&s=18 "
alt="avatar" width="18"/> [Jacques
Germishuys](https://togithub.com/jacquesg "+5/-1 (#​6524 )")
- <img
src="https://avatars.githubusercontent.com/u/53894505?v=4&s=18 "
alt="avatar" width="18"/> [kuroino721](https://togithub.com/kuroino721
"+3/-1 (#​6575 )")
</details>
<details>
<summary>pnpm/pnpm (pnpm)</summary>
### [`v9.9.0`](https://togithub.com/pnpm/pnpm/compare/v9.8.0...v9.9.0 )
[Compare Source](https://togithub.com/pnpm/pnpm/compare/v9.8.0...v9.9.0 )
</details>
---
### Configuration
📅 **Schedule**: Branch creation - "before 10am on monday" in timezone
Asia/Shanghai, Automerge - At any time (no schedule defined).
🚦 **Automerge**: Enabled.
♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.
👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions ) if
that's undesired.
---
- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box
---
This PR was generated by [Mend Renovate](https://mend.io/renovate/ ).
View the [repository job
log](https://developer.mend.io/github/oxc-project/oxc ).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC41Ni4wIiwidXBkYXRlZEluVmVyIjoiMzguNTYuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-01 19:31:44 +00:00
Dunqing
35f03db464
fix(transformer): ArrowfunctionExpression's expression is true but has more than one body statement ( #5366 )
...
close : #5363
We insert the new statement here, but it's broken if it a `() => x;`, we need to transform it to `function () { return x }`
8d565d5b23/crates/oxc_transformer/src/es2020/nullish_coalescing_operator.rs (L59-L76)
I don't where we should put the fallback logic, It's useful for all plugins. We had already done the same thing in the react refresh plugin.
8d565d5b23/crates/oxc_transformer/src/react/refresh.rs (L578-L605)
2024-08-31 14:49:58 +00:00
Boshen
e75e0f1465
chore: update test262 / babel / typescript submodules ( #5369 )
...
closes #5215
2024-08-31 12:28:25 +00:00
overlookmotel
8a178075b7
fix(parser): treat JSX element tags starting with _ or $ as IdentifierReferences ( #5343 )
...
#5223 added a new variant `JSXElementName::IdentifierReference` for JSX identifiers which are treated as references (e.g. `<Foo>`) as opposed to `JSXElementName::Identifier` which is for lowercase (e.g. `<div>`).
But we were incorrectly categorizing identifiers beginning with `_` or `$` - these should also be treated as references.
(as discussed in https://github.com/oxc-project/oxc/pull/5339#issuecomment-2321037779 )
2024-08-30 14:47:06 +00:00
overlookmotel
0de844d23c
refactor(transformer): remove unnecessary code from JSX transform ( #5339 )
...
Follow-on after #5223 .
JSX identifiers which start with a capital letter are now `JSXElementName::IdentifierReference`s, so no need to check for capitalized `JSXElementName::Identifier`s.
2024-08-30 12:17:08 +00:00
Dunqing
32f730085c
feat(ast)!: add JSXElementName::IdentifierReference and JSXMemberExpressionObject::IdentifierReference ( #5223 )
...
close : #3528
part of #4746
2024-08-30 11:11:04 +00:00