Commit graph

6297 commits

Author SHA1 Message Date
Cam McHenry
fc647ab7aa
fix(tasks/lint_rules): sync vitest compatible rules with jest rules (#6667)
Ensures that Jest rules which are compatible with Vitest are properly
reflected in the tracking issue.

Here is a preview of what the updated markdown looks like:

---

---

> [!WARNING]
> This comment is maintained by CI. Do not edit this comment directly.
> To update comment template, see
https://github.com/oxc-project/oxc/tree/main/tasks/lint_rules

This is tracking issue for `eslint-plugin-vitest`.


There are 51(+ 1 deprecated) rules.

- 1/8 recommended rules are remaining as TODO
- 30/43 not recommended rules are remaining as TODO


To get started, run the following command:

```sh
just new-vitest-rule <RULE_NAME>
```

Then register the rule in `crates/oxc_linter/src/rules.rs` and also
`declare_all_lint_rules` at the bottom.


## Recommended rules

<details open>
<summary>
  : 7, 🚫: 0 / total: 8
</summary>

| Status | Name | Docs |
| :----: | :--- | :--- |
|  | vitest/no-identical-title |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-identical-title.md
|
|  | vitest/expect-expect |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/expect-expect.md
|
|  | vitest/no-commented-out-tests |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-commented-out-tests.md
|
|  | vitest/no-import-node-test |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-import-node-test.md
|
| | vitest/valid-title |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-title.md
|
|  | vitest/valid-expect |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-expect.md
|
|  | vitest/require-local-test-context-for-concurrent-snapshots |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-local-test-context-for-concurrent-snapshots.md
|
|  | vitest/valid-describe-callback |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-describe-callback.md
|

 = Implemented, 🚫 = Not supported

</details>


## Not recommended rules

<details open>
<summary>
  : 13, 🚫: 0 / total: 43
</summary>

| Status | Name | Docs |
| :----: | :--- | :--- |
| | vitest/prefer-lowercase-title |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-lowercase-title.md
|
| | vitest/max-nested-describe |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/max-nested-describe.md
|
|  | vitest/no-focused-tests |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-focused-tests.md
|
|  | vitest/no-conditional-tests |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-tests.md
|
|  | vitest/consistent-test-it |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-it.md
|
| | vitest/prefer-to-be |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be.md
|
| | vitest/no-hooks |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-hooks.md
|
| | vitest/no-restricted-vi-methods |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-vi-methods.md
|
| | vitest/consistent-test-filename |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-filename.md
|
| | vitest/max-expects |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/max-expects.md
|
|  | vitest/no-alias-methods |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-alias-methods.md
|
|  | vitest/no-conditional-expect |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-expect.md
|
|  | vitest/no-conditional-in-test |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-in-test.md
|
|  | vitest/no-disabled-tests |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-disabled-tests.md
|
| | vitest/no-duplicate-hooks |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-duplicate-hooks.md
|
| | vitest/no-large-snapshots |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-large-snapshots.md
|
| | vitest/no-interpolation-in-snapshots |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-interpolation-in-snapshots.md
|
| | vitest/no-mocks-import |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-mocks-import.md
|
| | vitest/no-restricted-matchers |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-matchers.md
|
| | vitest/no-standalone-expect |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-standalone-expect.md
|
|  | vitest/no-test-prefixes |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-test-prefixes.md
|
| | vitest/no-test-return-statement |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-test-return-statement.md
|
| | vitest/prefer-called-with |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-with.md
|
|  | vitest/prefer-to-be-falsy |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-falsy.md
|
|  | vitest/prefer-to-be-object |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-object.md
|
|  | vitest/prefer-to-be-truthy |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-truthy.md
|
| | vitest/prefer-to-have-length |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-have-length.md
|
| | vitest/prefer-equality-matcher |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-equality-matcher.md
|
| | vitest/prefer-strict-equal |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-strict-equal.md
|
| | vitest/prefer-expect-resolves |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-resolves.md
|
|  | vitest/prefer-each |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-each.md
|
| | vitest/prefer-hooks-on-top |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-on-top.md
|
|  | vitest/prefer-hooks-in-order |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-in-order.md
|
| | vitest/prefer-mock-promise-shorthand |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-mock-promise-shorthand.md
|
| | vitest/prefer-snapshot-hint |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-snapshot-hint.md
|
| | vitest/require-top-level-describe |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-top-level-describe.md
|
| | vitest/require-to-throw-message |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-to-throw-message.md
|
| | vitest/require-hook |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-hook.md
|
| | vitest/prefer-todo |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-todo.md
|
| | vitest/prefer-spy-on |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-spy-on.md
|
| | vitest/prefer-comparison-matcher |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-comparison-matcher.md
|
| | vitest/prefer-to-contain |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-contain.md
|
| | vitest/prefer-expect-assertions |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-assertions.md
|

 = Implemented, 🚫 = Not supported

</details>


## Deprecated rules

<details >
<summary>
  : 0, 🚫: 0 / total: 1
</summary>

| Status | Name | Docs |
| :----: | :--- | :--- |
| | vitest/no-done-callback |
https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-done-callback.md
|

 = Implemented, 🚫 = Not supported

</details>

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-10-21 10:55:17 +08:00
camchenry
d6609e91c2 refactor(linter): use run_on_jest_node for existing lint rules (#6722)
- closes https://github.com/oxc-project/oxc/issues/6038

Migrates all simple iterations over Jest nodes to use the `run_on_jest_node` method. Rules which require more custom data (such as getting nodes in order or storing data about counts, duplicates, etc.) have not been migrated.

Some simple benchmarking shows that this is ~5% faster on `vscode` when the Jest/Vitest rules are NOT enabled (due to being able to skip them now). And it is up to 8% on `vscode` when the Jest/Vitest plugins are enabled.

```
hyperfine -i -N --warmup 3 --runs 30 './oxlint-jest-iter --deny=all --silent ./vscode' './oxlint-main --deny=all --silent ./vscode'
Benchmark 1: ./oxlint-jest-iter --deny=all --silent ./vscode
  Time (mean ± σ):      2.348 s ±  0.104 s    [User: 16.922 s, System: 0.641 s]
  Range (min … max):    2.141 s …  2.544 s    30 runs

Benchmark 2: ./oxlint-main --deny=all --silent ./vscode
  Time (mean ± σ):      2.476 s ±  0.042 s    [User: 17.768 s, System: 0.668 s]
  Range (min … max):    2.430 s …  2.598 s    30 runs

Summary
  ./oxlint-jest-iter --deny=all --silent ./vscode ran
    1.05 ± 0.05 times faster than ./oxlint-main --deny=all --silent ./vscode
```

```
hyperfine -i -N --warmup 3 --runs 30 './oxlint-jest-iter --deny=all --jest-plugin --vitest-plugin --silent ./vscode' './oxlint-main --deny=all --jest-plugin --vitest-plugin --silent ./vscode'
Benchmark 1: ./oxlint-jest-iter --deny=all --jest-plugin --vitest-plugin --silent ./vscode
  Time (mean ± σ):      2.728 s ±  0.118 s    [User: 19.782 s, System: 0.786 s]
  Range (min … max):    2.580 s …  3.078 s    30 runs

Benchmark 2: ./oxlint-main --deny=all --jest-plugin --vitest-plugin --silent ./vscode
  Time (mean ± σ):      2.939 s ±  0.051 s    [User: 21.259 s, System: 0.859 s]
  Range (min … max):    2.848 s …  3.064 s    30 runs

Summary
  ./oxlint-jest-iter --deny=all --jest-plugin --vitest-plugin --silent ./vscode ran
    1.08 ± 0.05 times faster than ./oxlint-main --deny=all --jest-plugin --vitest-plugin --silent ./vscode
```
2024-10-21 02:13:59 +00:00
camchenry
97195ec5a2 refactor(linter): add run_on_jest_node to run rules on only jest nodes (#6721)
- part of https://github.com/oxc-project/oxc/issues/6038

Adds a new `run_on_jest_node` method for running lint rules which allows only Jest/Vitest nodes to be linted. This simplifies a number of Jest rules by removing the need to iterate/collect Jest nodes inside of them. Now, they can simply run on the Jest nodes that are passed to them directly. This also saves time by skipping the running of the rule if it is not a test file or the Jest/Vitest plugins are not enabled.
2024-10-21 02:13:58 +00:00
camchenry
155fe7e5c2 refactor(linter): allow Semantic to be passed for collecting Jest nodes (#6720)
This refactors the Jest node collection to not be rule-specific by allowing `Semantic` to be passed instead of the LintContext. This prepares the code to be used outside of a particular rule context.
2024-10-21 02:13:58 +00:00
camchenry
ad8f28197e refactor(linter): use iter for collecting jest nodes (#6719)
Adds a new method for iterating over jest nodes instead of collecting them all at once. The jest node collection now uses the iterator internally for consistency between the two approaches. This should save time and memory anywhere we need to iterate over Jest nodes, as we don't need to collect everything at once.
2024-10-21 02:13:57 +00:00
DonIsaac
bad87704ce docs(ast): enforce doc comments on JSX nodes, literal nodes, and comments (#6712)
Part of https://github.com/oxc-project/backlog/issues/130
2024-10-21 02:08:05 +00:00
DonIsaac
2e2b748285 refactor(isolated-declarations): protect internal transform methods (#6723)
Change `pub fn` to `pub(crate) fn` for all internal methods in isolated declarations. I would appreciate someone who is more familiar with this code informing me if I incorrectly privatized methods that should be public.
2024-10-21 02:03:33 +00:00
Don Isaac
f05a2739da
ci(linter): skip linter benchmarks on unrelated file changes (#6705)
Skip building/running linter benchmarks on PRs that only change the
transformer, ID, formatter, or the minifier.
2024-10-21 10:02:35 +08:00
camchenry
dc19a8f792 refactor(linter): use iterator for collecting jest imports (#6718)
Uses an iterator for getting reference IDs now, so we don't have to collect all of them at once. Also removes the checking around whether there are any `JEST_METHOD_NAMES`: this occurs in `collect_ids_referenced_to_global` anyway (will return no elements in the iterator if there are not any).
2024-10-21 01:13:00 +00:00
DonIsaac
374b972143 docs(codegen): add #![warn(missing_docs)] to oxc_codegen (#6711)
Part of https://github.com/oxc-project/backlog/issues/130
2024-10-21 00:13:57 +00:00
DonIsaac
34b6221036 docs(macros): add #![warn(missing_docs] to oxc_macros (#6710)
Part of https://github.com/oxc-project/backlog/issues/130
2024-10-21 00:09:27 +00:00
Brian Liu
af257520e1
feat(linter): add unicorn/prefer-math-min-max (#6621)
[unicorn/prefer-math-min-max](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v56.0.0/docs/rules/prefer-math-min-max.md)
of #684

---------

Co-authored-by: Brian Liu <brian@redflagsdating.com>
Co-authored-by: Don Isaac <donald.isaac@gmail.com>
Co-authored-by: Cam McHenry <camchenry@users.noreply.github.com>
2024-10-20 19:39:20 -04:00
Tapan Prakash
29c14474ff
refactor(linter): jest/valid-title fixer to use Span::shrink method (#6703)
Used shrink apis from span
2024-10-20 18:40:09 -04:00
overlookmotel
902a3d0495 feat(ast_tools): ability to generate text files (#6686)
This was originally in #6404 but I pulled it out to reduce that PR's diff.

Add ability (currently unused) to output arbitrary text files from `oxc_ast_tools` generators.
2024-10-20 21:28:59 +00:00
overlookmotel
136029ee58 refactor(ast_tools): give GeneratorOutput and SideEffect named fields (#6685)
Pure refactor. Named fields are clearer.
2024-10-20 21:28:59 +00:00
overlookmotel
53049fe7fa fix(wasm): remove type defs for ArrayExpressionElement and Elision (#6683)
Follow-on after #6404.

`ArrayExpressionElement` and `Elision` are not used in the TS types, because `ArrayExpression` has an override for the field it uses.

002289b4b1/crates/oxc_ast/src/ast/js.rs (L293-L302)

Prevent these TS type defs being emitted by introducing a new `#[estree(custom_ts_def)]` attr, to go with `#[estree(custom_serialize)]`.
2024-10-20 21:22:56 +00:00
Don Isaac
d4a2529439
test(span): add Span::is_empty unit tests (#6706) 2024-10-20 15:39:14 -04:00
Boshen
f99528d3c2 refactor(coverage): remove unused run_sync_v8_test262_status (#6704) 2024-10-20 16:02:26 +00:00
DonIsaac
6a76ea8d3d perf(linter/no-unused-vars): use default IgnorePattern when /^_/ is provided as a pattern (#6697)
Use `IgnorePattern::Default` even when `/^_/` is explicitly provided as a regex. This gives better diagnostic messages and lets us use `starts_with('_')` in more cases.
2024-10-20 15:49:56 +00:00
Boshen
8b25131d11 refactor(minifier): binary operations use ConstantEvaluation (#6700) 2024-10-20 15:13:27 +00:00
Boshen
3711c32f22 chore(coverage): bump test262, babel and TypeScript (#6702)
closes #6692
2024-10-20 15:02:26 +00:00
Tapan Prakash
5095f027e5
feat(linter): Added fixer for duplicate prefix in valid title jest rule (#6699) 2024-10-20 10:46:49 -04:00
DonIsaac
01a35bb446 feat(linter/eslint): show ignore patterns in eslint/no-unused-vars diagnostic messages (#6696)
Inform users what pattern an unused variable must match in diagnostic help messages.

```
  ⚠ eslint(no-unused-vars): Variable 'a' is declared but never used. Unused variables should start with a '_'.
   ╭─[no_unused_vars.tsx:1:5]
 1 │ var a=10
   ·     ┬
   ·     ╰── 'a' is declared here
   ╰────
  help: Consider removing this declaration.
```
2024-10-20 04:24:53 +00:00
Tapan Prakash
e9976d46d4
feat(linter): Add title whitespace fixer for jest valid title rule (#6669)
Supported fixer for white space in title for valid title rule.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-10-19 23:56:51 -04:00
Brian Liu
45f02d5a41
feat(linter): add unicorn/consistent-empty-array-spread (#6695)
[unicorn/consistent-empty-array-spread](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v56.0.0/docs/rules/consistent-empty-array-spread.md)
of #684

---------

Co-authored-by: Brian Liu <brian@redflagsdating.com>
Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-10-19 23:40:11 -04:00
DonIsaac
a5de2309bc fix(linter/import): import/no-duplicates handles namespace imports correctly (#6694)
Closes #6660

- Value (i.e. not `import type`) namespace imports are now grouped correctly
- When grouping, consider _all_ import entries, not just the first one. Fixes a false negative when inlined `type` imports are used, e.g. `import { a, type b } from 'foo'`
2024-10-20 00:21:00 +00:00
DonIsaac
23f88b3e18 refactor(linter/import): better diagnostic messages for import/no-duplicates (#6693)
## What This PR Does
- Include the offending module in the diagnostic's message
- Add a help message
- Add label text to the first module request

It also includes these minor refactors:
- Move `check_request` closure into a separate function
- Move diagnostics creation to a separate function (same as every other rule)
2024-10-20 00:20:59 +00:00
overlookmotel
85e69a11ef refactor(ast_tools): add line breaks to generated code for ESTree derive (#6680)
Follow-on after #6404. Style nit. Add line breaks to generated code, to make it easier to read.
2024-10-19 19:50:13 +00:00
overlookmotel
ad8e293197 refactor(ast_tools): shorten generated code for impl Serialize (#6684)
Follow-on after #6404. Shorten generated code for `impl Serialize`.
2024-10-19 19:50:12 +00:00
overlookmotel
9ba2b0e3a3 refactor(ast_tools): move #[allow] attrs to top of generated files (#6679)
Follow-on after #6404. Shorten generated code for `impl Serialize` by moving `#[allow]` attrs to top of file.
2024-10-19 19:50:12 +00:00
overlookmotel
f0dd19a48f refactor(ast_tools): shorten code (#6678)
Follow-on after #6404. Pure refactor. Shorten code for deriving `ESTree` by reducing repetition.
2024-10-19 19:50:11 +00:00
overlookmotel
59dd061cea refactor(ast_tools): rename var (#6676)
Follow-on after #6404. Pure refactor. Rename `type_def` to `ts_type_def` to clarify that it's not an instance of `TypeDef` type.
2024-10-19 19:50:11 +00:00
overlookmotel
11458a5bfd refactor(ast_tools): shorten generated code by avoiding ref in matches (#6675)
Follow-on after #6404.

Shorten generated code for deriving `ESTree` by avoiding `ref` in matches.
2024-10-19 19:50:10 +00:00
camchenry
2eb984ab05 refactor(linter): add missing should_run implementations (#6666)
Added some `should_run` implementations that probably should exist but didn't previously.
2024-10-19 17:54:25 +00:00
7086cmd
34fe7c00a3 feat(minifier): dce meaningless labeled statements (#6688) 2024-10-19 15:48:54 +00:00
overlookmotel
e1c2d30d44 fix(allocator)!: make Vec non-drop (#6623)
`oxc_allocator::Vec` is intended for storing AST types in the arena. `Vec` is intended to be non-drop, because all AST types are non-drop. If they were not, it would be a memory leak, because those types will not have `drop` called on them when the allocator is dropped.

However, `oxc_allocator::Vec` is currently a wrapper around `allocator_api2::vec::Vec`, which *is* drop. That unintentionally makes `oxc_allocator::Vec` drop too.

This PR fixes this by wrapping the inner `allocator_api2::vec::Vec` in `ManuallyDrop`. This makes `oxc_allocator::Vec` non-drop.

The wider consequence of this change is that the compiler is now able to see that loads of other types which contain `oxc_allocator::Vec` are also non-drop. Once it can prove that, it can remove a load of code which handles dropping these types in the event of a panic. This probably also then allows it to make many further optimizations on that simplified code.

Strictly speaking, this PR is a breaking change. If `oxc_allocator::Vec` is abused to store drop types, then in some circumstances this change could produce a memory leak where there was none before. However, we've always been clear that only non-drop types should be stored in the arena, so such usage was always a bug.

#6622 fixes the only place in Oxc where we mistakenly stored non-drop types in `Vec`.

The change to `oxc_prettier` is because compiler can now deduce that `Doc` is non-drop, which causes clippy to raise a warning about using `then` instead of `then_some`.

As follow-up, we should:

1. Wrap other `allocator_api2` types (e.g. `IntoIter`) in `ManuallyDrop` too, so compiler can prove they are non-drop too (or reimplement `Vec` ourselves - #6488).
2. Introduce static checks to prevent non-drop types being used in `Box` and `Vec`, to make memory leaks impossible, and detect them at compile time.
2024-10-19 15:43:54 +00:00
oxc-bot
de99391032
release(crates): v0.32.0 (#6691)
## [0.32.0] - 2024-10-19

- c0e9d7e codegen: [**BREAKING**] `Codegen::into_source_text` consume
`Codegen` (#6539) (overlookmotel)

- 782f0a7 codegen: [**BREAKING**] Rename `print_char` method to
`print_ascii_byte` (#6512) (overlookmotel)

- 91c87dd codegen: [**BREAKING**] Remove `Codegen::enableSourceMap` API
(#6452) (Boshen)

- 7645e5c codegen: [**BREAKING**] Remove CommentOptions API (#6451)
(Boshen)

- 5200960 oxc: [**BREAKING**] Remove passing `Trivias` around (#6446)
(Boshen)

- 2808973 ast: [**BREAKING**] Add `Program::comments` (#6445) (Boshen)

### Features

- 5ee1ef3 allocator: Add `Vec::into_boxed_slice` (#6195) (DonIsaac)
- d9718ad ast_tools: Support `#[scope(exit_before)]` (#6350) (DonIsaac)
- e5ed6a5 codegen: Print negative numbers (#6624) (Boshen)
- 15c04e5 ecmascript: Add feature flag for constant evaluation (Boshen)
- d11770d ecmascript: Add `StringToNumber` (#6576) (Boshen)
- e561880 ecmascript: Add constant_evaluation and side_effects code
(#6550) (Boshen)
- 3556062 ecmascript: Add `ConstantEvaluation` (#6549) (Boshen)
- 39c2e66 ecmascript: Add `ToBigInt` and `StringToBigInt` (#6508)
(Boshen)
- 6f22538 ecmascript: Add `ToBoolean`, `ToNumber`, `ToString` (#6502)
(Boshen)
- 15dfc1d isolated-declarations: Impl `Default` for options (#6372)
(DonIsaac)
- 071e564 minifier: Finish implementing folding object expressions
(#6586) (camc314)
- 590925a minifier: Finish implementing folding array expressions
(#6575) (camc314)
- ef237cf minifier: Complete implementation of statement fusion (#6566)
(camc314)
- 97c8a36 minifier: Implement `collapse-variable-declarations` (#6464)
(dalaoshu)
- 096e590 minifier: Implement folding `charAt` string fns (#6436)
(camc314)
- e5a6f5d minifier: Implement converting template literals to strings
(#6486) (camc314)
- 14d0590 minifier: Implement folding of simple function calls
(`Boolean`) (#6484) (camc314)
- 7fbc7b6 minifier: Implement folding of simple function calls
(`String`) (#6483) (camc314)
- a4f57a4 minifier: Implement folding `indexOf` and `lastIndexOf` string
fns (#6435) (camc314)
- 3677ef8 minifier: Dce ExpressionStatements with no side effect (#6457)
(7086cmd)
- 06ea121 minifier: Fold for statement (#6450) (7086cmd)
- a9544ae minifier: Partially implement minification for some known
string methods (#6424) (camc314)
- 9dc4ee9 minifier: Implement block stmt support for `StatementFusion`
(#6422) (camc314)
- ebbf77d minifier: Implement calculations for NumberValue (#6419)
(7086cmd)
- 97ac179 minifier: Arithmetic operations for infinity. (#6332)
(7086cmd)
- 13b0b0b minifier: Fold literal object constructors on window (#6379)
(dalaoshu)
- e310e52 parser: Generate `Serialize` impls in ast_tools (#6404)
(ottomated)
- 58467a5 parser: Better handling of invalid modifiers (#6482)
(DonIsaac)
- 8ea6b72 parser: Better errors for reserved words used as identifier
names (#6478) (DonIsaac)
- b5b0af9 regular_expression: Support RegExp Modifiers (#6410)
(leaysgur)
- a01a5df transformer: Pass TransformerCtx to async-to-generator plugin
(#6633) (Dunqing)
- a9260cf transformer: `async-to-generator` plugin. (#5590) (Ethan Goh)
- 8fe1b0a transformer: Support helper loader (#6162) (Dunqing)
- ab51c2a transformer: Support `DefaultImport` in `ModuleImports`
(#6434) (Dunqing)
- a3dea9c transformer/async-to-generator: Handle arrow-function
correctly (#6640) (Dunqing)
- 41c8675 transformer/object-rest-spread: Using helper loader (#6449)
(Dunqing)

### Bug Fixes

- ba385fc codegen: Panic occurred when printing the comment of the right
parenthesis (#6593) (Dunqing)
- 02bfbfe codegen: Preserve parenthesis for `ChainExpression` (#6430)
(Dunqing)
- 2ade16e codegen: Invalid codegen when `in` inside bin expr in or loop
(#6431) (camc314)
- 6896efc codegen: Fix `in` in sequence expr in for loops (#6428)
(camc314)
- 7cc05f1 data_structures: Fix compilation failure on older Rust
versions (#6526) (overlookmotel)
- 2ce3e5f identifier: Add `ZWSP` to `is_irregular_whitespace` (#6662)
(Boshen)
- 2673397 isolated_declarations: Fix potential memory leak (#6622)
(overlookmotel)
- 389d261 minifier: `~~` operator should only work on numbers (#6598)
(Boshen)
- 16bea12 minifier: Use `to_js_string()` instead of `fs64::to_string`
(#6597) (Boshen)
- a71e8a0 minifier: Preserve init variable declarations when removing
`for` statements during DCE (#6551) (magic-akari)
- 721cf0f parser: Should be treated comments where after `(` as leading
comments of next token (#6588) (Dunqing)
- b1bf12c parser: Do not parse `as` and `satisfies` expression in
javascript (#6442) (Boshen)
- 9f9057b regular_expression: Fixed control Y regular expression (#6524)
(Tapan Prakash)
- c822b48 regular_expression: Fix CharacterClass negative codegen
(#6415) (leaysgur)
- 384d5be regular_expression: Flatten Spans on regex AST nodes (#6396)
(ottomated)
- 834ee2a semantic: `TSConditionalType` scope enter/exit locations
(#6351) (DonIsaac)
- 1d3d256 transformer: Correctly trim JSX (#6639) (magic-akari)
- c6f2b5f transformer: `HelperLoader` common transform: do not assume
`babelHelpers` is global (#6569) (overlookmotel)
- 85d93ed transformer: Arrow function transform: correctly resolve
`this` in class accessor properties (#6386) (overlookmotel)

### Performance

- 77f3a1a codegen: Check last char with byte methods (#6509)
(overlookmotel)
- 18b68ff codegen: Optimize `CodeBuffer::print_ascii_byte` (#6516)
(overlookmotel)
- 4d8bc8c parser: Precompute `is_typescript` (#6443) (Boshen)
- 7c20056 regex: Reduce string allocations in `Display` impls (#6528)
(DonIsaac)
- f70a413 transformer: Object spread transform: do not lookup `Object`
binding if not needed (#6570) (overlookmotel)
- ac77c87 traverse: Optimize `TraverseScoping::generate_uid_name`
(#6663) (overlookmotel)

### Documentation

- 9f555d7 allocator: Clarify docs for `Box` (#6625) (overlookmotel)
- 06e75b0 allocator: Enable lint warnings on missing docs, and add
missing doc comments (#6613) (DonIsaac)
- 7e909a7 codegen: Fix example for `CodeBuffer::print_ascii_bytes`
(#6535) (overlookmotel)
- 235d357 codegen: Improve doc comments for `CodeBuffer` (#6511)
(overlookmotel)
- c8fa2eb codegen: Correct and reformat doc comments for `CodeBuffer`
(#6504) (overlookmotel)
- 40d1ee4 codegen: Fix and reformat `CodeBuffer` examples (#6499)
(overlookmotel)
- de22b81 data-structures: Enable lint warnings on missing docs, and add
missing doc comments (#6612) (DonIsaac)
- 9e9fa9e span: Enable lint warnings on missing docs (#6617)
(overlookmotel)
- 6a194f9 span: Document validity of `ModuleKind::Unambiguous` (#6423)
(Boshen)
- 335b7f2 syntax: Enable lint warnings on missing docs, and add a lot of
documentation (#6611) (DonIsaac)
- f3451d7 transformer/async-to-generator: Remove empty lines from doc
comment (#6642) (overlookmotel)
- 448388a transformer/module_imports: Update outdated comments (#6574)
(Dunqing)

### Refactor

- 073b02a ast: Type params field before params in TS function
declaration types (#6391) (overlookmotel)
- 458f8f3 ast_tools: Consistent comments on `AstBuilder` methods (#6664)
(overlookmotel)
- 51fc63d codegen: Rename `CodeBuffer::print_bytes_unchecked` method
(#6517) (overlookmotel)
- 05a2ebd codegen: Reorder dependencies in `Cargo.toml` (#6514)
(overlookmotel)
- e7f3e28 codegen: Rename var in `CodeBuffer` (#6510) (overlookmotel)
- 1bbd383 codegen: Rename `CodeBuffer::print_ascii_bytes` method (#6507)
(overlookmotel)
- cd9fe9e codegen: Rename vars in `CodeBuffer` methods (#6506)
(overlookmotel)
- fc536a5 codegen: Inline `CodeBuffer` methods (#6501) (overlookmotel)
- 7420620 codegen: Add `CodeBuffer::as_bytes` method (#6498)
(overlookmotel)
- 8ae174b codegen: Rename `CodeBuffer::print_byte_unchecked` method
(#6496) (overlookmotel)
- 5843e01 codegen: Shorten `CodeBuffer::take_source_text` (#6495)
(overlookmotel)
- 951def6 codegen: Clarify safety comments in `CodeBuffer` (#6494)
(overlookmotel)
- 84a51ee codegen: Rename vars in `CodeBuffer` (#6493) (overlookmotel)
- 05bd616 codegen: Add line break (#6492) (overlookmotel)
- 204bf55 codegen: Add `CodeBuffer` to fix soundness hole (#6148)
(DonIsaac)
- 702b574 codegen: Only print necessary parentheses in TSAsExpression
(#6429) (Dunqing)
- aa6ba24 ecmascript: Improve string to number conversion (#6577)
(magic-akari)
- 6d041fb ecmascript: Remove `NumberValue` (#6519) (Boshen)
- 856cab5 ecmascript: Move ToInt32 from `oxc_syntax` to `oxc_ecmascript`
(#6471) (Boshen)
- 1ba2a24 ecmascript: Remove `HasProto` which is not part of the spec
(#6470) (Boshen)
- a504f96 isolated-declarations: Mark return struct as non exhaustive
(#6374) (DonIsaac)
- f4cdc56 minifier: Use constant folding unary expression from
`oxc_ecmascript` (#6647) (Boshen)
- 67ad08a minifier: Unify `ValueType` (#6545) (Boshen)
- bbca743 minifier: Move string methods to `oxc_ecmascript` (#6472)
(Boshen)
- 702c049 minifier: Move compress block to dce (#6468) (7086cmd)
- 46a38c6 minifier: Remove allow `clippy::unused_self` (#6441) (Boshen)
- 994b60b minifier: Use builtin get_number_value. (#6335) (7086cmd)
- 435a89c oxc: Remove useless `allocator.alloc(program)` calls (#6571)
(Boshen)
- c45723b parser: Fix typo in var name (#6500) (overlookmotel)
- 1a90ec4 rust: Backport v1.82.0 changes to main branch first (#6690)
(Boshen)
- 3faee66 span: Remove unused `ContentHash::content_hash_slice` (#6609)
(DonIsaac)
- 9281234 transformer: Shorten imports (#6643) (overlookmotel)
- 3af0840 transformer: `HelperLoader`: add import immediately (#6601)
(overlookmotel)
- f81aa7f transformer: `HelperLoader` common transform: comments (#6599)
(overlookmotel)
- 679cc68 transformer: `HelperLoader` common transform: construct string
directly in arena (#6596) (overlookmotel)
- c346ebb transformer: `HelperLoader` common transform: `Helper` enum
(#6595) (overlookmotel)
- 7a028b3 transformer: Remove unnecessary `#![warn]` attr (#6585)
(overlookmotel)
- 8c6afe0 transformer: Reorder imports (#6582) (overlookmotel)
- 779ff46 transformer: `HelperLoader` common transform: `Helper` struct
(#6568) (overlookmotel)
- bc24a24 transformer: `HelperLoader` common transform: use hashmap
`Entry` API (#6567) (overlookmotel)
- 9f02fc7 transformer: `HelperLoader` common transform: re-order fields
(#6565) (overlookmotel)
- 50ecade transformer: `HelperLoader` common transform: remove `Rc`s
(#6564) (overlookmotel)
- 1c1e9fc transformer: `HelperLoader` common transform: reorder methods
(#6563) (overlookmotel)
- c9054c8 transformer: Rename `ImportKind` to `Import` (#6561)
(overlookmotel)
- 9542c4e transformer: Add more specific methods to `ModuleImportsStore`
(#6560) (overlookmotel)
- 7e57a1d transformer: `ImportKind` use `BoundIdentifier` (#6559)
(overlookmotel)
- 602df9d transformer: Re-order fields of `Common` and `TransformCtx`
(#6562) (overlookmotel)
- 390abca transformer/async-to-generator: Use `helper_call_expr` (#6634)
(Dunqing)
- 2ff917f transformer/async-to-generator: Move internal methods below
entry points (#6632) (Dunqing)

### Styling

- fb916b2 regular_expression: Re-order dependencies in `Cargo.toml`
(#6672) (overlookmotel)
- 9d43a11 transformer: Re-order dependencies (#6659) (overlookmotel)

### Testing

- e7c89a5 codegen: Uncomment passed tests that are related to trailing
comments (#6589) (Dunqing)
- d816b0b codegen: Add test for `CodeBuffer::print_byte_unchecked`
(#6497) (overlookmotel)
- c5deb32 minifier: Port the rest of tests (#6420) (7086cmd)
- e59da61 minifier: Add all test cases for
`collapse_variable_declarations` (#6421) (dalaoshu)
- 73d6a4a minifier: Port all replace_known_methods tests. (#6418)
(7086cmd)

---------

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-10-19 23:09:35 +08:00
Boshen
1a90ec4b85 refactor(rust): backport v1.82.0 changes to main branch first (#6690) 2024-10-19 14:30:55 +00:00
dalaoshu
ce25c450fc
fix(linter): panic in disable-directives (#6677)
closes #6670
2024-10-19 22:09:37 +08:00
overlookmotel
002289b4b1 style(ast_tools): do not use ref in matches (#6674)
Style nit.
2024-10-19 08:57:06 +00:00
overlookmotel
a47b38ff1a style(ast_tools): fix formatting (#6673) 2024-10-19 08:50:05 +00:00
overlookmotel
fb916b2532 style(regular_expression): re-order dependencies in Cargo.toml (#6672)
Follow-on after #6404. Nit. Group optional dependencies together.
2024-10-19 08:50:04 +00:00
ottomated
e310e52ca2
feat(parser): Generate Serialize impls in ast_tools (#6404)
Beginning of #6347. Instead of using serde-derive, we generate
`Serialize` impls manually.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
2024-10-19 09:38:44 +01:00
camchenry
b0b6ac71e7 fix(linter/no-cond-assign): false positive when assignment is in body statement (#6665)
- fixes https://github.com/oxc-project/oxc/issues/6656

rather than reporting any assignment inside of `if`, `while`, etc. when the `always` option is enabled, we only check if the assignment resides in specific areas that assignment should not be. for example, inside the test of an `if`, or the test of a `for` loop.

incidentally, this also fixes an issue (seen in snapshot file) where the same assignment was reported twice.
2024-10-19 03:17:08 +00:00
oxc-bot
70c6f24a08
release(oxlint): v0.10.0 (#6661)
## [0.10.0] - 2024-10-18

- 7f6b219 editor/vscode: [**BREAKING**] Unify configuration logic
(#6630) (DonIsaac)

- 782f0a7 codegen: [**BREAKING**] Rename `print_char` method to
`print_ascii_byte` (#6512) (overlookmotel)

- 7645e5c codegen: [**BREAKING**] Remove CommentOptions API (#6451)
(Boshen)

- 5200960 oxc: [**BREAKING**] Remove passing `Trivias` around (#6446)
(Boshen)

- 80266d8 linter: [**BREAKING**] Support plugins in oxlint config files
(#6088) (DonIsaac)

### Features

- 6f22538 ecmascript: Add `ToBoolean`, `ToNumber`, `ToString` (#6502)
(Boshen)
- 1e7fab3 linter: Implement `no-callback-in-promise` (#6157) (dalaoshu)
- c56343d linter: Promote `no_unsafe_optional_chaining` to correctness
(#6491) (Boshen)
- 454874a linter: Implement `react/iframe-missing-sandbox` (#6383) (Radu
Baston)
- c8174e2 linter: Add suggestions for `no-plusplus` (#6376) (camchenry)
- 6e3224d linter: Configure by category in config files (#6120)
(DonIsaac)
- c5e66e1 linter/no-unused-vars: Report own type references within
class, interface, and type alias declarations (#6557) (DonIsaac)
- 8c78f97 linter/node: Implement no-new-require (#6165) (Jelle van der
Waa)

### Bug Fixes

- cf92730 editor: Use human-readable output channel names (#6629)
(DonIsaac)
- d9159a2 editor: Misaligned command prefixes (#6628) (DonIsaac)
- b9c94bb editors/vscode: Temporarily solve oxc_language_server issue on
windows (#6384) (dalaoshu)
- e340424 linter: Support import type with namespaced import in
`import/no-duplicates` (#6650) (Dmitry Zakharov)
- a668397 linter: Panic in `no-else-return` (#6648) (dalaoshu)
- 41dc8e3 linter: Stack overflow in `oxc/no-async-endpoint-handlers`
(#6614) (DonIsaac)
- d07a9b0 linter: Panic in `no-zero-fractions` (#6607) (dalaoshu)
- d6a0d2e linter: Fix file name checking behavior of
`unicorn/filename-case` (#6463) (camchenry)
- 0784e74 linter: Error fixer of `switch-case-braces` (#6474) (dalaoshu)
- e811812 linter: Error diagnostic message based on parameter length of
valid-expect (#6455) (dalaoshu)
- f71c91e linter: Move `eslint/sort-keys` to `style` category (#6377)
(DonIsaac)
- 2b86de9 linter/no-control-regex: False negative for flags in template
literals (#6531) (DonIsaac)
- 685a590 linter/no-control-regex: Better diagnostic messages (#6530)
(DonIsaac)
- 6d5a9f2 linter/no-control-regex: Allow capture group references
(#6529) (DonIsaac)
- ba53bc9 linter/no-unused-vars: False positives in TS type assertions
(#6397) (DonIsaac)
- d3e59c6 linter/no-unused-vars: False positive in some default export
cases (#6395) (DonIsaac)
- e08f956 linter/no-unused-vars: False positive for functions and
classes in arrays (#6394) (DonIsaac)
- b9d7c5f no-unused-vars: Consider functions within conditional
expressions usable (#6553) (Brian Donovan)

### Performance

- 0cbd4d0 linter: Avoid megamorphism in `RuleFixer` methods (#6606)
(DonIsaac)
- 725f9f6 linter: Get fewer parent nodes in
`unicorn/prefer-dom-node-text-content` (#6467) (camchenry)
- c00f669 linter: Use NonZeroUsize for pending module cache entries
(#6439) (DonIsaac)
- a1a2721 linter: Replace `ToString::to_string` with `CompactStr` in
remaining rules (#6407) (camchenry)
- c5c69d6 linter: Use `CompactStr` in `valid-title` (#6406) (camchenry)
- d66e826 linter: Use `CompactStr` in `prefer-lowercase-title` (#6405)
(camchenry)
- 889400c linter: Use `CompactStr` for `get_node_name` in Jest rules
(#6403) (camchenry)
- 9906849 linter: Use `CompactStr` in `no-large-snapshots` (#6402)
(camchenry)
- c382ec4 linter: Use `CompactStr` in `no-hooks` (#6401) (camchenry)
- 24a5d9b linter: Use `CompactStr` in `expect-expect` (#6400)
(camchenry)
- 71dbdad linter: Use `CompactStr` in `no-console` (#6399) (camchenry)
- f5f00a1 linter: Use `CompactStr` in `no-bitwise` (#6398) (camchenry)
- 62afaa9 linter/jsx-no-comment-textnodes: Remove regex for checking
comment patterns (#6534) (camchenry)
- b3d0cce linter/no-unescaped-entities: Add fast path to check if char
should be replaced (#6594) (camchenry)
- ee73f56 linter/no-unused-vars: Do not construct `Regex` for default
ignore pattern (#6590) (camchenry)
- 77ddab8 linter/numeric-separators-style: Replace regex with number
parser (#6546) (camchenry)
- 8f47cd0 linter/react: Remove regex patterns in `no-unknown-property`
(#6536) (camchenry)

### Documentation

- 557f941 linter: Add docs to no-unused-vars and Tester (#6558)
(DonIsaac)

### Refactor

- ecce5c5 linter: Improve recursive argument handling and diagnostics
creation (#6513) (no-yan)
- f960e9e linter: Add suggested file names for `unicorn/filename-case`
(#6465) (camchenry)
- 7240ee2 linter: Make advertised fix kinds consistent (#6461)
(Alexander S.)
- b48c368 linter: `no_global_assign` rule: reduce name lookups (#6460)
(overlookmotel)
- 2566ce7 linter: Remove OxlintOptions (#6098) (DonIsaac)
- 002078a linter: Make Runtime's members private (#6440) (DonIsaac)
- 6a0a533 linter: Move module cache logic out of Runtime (#6438)
(DonIsaac)
- c18c6e9 linter: Split service code into separate modules (#6437)
(DonIsaac)
- 5ea9ef7 linter: Improve labels and help message for
`eslint/no-useless-constructor` (#6389) (DonIsaac)
- 2c32dac linter/no-control-regex: Remove duplicate code (#6527)
(DonIsaac)
- 435a89c oxc: Remove useless `allocator.alloc(program)` calls (#6571)
(Boshen)
- f70e93b oxc: Ban index methods on std::str::Chars (#6075) (dalaoshu)

### Testing

- a6cae98 linter: Make sure all auto-fixing rules have fixer test
(#6378) (DonIsaac)
- 06b09b2 linter/no-unused-vars: Enable now-passing tests (#6556)
(DonIsaac)
- badd11c linter/no-unused-vars: Ignored catch parameters (#6555)
(DonIsaac)
- 84aa2a2 linter/no-useless-constructor: Add cases for initializers in
subclass constructors (#6390) (DonIsaac)

---------

Co-authored-by: DonIsaac <22823424+DonIsaac@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-10-18 20:34:15 -04:00
Boshen
2ce3e5fefc fix(identifier): add ZWSP to is_irregular_whitespace (#6662)
closes #6646
2024-10-18 22:20:02 +00:00
overlookmotel
458f8f3822 refactor(ast_tools): consistent comments on AstBuilder methods (#6664)
Affects comment style only. Use "Build" consistently, not "Builds" in some places, and correct use of "a" / "an".
2024-10-18 15:57:36 +00:00
overlookmotel
ac77c87cec perf(traverse): optimize TraverseScoping::generate_uid_name (#6663)
Tiny optimization. Move initializing `self.uid_names` to just before `self.uid_names.as_mut().unwrap()` so compiler can see that the `unwrap` is infallible and elide it, even if `get_uid_names` isn't inlined.
2024-10-18 15:43:47 +00:00
overlookmotel
9d43a1124d style(transformer): re-order dependencies (#6659)
Nit. Move `oxc_*` dependencies to first in list.
2024-10-18 14:41:36 +00:00
overlookmotel
683c3443c0 chore(semantic, wasm): re-order dependencies in Cargo.toml files (#6657)
Nit. Move `serde` dependency into more natural place in the list.
2024-10-18 13:40:37 +00:00