Commit graph

6311 commits

Author SHA1 Message Date
Boshen
82bc745da1
chore: use bacon instead of cargo watch 2024-10-21 15:04:40 +08:00
Boshen
2e8579ce81 chore(coverage): update codegen runtime snapshot (#6730) 2024-10-21 06:14:53 +00:00
DonIsaac
a7dd5aa3ee docs(ast): enforce doc comments on AST node methods (#6714)
Part of https://github.com/oxc-project/backlog/issues/130
2024-10-21 05:28:55 +00:00
DonIsaac
8d27e2daab docs(ast): enforce doc comments on generated ASTBuilder methods (#6713)
Part of https://github.com/oxc-project/backlog/issues/130
2024-10-21 05:28:54 +00:00
Boshen
661dfd2026
ci: no need to set draft for oxlint github release 2024-10-21 13:05:19 +08:00
oxc-bot
abb4ff30eb
release(oxlint): v0.10.1 (#6729)
## [0.10.1] - 2024-10-21

### Features

- af25752 linter: Add `unicorn/prefer-math-min-max` (#6621) (Brian Liu)
- 5095f02 linter: Added fixer for duplicate prefix in valid title jest
rule (#6699) (Tapan Prakash)
- e9976d4 linter: Add title whitespace fixer for jest valid title rule
(#6669) (Tapan Prakash)
- 45f02d5 linter: Add `unicorn/consistent-empty-array-spread` (#6695)
(Brian Liu)
- 01a35bb linter/eslint: Show ignore patterns in `eslint/no-unused-vars`
diagnostic messages (#6696) (DonIsaac)

### Bug Fixes

- 1bcd707 editor: Update config sent to language server (#6724)
(Nicholas Rayburn)
- ce25c45 linter: Panic in `disable-directives` (#6677) (dalaoshu)
- a5de230 linter/import: `import/no-duplicates` handles namespace
imports correctly (#6694) (DonIsaac)
- b0b6ac7 linter/no-cond-assign: False positive when assignment is in
body statement (#6665) (camchenry)

### Performance

- 6a76ea8 linter/no-unused-vars: Use default IgnorePattern when /^_/ is
provided as a pattern (#6697) (DonIsaac)

### Refactor

- d6609e9 linter: Use `run_on_jest_node` for existing lint rules (#6722)
(camchenry)
- 97195ec linter: Add `run_on_jest_node` to run rules on only jest nodes
(#6721) (camchenry)
- 155fe7e linter: Allow `Semantic` to be passed for collecting Jest
nodes (#6720) (camchenry)
- ad8f281 linter: Use iter for collecting jest nodes (#6719) (camchenry)
- dc19a8f linter: Use iterator for collecting jest imports (#6718)
(camchenry)
- 29c1447 linter: `jest/valid-title` fixer to use `Span::shrink` method
(#6703) (Tapan Prakash)
- 2eb984a linter: Add missing `should_run` implementations (#6666)
(camchenry)
- 23f88b3 linter/import: Better diagnostic messages for
`import/no-duplicates` (#6693) (DonIsaac)

---------

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-21 12:29:57 +08:00
Boshen
f110e757b4 chore(deps): update rust crates (#6728) 2024-10-21 04:11:05 +00:00
Boshen
3e2adfdcc7
ci: use another cache for clippy (#6726)
closes #6715
2024-10-21 12:00:18 +08:00
renovate[bot]
2c569a4dbf
chore(deps): update vscode npm packages (#6727) 2024-10-21 11:56:06 +08:00
Boshen
63f756c78b
ci: only cache dprint plugins on main branch (#6725) 2024-10-21 11:54:11 +08:00
Dunqing
0e9b695634 refactor(ast): change plain_function to accept FunctionBody as a required parameter (#6709)
The `plain_function` method is used to construct js-only AST, and the `FunctionBody` is never empty in js
2024-10-21 03:03:33 +00:00
Dunqing
1370c2da70 refactor(traverse): change generate_uid_in_based_on_node to accept a generic type parameter as node type (#6708)
Not only the `Expression` can be used to generate a binding name, but as long as AST that implements `GatherNodeParts` trait can do
2024-10-21 03:03:32 +00:00
Nicholas Rayburn
1bcd707c8c
fix(editor): Update config sent to language server (#6724)
Syncs up the options from the language server `Options` struct with the
values that the extension supplies.

I tend to avoid `toJSON` because it will be used by `JSON.stringify`
when called and it's not well known.
There's no reason that `LanguageServerConfig` and `Config` have to both
exist, but I think two types is easier to understand.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-10-21 11:01:21 +08:00
overlookmotel
41a6ad63b6 refactor(ast_tools): add Derive::snake_name method (#6717)
Follow-on after #6404. Add `Derive::snake_name` method which defaults to `Self::trait_name().to_case(Case::Snake)`, but can be overridden. This allows moving the "special case" code for `ESTree` filename into `estree.rs`.
2024-10-21 02:55:38 +00:00
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