Commit graph

7988 commits

Author SHA1 Message Date
Dunqing
e472ced05f perf(mangler): optimize handling of collecting lived scope ids (#8724)
Just some low-hanging fruit optimization.

I initially want to dedupe for reference scopes, so that we can avoid calling `scope_tree.ancestors(used_scope_id).take_while(|s_id| *s_id != scope_id)` for duplicate `used_scope_id` but the overhead of calling `unique` or `dedup` is over the improvement.
2025-01-26 10:53:48 +00:00
Dunqing
c79206850c refactor(semantic): simplify ScopeTree::iter_bindings (#8723)
The previous implementation is a little weird, I think it should be a shortcut of `bindings.iter`, It is infrequent we need to iter all symbols and know its scope ID. Only two cases in tests, and no use case in `Rolldown`
2025-01-26 10:53:48 +00:00
Boshen
2e9a5602e9 feat(minifier): NaN.toString(radix) is always NaN (#8727) 2025-01-26 10:38:27 +00:00
Boshen
cbe0e8239d feat(minifier): minimize foo(...[]) -> foo() (#8726) 2025-01-26 10:30:33 +00:00
Boshen
ad87fc7a53
ci: download ast-grep from github (#8728) 2025-01-26 18:19:00 +08:00
Boshen
e9fb5febdf
feat(minifier): dce pure expressions such as new Map() (#8725) 2025-01-26 18:08:34 +08:00
Boshen
03229c5367 test(minifier): fix broken tests (#8722) 2025-01-26 03:47:07 +00:00
Tyler Earls
37909337bd
feat(linter): add vitest/prefer-lowercase-title rule (#8152)
This pull request implements the
[vitest/prefer-lowercase-title](https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-lowercase-title.md)
rule.

Since there was an existing jest rule with this title, I followed the
existing pattern in
[no-unused-vars](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/eslint/no_unused_vars/mod.rs)
to group the jest and vitest rules together in a shared module. I used
the existing `jest/prefer-lowercase-title` documentation as a base and
modified it where it seemed appropriate. I added a `jest` and `vitest`
snapshot suffix for each respective test suite.

One item I wasn't 100% about is adding `bench` to the jest test names.
Without this change, the vitest test suite fails because of [this
check](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/utils/jest/parse_jest_fn.rs#L108)
which validates that we're only parsing valid jest functions from a
detected jest file. The unit tests that are sourced from the vitest
plugin are all read by the linting host as jest-like files, so adding
`bench` as a "valid" jest method allows us to lint a unit test using
this keyword. This seemed to me like the least invasive solution to
accommodate the new rule without breaking any existing code, but I'm
certainly open to alternatives.
2025-01-26 09:21:13 +08:00
Tyler Earls
1de6f854cb
fix(linter): no-lone-blocks erroring on block statements containing comments (#8720)
This PR fixes #8697 by checking if semantic detects a comment in the
span of an otherwise empty block statement.

I also formatted some of the existing test cases to improve readability.
2025-01-26 09:20:05 +08:00
branchseer
3e509e1c9b
fix(transformer/typescript): enum merging when same name declared in outer scope (#8691)
```typescript
var x = 10;
enum Merge { x = Math.random() }
enum Merge {
    y = x // <-- refers to Merge.x
}
```

This case wasn't covered in #8543 and by the [babel test
case](e568916ef3/packages/babel-plugin-transform-typescript/test/fixtures/enum/non-constant-member-reference/input.ts).
To handle it we still have to go through the scope ancestors.

---------

Co-authored-by: Dunqing <dengqing0821@gmail.com>
2025-01-26 09:18:00 +08:00
camchenry
77ef61a68e fix(linter): fix diagnostic spans for oxc/no-async-await (#8721)
Fixes broken diagnostic spans for async functions that did not correctly report on the `async` keyword. I changed the diagnostic reporting to look for the `async` keyword itself within a given span which is a little slower but worth it for accuracy I think.

I also updated the diagnostic to be async-specific as we don't report on await yet.
2025-01-25 20:55:20 +00:00
camchenry
d318238cd2 perf(linter): Remove sorting of rules in cache (#8718)
Experimentally removing this sort as the TODO indicated this might not be needed. If there's no performance loss, I'd say we should merge it.
2025-01-25 17:06:53 +00:00
Boshen
58002e270b refactor(ecmascript): remove the lifetime annotation on MayHaveSideEffects (#8717) 2025-01-25 16:21:03 +00:00
Dunqing
e7ab96cbb6 fix(transformer/jsx): incorrect isStaticChildren argument for Fragment with multiple children (#8713)
close: #8650
2025-01-25 16:11:28 +00:00
Boshen
bf8be23f11 refactor(minifier): use Ctx (#8716) 2025-01-25 16:03:18 +00:00
Boshen
0af0267077 refactor(minifier): side effect detection needs symbols resolution (#8715) 2025-01-25 15:01:00 +00:00
Sysix
4a2f2a9cd9 refactor(linter): move default all_rules output to trait (#8710) 2025-01-25 13:42:20 +00:00
翠 / green
33de70ae71
fix(mangler): handle cases where a var is declared in a block scope (#8706)
This PR fixes the mangler that it was outputting `function _() { { var
a; let a; } }` for `function _() { { var x; let y; } }`.
This caused this error:
https://github.com/oxc-project/monitor-oxc/actions/runs/12962575667/job/36159286596#step:8:31

refs #8705
2025-01-25 19:30:03 +08:00
sapphi-red
d982cdba85
fix(minifier): Unknown.fromCharCode should not be treated as String.fromCharCode (#8709) 2025-01-25 10:56:09 +00:00
Alexander S.
bf895eb90d
test(linter): add diagnostic format test snapshots (#8696)
windows will fail, looks like the offset missmatch is because of `\r\n`
vs `\n`.

```
Snapshot file: apps\oxlint\src\snapshots\--format=json test.js@oxlint.snap
Snapshot: --format=json test.js@oxlint
Source: C:\dev\oxc:74
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────-old snapshot
+new results
────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────    0     0 │ ##########
    1     1 │ --format=json test.js
    2     2 │ ----------
    3     3 │ [
    4       │-  {"message": "`debugger` statement is not allowed","code": "eslint(no-debugger)","severity": "error","causes": [],"url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html","help": "Delete this code.","filename": "test.js","labels": [{"span": {"offset": 38,"length": 9}}],"related": []},
          4 │+  {"message": "`debugger` statement is not allowed","code": "eslint(no-debugger)","severity": "error","causes": [],"url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html","help": "Delete this code.","filename": "test.js","labels": [{"span": {"offset": 42,"length": 9}}],"related": []},
    5     5 │   {"message": "Function 'foo' is declared but never used.","code": "eslint(no-unused-vars)","severity": "warning","causes": [],"url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unused-vars.html","help": "Consider removing this declaration.","filename": "test.js","labels": [{"label": "'foo' is declared here","span": {"offset": 9,"length": 3}}],"related": []},
    6     6 │   {"message": "Parameter 'b' is declared but never used. Unused parameters should start with a '_'.","code": "eslint(no-unused-vars)","severity": "warning","causes": [],"url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unused-vars.html","help": "Consider removing this parameter.","filename": "test.js","labels": [{"label": "'b' is declared here","span": {"offset": 16,"length": 1}}],"related": []}
    7     7 │ ]
────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────To update snapshots run `cargo insta review`
Stopped on the first failure. Run `cargo insta test` to run all snapshots.
thread 'output_formatter::test::test_output_formatter_diagnostic_json' panicked at C:\Users\sysix\.cargo\registry\src\index.crates.io-6f17d22bba15001f\insta-1.42.0\src\runtime.rs:679:13:
snapshot assertion for '--format=json test.js@oxlint' failed in line 74
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- output_formatter::test::test_output_formatter_diagnostic_stylish stdout ----
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Snapshot Summary ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━Snapshot file: apps\oxlint\src\snapshots\--format=stylish test.js@oxlint.snap
Snapshot: --format=stylish test.js@oxlint
Source: C:\dev\oxc:74
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────-old snapshot
+new results
────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────    3     3 │
    4     4 │ ␛[4mtest.js␛[0m␊
    5     5 │   ␛[2m9:3 ␛[0m  ␛[33mwarning␛[0m  Function 'foo' is declared but never used.  ␛[2meslint(no-unused-vars)␛[0m␊
    6     6 │   ␛[2m16:1␛[0m  ␛[33mwarning␛[0m  Parameter 'b' is declared but never used. Unused parameters should start with a '_'.  ␛[2meslint(no-unused-vars)␛[0m␊
    7       │-  ␛[2m38:9␛[0m  ␛[31merror␛[0m  `debugger` statement is not allowed  ␛[2meslint(no-debugger)␛[0m␊
          7 │+  ␛[2m42:9␛[0m  ␛[31merror␛[0m  `debugger` statement is not allowed  ␛[2meslint(no-debugger)␛[0m␊
    8     8 │ 
    9     9 │ ␛[31m✖ 3 problems (1 error, 2 warnings)␛[0m
────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────To update snapshots run `cargo insta review`
Stopped on the first failure. Run `cargo insta test` to run all snapshots.
thread 'output_formatter::test::test_output_formatter_diagnostic_stylish' panicked at C:\Users\sysix\.cargo\registry\src\index.crates.io-6f17d22bba15001f\insta-1.42.0\src\runtime.rs:679:13:
snapshot assertion for '--format=stylish test.js@oxlint' failed in line 74


failures:
    output_formatter::test::test_output_formatter_diagnostic_json
    output_formatter::test::test_output_formatter_diagnostic_stylish

test result: FAILED. 85 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.12s

```
2025-01-25 18:51:00 +08:00
Boshen
0944758cc7 fix(codegen): remove parens from new (import(''), function() {}) (#8707) 2025-01-25 10:07:18 +00:00
Rintaro Itokawa
f15bdce53b
fix(linter): catch Promise in typescript/array-type rule (#8702)
close #8693 

Correctly catch `Promise<string[]>` and `Promise<Array<number>>`.
2025-01-25 17:30:33 +08:00
1zumii
e8e69179d1
feat(linter): unicorn/switch-cases-braces support options (#8704)
close #8492
2025-01-25 17:30:01 +08:00
翠 / green
6589c3bbb3
feat(mangler): reuse variable names (#8562)
Changed the mangler to reuse variable names where possible.

This will reduce the code size as shorter variable names can be used in
more places. But requires global information and limits parallelism in a
single file and requires more memory.

---------

Co-authored-by: Boshen <boshenc@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-25 14:00:24 +08:00
Boshen
32e0e4796c
refactor(minifier): clean up Normalize (#8700) 2025-01-25 13:52:35 +08:00
Boshen
8587965e45
perf(minifier): normalize undefined to void 0 before everything else (#8699)
so subsequent code don't need to lookup `undefined`.
2025-01-25 11:50:08 +08:00
Sysix
34d3d72b64 test(linter): add snapshot tester for cli (#8695)
Our first Snapshot 🥳
2025-01-24 17:19:31 +00:00
Sysix
741fb40a53 refactor(linter): move stdout outside LintRunner (#8694)
This is needed so we can use a custom `Write` implementation (or just `[u8]`) to make snapshots.
In this step I also updated `OutputFormatter::all_rules` so the Formatter does not need to handle the write-error.
2025-01-24 17:05:19 +00:00
Boshen
b7f13e636e feat(ast): implement utf8 to utf16 span converter (#8687)
closes #8629
2025-01-24 16:57:44 +00:00
Sysix
10e59209ef refactor(linter): move finishing default diagnostic message to GraphicalReporter (#8683)
Now every lint output is owned by is right OutputFormatter and his DiagnosticReporter 🥳
Next step is to setup a snapshot Tester, so I can remove the ToDos.

Reorded some lines so the outfor is now for: `cargo run -p oxlint -- test.js --max-warnings=2`
```
Found 4 warnings and 0 errors.
Exceeded maximum number of warnings. Found 4.
Finished in 5ms on 1 file with 97 rules using 24 threads.
```

and for `cargo run -p oxlint -- test.js`

```
Found 4 warnings and 0 errors.
Finished in 5ms on 1 file with 97 rules using 24 threads.
```

The output time and warnings/error count wil be always printed.
2025-01-24 16:39:17 +00:00
oxc-bot
b97767874f
release(oxlint): v0.15.8 (#8689)
## [0.15.8] - 2025-01-24

### Features

- 79ba9b5 linter: Added support to run in Node.JS legacy versions
(#8648) (Luiz Felipe Weber)
- dcaebe6 linter: Add "strict" option to `promise/prefer-await-to-then`
rule (#8674) (Neil Fisher)
- 4ae568e linter: Add DiagnosticResult to the Reporters for receiving a
sub part result (#8666) (Alexander S.)
- 8a0eb2a oxlint: Add stylish formatter (#8607) (Andrew Powell)

### Bug Fixes

- 40316af linter: Fix github `endColumn` output (#8647) (Alexander S.)
- dc912fa linter: Added missing $schema property to default config
(#8625) (Tapan Prakash)

### Refactor

- a3dc4c3 crates: Clean up snapshot files (#8680) (Boshen)
- e66da9f isolated_declarations, linter, minifier, prettier, semantic,
transformer: Remove unnecessary `ref` / `ref mut` syntax (#8643)
(overlookmotel)
- 23b49a6 linter: Use `cow_to_ascii_lowercase` instead
`cow_to_lowercase` (#8678) (Boshen)
- b8d9a51 span: Deal only in owned `Atom`s (#8641) (overlookmotel)
- ac4f98e span: Derive `Copy` on `Atom` (#8596) (branchseer)
- 259a47b vscode: Move commands and `findBinary` to separate files
(#8605) (Alexander S.)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-01-24 18:07:14 +08:00
Boshen
4f6d164f52
ci: fix release napi scripts 2025-01-24 13:37:01 +08:00
oxc-bot
8a72b8ecc7
release(crates): v0.48.0 (#8686)
## [0.48.0] - 2025-01-24

- 54d0fac span: [**BREAKING**] Remove `PartialEq` impl for `&Atom`
(#8642) (overlookmotel)

### Features

- 2a2ad53 allocator: Add `Allocator::capacity` and `used_bytes` methods
(#8621) (overlookmotel)
- 6801c81 allocator: Add `Allocator::new` and `with_capacity` methods
(#8620) (overlookmotel)
- 99607d3 codegen: Print comments in `TSTypeLiteral` (#8679) (Boshen)
- 4ae568e linter: Add DiagnosticResult to the Reporters for receiving a
sub part result (#8666) (Alexander S.)
- 343690e minifier: Replace `Number.*_SAFE_INTEGER`/`Number.EPSILON`
(#8682) (sapphi-red)
- 0c5bb30 minifier: Replace
`Number.POSITIVE_INFINITY`/`Number.NEGATIVE_INFINITY`/`Number.NaN`
(#8681) (sapphi-red)
- 835b258 minifier: Compress `typeof foo === 'object' && foo !== null`
to `typeof foo == 'object' && !!foo` (#8638) (sapphi-red)
- 2bcbed2 minifier: Compress `(a = b) === null || a === undefined` to
`(a = b) == null` (#8637) (sapphi-red)

### Bug Fixes

- 40316af linter: Fix github `endColumn` output (#8647) (Alexander S.)
- 883d25b minifier: Keep esm in dce (#8677) (Boshen)
- 878ce10 minifier: `void 0` equals to `undefined` (#8673) (Boshen)
- ba201a6 minifier: Remove "non esbuild optimizations" which is
incorrect (#8668) (Boshen)
- 8c8b5fa minifier: Avoid minifing `String(a)` into `"" + a` for symbols
(#8612) (翠 / green)
- 4ff6e85 minifier: Remove expression statement `void 0` (#8602)
(Boshen)
- 93d643e minifier: Keep side effects when folding const conditional
exprs (#8591) (camc314)
- 178c232 parser: Parse `intrinsic` TS keyword (#8627) (Kevin Deng 三咲智子)
- 48717ab parser: Parse `true` as `TSLiteralType` (#8626) (Kevin Deng
三咲智子)
- d1c5dc4 semantic: Fix const assertions in `UnresolvedReferencesStack`
(#8653) (overlookmotel)

### Performance

- 787aaad allocator: Make `String` non-drop (#8617) (overlookmotel)
- d966e0a codegen: Do not check for comments if turned off (#8598)
(Boshen)
- 3fa87ff lexer: Peak 2 bytes after `!` (#8662) (Boshen)
- 9953ac7 minifier: Add `LatePeepholeOptimizations` (#8651) (Boshen)
- 00dc63f minifier: Only substitute typed array constructor once (#8649)
(Boshen)
- 3e19e4e minifier: Remove the useless empty statement removal code in
statement fusion (#8646) (Boshen)
- 5b3c412 minifier: Only run optimizations on local changes (#8644)
(Boshen)

### Documentation

- c1d243b allocator: Improve docs for `Allocator` (#8623)
(overlookmotel)
- 01a5e5d allocator: Improve docs for `HashMap` (#8616) (overlookmotel)
- 87568a1 allocator: Reformat docs (#8615) (overlookmotel)
- 3be0392 lexer: Fix doc comment (#8664) (overlookmotel)
- 5029547 semantic: Fix and reformat doc comments (#8652)
(overlookmotel)

### Refactor

- ae8db53 allocator: Move `Allocator` into own module (#8656)
(overlookmotel)
- 0f85bc6 allocator: Reduce repeat code to prevent `Drop` types in arena
(#8655) (overlookmotel)
- de76eb1 allocator: Reorder `Box` methods (#8654) (overlookmotel)
- 997859c ast: Align `#[estree(via)]` behavior (#8599) (sapphi-red)
- db863a3 codegen: Use `Stack` for `binary_expr_stack` (#8663) (Boshen)
- 8cce69a codegen: Remove `match_member_expression` (#8597) (Boshen)
- a3dc4c3 crates: Clean up snapshot files (#8680) (Boshen)
- e66da9f isolated_declarations, linter, minifier, prettier, semantic,
transformer: Remove unnecessary `ref` / `ref mut` syntax (#8643)
(overlookmotel)
- 23b49a6 linter: Use `cow_to_ascii_lowercase` instead
`cow_to_lowercase` (#8678) (Boshen)
- ce2b9da minifier: Remove `wrap_to_avoid_ambiguous_else` (#8676)
(Boshen)
- 75a579b minifier: Clean up
`has_no_side_effect_for_evaluation_same_target` (#8675) (Boshen)
- 1bb2539 minifier: Move more code into `minimize_conditions` local loop
(#8671) (Boshen)
- 13e4a45 minifier: Move conditional assignment to `minimize_conditions`
(#8669) (Boshen)
- ae895d8 minifier: Use `NonEmptyStack` for function stack (#8661)
(Boshen)
- 3802d28 minifier: Clean up `try_minimize_conditional` (#8660) (Boshen)
- dcc1f2b minifier: Rename `ast_passes` to `peephole` (#8635) (Boshen)
- 52458de minifier: Remove unused code and traits (#8632) (Boshen)
- 6f95cd5 minifier: Remove all the unnecessary fake ast passes (#8618)
(Boshen)
- 712cae0 minifier: Run the compressor on all test cases (#8604)
(Boshen)
- 864b8ef parser: Shorten code (#8640) (overlookmotel)
- b8d9a51 span: Deal only in owned `Atom`s (#8641) (overlookmotel)
- 20f52b1 span: Remove unnecessary lifetimes on `Atom` impls (#8639)
(overlookmotel)
- ac4f98e span: Derive `Copy` on `Atom` (#8596) (branchseer)
- a730f99 transformer: Move `create_prototype_member` to utils module
(#8657) (Dunqing)
- 61d96fd transformer/class-properties: Correct comments (#8636)
(overlookmotel)

### Testing

- 39dbd2d codegen: Fix snapshot file (#8685) (Boshen)
- d9f5e7f minifier: Enable passed esbuild tests (Boshen)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-01-24 12:09:37 +08:00
Dunqing
233dc07738 feat(ast): derive Clone for TemplateElement and TemplateElementValue (#8658)
In #8614, we need to duplicate the same template literal, and derive `Copy` and `Clone` to avoid using `CloneIn`.
2025-01-24 03:58:33 +00:00
Boshen
39dbd2d472
test(codegen): fix snapshot file (#8685) 2025-01-24 11:58:02 +08:00
sapphi-red
343690e178
feat(minifier): replace Number.*_SAFE_INTEGER/Number.EPSILON (#8682)
The value of `Number.*_SAFE_INTEGER`, `Number.EPSILON` are constants as they cannot be changed. This PR replaces them with `2**53-1` / `-(2**53-1)` / `2**-52` for ES2016+. For ES2015, `Number.EPSILON` is not changed but `Number.*_SAFE_INTEGER`s are replaced with `9007199254740991` / `-9007199254740991`.

**Reference**
- Spec of [`Number.MAX_SAFE_INTEGER`](https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-number.max_safe_integer)
- Spec of [`Number.MIN_SAFE_INTEGER`](https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-number.min_safe_integer)
- Spec of [`Number.EPSILON`](https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-number.epsilon)

### Additional Information
- [`Number.MIN_VALUE`](https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-number.min_value) cannot be replaced as the value depends on the runtime
- [`Number.MAX_VALUE`](https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-number.max_value) can be replaced but I didn't come up with a shorter representation that does not lack precision
2025-01-24 03:47:52 +00:00
sapphi-red
0c5bb30859
feat(minifier): replace Number.POSITIVE_INFINITY/Number.NEGATIVE_INFINITY/Number.NaN (#8681)
The value of `Number.POSITIVE_INFINITY`, `Number.NEGATIVE_INFINITY`, `Number.NaN` are constants as they cannot be changed. This PR replaces them with `Infinity`/`-Infinity`/`NaN`.

**Reference**
- Spec of [`Number.POSITIVE_INFINITY`](https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-number.positive_infinity)
- Spec of [`Number.NEGATIVE_INFINITY`](https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-number.positive_infinity)
- Spec of [`Number.NaN`](https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-number.positive_infinity)
2025-01-23 15:26:22 +00:00
Boshen
a3dc4c3cbe refactor(crates): clean up snapshot files (#8680) 2025-01-23 14:43:32 +00:00
Boshen
99607d3f82 feat(codegen): print comments in TSTypeLiteral (#8679)
fixes #8665
2025-01-23 14:31:55 +00:00
Boshen
23b49a665f refactor(linter): use cow_to_ascii_lowercase instead cow_to_lowercase (#8678)
`cow_to_lowercase` is slow as it deals with unicode.

closes #8659
2025-01-23 13:46:52 +00:00
Boshen
883d25b27d fix(minifier): keep esm in dce (#8677)
fixes https://github.com/rolldown/rolldown/issues/3402
2025-01-23 13:30:41 +00:00
Boshen
ce2b9da5c7 refactor(minifier): remove wrap_to_avoid_ambiguous_else (#8676) 2025-01-23 13:20:32 +00:00
Luiz Felipe Weber
79ba9b5970
feat(linter): added support to run in Node.JS legacy versions (#8648)
With a few adjustments It is possible to run _oxlint_ in projects which
use legacy **Node.js** versions, such as **8.x.x**. Basically this is
possible by removing spread operator in 'binpath' environment assemble
and changing a catch command to inform an error variable.

Without this modification, we got always this error:

```
node_modules/oxlint/bin/oxlint:23
  } catch {
          ^

SyntaxError: Unexpected token {
    at createScript (vm.js:74:10)
    at Object.runInThisContext (vm.js:116:10)
    at Module._compile (module.js:533:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3
```
2025-01-23 21:17:48 +08:00
Neil Fisher
dcaebe69b1
feat(linter): Add "strict" option to promise/prefer-await-to-then rule (#8674)
Implementation of the strict option [specified in the eslint docs for
`promise/prefer-await-to-then`](https://github.com/eslint-community/eslint-plugin-promise/blob/main/docs/rules/prefer-await-to-then.md)

```js
// Examples of **incorrect** code with `{ strict: true }`:
async function hi() {
  await thing().then(x => {})
}
```
2025-01-23 13:13:50 +00:00
Boshen
75a579b619
refactor(minifier): clean up has_no_side_effect_for_evaluation_same_target (#8675) 2025-01-23 20:55:16 +08:00
Boshen
3fa87ff6a6
perf(lexer): peak 2 bytes after ! (#8662)
`!==` and `!=` is very frequent.

<img width="845" alt="image"
src="https://github.com/user-attachments/assets/91ff20fc-ae1c-4fb9-9444-4eb90d8e95f3"
/>

Picked this up while profiling.
2025-01-23 18:19:03 +08:00
Boshen
878ce10296 fix(minifier): void 0 equals to undefined (#8673) 2025-01-23 08:27:47 +00:00
Boshen
1bb2539d64 refactor(minifier): move more code into minimize_conditions local loop (#8671) 2025-01-23 07:03:42 +00:00
Yuji Sugiura
a529412fe7
refactor(prettier): Verify printing module exports (#8670)
Part of #5068 

- ExportAllDeclaration
- ExportNamedDeclaration
- ExportDefaultDeclaration
- (ExportNamespaceSpecifier = ExportAllDeclaration+exported)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-23 14:54:06 +08:00
Boshen
13e4a4593f refactor(minifier): move conditional assignment to minimize_conditions (#8669) 2025-01-23 04:42:44 +00:00