Commit graph

4078 commits

Author SHA1 Message Date
github-actions[bot]
06e4ce4f5d
Release oxlint v0.5.0 (#3940)
## [0.5.0] - 2024-06-27

- 6796891 ast: [**BREAKING**] Rename all instances of `BigintLiteral` to
`BigIntLiteral`. (#3898) (rzvxa)

- ae09a97 ast: [**BREAKING**] Remove `Modifiers` from ts nodes (#3846)
(Boshen)

- 1af5ed3 ast: [**BREAKING**] Replace `Modifiers` with `declare` and
`const` on `EnumDeclaration` (#3845) (Boshen)

- ee6ec4e ast: [**BREAKING**] Replace `Modifiers` with `declare` and
`abstract` on `Class` (#3841) (Boshen)

- 4456034 ast: [**BREAKING**] Add `IdentifierReference` to
`ExportSpecifier` (#3820) (Boshen)

- 0537d29 cfg: [**BREAKING**] Move control flow to its own crate.
(#3728) (rzvxa)

- 5c38a0f codegen: [**BREAKING**] New code gen API (#3740) (Boshen)

- 4bce59d semantic/cfg: [**BREAKING**] Re-export `petgraph` as
`control_flow::graph`. (#3722) (rzvxa)

### Features

- 3ae2628 linter: Change `no-import-assign` to correctness (#3928)
(Boshen)
- a89d501 linter: Implement
@typescript-eslint/no-non-null-asserted-nulli… (#3850) (kaykdm)
- fc48cb4 linter: eslint-plugin-jest/prefer-jest-mocked (#3865)
(cinchen)
- 63b98bd linter: Accept multiple fixes when fix code (#3842)
(mysteryven)
- 328445b linter: Support `vitest/no-disabled-tests` (#3717)
(mysteryven)
- 8c61f9c linter: Implement @typescript-eslint/no-non-null-assertion
(#3825) (kaykdm)
- 080ecbd linter: Add `no-fallthrough`. (#3673) (rzvxa)
- 9493fbe linter: Add `oxc/no-optional-chaining` rule (#3700)
(mysteryven)
- 139adfe linter: Add `@typescript-eslint/no-import-type-side_effects`
(#3699) (mysteryven)
- 5f84500 linter/eslint-plugin-react: Implement prefer-es6-class (#3812)
(Jelle van der Waa)
- fafe67c linter/import: Implement max-dependencies (#3814) (Jelle van
der Waa)
- d5f6aeb semantic: Check for illegal symbol modifiers (#3838) (Don
Isaac)

### Bug Fixes

- 4bd2c88 linter: Fix and promote `getter-return` to correctness.
(#3777) (rzvxa)
- 1190dee linter: False positives with setters in the `getter-return`
rule. (#3714) (rzvxa)
- de0690f linter: Do not run getter-return in typescript (#3693)
(Boshen)
- cf71c23 linter: Edge case with infinite loops. (#3672) (rzvxa)
- 5902331 oxlint: Properly report error (#3889) (Luca Bruno)
- 99a40ce semantic: `export default foo` should have
`ExportLocalName::Default(NameSpan)` entry (#3823) (Boshen)
- abd6ac8 semantic/cfg: Discrete finalization path after `NewFunction`s.
(#3671) (rzvxa)

### Performance
- 4f7ff7e Do not pass `&Atom` to functions (#3818) (overlookmotel)

### Refactor

- 4d2b7f1 linter: `LintContext` can now only be constructed with a cfg
enabled semantic. (#3761) (rzvxa)
- 7302429 linter/prefer_number_properties: Remove the unused
`IdentifierName` check (#3822) (Boshen)
- d8ad321 semantic: Make control flow generation optional. (#3737)
(rzvxa)

### Testing

- 887da40 linter: Enable `no-fallthrough` test with `disable-next-line`.
(#3766) (rzvxa)

Co-authored-by: Boshen <Boshen@users.noreply.github.com>
2024-06-27 15:09:13 +08:00
Boshen
75592e0d4d
ci: fix reusable_prepare_release version output 2024-06-27 15:08:31 +08:00
Boshen
cd4bd6ec7f
chore(linter): change getter-return to nursery
relates #3935
2024-06-27 14:38:43 +08:00
Boshen
37fceefbbf
chore(linter): change no-fallthrough to pedantic
Because the code is still correct.
2024-06-27 14:37:44 +08:00
Boshen
9f2e09eade
chore: make npm/oxc-transform part of the crates release 2024-06-26 23:13:23 +08:00
Boshen
3ae2628832
feat(linter): change no-import-assign to correctness (#3928)
closes #3733
2024-06-26 22:43:45 +08:00
Jelle van der Waa
5f84500200
feat(linter/eslint-plugin-react): Implement prefer-es6-class (#3812)
Rule Detail:

[link](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md)

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-06-26 22:20:16 +08:00
underfin
bbe8336c7b
feat(napi/transform): add crate-type: "lib" (#3876) 2024-06-26 21:57:53 +08:00
kaykdm
a89d501d51
feat(linter): implement @typescript-eslint/no-non-null-asserted-nulli… (#3850)
…sh-coalescing

Related issue: https://github.com/oxc-project/oxc/issues/2180

original implementation

- code:
https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/rules/no-non-null-asserted-nullish-coalescing.ts
- test:
https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/tests/rules/no-non-null-asserted-nullish-coalescing.test.ts
- doc:
https://typescript-eslint.io/rules/no-non-null-asserted-nullish-coalescing/
2024-06-26 21:57:33 +08:00
underfin
d3cd3ea2de
feat: oxc transform binding (#3896)
closes #3877

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-06-26 21:57:19 +08:00
cinchen
fc48cb4560
feat(linter): eslint-plugin-jest/prefer-jest-mocked (#3865)
part of https://github.com/oxc-project/oxc/issues/492

Rule Detail:
[link](https://github.com/jest-community/eslint-plugin-jest/blob/main/src/rules/prefer-jest-mocked.ts)
2024-06-26 21:46:46 +08:00
Boshen
275349a9fe fix(parser): parse function type parameter name accessor (#3926)
fixes #3910
2024-06-26 13:34:24 +00:00
mysteryven
63b98bddd9 feat(linter): accept multiple fixes when fix code (#3842)
Want to add this because of there are bunch of fix codes in [consistent-type-import](e408b93e48/packages/eslint-plugin/src/rules/consistent-type-imports.ts (L610-L945)) are not easy to port.
2024-06-26 13:29:22 +00:00
Boshen
a471e62e2d refactor(parser): clean up try_parse (#3925) 2024-06-26 11:18:02 +00:00
Dunqing
253410017f
chore(ci): auto label for oxc_isolated_declarations (#3924) 2024-06-26 19:13:51 +08:00
Dunqing
27665945f1 fix(codegen): print type parameters for MethodDefinition (#3922)
close: #3918
2024-06-26 07:21:42 +00:00
Dunqing
27f0531aac fix(isolated-declarations): private constructor reaching unreachable (#3921)
fix: #3917
2024-06-26 07:21:38 +00:00
Dunqing
59ce38bb85 fix(isolated-declarations): inferring of UnrayExpression incorrectly (#3920)
close: #3914
2024-06-26 07:21:35 +00:00
Boshen
3db2553dc2 refactor(parser): improve parsing of TypeScript type arguments (#3923) 2024-06-26 07:16:18 +00:00
Boshen
4cf3c7645f refactor(parser): improve parsing of TypeScript types (#3903)
- [x] fix everything
2024-06-26 05:58:16 +00:00
overlookmotel
1061baabbf refactor(traverse): separate #[scope] attr (#3901)
Separate out attributes which communicate info to codegen related to scopes into `#[scope]` attr.

Before:

```rs
#[visited_node(scope(ScopeFlags::empty()))]
pub struct BlockStatement<'a> { /* ... */ }
```

After:

```rs
#[visited_node]
#[scope]
pub struct BlockStatement<'a> { /* ... */ }
```

I think this is clearer.
2024-06-26 05:43:10 +00:00
overlookmotel
5ef28b7375 refactor(transformer): shorten code (#3912)
Abbreviate `self.ctx.ast` to just `ast` to shorten code.
2024-06-26 05:16:07 +00:00
overlookmotel
08fcfb3c2f fix(transformer): fix spans and scopes in TS enum transform (#3911)
Fix scope and spans in TS `enum` transform.

Incomplete - not yet fixed either scopes or spans for the interior of the function which TS `enum` is transformed into, only what's outside the function.
2024-06-26 05:16:05 +00:00
overlookmotel
17ad8f7d93 fix(transformer): create new scopes for new blocks in TS transform (#3908)
Create scopes for new `BlockStatement`s inserted in TS transform, and update scope tree.
2024-06-26 05:16:02 +00:00
DonIsaac
01572f037d feat(sourcemap): impl std::fmt::Display for Error (#3902) 2024-06-26 05:10:48 +00:00
camc314
77a4a0b77c feat(minifier) minify conditional expressions (#3907) 2024-06-26 05:06:53 +00:00
overlookmotel
6f260871d7 refactor(ast): add comment about alternatives to AstBuilder::copy (#3905)
Expand on comment added in #3891.
2024-06-25 18:45:06 +00:00
Jelle van der Waa
fafe67c817
feat(linter/import): Implement max-dependencies (#3814)
Rule Detail:

[link](https://github.com/import-js/eslint-plugin-import/blob/v2.29.1/docs/rules/max-dependencies.md)

---

This lacks the handling of `require()` which seems to be the case for
most existing `import` rules.

Another "issue" could be if you have:
```
import { foo } from "./foo";
import { bar } from "./foo";
```

But then again there should be another rule to filter these duplicate
imports out and combine them into one.

Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-06-25 13:18:01 -04:00
rzvxa
2e026e1b7f feat(ast_codegen): generate ast_kind.rs. (#3888)
[List of 68 blacklisted items](https://github.com/oxc-project/oxc/pull/3888/files#diff-59cbea4a1444e752992821d3429a5f27bf1027a530977d075ec89aa55995912aR11)
2024-06-25 15:47:04 +00:00
rzvxa
6796891e2e fix(ast)!: rename all instances of BigintLiteral to BigIntLiteral. (#3898)
Notice the casing! Just for the sake of consistency.
2024-06-25 14:39:42 +00:00
rzvxa
09f4d3c4d3 feat(ast_codegen): add ImplGetSpanGenerator. (#3852)
This one is ready to replace the handwritten module.
2024-06-25 14:39:39 +00:00
rzvxa
f6c4ec44ca feat(tasks/ast_codegen): prototype for codegen AST related code (#3815)
Part of https://github.com/oxc-project/oxc/issues/3819
2024-06-25 13:54:50 +00:00
Luca Bruno
92c21b266e
perf(diagnostics): optimize string-buffer reallocations (#3897)
This improves `GraphicalReportHandler` logic by using a string-buffer
with a capacity hint. That avoids growing the buffer from zero each
time, saving a bunch of reallocations.
2024-06-25 17:55:53 +08:00
rzvxa
1f85f1a5f7 refactor(ast)!: revert adding span field to the BindingPattern type. (#3899)
Since this is a temporary solution in the time that we are waiting for the `#[span]` hint, And there are already other workarounds used in our `ast_codegen` I propose removing it right away - sorry in my opinion adding it in the first place was a mistake - in favor of adding an edge case in the codegen. It is better to do the refactoring in the codegen instead of the production code which people may depend on.
2024-06-25 09:43:48 +00:00
Boshen
4bf405ddfc perf(parser): add a few more inline hints to cursor functions (#3894) 2024-06-25 06:00:46 +00:00
Boshen
187f0782c1 refactor(parser): improve parsing of parse_function_or_constructor_type (#3892)
part of #3502
2024-06-25 03:43:02 +00:00
overlookmotel
442aca3ba8
refactor(ast): add comment not to use AstBuilder::copy (#3891)
As discussed in #3483, `AstBuilder::copy` is unsound. It's going to be a
hard slog removing all uses of it. This PR adds a comment to please not
introduce any further usages of it in meantime.
2024-06-25 09:12:43 +08:00
Luca Bruno
5902331cac
fix(oxlint): properly report error (#3889)
This fixes an incorrect error formatting in the lint runner logic.
2024-06-25 01:16:56 +03:30
mysteryven
328445b4ca feat(linter): support vitest/no-disabled-tests (#3717) 2024-06-24 15:16:32 +00:00
Dunqing
ef82c78a72 fix(parser): trailing comma is not allowed in ParenthesizedExpression (#3885)
close: #3878

The implementation is copied from `SeparatedList`'s `print_list`.
```diff
    fn parse_list(&mut self, p: &mut ParserImpl<'a>) -> Result<()> {
        p.expect(self.open())?;

        let mut first = true;

        while !p.at(self.close()) && !p.at(Kind::Eof) {
            if first {
                first = false;
            } else {
                p.expect(self.separator())?;
-                if p.at(self.close()) {
-                    break;
-               }
            }

            self.parse_element(p)?;
        }

        p.expect(self.close())?;
        Ok(())
    }
```
2024-06-24 14:56:32 +00:00
Boshen
41fbe05b58 chore: bump oxc-browserslist to v1.0.1 (#3884) 2024-06-24 14:51:17 +00:00
Boshen
80c17ac66e chore: bump oxc-resolver to 1.8.2 (#3883) 2024-06-24 14:16:12 +00:00
overlookmotel
fcd21a6a75 refactor(traverse): indicate scope entry point with scope(enter_before) attr (#3882)
Improve annotation of AST types for codegen.

Currently:

```rs
#[visited_node(
    scope(ScopeFlags::empty()),
    enter_scope_before(cases),
)]
pub struct SwitchStatement<'a> {
    pub span: Span,
    pub discriminant: Expression<'a>,
    pub cases: Vec<'a, SwitchCase<'a>>,
    pub scope_id: Cell<Option<ScopeId>>,
}
```

After this PR:

```rs
#[visited_node(scope(ScopeFlags::empty()))]
pub struct SwitchStatement<'a> {
    pub span: Span,
    pub discriminant: Expression<'a>,
    #[scope(enter_before)]
    pub cases: Vec<'a, SwitchCase<'a>>,
    pub scope_id: Cell<Option<ScopeId>>,
}
```

I think this is easier to read.

In order to enable use of `#[scope]` attr, this introduces a dummy `VisitedNode` derive macro. Like the `visited_node` macro, `VisitedNode` derive macro is designed to do very minimal work and have no heavy dependencies, so it should be almost 0 cost in terms of compile time.
2024-06-24 14:12:15 +00:00
overlookmotel
24979c98b2 refactor(traverse): use camel case props internally (#3880)
Small change to internals of `oxc_traverse` codegen. Use camel-case property names.
2024-06-24 13:19:34 +00:00
overlookmotel
2045c92338 refactor(traverse): improve parsing attrs in traverse codegen (#3879)
Make parser in `oxc_traverse` codegen a bit more robust - handle trailing comma in `#[visited_node]` attrs.
2024-06-24 13:19:31 +00:00
Boshen
7f1266a37b chore(deps): update rust crates (#3873) 2024-06-24 11:24:54 +00:00
Boshen
09bc0fba23 chore(deps): update rust crates (#3875) 2024-06-24 11:04:29 +00:00
Dunqing
5e2baf3edd feat(isolated-declarations): report error for expando functions (#3872)
close: #3703
2024-06-24 10:56:23 +00:00
Boshen
a85d313a43
chore(deps): update oven-sh/setup-bun action to v2 (#3874)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-24 18:28:48 +08:00
renovate[bot]
0b41303d14
chore(deps): update npm packages (#3871)
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [pnpm](https://pnpm.io) ([source](https://togithub.com/pnpm/pnpm)) |
[`9.3.0` -> `9.4.0`](https://renovatebot.com/diffs/npm/pnpm/9.3.0/9.4.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/pnpm/9.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/pnpm/9.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/pnpm/9.3.0/9.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/pnpm/9.3.0/9.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| [tar](https://togithub.com/isaacs/node-tar) | [`7.2.0` ->
`7.4.0`](https://renovatebot.com/diffs/npm/tar/7.2.0/7.4.0) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/tar/7.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/tar/7.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/tar/7.2.0/7.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/tar/7.2.0/7.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>pnpm/pnpm (pnpm)</summary>

### [`v9.4.0`](https://togithub.com/pnpm/pnpm/compare/v9.3.0...v9.4.0)

[Compare Source](https://togithub.com/pnpm/pnpm/compare/v9.3.0...v9.4.0)

</details>

<details>
<summary>isaacs/node-tar (tar)</summary>

###
[`v7.4.0`](https://togithub.com/isaacs/node-tar/compare/v7.3.0...v7.4.0)

[Compare
Source](https://togithub.com/isaacs/node-tar/compare/v7.3.0...v7.4.0)

###
[`v7.3.0`](https://togithub.com/isaacs/node-tar/compare/v7.2.0...v7.3.0)

[Compare
Source](https://togithub.com/isaacs/node-tar/compare/v7.2.0...v7.3.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 10am on monday" in timezone
Asia/Shanghai, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/oxc-project/oxc).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MTMuMiIsInVwZGF0ZWRJblZlciI6IjM3LjQxMy4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-24 07:56:18 +00:00