Commit graph

7252 commits

Author SHA1 Message Date
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
Dunqing
0f367e5ab6 refactor(semantic): improve the logic of resolving references to be cleaner (#7829)
fine-tuning the logic, reducing unnecessary calls, and early return if it doesn't resolve. Also, add many comments to describe what code does.
2024-12-13 09:08:44 +00:00
Dunqing
57109507db refactor(semantic): move export-related reference flags logic to visit functions (#7828)
Follow-on after #7812, move setting current references flags to visit functions can reduce some unnecessary upward checking
2024-12-13 09:08:43 +00:00
Yuji Sugiura
40334ba66e
refactor(prettier): Align exported function names to Prettier (#7827)
Some refactoring works to update
https://github.com/oxc-project/oxc/issues/5068#issuecomment-2507272735
table.

- Implement `array::is_consisely_printed_array()` and use it
  - This improved compat-rate a bit ✌🏻 
- Align exported function names to align prettier's
- Split `format/mod.rs` into `js`, `jsx` and `typescript`
- Move `format/*.rs` to `format/print/*.rs`
2024-12-13 17:06:15 +08:00
Boshen
d4b8377841
ci: improve benchmark trigger 2024-12-13 13:50:02 +08:00
Nicholas Rayburn
38b1c2ec65
feat(editor): Create a command to apply all auto-fixes for the current active text editor (#7672)
Ref #7456

- Creates a custom action in the language server that applies all
auto-fixes for a given file.
- Updates VS Code to use the custom action with a command to apply fixes
for the currently active text editor.
2024-12-13 13:46:05 +08:00
Alexander S.
b24a636b0a
ci: add zizmor for github actions security (#7822)
> zizmor is a static analysis tool for GitHub Actions. It can find many
common security issues in typical GitHub Actions CI/CD setups.

https://woodruffw.github.io/zizmor/

EDIT: what is the right PR-syntax for this?

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-12-13 13:36:41 +08:00
overlookmotel
4448b63692 perf(codegen): faster writing indentation (#7820)
Write indentation faster. Previously was writing indentation to buffer with a call to `memset`, which is relatively expensive. Where indentation `<= 16` (common case), write 16 tabs with a single 16-byte XMM write, which is faster.
2024-12-13 05:17:32 +00:00
overlookmotel
14896cb318 fix(transformer/class-properties): create temp vars in correct scope (#7824)
Create `var` temp vars in current *hoist* scope, not current scope.
2024-12-13 04:04:45 +00:00
Yunfei He
9479e2b0a2
fix(semantic): missing references when export {} references a type-only binding and a normal (#7812)
https://playground.oxc.rs/#eNpdTzEOgzAM/AryzFAqdUHq2rlD1YklUIMihTiyTQGh/L0BBEMn31l35/MCDZTQkBfNXmRE3xbHQKzZPSsqX3mcNrZkOgfcJU+mIPmfPEIOBOUCPPh1yOzVTFAqD5iDs14PLA0FPMnc1+QOpmy8tMT9vog5BMOCnAITXkMOfCq3BajhDtMFQLleihskRUMf7HDtkkhvvW3tYU7vKpN7OBpX8xe5JkmVWuMEY4w/P71iMw==

Current:

<img width="876" alt="image"
src="https://github.com/user-attachments/assets/58327920-44ef-469d-8c7c-a2d7b17da717"
/>


Expected:


https://babeljs.io/repl#?browsers=&build=&builtIns=false&corejs=false&spec=false&loose=false&code_lz=MYewdgzgLgBAKiAhtAagSwKYHcAOIBOsAvDAIwBQ5UAnjhvEtAAr4g4QwkXkYAeehGAG8YNOg2RQWbCABoJqTLgKwAvkA&debug=false&forceAllTransforms=false&modules=false&shippedProposals=false&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=env%2Ctypescript&prettier=false&targets=&version=7.26.4&externalPlugins=&assumptions=%7B%7D

<img width="877" alt="image"
src="https://github.com/user-attachments/assets/9b847baa-5b5a-43be-b77d-d529fb3f8026"
/>

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-12-13 12:00:58 +08:00
overlookmotel
25bb6daa40 fix(transformer/class-properties): fix ScopeIds in instance prop initializers (#7823)
Code in instance property initializers moves from class body into constructor, or a `_super` function. Update parent `ScopeId`s for first level scopes in initializers.
2024-12-13 03:21:37 +00:00
overlookmotel
e70deb9b48 refactor(transformer/class-properties): locate instance props insertion location in separate step (#7819)
Refactor only. Does not change behavior. Determine where instance prop initializers will need to be inserted in a separate step before instance props are extracted from class.

This achieves nothing in itself, but is preparatory work for transforming initializers to correct their `ScopeId`s and deal with binding clashes.
2024-12-13 02:56:47 +00:00
overlookmotel
65b109a582 fix(transformer/class-properties): no raw for generated StringLiteral (#7825)
Follow-on after #7815. Generated `StringLiteral`s should have `raw: None`.
2024-12-13 02:33:38 +00:00
Dunqing
e727ae9698 feat(transformer/class-properties): transform super member expressions that are inside static prop initializer (#7815)
This PR support for transforming `super.prop` to  `babelHelpers.superPropGet(_B, "prop", _B)`

Input:
```js
class A {
  static prop = 1;
}

class B extends A {
  static prop = 2;
  static propA = super.prop;
  static getPropA = () => super.prop;
}
```

Output:
```js
var _B;
class A {}
babelHelpers.defineProperty(A, "prop", 1);
class B extends A {}
_B = B;
babelHelpers.defineProperty(B, "prop", 2);
babelHelpers.defineProperty(B, "propA", babelHelpers.superPropGet(_B, "prop", _B));
babelHelpers.defineProperty(B, "getPropA", () => babelHelpers.superPropGet(_B, "prop", _B));
```
2024-12-13 02:33:37 +00:00
Dunqing
b290ebd2b0 refactor(transformer): handle <CWD> in test runner (#7799)
We should move the handling of  `<CWD>` to the test runner because this is just only used in testing, and it causes us always get a path by `self.ctx.source_path` like `<CWD>/xxx/xxx.js`, we should get a real path for this.
2024-12-12 17:22:01 +00:00
Boshen
fb325dce99 refactor(ast)!: span field must be the first element (#7821)
For consistency. And maybe a small performance improvement when enum
bytes are aligned.
2024-12-12 16:50:01 +00:00
renovate[bot]
358d375bbd
chore(deps): update rust crates (#7787) 2024-12-12 22:45:45 +08:00
Dunqing
7a832307c2 fix(semantic): missing reference when export default references a type alias binding (#7813)
Fixes: #7809

`ExportNamedDecalration` and `ExportDefaultDeclaration` can reference both type binding and value, so we need to make sure the `ReferenceFlags` is `Read | Type`
2024-12-12 14:12:30 +00:00
Boshen
ed93193c32
chore: bump dprint plugins (#7818) 2024-12-12 22:12:01 +08:00
overlookmotel
8991f33fc7 feat(ast): add visit_span to Visit and VisitMut (#7816)
Add `Visit::visit_span` and `VisitMut::visit_span` methods, to facilitate #7811.

Both are no-ops by default, and marked `#[inline]`, so this produces no performance impact.
2024-12-12 13:33:12 +00:00
overlookmotel
d14d360061 test(transformer): remove dead code from fixtures update script (#7808)
Follow-up after #7771 and #7779. Remove dead code from transformer fixtures updater script.
2024-12-12 09:27:54 +00:00
Dunqing
74bf141b1a chore(tasks/transform-conformance): update only when the output differs from the original output (#7779)
From `5xx` files changed to `3xx`
2024-12-11 16:26:36 +00:00
Dunqing
4d33ffbbc8 chore(tasks/transform-conformance): support --override flag (#7774)
The `--override` flag used to write the output which is generated by the transformer to the `overrides` folder according to the test path. The acting is similar to the previous `takeover` mode
2024-12-11 16:18:16 +00:00