Commit graph

3200 commits

Author SHA1 Message Date
Cameron
98a3acd8b5
feat(linter) eslint-plugin-unicorn no single promise in promise methods (#2962)
part of #684
2024-04-14 10:39:12 +08:00
Boshen
6561392202
feat(transform_conformance): add baseline for all TypeScript and jsx plugins 2024-04-13 19:05:39 +08:00
Miles Johnson
e67355045e
feat(transformer): start on TypeScript annotation removal (#2951) 2024-04-13 18:49:54 +08:00
Boshen
93ce5a919a
chore: fix internal doc warnings 2024-04-13 15:59:24 +08:00
Boshen
9df5001543
ci: explicitly disable incremental build and deny warnings for cargo and rust 2024-04-13 15:40:10 +08:00
Boshen
21509ae15b
chore: disable profile.dev debug symbols because we don't need it that much 2024-04-13 15:38:19 +08:00
Boshen
56c71e2b1e
chore: enable some rust lints 2024-04-13 15:38:00 +08:00
Boshen
b15bf2826b
feat(napi/parser): remove experimental flexbuffer api (#2957) 2024-04-13 14:59:31 +08:00
renovate[bot]
071010964e
chore(deps): update dependency rust to v1.77.2 (#2956) 2024-04-13 06:19:38 +00:00
Boshen
51e1fe32e5
chore: fix rust toolchain update not working 2024-04-13 14:12:10 +08:00
Boshen
bd56d51443
chore(macros): only select required features from syn to reduce compile time (#2955) 2024-04-13 13:37:59 +08:00
Boshen
f366d9bd7c
chore(minsize): remove brotlic because it takes too long to compile (#2954) 2024-04-13 13:24:25 +08:00
Boshen
adabbac696
ci: only run cargo-shear when Rust changes (#2953) 2024-04-13 13:24:09 +08:00
Boshen
003c2960c6
chore: add auto rust-toolchain.toml version update 2024-04-13 12:58:35 +08:00
Boshen
063b281c39
feat(allocator): make Box's PhantomData own the passed in T (#2952) 2024-04-13 12:31:40 +08:00
Boshen
e651e50bda
feat(transformer): add the most basic plugin toggles (#2950) 2024-04-12 20:25:34 +08:00
Boshen
60ccbb105c
refactor(transformer): clean up some code (#2949) 2024-04-12 20:23:44 +08:00
Boshen
14754777a4
feat(transformer): implement react-jsx-source (#2948) 2024-04-12 20:21:54 +08:00
Boshen
b05c26374c
ci: fix codecov stack overflow by increasing the stack size
The underlying cause is oxc_prettier recursively printing assignment expressions.
2024-04-12 20:17:53 +08:00
branchseer
f159f60084
Make ast types covariant over the allocator lifetime. (#2943)
## Why

Due to the usage of `&'alloc mut T` in `oxc_allocator::Box`, and
`bumpalo::collections::Vec` in `oxc_allocator::Vec`, ast types are
currently invariant over their allocator lifetime `'a`. This prevents
`ouroboros` from generating `borrow_*` on ast type fields, leading to
the unfriendly `with_*` api:
c250b288ef/crates/oxc_parser/examples/multi-thread.rs (L82-L84)

## How

- For `oxc_allocator::Vec`, switch to `allocator_api2::vec::Vec`, which
has a covariant relationship with the allocator lifetime.
- For `oxc_allocator::Box`, use `std::ptr::NonNull` which is
specifically designed to be covariant. I don't use
`allocator_api2::boxed::Box` because it holds the allocator for
dropping, so the size is bigger.

## Downside

Now that `oxc_allocator::Box` uses the unsafe `NonNull`. It has to be a
private field to be safe. This make it impossible to do `Box(....)`
pattern matching.
2024-04-12 18:12:18 +08:00
Boshen
f903a225a8
feat(transformer): implement react-jsx-self (#2946) 2024-04-12 18:08:36 +08:00
Yuji Sugiura
ba2121f17d
feat(linter): Add --jsdoc-plugin flag (#2935)
Add flag to:

```sh
$ oxlint --jsdoc-plugin
```


![image](https://github.com/oxc-project/oxc/assets/6259812/0e12ceab-966f-47e1-b4b9-5bc2eb6bdb56)
2024-04-12 10:39:12 +08:00
Boshen
0c04bf743f
feat(transformer): transform TypeScript namespace (#2942) 2024-04-12 10:19:13 +08:00
Boshen
c250b288ef
fix(cli): return error if --format receives an unknown value 2024-04-11 21:38:39 +08:00
Boshen
f3a28c61b9
chore(transform_conformance): enable typescript plugin snapshot 2024-04-11 20:06:53 +08:00
Boshen
3419306ac0
feat(transformer): add filename (#2941) 2024-04-11 18:43:51 +08:00
Boshen
df11d10a22
Release oxlint and vscode extension v0.2.17 2024-04-11 16:27:56 +08:00
Boshen
614f73b66c
Release crates v0.12.3 2024-04-11 16:18:17 +08:00
Boshen
ced0721b3b
ci: cache codecov; enable code coverage for oxc_transformer 2024-04-11 16:16:02 +08:00
Boshen
98bf7e6767
fix(cli): fix oxlint --format json yields 0 files to lint (#2940)
closes #2930
2024-04-11 16:03:31 +08:00
Boshen
02adc76760
feat(transformer): implement plugin-transform-react-display-name top-down (#2937)
Missing case:


https://github.com/babel/babel/blob/main/packages/babel-plugin-transform-react-display-name/test/fixtures/display-name/nested/input.js

```js
var foo = qux(createReactClass({}));
var bar = qux(React.createClass({}));
```

This requires recursing down.

Top-down implementation in swc:


67ec5e09b9/crates/swc_ecma_transforms_react/src/display_name/mod.rs (L108-L132)

Or bottom-up in babel:


08b0472069/packages/babel-plugin-transform-react-display-name/src/index.ts (L87-L98)
2024-04-11 15:32:32 +08:00
Boshen
59748199da
refactor(ast): clean up the ts type visit methods 2024-04-11 15:26:24 +08:00
Boshen
88270fe605
chore(benchmark): use a larger file for sourcemap benchmark 2024-04-11 15:11:26 +08:00
Brad Zacher
6c0090882f
feat(oxc_ast): add missing ast visits for types (#2938)
Fixes #2936

*personally* I think it's best if all of the `_ => {}` match cases were
removed from the codebase so that things are provably exhaustive.
This does exactly that specifically for `walk_ts_type` - filling in the
missing cases and all the required code for them.
2024-04-11 07:11:00 +00:00
Boshen
07bd85e25d
chore(transform_conformance): clear the conformance snapshot 2024-04-11 14:09:59 +08:00
cinchen
6757dbab8a
feat(linter): eslint-plugin-jest/prefer-lowercase-title (#2911)
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-lowercase-title.ts)
2024-04-10 21:56:56 +08:00
Todor Andonov
b4b471f4cf
feat(linter): typescript-eslint/consistent-type-definitions (#2885)
Co-authored-by: wenzhe <mysteryven@gmail.com>
2024-04-10 21:09:05 +08:00
Boshen
255c74ccc5
feat(transformer): add transform context to all plugins (#2931) 2024-04-10 14:49:00 +08:00
Yuji Sugiura
0a77d621e2
refactor(semantic/jsdoc): Rework JSDoc struct for better Span handling (#2917)
> The error message emphasizes "empty text" so I would put the span on
the extra text.
> https://github.com/oxc-project/oxc/pull/2893#discussion_r1548843621

To address this, special `Span` handling should be implemented for
comment part.

So, this PR introduces:

- `JSDocCommentPart` struct holds raw `.span` and special
`.span_trimmed_first_line()`
- Add `JSDocKindPart`, `JSDocTypePart` and `JSDocTypeNamePart` in the
same manner
  - `JSDocTag` uses these depending on the purpose
2024-04-10 14:32:51 +08:00
Boshen
79ca6feca9
feat(transformer): add transform callback methods (#2929)
For milestone 1, I think it's safe to just layout all the
transformations manually.


In TypeScript, the transformers are collected dynamically and ran on
each ast node; this achieves a single AST pass.
https://github.com/microsoft/TypeScript/blob/main/src/compiler/transformer.ts#L129-L145

To maximize performance and reduce confusion, I think it's safe to
layout all the transformations manually for milestone 1.

The next PR will add transformation context to all presets so we can
start adding "context".
2024-04-10 11:06:49 +08:00
underfin
8662f4f613
feat(sourcemap): add x_google_ignoreList (#2928) 2024-04-09 20:55:04 +08:00
underfin
5cb3991b67
feat(sourcemap): add sourceRoot (#2926) 2024-04-09 15:42:23 +08:00
Boshen
3e5530805d
Update issue templates 2024-04-09 14:54:46 +08:00
Boshen
0bada0bc93
Update issue templates (#2927) 2024-04-09 14:52:49 +08:00
Kalven Schraut
6eba02f472
fix(cli): if format is json do not print summary information (#2899) (#2925)
this allows the ability to redirect the stdout to so can create a valid
json file

this also matches with eslint's format option

closes #2899
2024-04-09 14:26:10 +08:00
Boshen
d65eab3b8b
feat(transformer): add react preset (#2921) 2024-04-09 12:39:33 +08:00
John Daly
5abbb0cada
fix(linter): import/no-cycle ignore type-only imports (#2924)
A fix for the work done in: https://github.com/oxc-project/oxc/pull/2905

The existing code checks if _all_ import entries in a ModuleRecord are
type-only, when determining if the ModuleRecord should be skipped when
checking for cycles. This is incorrect.

To demonstrate the problem: Running the `no-cycles` rule, with
`ignoreTypes` enabled, on the following example code will cause a cycle
to be reported between Module A and Module B

```typescript
// Module A
import type { Bar } from './b';
import { Baz } from './c'

// Module B
import type { Foo } from './a';

// Module C
export const Baz = 'baz';
```

The reason this is happening is because the import to Module C in Module
A is causing the `was_imported_as_type` variable to evaluate to `false`,
since the Module C import is not type-only.

What we actually want to do is skip visiting Module B entirely, by
checking if its import request from Module A is type-only.

This PR fixes the logic so that only the import entries for the next
ModuleRecord are considered when determining `was_imported_as_type`.
2024-04-09 12:38:15 +08:00
Wang Wenzhe
990eda61d7
feat(linter/tree-shaking): support part BinaryExpression (#2922) 2024-04-09 12:33:51 +08:00
Boshen
659e891615
ci: skip benchmark-napi because it is flaky (#2918)
The flakiness and all the noise produced by it is starting to hurt
maintenance because I can no longer tell if main or PR is failing
properly :-(

codspeed doesn't have the feature "let it run but don't report as error"
or "different thresholds on different benchmarks"
2024-04-08 19:21:57 +08:00
Boshen
79837bd410
Release @oxc-parser/wasm v0.1.0 2024-04-08 15:47:51 +08:00