Commit graph

3968 commits

Author SHA1 Message Date
Dunqing
a37138f1ec feat(isolated-declarations): improve the inference template literal (#3797) 2024-06-20 15:02:45 +00:00
Dunqing
b0d7355c98 feat(isolated-declarations): transform const expression correctly (#3793) 2024-06-20 15:02:41 +00:00
Boshen
2a16ce0624 feat(traverse): disable syntax check and disable build module record (#3794)
These can be skipped because :
 * semantic errors are not passed to the caller
 * module record is not used
2024-06-20 13:05:35 +00:00
Dunqing
01da2f78c1 feat(codegen): print TSThisParameter for TSCallSignatureDeclaration and TSMethodSignature (#3792) 2024-06-20 10:13:58 +00:00
Dunqing
2821e0e307 feat(codegen): print readonly keyword for TSIndexSignature (#3791) 2024-06-20 10:13:51 +00:00
Dunqing
7d47fc3fcc fix(isolated-declarations): should stripe async and generator keyword after transformed (#3790) 2024-06-20 10:13:44 +00:00
Dunqing
dc8e2b8dc0 feat(coverage/transpile): compare error message (#3789) 2024-06-20 10:13:36 +00:00
Boshen
ebb6eb8c67
chore(coverage): add a prepass benchmark 2024-06-20 15:07:17 +08:00
Alexander S
a5e0f2274a
fix(docs): detect typescript alias rules and mark them as supported (#3779)
Some tpyescript rules are extensions of the core eslint rules.  

Now we mark them as supported :) 

Maybe add a info for the user about this behavior?

Some discord discussion:

https://discord.com/channels/1079625926024900739/1080712072012238858/1226407188650659845

## Current State

Found Aliases:
- default-param-last
- max-params
- no-array-constructor
- require-await
- no-dupe-class-members
- no-empty-function
- no-loss-of-precision
- no-redeclare
- no-useless-constructor

Todo: why im getting following output:
```
👀 typescript/require-await is implemented but not found in their rules
👀 tree-shaking/no-side-effects-in-initialization is implemented but not found in their rules
```
2024-06-20 14:56:31 +08:00
overlookmotel
24df88099a
ci: enable semantic benchmarks (#3784)
#3776 does seem to have stabilized the benchmark results. Re-enable
semantic benchmarks which we disabled because they were showing wild
variance, and see if they still do.
2024-06-20 14:55:33 +08:00
Boshen
a94ef68c0f
ci: add JEMALLOC_SYS_WITH_LG_PAGE=16 to aarch64 systems
closes #3783
2024-06-20 14:30:17 +08:00
Dunqing
97575d8cab feat(codegen): print TSClassImplements and TSThisParameter (#3786)
close: https://github.com/oxc-project/oxc/issues/3692#issuecomment-2178994839
2024-06-20 06:15:23 +00:00
Dunqing
497769cb60 feat(ast): add some visitor functions (#3785) 2024-06-20 05:23:04 +00:00
overlookmotel
aea3e9a3f5 fix(transformer): correct spans for TS annotations transform (#3782)
Correct spans in output for TS annotations transform.
2024-06-20 01:33:12 +00:00
overlookmotel
21b0d0196b refactor(transformer): pass ref to function (#3781)
Tiny refactor. Pass `&TSEnumDeclaration` to function instead of `&Box<TSEnumDeclaration>` (which is a reference to a reference).
2024-06-20 01:33:09 +00:00
rzvxa
4bd2c882d3 fix(linter): fix and promote getter-return to correctness. (#3777)
I had to rewrite some parts of this rule so now it uses a set dfs. It is arguably a little bit slower than before but it is less prone to false negatives.

closes #2312

[oxlint-ecosystem-ci](https://github.com/oxc-project/oxlint-ecosystem-ci/actions/runs/9586832129/job/26435575457?pr=16)
2024-06-20 01:27:07 +00:00
rzvxa
3e78f9852f feat(cfg): add depth first search with hash sets. (#3771)
petgraph allocates a chunk of memory for all of the graph for its dfs which is really costly for small subgraph sreachs.
This PR adds a new `set_depth_first_search` function which uses a `FxHashSet` instead.
2024-06-20 01:27:03 +00:00
overlookmotel
6ba60e978a ci: custom global allocator for benchmarks (#3776)
Use a custom global allocator for benchmarks. Will hopefully fix the wild variance in many benchmarks that we've been seeing, which I believe is caused by unpredictable behavior in the system allocator.
2024-06-19 17:02:19 +00:00
Boshen
ae6654f247 ci: speed up conformance with thin lto (#3773) 2024-06-19 16:05:06 +00:00
Dunqing
4b06dc72ae feat(ast): add TSType::TSIntrinsicKeyword to is_keyword (#3775)
follow up #3767
2024-06-19 16:00:57 +00:00
overlookmotel
7c44703a4c refactor(transformer): remove needless pub on TS enum transform methods (#3774)
Tiny refactor. Remove `pub` visibility on methods not used outside of module.
2024-06-19 15:51:04 +00:00
Dunqing
b38c34dfce feat(isolated-declarations): support inferring ParenthesizedExpression (#3769) 2024-06-19 15:43:21 +00:00
Dunqing
8ce794d740 fix(isolated-declarations): inferring an incorrect return type when there is an arrow function inside a function (#3768) 2024-06-19 15:43:15 +00:00
rzvxa
315f9ad9bf
chore(ci): add A-cfg label to auto-labler. (#3772)
I have already added the `A-cfg` label if you don't want to merge this
please also remove the said label.
2024-06-19 23:23:31 +08:00
Boshen
a658ca8675
ci: try graphite ci optimizer (#3770) 2024-06-19 23:07:35 +08:00
Boshen
5847e16a15 feat(ast,parser): add intrinsic keyword (#3767)
closes #3759
2024-06-19 14:52:05 +00:00
rzvxa
1190dee47f fix(linter): false positives with setters in the getter-return rule. (#3714)
related but won't close #2312

[oxlint-ecosystem-ci](https://github.com/rzvxa/oxlint-ecosystem-ci/actions/runs/9547942249/job/26314030884)
2024-06-19 14:45:06 +00:00
Dunqing
4134de8dcf feat(isolated-declarations): add ts error code to the error message (#3755) 2024-06-19 14:33:29 +00:00
Dunqing
94202de250 feat(isolated-declarations): add export {} when needed (#3754)
https://github.com/microsoft/TypeScript/pull/58912
2024-06-19 14:33:27 +00:00
Dunqing
d29316a5ff fix(isolated-declarations): transform incorrectly when there are multiple functions with the same name (#3753) 2024-06-19 14:33:25 +00:00
Dunqing
e95d8e3990 feat(isolated-declarations): shrink span for arrow function that needs an explicit return type (#3752)
Current `span` we can't be consistent with typescript.

We report the following
```ts
(a, b) =>
^^^^^^^^^
{ }
^
```

TypeScript reports the following
```ts
(a, b) =>
^^^^^^^^^
{}
```

The TypeScript only reports the first line, if we want it to be exactly the same we need to find the first newline position
2024-06-19 14:33:24 +00:00
Dunqing
bf1c250d56 fix(isolated-declarations): false positives for non-exported binding elements (#3751) 2024-06-19 14:06:08 +00:00
Dunqing
df9971da4c feat(isolated-declarations): improve inferring the return type from function (#3750) 2024-06-19 14:06:05 +00:00
Dunqing
4aea2b158c feat(isolated-declarations): improve inferring the type of accessor (#3749) 2024-06-19 14:06:02 +00:00
Dunqing
9ea30c41ff feat(isolated-declarations): treat AssignmentPattern as optional (#3748) 2024-06-19 14:05:59 +00:00
rzvxa
887da40518 test(linter): enable no-fallthrough test with disable-next-line. (#3766)
I thought we didn't have this, But now that I've read the `LintContext` I have realized it wasn't true.
2024-06-19 13:24:21 +00:00
rzvxa
4d2b7f1227 refactor(linter): LintContext can now only be constructed with a cfg enabled semantic. (#3761)
It has the same spirit as #3747 but with a much simpler approach. I've used the fact that @Boshen mentioned about linter always using CFG so now we assert `semantic.cfg().is_some()` in the `LintContext::new` because of this assertion we can have a `LintContext::cfg` that unwraps unchecked.
Eliminates unnecessary checks in our hot paths.

It has the best of both worlds, No complicated typing yet we still get the CFG as a non-optional value without extra ASM or branching.
2024-06-19 13:01:33 +00:00
Boshen
4fb90eb009 feat(oxc): export isolated-declarations (#3765) 2024-06-19 12:54:02 +00:00
overlookmotel
22c56d73c3 refactor(transformer): move TSImportEqualsDeclaration transform code (#3764)
Pure refactor. Move all code related to `TSImportEqualsDeclaration` transform into `module.rs`.
2024-06-19 12:48:44 +00:00
overlookmotel
cd56aa9dd8 refactor(transformer): simplify TS export assignment transform (#3762)
Remove unnecessary jump through a `ModuleDeclaration` visitor, and visit as `TSExportAssignment` directly.
2024-06-19 12:31:02 +00:00
overlookmotel
512740d33d refactor(transformer): move and simplify TS enum transform entry point (#3760)
Move logic for TS enum transform into `enum.rs`. Also simplify the logic, using `Statement` enum variants directly.
2024-06-19 12:16:30 +00:00
Boshen
bd534375a1
chore: update MAINTENANCE.md 2024-06-19 20:13:12 +08:00
Boshen
a11bdae1bb
chore(justfile): add a pre-commit hook
closes #3741
2024-06-19 20:09:42 +08:00
Boshen
3d0693f4d4 chore(linter): regenerate snapshot (#3758) 2024-06-19 09:33:04 +00:00
Boshen
45b0d1147e chore(semantic): regenerate snapshot (#3757) 2024-06-19 09:28:31 +00:00
Boshen
8c02c1dac3 chore(isolated-declarations): add snapshot testing (#3756) 2024-06-19 09:20:17 +00:00
Boshen
b7f659ee47
chore(oxc-transform): update README 2024-06-19 14:30:15 +08:00
Boshen
36de684fd1
chore(benchmark): use a more complated file for codegen_sourcemap 2024-06-19 13:31:21 +08:00
rzvxa
49d28c0dd2 chore(benchmark): enable cfg for linter benchmarks. (#3746)
The benchmark result on this PR - if we filter out the unstable benchmarks - can also be used to show the total impact of CFG enable rules.
2024-06-19 05:12:58 +00:00
github-actions[bot]
1b3cd6c24d
Release crates v0.15.0 (#3743)
## [0.15.0] - 2024-06-18

- 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)

- 534242a codegen: [**BREAKING**] Remove
`CodegenOptions::enable_typescript` (#3674) (Boshen)

- 0578ece ast: [**BREAKING**] Remove
`ExportDefaultDeclarationKind::TSEnumDeclaration` (#3666) (Dunqing)

### Features

- 5a99d30 codegen: Improve codegen formatting (#3735) (Boshen)
- bf9b38a codegen: Improve codegen formatting (#3731) (Boshen)
- 4a004e2 codegen: Print TSImport remaining fields (#3695) (Dunqing)
- a56cb1b codegen: Print accessibility for MethodDefinition (#3690)
(Dunqing)
- 38a75e5 coverage: Improve codegen (#3729) (Boshen)
- 750a534 coverage: Transformer idempotency test (#3691) (Boshen)
- ee627c3 isolated-declarations: Create unique name for `_default`
(#3730) (Dunqing)
- 81e9526 isolated-declarations: Inferring set accessor parameter type
from get accessor return type (#3725) (Dunqing)
- 77d5533 isolated-declarations: Report errors that are consistent with
typescript. (#3720) (Dunqing)
- 8f5655d linter: Add eslint/no-useless-constructor (#3594) (Don Isaac)
- 046ff3f linter/eslint: Add `no_unreachable` rule. (#3238) (rzvxa)
- 0b8098a napi: Isolated-declaration (#3718) (Boshen)
- 527bfc8 npm/oxc-transform: Setup npm/oxc-transform and publish
(Boshen)
- d65c652 parser: Display jsx mismatch error, e.g. `<Foo></Bar>` (#3696)
(Boshen)
- 9c31ed9 semantic/cfg: Propagate unreachable edges through subgraphs.
(#3648) (rzvxa)
- d9c5b33 semantic/cfg: Add `Condition` instruction. (#3567) (Ali
Rezvani)
- f2dfd66 semantic/cfg: Add iteration instructions. (#3566) (rzvxa)
- 910193e transformer-dts: Report error for super class (#3711)
(Dunqing)
- 413d7be transformer-dts: Transform enum support (#3710) (Dunqing)
- 35c382e transformer-dts: Remove type annotation from private field
(#3689) (Dunqing)
- 0e6d3ce transformer-dts: Report error for async function and generator
(#3688) (Dunqing)
- b22b59a transformer-dts: Transform namespace support (#3683) (Dunqing)
- 4f2db46 transformer-dts: `--isolatedDeclarations` dts transform
(#3664) (Dunqing)

### Bug Fixes

- 2158268 ast: Incorrect visit order in function (#3681) (Dunqing)
- da1e2d0 codegen: Improve typescript codegen (#3708) (Boshen)
- f1b793f isolated-declarations: Function overloads reaching unreachable
(#3739) (Dunqing)
- 0fbecdc isolated-declarations: Should be added to references, not
bindings (#3726) (Dunqing)
- 8f64d99 minifier: Respect `join_vars: false` option (#3724)
(mysteryven)
- 70fc69b semantic: Add Eq to CtxFlags (#3651) (Yuji Sugiura)
- 7a58fec semantic/cfg: Issue in unlabeled `Ctx`s. (#3678) (rzvxa)
- abd6ac8 semantic/cfg: Discrete finalization path after `NewFunction`s.
(#3671) (rzvxa)
- e148a32 semantic/cfg: Correct unreachability propagation in
try-finally. (#3667) (Ali Rezvani)
- 59666e0 transformer: Do not rename accessible identifier references
(#3623) (Dunqing)
- 90743e2 traverse: Change visit order for `Function` (#3685)
(overlookmotel)

### Performance

- 2717a1a semantic/cfg: Lower the visits in
`neighbors_filtered_by_edge_weight`. (#3676) (rzvxa)

### Refactor

- fa7a6ba codegen: Add `gen` method to ast nodes (#3687) (Boshen)
- 09b92b6 codegen: Move `gen_ts` into `gen` to make searching things
easier (#3680) (Boshen)
- 3c59735 isolated-declarations: Remove `TransformDtsCtx` (#3719)
(Boshen)
- 815260e isolated-declarations: Decouple codegen (#3715) (Boshen)
- 7ec44f8 semantic: Rename `cfg` macro to `control_flow`. (#3742)
(rzvxa)
- d8ad321 semantic: Make control flow generation optional. (#3737)
(rzvxa)
- a94a72d semantic: Expose 1 checker function instead of 2 (#3694)
(Boshen)
- bd8d115 semantic/cfg: Remove unused types. (#3677) (rzvxa)
- f702fb9 semantic/cfg: Cleanup control flow and it's builder. (#3650)
(rzvxa)
- 4f16664 transformer_dts: Create a `Program` for codegen (#3679)
(Boshen)

Co-authored-by: Boshen <Boshen@users.noreply.github.com>
2024-06-19 01:15:55 +08:00