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
Boshen
9e14c75e2a
chore: oxc_cfg.publish = true
2024-06-19 01:09:47 +08:00
rzvxa
7ec44f84a5
refactor(semantic): rename cfg macro to control_flow. ( #3742 )
...
As requested here https://github.com/oxc-project/oxc/pull/3737#discussion_r1644713121
2024-06-18 17:01:49 +00:00
Boshen
4e9d8a5585
chore: fix some nightly clippy warnings
2024-06-19 00:53:58 +08:00
Boshen
051ceb6539
chore: improve some format by running cargo +nightly fmt
2024-06-19 00:48:30 +08:00
Boshen
e592883bc1
chore: add oxc-transform to oxc_release.toml
2024-06-19 00:46:45 +08:00
Boshen
ce05671e90
Update README.md
2024-06-19 00:37:47 +08:00
Dunqing
f1b793fbba
fix(isolated-declarations): function overloads reaching unreachable ( #3739 )
2024-06-18 16:14:14 +00:00
rzvxa
256acc949b
chore(semantic)!: no longer generate CFG by default. ( #3738 )
...
related but won't close #3641
2024-06-19 00:13:29 +08:00
rzvxa
d8ad321687
refactor(semantic): make control flow generation optional. ( #3737 )
...
For maximum backward compatibility, we generate CFG by default.
Note: It can't be done with a simple method since lifetimes make it impossible(at least without unsafe trickery) I've tried to do it without a macro but it was just unintuitive.
2024-06-18 15:59:38 +00:00
rzvxa
0537d298db
refactor(cfg)!: move control flow to its own crate. ( #3728 )
2024-06-18 15:59:29 +00:00
Boshen
5c38a0fd69
feat(codegen)!: new code gen API ( #3740 )
...
This PR introduces two type alias to avoid the confusing const generic `pub struct Codegen<'a, const MINIFY: bool>`
* CodeGenerator - Code generator without whitespace removal.
* WhitespaceRemover - Code generator with whitespace removal.
Usage is changed to a builder pattern:
```rust
CodeGenerator::new()
.enable_comment(...)
.enable_sourcemap(...)
.build(&program);
```
2024-06-18 15:50:12 +00:00
Boshen
527bfc82f5
feat(npm/oxc-transform): setup npm/oxc-transform and publish
2024-06-18 22:12:47 +08:00
Boshen
02cc14e90c
chore: remove npm/oxc package
2024-06-18 21:32:25 +08:00
Boshen
5a99d30eba
feat(codegen): improve codegen formatting ( #3735 )
2024-06-18 11:10:36 +00:00
Wang Wenzhe
4d462636cb
feat(playground): support modify compressor's options ( #3734 )
...

2024-06-18 18:49:16 +08:00