Commit graph

1414 commits

Author SHA1 Message Date
Alexander S.
c6d97e9366
feat(prettier): improve ts class output (#5835)
please look first at  #5834 :)
2024-09-17 17:33:35 -04:00
Alexander S.
6d9ccdda92
feat(prettier): support TSMappedType (#5834) 2024-09-17 16:25:51 -04:00
Boshen
5901d2a0f1 fix(codegen): various spacing issues (#5820) 2024-09-17 09:03:28 +00:00
Alexander S.
18e4ac22ad
feat(prettier): improve TSInterfaceDeclaration (#5817)
last one for today :)

---------

Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-09-17 14:41:33 +08:00
DonIsaac
a438743191 refactor(linter): move OxlintConfig to Oxlintrc (#5707) 2024-09-17 05:15:37 +00:00
Alexander S.
b5ac5a6bf0
feat(prettier): support TSModuleDeclaration (#5813)
Goal of this PR is to resolve this test:
aa3853b776/tests/format/typescript/interface/separator.ts
2024-09-16 16:39:42 -04:00
Alexander S.
8b1485bb00
feat(prettier): improve ClassMemberish with print_class_property (#5811) 2024-09-16 13:32:20 -04:00
Alexander S.
01f8c1bca8
feat(prettier): support TSIntersectionType and TSUnionType (#5794) 2024-09-16 13:09:30 -04:00
Alexander S.
52c64093f9
feat(prettier): support typescript enums (#5790)
The last failed test is only because of the comments. the oxc prettier
output is:

```
enum Direction {
  Up = 1,
  Down,
  Left,
  Right,
}

enum FileAccess {
  None,
  Read = // constant members
  1 << 1,
  Write = 1 << 2,
  ReadWrite = Read | Write,
  G = // computed member
  "123".length,
}

enum Empty {}

const enum Enum {
  A = 1,
  B = A * 2,
}
```
Expected output:
aa3853b776/tests/format/typescript/enum/__snapshots__/format.test.js.snap (L91-L99)

Hope you can tell more why this happens :)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-09-16 11:58:04 +08:00
Boshen
213dbc04ff chore(transform_conformance): do not print comments yet (#5788) 2024-09-15 15:48:58 +00:00
Boshen
512be65fa7 refactor(coverage): remove sourcemap snapshot (#5782) 2024-09-15 08:56:54 +00:00
overlookmotel
3230ae5842 feat(semantic): add SemanticBuilder::with_excess_capacity (#5762)
Add `SemanticBuilder::with_excess_capacity` method to request that `SemanticBuilder` over-allocate space in `Semantic`'s `Vec`s.

Use this method to reserve 200% extra capacity for transformer to create more scopes, symbols and references.

200% is an unscientific guess of how much extra capacity is required. Obviously it depends on what transforms are enabled and content of the source code.
2024-09-14 15:02:16 +00:00
Dunqing
36e698b411 perf(transformer): call transform_jsx in exit_expression rather than enter_expression (#5751)
### Difference

In `enter_expression`: Recursive transform JSX
In `exit_expression`: Deep first transform

After the change,  `transform_jsx` still has a lot of room for improvement.
2024-09-13 17:58:41 +00:00
Dunqing
3cc38dfc05 fix(transformer/react): react refresh panics when encounter use hook (#5768)
close: #5766

I even forgot that React has a `use` hook in the latest version
2024-09-13 16:17:33 +00:00
Dunqing
77d9170f84 fix(transformer/react): isStaticChildren should be false when there is only one child (#5745)
We found a warning report [here](206df66e70/packages/react/src/jsx/ReactJSXElement.js (L614-L632)). It caused by we transform incorrectly
2024-09-13 13:20:59 +00:00
Dunqing
c9fea5dd16 chore(tasks/transformer_conformance): remove an ignored test that has passed (#5750) 2024-09-13 09:03:48 +00:00
Boshen
6bc13f6cd4 feat(minifier): add MinimizeConditions pass (#5747)
I expect small performance regression.

But managed to improve the following case from react.developmement.js

```
oxc  main ❯ diff before.js after.js
670c670
< 		if (!(dispatcher !== null)) throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.");
---
> 		if (dispatcher === null) throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.");
```
2024-09-13 08:31:45 +00:00
overlookmotel
3ce8546393 ci(benchmarks): NeverGrowInPlaceAllocator not pub (#5727)
Global allocator used in benchmarks `NeverGrowInPlaceAllocator` doesn't need to be `pub`.
2024-09-12 12:58:13 +00:00
Boshen
748e6f80fe
chore(minsize): update minsize.snap 2024-09-12 19:02:46 +08:00
Boshen
945d2744ae
chore(linter: fix snapshot 2024-09-11 21:07:23 +08:00
dalaoshu
d18c896a2c
perf(rust): use cow_utils instead (#5664)
Related to #5586 and #5662

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-09-11 18:39:30 +08:00
heygsc
5482e73189
feat(prettier): add assignment/sequence (#5694)
test:
https://github.com/prettier/prettier/blob/main/tests/format/js/assignment/sequence.js


snap:https://github.com/prettier/prettier/blob/main/tests/format/js/assignment/__snapshots__/format.test.js.snap#L870-L888

code:
https://github.com/prettier/prettier/blob/main/src/language-js/needs-parens.js#L790-L796
2024-09-11 18:19:09 +08:00
Dunqing
a1afd48c68 fix(transformer/react): incorrect scope_id for var hoisted in fast refresh plugin (#5695)
Fix the last one semantic error in the fast react plugin
2024-09-11 09:02:29 +00:00
Dunqing
f2f5e5aaf5 fix(transformer/react): missing scope_id for function in fast refresh plugin (#5693)
Fix semantic error in the fast react plugin
2024-09-11 09:02:28 +00:00
Dunqing
a891c31889 fix(transformer/react): refresh plugin has incorrect reference flags (#5656)
As you see the diff
2024-09-11 07:57:17 +00:00
Dunqing
ffbc4625b4 chore(transformer): treat all React Refresh tests as ESM syntax (#5644)
related: #5612
2024-09-11 07:57:17 +00:00
Dunqing
3e8b96f165 fix(transformer/react): the refresh plugin cannot handle member expressions with React hooks (#5655)
The previous implementation doesn't handle nested StaticMemberExpression. For example: `A.B.C.useHook`.
2024-09-11 07:57:16 +00:00
Dunqing
7b543dffd9 feat(transformer/react): handle refresh_sig and refresh_reg options correctly (#5638)
In previous implementations, even if pass `import.meta.xxxx` into these options this plugin still treats them as `IdentifierReference`
2024-09-11 07:57:15 +00:00
Dunqing
3bf6aaf06a fix(transformer/react): support emit_full_signatures option in refresh plugin (#5629) 2024-09-11 07:57:14 +00:00
Dunqing
36d864a0c3 fix(transformer/react): don't transform if the variable does not have a value reference (#5528)
close: #4746

Solved the last two tests, but it's a coincidence. I've added a test to cover it.
2024-09-11 07:10:55 +00:00
leaysgur
304ce25446 fix(regular_expression): Keep LegacyOctalEscape raw digits for to_string (#5692)
Fixes #5690

- Update `CharacterKind` enum from `Octal` to `Octal1`, `Octal2` and `Octal3`
- Stylistic refactoring for `impl Display`
2024-09-11 07:07:00 +00:00
DonIsaac
9e9435f03b refactor(linter): add LintFilter (#5685)
Re-creation of #5329
2024-09-11 03:19:04 +00:00
Boshen
2016bae98c feat(coverage): add regular expression idempotency test (#5676)
closes #5634
2024-09-11 02:07:42 +00:00
Boshen
f9e3a41dd2 fix(semantic): bind SymbolId to function name in if (foo) function id() {} (#5673) 2024-09-10 11:05:26 +00:00
DonIsaac
5ae9b48509 refactor(linter): start internal/external split of OxlintOptions (#5659)
re-creation of #5141
2024-09-10 03:19:04 +00:00
leaysgur
0511d55aa8 fix(regular_expression): Report more MayContainStrings error in (nested)class (#5661)
Fixes #5632
2024-09-10 01:55:51 +00:00
IWANABETHATGUY
e38114b825
fix(ast_tools): fix ast-tool panic (#5641)
`just ast` panic due to
553262842c,
change the filename to makesure `ast_tool` still working
1. crates/oxc_span/src/source_type/types.rs is removed in
553262842c
2024-09-09 17:57:20 +08:00
DonIsaac
20d006838e refactor(oxlint): move cli-related exports to cli module (#5139) 2024-09-08 15:29:37 +00:00
Boshen
f49e6ebd41 fix(span): treat .js as module file (reverts the previous breaking change) (#5612)
As it turns out it's not ideal to treat `.js` as `script` in today's world anymore.

This makes https://github.com/oxc-project/oxlint-ecosystem-ci pass again.
2024-09-08 15:14:04 +00:00
Boshen
4a8aec1605 feat(span)!: change SourceType::js to SourceType::cjs and SourceType::mjs (#5606) 2024-09-08 14:11:02 +00:00
Boshen
63a830e08c
chore(dprint): format toml files (#5599)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-09-08 14:26:16 +08:00
Boshen
d00a1f6511
chore: use dprint to format js, json and markdown 2024-09-08 13:24:58 +08:00
Boshen
919d17fc5c fix(transform_conformance): only print semantic mismatch errors when output is correct (#5589)
closes #5166

Had to rerun for mismatch errors :-/
2024-09-07 16:32:53 +00:00
Boshen
1bc08e296e fix(coverage): parse babel unambiguously (#5579) 2024-09-07 10:49:00 +00:00
Boshen
43933912ce fix(coverage): parse typescript unambiguously (#5575) 2024-09-07 10:48:59 +00:00
Boshen
603817bef9 feat(oxc)!: add SourceType::Unambiguous; parse .js as unambiguous (#5557)
See https://babel.dev/docs/options#misc-options for background on `unambiguous`

Once `SourceType::Unambiguous` is parsed, it will correctly set the returned `Program::source_type` to either `module` or `script`.
2024-09-07 10:48:58 +00:00
rzvxa
c78a8507d1 refactor(ast_tools): only use type names to ignore fields in the DeriveContentHash. (#5573)
related to https://github.com/oxc-project/backlog/issues/107
2024-09-07 09:57:25 +00:00
rzvxa
db55fb0fce fix(ast_tools, ci): watch tasks/ast_tools instead of tasks/ast_codegen. (#5576)
I was so confused as to why the `AST Changes` step wasn't running at times. Turns out we weren't watching it at all😅

This means for a duration of time we weren't running the `AST Changes` step on PRs that edited only `ast_tools` that didn't update any side-effects.
2024-09-07 09:41:18 +00:00
rzvxa
7a6b64c3f0 refactor(ast_tools): remove unsafe code from logger. (#5574)
https://github.com/oxc-project/oxc/pull/5519#discussion_r1747097404
2024-09-07 09:03:26 +00:00
Boshen
f7912ad6c0
chore: remove unused pnpm-lock.yaml 2024-09-07 13:11:34 +08:00