Boshen
7aebed012d
perf(semantic): allocate Bindings in allocator ( #8021 )
2024-12-19 15:16:03 +00:00
Boshen
02f968d02d
refactor(semantic): change Bindings to a plain FxHashMap ( #8019 )
...
`IndexMap` was needed for the insertion order requirement in mangler.
Bindings (symbol ids) are monotonically increasing by binding
positions, which means we can get insertion order by sorting the symbol ids in
mangler.
Previous attempt: https://github.com/oxc-project/oxc/pull/4228
2024-12-19 14:16:28 +00:00
Dunqing
862838fd28
perf(codegen): remove useless to_owned ( #8014 )
2024-12-19 12:06:55 +00:00
Dunqing
7b703471b1
perf(transformer/react-refresh): avoid allocating string in each hook call ( #8013 )
...
related: https://github.com/oxc-project/oxc/pull/7970#issuecomment-2551294930 ;
Just realized this can be simplified to that
2024-12-19 12:06:54 +00:00
Boshen
e7476a1a28
refactor(semantic): remove serialize ( #8015 )
2024-12-19 09:51:12 +00:00
overlookmotel
0a38eea95c
refactor(transformer/class-properties): use temp_var_name_base to generate temp var names for super transform ( #8004 )
...
Follow-on after #7997 .
Generate "base name" for temp var using `temp_var_name_base` and then create the 2 temp bindings from it.
This is a bit more efficient than creating 2nd temp binding from name of the first temp binding, because the first binding's name has `_` added to start, and may have digits on the end, which have to be trimmed off again. Whereas the "base name" is ready to go.
Incidentally, changing the timing of when temp bindings are created also aligns output with Babel.
2024-12-19 02:24:58 +00:00
overlookmotel
63a95e4aa2
feat(ast): add AstBulder::move_property_key ( #7998 )
...
Add `AstBuilder::move_property_key` method, same as the rest of `move_*` methods.
2024-12-18 23:17:54 +00:00
overlookmotel
d1b7181452
refactor(transformer/class-properties): rename var ( #8006 )
...
Give var more descriptive name.
2024-12-18 21:59:47 +00:00
overlookmotel
87ea928e17
test(transformer/class-properties): failing test for super.prop as assignment target ( #8005 )
...
Add failing test for syntax we can't support yet.
2024-12-18 19:07:24 +00:00
Dunqing
3ea4109d14
feat(transformer/class-properties): transform super update expressions within static prop initializer ( #7997 )
2024-12-18 18:29:05 +00:00
overlookmotel
5a23d72b37
refactor(transformer/class-properties): remove outdated comment ( #8000 )
2024-12-18 16:51:35 +00:00
Boshen
ed75e42ed6
refactor(semantic)!: make SymbolTable fields pub(crate) instead of pub ( #7999 )
...
SymbolTable needs some internal changes.
2024-12-18 16:38:58 +00:00
overlookmotel
df5c341c38
docs(ast): improve docs for AstBuilder::move_* methods ( #7994 )
2024-12-18 15:07:25 +00:00
Dunqing
b3a5f3eb59
refactor(transformer/class-properties): mark transform_assignment_expression_if_super_member_assignment_target as inline ( #7993 )
...
I forgot to mark it as inline like other methods do.
2024-12-18 13:59:40 +00:00
overlookmotel
5cf253c216
test(transformer/class-properties): more testing for assignment to super[prop] ( #7992 )
...
Amend test added in #7991 to test transform of `super[prop] = value` where `prop` is not bound.
We should ideally have the `_unbound` temp vars *inside* the arrow function rather than outside, as Babel does, but that's not possible with our double-visitor scheme at present, and I think current output will operate correctly anyway.
Probably these temp vars could be hoisted even higher up - to very top level of the file, even if the class and `super[prop]` were deeply nested in many functions - and it'd still be correct. That'd be good for transformer performance as less `var` statements to insert, and also slightly smaller output size - less `var`s in code. But I don't know if that would be worse for runtime performance, as it makes the arrow function more impure. 🤔
2024-12-18 12:49:42 +00:00
Dunqing
cc57db38e1
feat(transformer/class-properties): transform super assignment expressions within static prop initializer ( #7991 )
...
Alternative of #7956 and #7959 . Unlike the previous method, adapting duplicating the same logic rather than making the same logic transform function to be generic
2024-12-18 11:28:39 +00:00
Dunqing
e3d0889009
test(transformer/class-properties): add static super tagged template test ( #7964 )
...
I just found that we don't need to transform `TaggedTemplateExpression` because its `tag` can be transformed by `transform_static_member_expression` and `transform_computed_member_expression`
2024-12-18 10:25:21 +00:00
Dunqing
bcb33c00fa
test(semantic): add a test for catch parameters reference ( #7988 )
...
I am trying to clean up Semantic, just found that we can remove this code without any test failing, but it should fail in that test case I added.
1082868855/crates/oxc_semantic/src/builder.rs (L2085-L2087)
2024-12-18 08:47:27 +00:00
Boshen
6da0b219dd
refactor(oxlint): remove unused git.rs ( #7990 )
2024-12-18 08:41:50 +00:00
Boshen
58e7777814
refactor(oxlint): remove extra if check in Walkdir ( #7989 )
2024-12-18 08:37:20 +00:00
Dunqing
1cf7b83431
refactor(semantic): simplify handling namespace stack ( #7987 )
...
We had a BindingIdentifier to `TSModuleDeclarationName` so that we don't need to get binding from name.
2024-12-18 07:56:13 +00:00
Dunqing
48cb52b335
refactor(semantic): remove resetting current_reference_flags in visit functions ( #7986 )
...
We have reset current_reference_flags after resolving reference flags in https://github.com/oxc-project/oxc/pull/7923 , so that we don't need to set it to empty in another place.
2024-12-18 07:56:12 +00:00
Dunqing
3250a47a97
refactor(semantic): remove unused current_symbol_flags ( #7985 )
2024-12-18 06:44:03 +00:00
Dunqing
efe96ecc12
refactor(semantic): use Stack for function stack node ids ( #7984 )
2024-12-18 06:38:59 +00:00
oxc-bot
3631eed975
release(crates): v0.42.0 ( #7983 )
...
## [0.42.0] - 2024-12-18
- 84b75a0 semantic: [**BREAKING**] Remove `ScopeFlags::Modifiers`
(#7935 ) (overlookmotel)
- c071494 semantic: [**BREAKING**] Remove `SymbolTable::rename` method
(#7868 ) (overlookmotel)
### Features
- 8b7c5ae ast: Add `AstBuilder::atom_from_cow` (#7974 ) (overlookmotel)
- 46e2e27 data_structures: Implement `Default` for `NonEmptyStack`
(#7946 ) (overlookmotel)
- db9e93b mangler: Mangle top level variables (#7907 ) (翠 / green)
- 075bd16 minifier: Fold bitwise operation (#7908 ) (翠 / green)
- c16a851 napi/transform: Add `jsx: 'preserve'` option (#7965 ) (Boshen)
- 81eedb1 parser: 'readonly' type modifier is only permitted on array
and tuple literal types. (#7880 ) (Boshen)
- b9322c6 semantic: Re-export all flags and ID types (#7886 )
(overlookmotel)
- c30a982 span: Add `impl From<ArenaString> for Atom` (#7973 )
(overlookmotel)
- 02b653c transformer/class-properties: Do not create temp var for
template literal computed key (#7919 ) (overlookmotel)
- feac02e transformer/class-properties: Only rename symbols if necessary
(#7896 ) (overlookmotel)
- 6bc530d transformer/class-properties: Transform super call expression
that is inside static prop initializer (#7831 ) (Dunqing)
- 53e2bc0 traverse: Add `TraverseScoping::rename_symbol` method (#7871 )
(overlookmotel)
### Bug Fixes
- 3659e6d cfg: Include export default code in CFG instructions (#7862 )
(Jan Olaf Martin)
- 850dd43 codegen: Missing `,` when generating type parameters with jsx
(#7929 ) (Dunqing)
- 4799471 minfier: Bigint bitwise operation only works with bigint
(#7937 ) (Boshen)
- de8a86e minifier: Incorrect minification in `try_fold_left_child_op`
(#7949 ) (翠 / green)
- 9a30910 oxc_transformer: Inject_global_variables should considering
string imported name (#7768 ) (IWANABETHATGUY)
- 111dc52 parser: Include export token in spans of
TSNamespaceExportDeclaration (#7963 ) (branchseer)
- 14c51ff semantic: Remove inherting `ScopeFlags::Modifier` from parent
scope (#7932 ) (Dunqing)
- 596aead semantic: Reset references flags when resolved (#7923 )
(Dunqing)
- 4924073 semantic: `ScopeTree::rename_binding` preserve order of
bindings (#7870 ) (overlookmotel)
- bb38065 transformer/class-properties: Do not transform `super.prop` in
nested method within static prop initializer (#7978 ) (overlookmotel)
- e76fbb0 transformer/class-properties: Fix symbol clashes in instance
prop initializers (#7872 ) (overlookmotel)
- c0576fa transformer/class-properties: Use UID for `args` in created
class constructor (#7866 ) (overlookmotel)
- d660d8d transformer/optional-chaining: Do not create unused reference
when `noDocumentAll` assumption (#7847 ) (overlookmotel)
- 4920c6a transformer/optional-chaining: Avoid creating a useless
reference when `noDocumentAll` is true (#7832 ) (Dunqing)
### Performance
- a5f04a7 ast: Faster `Comment::is_jsdoc` (#7905 ) (overlookmotel)
- 4b24335 codegen: Improve printing of statement comments (#7857 )
(Boshen)
- 71a40a2 codegen: Guard comment printing comments when there are no
comments (#7856 ) (Boshen)
- b31f123 transformer/class-properties: Do not re-generate same method
key (#7915 ) (overlookmotel)
- 8ca8fce transformer/class-properties: Reduce work updating scopes when
transforming static prop initializers (#7904 ) (overlookmotel)
- 80d0b3e transformer/class-properties: Fast path for instance prop
initializer scope re-parenting (#7901 ) (overlookmotel)
- 38aafa2 transformer/class-properties: Reduce size of
`transform_call_expression_for_super_member_expr` (#7859 )
(overlookmotel)
### Documentation
- e49de81 ast: Document `Expression::is_*` methods (#7853 )
(overlookmotel)
- 10a86b9 transformer: Fix comments (#7925 ) (overlookmotel)
- f4cb5d3 transformer: Clarify comment (#7918 ) (overlookmotel)
- 41a1456 transformer/class-properties: Correct doc comments (#7966 )
(overlookmotel)
- 18441af transformer/class-properties: Remove oudated todo for
assignment expression (#7955 ) (Dunqing)
- 1317c00 transformer/class-properties: Clarify doc comments (#7914 )
(overlookmotel)
- 9989b58 transformer/class-properties: Re-order file list in doc
comment (#7911 ) (overlookmotel)
- 7390048 transformer/class-properties: Reformat doc comment (#7909 )
(overlookmotel)
### Refactor
- beb982a ast: Use exhaustive match for `Argument` to
`ArrayExpressionElement` conversion (#7848 ) (overlookmotel)
- 3858221 global: Sort imports (#7883 ) (overlookmotel)
- 1314c97 minifier: Expose dce as an API instead of an option (#7957 )
(Boshen)
- 6551dfe semantic: Pass `&str` instead of `Cow` (#7972 ) (overlookmotel)
- b8d2bd2 semantic: Move determining references flags for export
specifier to `visit_export_named_declaration` (#7924 ) (Dunqing)
- 98d7946 semantic: Import flags and ID types from `oxc_syntax` (#7887 )
(overlookmotel)
- 1cf8f8f semantic: `SymbolTable::set_name` return old name (#7869 )
(overlookmotel)
- 5d42df8 semantic: Use `Expression::is_super` (#7851 ) (overlookmotel)
- 8cf9766 semantic, syntax, wasm: Remove `#![allow(non_snake_case)]`
(#7863 ) (overlookmotel)
- d59bbae transformer: Remove unneeded lint `#[allow]` (#7971 )
(overlookmotel)
- 2c94236 transformer: Improve encapsulation of transforms (#7888 )
(overlookmotel)
- 34091b2 transformer: Use `Expression::is_super` (#7852 )
(overlookmotel)
- d4d7bc0 transformer/async-to-generator: Avoid allocating unnecessary
`Atom`s (#7975 ) (overlookmotel)
- 2e5ffd3 transformer/class-properties: Store `temp_var_is_created` on
`ClassBindings` (#7981 ) (overlookmotel)
- 27cc6da transformer/class-properties: Store `is_declaration` only on
`ClassDetails` (#7980 ) (overlookmotel)
- ee282f8 transformer/class-properties: Remove `move_expression`s
(#7979 ) (overlookmotel)
- 94b376a transformer/class-properties: Simplify logic for when to
create temp binding (#7977 ) (overlookmotel)
- ff9d1b3 transformer/class-properties: Comments about shorter output
(#7976 ) (overlookmotel)
- 6fc40f0 transformer/class-properties: Pass `BoundIdentifier`s by
reference (#7968 ) (overlookmotel)
- 69eeeea transformer/class-properties: Methods take `&self` where
possible (#7967 ) (overlookmotel)
- 98340bb transformer/class-properties: Use stack of `ClassDetails`
(#7947 ) (overlookmotel)
- 088dd48 transformer/class-properties: Shorten code (#7913 )
(overlookmotel)
- 544ffbf transformer/class-properties: Split up code into multiple
files (#7912 ) (overlookmotel)
- dcaf674 transformer/class-properties: Rename file (#7910 )
(overlookmotel)
- 6243980 transformer/class-properties: Instance prop inits visitor use
`Visit` (#7867 ) (overlookmotel)
- eb47d43 transformer/class-properties: Re-use existing `Vec` (#7854 )
(overlookmotel)
- 1380b7b transformer/class-properties: Reduce visibility of method
(#7858 ) (overlookmotel)
- 0f5e078 transformer/class-properties: Rename `*_owner` to `owned_*`
(#7855 ) (Dunqing)
- 4ea90d4 transformer/react-refresh: Calculate signature key once
(#7970 ) (Dunqing)
- 15b9bff transformer/typescript: Reuse `Atom` (#7969 ) (overlookmotel)
### Styling
- fb897f6 data_structures: Add line break (#7882 ) (overlookmotel)
- 7fb9d47 rust: `cargo +nightly fmt` (#7877 ) (Boshen)
### Testing
- 523d48c transformer: Move named test to exports folder (#7922 )
(Dunqing)
- e766051 transformer: Skip test which uses filesystem under miri
(#7874 ) (overlookmotel)
- f39e65e transformer: Prevent lint error when running miri (#7873 )
(overlookmotel)
Co-authored-by: Dunqing <29533304+Dunqing@users.noreply.github.com>
2024-12-18 11:48:12 +08:00
overlookmotel
2e5ffd30a1
refactor(transformer/class-properties): store temp_var_is_created on ClassBindings ( #7981 )
...
Move `temp_var_is_created` from main `ClassProperties` object to `ClassBindings`. It makes more sense there.
2024-12-18 03:16:31 +00:00
overlookmotel
27cc6da328
refactor(transformer/class-properties): store is_declaration only on ClassDetails ( #7980 )
...
`is_declaration` was stored in 2 places. Only store it in `ClassDetails` struct.
2024-12-18 03:16:28 +00:00
overlookmotel
ee282f8897
refactor(transformer/class-properties): remove move_expressions ( #7979 )
...
Remove 2 x `move_expression` calls by taking value from `Option` instead. This avoids allocating dummy `Expression`s into arena.
2024-12-18 03:06:04 +00:00
overlookmotel
94b376a713
refactor(transformer/class-properties): simplify logic for when to create temp binding ( #7977 )
...
Remove the hack of overwriting temp binding with name binding before traversing class body. Instead decide which binding to use in `ClassBindings::get_or_init_static_binding` based on a flag.
This less performant than what we had before. But it simplifies some confusing logic, and prepares the ground for changes to come where we'll need to duck in and out of static context repeatedly while traversing the class body.
2024-12-18 03:06:04 +00:00
overlookmotel
bb3806554f
fix(transformer/class-properties): do not transform super.prop in nested method within static prop initializer ( #7978 )
...
Don't transform `super` in static property initializers if it's nested in another method, so is a *different* `super`.
```js
class C {
static prop = () => {
const object = {
method() {
// `super` here refers to prototype of `object`, not class `C`
return super.foo;
}
};
};
}
```
2024-12-18 03:00:04 +00:00
overlookmotel
15b9bffe16
refactor(transformer/typescript): reuse Atom ( #7969 )
...
Re-use existing `Atom` rather than allocating multiple copies of it into the arena.
2024-12-18 02:54:29 +00:00
overlookmotel
6551dfef5c
refactor(semantic): pass &str instead of Cow ( #7972 )
...
As suggested by clippy...
2024-12-18 02:37:12 +00:00
overlookmotel
d4d7bc08d3
refactor(transformer/async-to-generator): avoid allocating unnecessary Atoms ( #7975 )
...
Remove several `Atom` allocations from this function.
1. Take a `Cow<'a, str>` instead of `&str`, and use `AstBuilder::atom_from_cow` to avoid reallocating the string when possible.
2. Create a static `Atom` for `"_"` (no allocation required, as `"_"` is a `&'static str`).
3. `name` is an `ArenaString`, so already in arena. Convert `name` to `Atom` directly with `Atom::from`, instead of `AstBuilder::atom` (which makes a 2nd copy of the string in arena).
2024-12-18 02:25:36 +00:00
overlookmotel
8b7c5ae09c
feat(ast): add AstBuilder::atom_from_cow ( #7974 )
...
Various methods e.g. `PropertyKey::static_name` return a `Cow<'a, str>`.
When we need to create an `Atom` from such a `Cow`, we can avoid reallocating the string into arena again if the `Cow` already borrows an arena string. The `Atom` can reference that same string, rather than making another copy of it in arena.
Add `AstBuilder::atom_from_cow` method for this purpose.
2024-12-18 02:25:35 +00:00
overlookmotel
c30a982da3
feat(span): add impl From<ArenaString> for Atom ( #7973 )
...
Add conversion method from `oxc_allocator::String` to `Atom`. This is a zero-cost conversion, because the string is already in the arena.
2024-12-18 02:25:34 +00:00
overlookmotel
ff9d1b35d7
refactor(transformer/class-properties): comments about shorter output ( #7976 )
...
Add TODO comments about how output could be shorter.
2024-12-17 19:21:39 +00:00
Dunqing
4ea90d4acd
refactor(transformer/react-refresh): calculate signature key once ( #7970 )
...
I can't remember why I wrote such code. This change reduced big allocation.
2024-12-17 17:11:44 +00:00
overlookmotel
d59bbaed08
refactor(transformer): remove unneeded lint #[allow] ( #7971 )
2024-12-17 16:54:39 +00:00
overlookmotel
6fc40f030e
refactor(transformer/class-properties): pass BoundIdentifiers by reference ( #7968 )
...
Don't pass by value when passing by reference is sufficient.
2024-12-17 16:34:09 +00:00
overlookmotel
69eeeea138
refactor(transformer/class-properties): methods take &self where possible ( #7967 )
...
These 2 methods don't need to take `&mut self`.
2024-12-17 15:59:09 +00:00
overlookmotel
41a14564ec
docs(transformer/class-properties): correct doc comments ( #7966 )
...
Correct doc comments which were inaccurate.
2024-12-17 15:22:08 +00:00
Boshen
c16a85176d
feat(napi/transform): add jsx: 'preserve' option ( #7965 )
...
closes #7958
2024-12-17 13:49:51 +00:00
branchseer
111dc52f62
fix(parser): include export token in spans of TSNamespaceExportDeclaration ( #7963 )
...
Spans of `TSNamespaceExportDeclaration`(`export as namespace Foo`)
should start with `export`:
cc89efb2b7
2024-12-17 20:55:56 +08:00
Dmitry Zakharov
ec2128e614
fix(linter): fix line calculation for eslint/max-lines in diagnostics ( #7962 )
...
closes #7961
2024-12-17 20:53:56 +08:00
Boshen
1314c9763b
refactor(minifier): expose dce as an API instead of an option ( #7957 )
2024-12-17 04:47:13 +00:00
Dunqing
18441afe1c
docs(transformer/class-properties): remove oudated todo for assignment expression ( #7955 )
2024-12-17 04:41:09 +00:00
overlookmotel
98340bbaa1
refactor(transformer/class-properties): use stack of ClassDetails ( #7947 )
...
Replace stack of `PrivateProps` with a stack of `ClassDetails`.
Primary purpose is to prepare for further changes to come, but this also allows removing the messy hack of storing `ClassBindings` in 2 places, and having to decide which is the source of truth at any given moment. Now there is only 1 copy of `ClassBindings`.
2024-12-17 04:30:41 +00:00
oxc-bot
fc5380442b
release(oxlint): v0.15.3 ( #7954 )
...
## [0.15.3] - 2024-12-17
### Features
- 25ddb35 linter: Add the import/no_named_default rule (#7902 )
(Guillaume Piedigrossi)
- ee26b44 linter: Enhance `get_element_type` to resolve more element
types (#7885 ) (dalaoshu)
### Bug Fixes
- 6f41d92 linter: False positive in `unicorn/no-useless-spread` (#7940 )
(dalaoshu)
- 0867b40 linter: Fix configuration parser for `no-restricted-imports`
(#7921 ) (Alexander S.)
- 9c9b73d linter: Fix incorrect fixer for `prefer-regexp-test` (#7898 )
(Cameron)
- 32935e6 linter: False positive in
`jsx-a11y/label-has-associated-control` (#7881 ) (dalaoshu)
- 14c51ff semantic: Remove inherting `ScopeFlags::Modifier` from parent
scope (#7932 ) (Dunqing)
### Refactor
- 3858221 global: Sort imports (#7883 ) (overlookmotel)
- b99ee37 linter: Move rule "no-restricted-imports" to nursery (#7897 )
(Alexander S.)
- ff2a68f linter/yoda: Simplify code (#7941 ) (overlookmotel)
### Styling
- 7fb9d47 rust: `cargo +nightly fmt` (#7877 ) (Boshen)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-17 12:24:09 +08:00
Guillaume Piedigrossi
25ddb35192
feat(linter): add the import/no_named_default rule ( #7902 )
...
Co-authored-by: Boshen <boshenc@gmail.com>
2024-12-17 12:04:40 +08:00
Boshen
99a431be74
fix(coverage): make coverage runtime timeout stable ( #7953 )
...
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-17 12:02:56 +08:00