Commit graph

7274 commits

Author SHA1 Message Date
overlookmotel
588df9f366 test(transformer): transformer conformance runner --override output with spaces not tabs (#7865)
When running `just test-transform --override`, generate override files with indentation as double spaces, instead of tabs. This matches our convention for formatting JS files.
2024-12-14 04:57:00 +00:00
overlookmotel
53e2bc0896 feat(traverse): add TraverseScoping::rename_symbol method (#7871)
Add `TraverseScoping::rename_symbol` method. This renames the symbol, and also the binding for that symbol.
2024-12-14 04:28:54 +00:00
overlookmotel
492407386b fix(semantic): ScopeTree::rename_binding preserve order of bindings (#7870)
`ScopeTree::rename_binding` was previously altering the order of bindings in the `FxIndexMap`. Order of bindings matters in the mangler. Reimplement `rename_binding` to preserve original order.
2024-12-14 04:28:53 +00:00
overlookmotel
1cf8f8f2ca refactor(semantic): SymbolTable::set_name return old name (#7869)
`SymbolTable::set_name` return old symbol name. `set_name` is marked `#[inline]`, so where the caller does not use the old name, getting it should be optimized out by the compiler. So it makes the method more flexible, at no cost.
2024-12-14 04:28:52 +00:00
overlookmotel
c0714945b2 refactor(semantic)!: remove SymbolTable::rename method (#7868)
Remove `SymbolTable::rename` method. We also have `SymbolTable::set_name` method which does the same thing.
2024-12-14 04:28:51 +00:00
overlookmotel
624398083a refactor(transformer/class-properties): instance prop inits visitor use Visit (#7867)
Use `Visit` instead of `VisitMut` as `InstanceInitializerVisitor` does not need to mutate the AST.
2024-12-14 04:28:49 +00:00
Boshen
0f540ecc9f
chore(just): remove update_fixtures from just submodules (#7875)
It is replaced by `update-transformer-fixtures`
2024-12-14 12:28:15 +08:00
overlookmotel
c0576faf80 fix(transformer/class-properties): use UID for args in created class constructor (#7866)
When creating class constructor for a class which has super class, use UID `_args` for temp var (rather than `args`). This avoids shadowing a var called `args` used in an instance property initializer.

This diverges from Babel. Babel uses `args` unless it finds a var called `args` in an instance property initializer. But searching the AST of initializers can be fairly expensive, so it's better to skip it. The overrides for test fixtures included in this PR are just to account for that difference.
2024-12-14 04:18:48 +00:00
Boshen
0b67b37584
ci: fix ci_security.yml 2024-12-14 12:17:26 +08:00
Jan Olaf Martin
3659e6d768
fix(cfg): include export default code in CFG instructions (#7862)
Previously any instructions happening inside of the expression passed to
`export default` were invisible in the CFG.

Example:

```
// Uncommenting this line makes the call to bar() disappear from the
// CFG view of the program:
// export default
bar();
```
2024-12-14 12:09:28 +08:00
overlookmotel
eb47d433ff refactor(transformer/class-properties): re-use existing Vec (#7854)
Follow-on after #7831.

Previously this code was:

1. Create a new empty `Vec` (in `move_vec` call).
2. Consume the old `Vec` and create a new `Vec<ArrayExpressionElement>`.
3. Push to the empty `Vec` created in step 1.

Instead:

1. Drain the old `Vec` and create a new `Vec<ArrayExpressionElement>`.
2. The old `Vec` is now empty, but still holds an allocation if it wasn't empty before.
3. Push to the old `Vec` (re-using the existing allocation).

i.e. We create 1 less `Vec`, and re-use an existing allocation if possible.
2024-12-14 03:27:56 +00:00
overlookmotel
1380b7b7e9 refactor(transformer/class-properties): reduce visibility of method (#7858)
Follow-on after #7831. `transform_super_call_expression_arguments` is only used within this file, so does not need to be `pub(super)`.
2024-12-14 03:21:58 +00:00
overlookmotel
e766051c2d test(transformer): skip test which uses filesystem under miri (#7874)
Miri does not support filesystem operations. Skip this test which loads snapshot from disk when running under Miri.
2024-12-14 03:16:27 +00:00
overlookmotel
f39e65e722 test(transformer): prevent lint error when running miri (#7873) 2024-12-14 03:10:07 +00:00
overlookmotel
3542b4f55f style(wasm): re-order imports (#7864) 2024-12-14 02:30:26 +00:00
overlookmotel
8cf9766be3 refactor(semantic, syntax, wasm): remove #![allow(non_snake_case)] (#7863)
`#![allow(non_snake_case)]` was required in files using `#[derive(Tsify)]`, as a bug in Rust Analyser caused erroneous warnings. This appears to be fixed now, so we can remove these `#![allow]` attributes.
2024-12-14 01:52:32 +00:00
Dunqing
0f5e0787b8 refactor(transformer/class-properties): rename *_owner to owned_* (#7855)
If I understand https://github.com/oxc-project/oxc/pull/7831?notification_referrer_id=NT_kwDOAcKkeLQxMzgzNzE1MTAwNjoyOTUzMzMwNA#pullrequestreview-2502317967 correctly, `owned_*` are better here
2024-12-13 15:28:55 +00:00
Boshen
4b2433539b perf(codegen): improve printing of statement comments (#7857)
closes #7814
2024-12-13 15:20:28 +00:00
Boshen
71a40a222f perf(codegen): guard comment printing comments when there are no comments (#7856) 2024-12-13 15:12:09 +00:00
overlookmotel
34091b2e7a refactor(transformer): use Expression::is_super (#7852)
Shorten code by using `Expression::is_super`, which was introduced in #7831.
2024-12-13 15:05:12 +00:00
overlookmotel
d660d8d12d fix(transformer/optional-chaining): do not create unused reference when noDocumentAll assumption (#7847)
Similar to #7832. Only create an `IdentifierReference` if it's going to be used in AST.
2024-12-13 14:59:13 +00:00
overlookmotel
beb982a69e refactor(ast): use exhaustive match for Argument to ArrayExpressionElement conversion (#7848)
Follow-on after #7830. Refactor.

Use an exhaustive match in implementation of `From<Argument<'a>> for ArrayExpressionElement<'a>`.

At present this change makes no difference. But the reason I feel an exhaustive match is preferable here is that if we add a variant to `Argument` enum later, then this match will be missing an arm to handle that variant, and compiler will refuse to compile until we deal with it.

Whereas before this PR, compiler would not complain, but instead it'd be a runtime panic when `into_expression` discovers that the new `Argument` variant is not an `Expression`.
2024-12-13 14:52:12 +00:00
overlookmotel
e55ab24cc9 refactor(linter): use Expression::is_super (#7850)
Simplify code by using `Expression::is_super` which was introduced in #7831.

Also remove a lifetime bound which is unnecessary and replace use of `bool::then` (which I always find hard to read) with more explicit code.
2024-12-13 14:47:31 +00:00
Boshen
1eab12a03a
ci(release_oxlint): split out github release job 2024-12-13 22:46:15 +08:00
overlookmotel
5d42df8dd6 refactor(semantic): use Expression::is_super (#7851)
Shorten code by using `Expression::is_super`, which was introduced in #7831.
2024-12-13 14:35:13 +00:00
overlookmotel
e49de81544 docs(ast): document Expression::is_* methods (#7853) 2024-12-13 14:12:45 +00:00
Boshen
f8175c545b
ci: wait 3 minutes before smoke test and eslint-plugin-oxlint
closes #7789
2024-12-13 21:54:32 +08:00
Dunqing
6bc530d2e2 feat(transformer/class-properties): transform super call expression that is inside static prop initializer (#7831) 2024-12-13 13:47:38 +00:00
Boshen
c039a5ae4f
ci: fix release crates 2024-12-13 21:46:19 +08:00
Dunqing
4920c6a455 fix(transformer/optional-chaining): avoid creating a useless reference when noDocumentAll is true (#7832) 2024-12-13 13:28:37 +00:00
oxc-bot
1428527da6
release(crates): v0.41.0 (#7846)
## [0.41.0] - 2024-12-13

- fb325dc ast: [**BREAKING**] `span` field must be the first element
(#7821) (Boshen)

- 96a26d3 ast: [**BREAKING**] Rename `is_strict` methods to
`has_use_strict_directive` (#7783) (overlookmotel)

### Features

- 8991f33 ast: Add `visit_span` to `Visit` and `VisitMut` (#7816)
(overlookmotel)
- f7900ab ast: Add `ArrowFunctionExpression::has_use_strict_directive`
method (#7784) (overlookmotel)
- e727ae9 transformer/class-properties: Transform super member
expressions that are inside static prop initializer (#7815) (Dunqing)

### Bug Fixes

- 7610dc1 parser: Parse `import source from 'mod'` (#7833) (Boshen)
- 9479e2b semantic: Missing references when `export {}` references a
type-only binding and a normal (#7812) (Yunfei He)
- 7a83230 semantic: Missing reference when `export default` references a
type alias binding (#7813) (Dunqing)
- 4a3bca8 semantic: Fix identifying strict mode arrow functions (#7785)
(overlookmotel)
- 5b7e1ad transformer: Remove span of define value (#7811) (Hiroshi
Ogawa)
- 14896cb transformer/class-properties: Create temp vars in correct
scope (#7824) (overlookmotel)
- 25bb6da transformer/class-properties: Fix `ScopeId`s in instance prop
initializers (#7823) (overlookmotel)
- 65b109a transformer/class-properties: No `raw` for generated
`StringLiteral` (#7825) (overlookmotel)
- 2964a61 transformer/class-properties: Unwrap failed when private field
expression doesn't contain optional expression in `ChainExpression`
(#7798) (Dunqing)
- 6fa6785 transformer/class-properties: Panic when the callee or member
is `ParenthesisExpression` or TS-syntax expressions. (#7795) (Dunqing)
- bb22c67 transformer/class-properties: Fix `ScopeId`s in static prop
initializers (#7791) (overlookmotel)
- caa57f1 transformer/class-properties: Fix scope flags in static prop
initializers (#7786) (overlookmotel)

### Performance

- 4448b63 codegen: Faster writing indentation (#7820) (overlookmotel)
- afaaffa codegen: Fast path for `options.print_comments()` (#7806)
(Boshen)

### Refactor

- 0f367e5 semantic: Improve the logic of resolving references to be
cleaner (#7829) (Dunqing)
- 5710950 semantic: Move export-related reference flags logic to visit
functions (#7828) (Dunqing)
- b290ebd transformer: Handle `<CWD>` in test runner (#7799) (Dunqing)
- e70deb9 transformer/class-properties: Locate instance props insertion
location in separate step (#7819) (overlookmotel)
- afc5f1e transformer/class-properties: De-deduplicate code (#7805)
(overlookmotel)
- 47a91d2 transformer/class-properties: Shorten code (#7804)
(overlookmotel)
- 54ef2b9 transformer/class-properties: Rename
`debug_assert_expr_is_not_parenthesis_or_typescript_syntax` (#7803)
(overlookmotel)
- 3cdc47c transformer/class-properties: `#[inline(always)]` on
`assert_expr_neither_parenthesis_nor_typescript_syntax` (#7802)
(overlookmotel)

### Testing

- d72c888 transformer/replace-global-defines: Remove panicking test
(#7838) (overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-13 21:25:13 +08:00
oxc-bot
bb4a92c80c
release(oxlint): v0.15.1 (#7845)
## [0.15.1] - 2024-12-13

### Features

- 38b1c2e editor: Create a command to apply all auto-fixes for the
current active text editor (#7672) (Nicholas Rayburn)

### Bug Fixes

- 2b187e5 linter: Fix configuration casing for
`typescript/no_this_alias` (#7836) (Boshen)
- 06e6d38 linter: Fix unicorn/prefer-query-selector to use the correct
replacement for getElementsByClassName (#7796) (Nicholas Rayburn)
- 7a83230 semantic: Missing reference when `export default` references a
type alias binding (#7813) (Dunqing)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-13 21:23:33 +08:00
Dunqing
6466a4a990 feat(ast): implement From<Argument> for ArrayExpressionElement (#7830) 2024-12-13 13:14:28 +00:00
Alexander S.
5172f32457
ci: use zizmor as a rust package (#7844)
Co-authored-by: Boshen <boshenc@gmail.com>
2024-12-13 20:54:26 +08:00
Boshen
369c7a0eeb
chore(Cargo.toml): relax more versions 2024-12-13 20:42:44 +08:00
overlookmotel
d72c888371
test(transformer/replace-global-defines): remove panicking test (#7838)
Follow-on after #7811. Remove the panicking test. It *does* currently
cause a panic if replacement contains scopes (e.g. `() => 123`) but
that's a bug. So we shouldn't have a test saying that it *should* panic.
2024-12-13 20:26:40 +08:00
Boshen
e812ae3117
chore(deps): pin dependencies (#7842)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-13 20:12:09 +08:00
Boshen
13fe68d0dd
ci: fix more action versions 2024-12-13 20:04:27 +08:00
Boshen
4dd69b5811
ci: fix action versions 2024-12-13 19:55:47 +08:00
Boshen
0970168a48
chore(deps): pin dependencies (#7837)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-13 19:45:48 +08:00
overlookmotel
2307c633ab
ci(pr-title): fix version of actions-ecosystem/action-add-labels action (#7841)
v1.1.0 is the latest version.
2024-12-13 11:42:37 +00:00
Boshen
846375d01e
chore(deps): update crate-ci/typos action to v1.28.3 (#7839)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-13 19:41:33 +08:00
Boshen
2b187e59ba
fix(linter): fix configuration casing for typescript/no_this_alias (#7836)
closes #7835
2024-12-13 19:39:59 +08:00
Hiroshi Ogawa
5b7e1adc9b
fix(transformer): remove span of define value (#7811)
- Closes https://github.com/oxc-project/oxc/issues/7797

Removing span seems to work, but I'm not sure traversing all the time is
okay.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-13 11:22:49 +00:00
Boshen
1bb097d459
chore(renovate): temporary "updateNotScheduled": true 2024-12-13 19:13:49 +08:00
Boshen
fdf01cfe08
ci: pin lycheeverse/lychee-action@v2.1.0 2024-12-13 19:07:57 +08:00
Boshen
ba84acd5cf
ci: pin github action versions (#7826) 2024-12-13 18:53:16 +08:00
Boshen
befb0a5997
ci: pin oxc-project/setup-rust@1.0.0 (#7834) 2024-12-13 18:45:43 +08:00
Boshen
7610dc19ff fix(parser): parse import source from 'mod' (#7833) 2024-12-13 10:26:36 +00:00
Boshen
e4d040583c
chore(renovate): try extend helpers:pinGitHubActionDigests 2024-12-13 18:24:21 +08:00