Commit graph

720 commits

Author SHA1 Message Date
Boshen
be6b8b7ce6
[BREAKING CHANGE] Change Atom to Atom<'a> to make it safe (#2497)
Part of #2295

This PR splits the `Atom` type into `Atom<'a>` and `CompactString`.

All the AST node strings now use `Atom<'a>` instead of `Atom` to signify
it belongs to the arena.

It is now up to the user to select which form of the string to use.

This PR essentially removes the really unsafe code 


93742f89e9/crates/oxc_span/src/atom.rs (L98-L107)

which can lead to 

![image](https://github.com/oxc-project/oxc/assets/1430279/8c513c4f-19b0-4b63-b61c-e07c187c95b5)
2024-02-26 19:34:40 +08:00
Dunqing
cd75c1ca59
feat(transformer/decorators): insert only one private in expression (#2486) 2024-02-26 15:48:47 +08:00
Yuji Sugiura
f66fb886b3
fix(tasks/rulegen): Parse 'export default' test file for plugin-jsdoc (#2510) 2024-02-26 14:31:51 +08:00
renovate[bot]
29b213eac7
chore(deps): update rust crates (#2503) 2024-02-26 10:38:11 +08:00
Boshen
5212f7b51e
fix(parser): fix missing end span from TSTypeAliasDeclaration (#2485)
closes #2483
2024-02-24 16:51:00 +08:00
Dunqing
3d008abacb
feat(transformer/decorators): insert instanceBrand function (#2480) 2024-02-23 23:04:27 +08:00
Dunqing
2628c97eda
feat(transformer/decorators): transform getter function (#2473) 2024-02-23 10:11:45 +08:00
Boshen
d08abc638e refactor(ast): s/NumberLiteral/NumericLiteral to align with estree 2024-02-21 21:41:08 +08:00
Andrew McClenaghan
6b3b260dcc
feat(Codegen): Improve codegen (#2460)
This gets all the new TS types working to the same level TS output was
before and fixes a bunch of other codegen

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-02-21 14:41:57 +08:00
Dunqing
197fa16613
feat(semantic): add check for duplicate class elements in checker (#2455)
1. Remove the check implementation of the parser
2. Implement it to semantic checker
3. Support typescript's check for duplicate class elements

Support checking for duplicate class elements in semantic checker is
easier to support typescript checking rules.
2024-02-21 14:10:19 +08:00
Andrew McClenaghan
e6d536cb9b
feat(codegen): configurable typescript codegen (#2443)
- Adds option to `CodegenOptions` - `enable_typescript` to enable output
of TS.
- Stops skipping output that is TS when `enable_typescript` is enabled
- Adds TS support to 
    - Function
    - FormalParameter
    - BindingPattern
 - Adds basic tests for TS generation

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-02-20 12:09:28 +08:00
Dunqing
27b2c212c4
refactor(transformer/decorators): if it is a private method definition, transform it (#2427) 2024-02-19 19:17:11 +08:00
Dunqing
60db720fa6
feat(parser): parse import attributes in TSImportType (#2436)
close: #2394 

64d2eeea7b/src/compiler/types.ts (L2177-L2185)

The corresponding test cases were skipped, so I manually added some
cases to misc

f5db48237f/tasks/coverage/src/typescript.rs (L118-L121)
2024-02-19 12:26:42 +08:00
Dunqing
b5deb9a708
fix(codegen): when async is on the left-hand side of a for-of, wrap it in parentheses (#2407)
Refer to
55e1127a49/internal/js_printer/js_printer.go (L3097-L3104)
2024-02-13 22:42:23 +08:00
Boshen
83cb78fbb0
feat(coverage): add prettier idempotency test (#2403)
feat(coverage): add prettier idempotency test

closes #1329

feat(prettier_conformance): enable TypeScript
2024-02-12 16:20:09 +08:00
Boshen
1cbd7539fb
feat(coverage): add prettier idempotency test (#2402)
closes #1329
2024-02-12 15:30:16 +08:00
Boshen
70a0076eed
refactor: remove global allocator from non-user facing apps (#2401)
The runtime performance gains does not out weight the compilation speed from
building the custom allocators, which takes about a minute to build on
slower machines.
2024-02-12 14:09:05 +08:00
Dunqing
73e116e8a1
fix(parser): incorrect parsing of class accessor property name (#2386) 2024-02-11 22:57:13 +08:00
Boshen
9ff7986610
feat(prettier): handle binaryish expression in return statement (#2388) 2024-02-11 20:01:25 +08:00
Boshen
871a73afdd
fix(prettier): semi colon after class property (#2387) 2024-02-11 19:25:38 +08:00
Dunqing
0df7e296f9
feat(tasks/codegen): check node version >= 20 (#2385)
This syntax only works on node >= 20
`import value from './json-value-array_FIXTURE.json' with { type: 'json'
};`
2024-02-11 19:23:11 +08:00
Boshen
15a8857927
refactor(prettier): improve print_statement_sequence (#2383) 2024-02-11 00:16:26 +08:00
Boshen
82a6dc17d3
feat(pretter): implement print_binaryish_expressions (#2382) 2024-02-10 23:18:56 +08:00
Boshen
2dfe5210bb
fix(prettier): print strings as raw strings (#2380) 2024-02-10 17:52:17 +08:00
Boshen
642484e2cb
feat(prettier): print newlines between array expression elements (#2379) 2024-02-10 17:31:09 +08:00
Boshen
ef336cb66b
feat(parser): recover from async x [newline] => x (#2375)
```javascript
async x
=> x
```

Babel recovers and displays "No line break is allowed before '=>'
2024-02-10 11:19:08 +08:00
Boshen
70c983d4bb
feat(prettier): print rest parameters (#2370) 2024-02-09 22:59:28 +08:00
Boshen
9b6c313ebf
fix(prettier): flatten all binary expressions for now (#2367) 2024-02-09 21:48:27 +08:00
Boshen
90a834f87b
chore: update snapshot 2024-02-09 21:08:39 +08:00
Dunqing
2eb489e996
fix(codegen): format new expession + import expression with the correct parentheses (#2346)
Similar to #2330
2024-02-09 20:51:50 +08:00
Dunqing
e4754873ee
fix(prettier): printing value instead of key in BindingProperty (#2334)
fix: #2314
2024-02-08 21:49:10 +08:00
Boshen
5d9b0f3312
ci: speed up benchmark build (#2343)
closes #2299

Managed to figure out what `cargo codspeed build` is doing :-)
2024-02-08 19:47:50 +08:00
overlookmotel
aef593fb50
parser(refactor): promise only one Source on a thread at a time (#2340)
Introduce invariant that only a single `lexer::Source` can exist on a thread at one time.

This is a preparatory step for #2341.

2 notes:

Restriction is only 1 x `ParserImpl` / `Lexer` / `Source` on 1 *thread* at a time, not globally. So this does not prevent parsing multiple files simultaneously on different threads.

Restriction does not apply to public type `Parser`, only `ParserImpl`. `ParserImpl`s are not created in created in `Parser::new`, but instead in `Parser::parse`, where they're created and then immediately consumed. So the end user is also free to create multiple `Parser` instances (if they want to for some reason) on the same thread.
2024-02-08 14:51:17 +08:00
Dunqing
3268d7d66e
feat(tasks/prettier): add some information for debug no spec calls (#2333) 2024-02-07 16:55:59 +08:00
Boshen
e8dc68c525
chore: update prettier to v3.2.5 (#2332) 2024-02-06 22:55:43 +08:00
Dunqing
55011e2793
feat(codegen): avoid printing comma in ArrayAssignmentTarget if the elements is empty (#2331) 2024-02-06 22:45:19 +08:00
Boshen
43a9cb5522
chore: update snapshot 2024-02-06 22:17:59 +08:00
Dunqing
a3570d41f0
feat(semantic): report parameter related errors for setter/getter (#2316) 2024-02-05 17:38:43 +08:00
Dunqing
9ca13d040d
feat(semantic): report type parameter list cannot be empty (#2315) 2024-02-05 16:05:51 +08:00
Dunqing
d6d931cd80
fix(tasks/coverage): when providing filter, do not run just submodules (#2310) 2024-02-05 15:06:37 +08:00
Dunqing
f53c54ced9
feat(semantic): report unexpected type annotation in ArrayPattern (#2309) 2024-02-05 13:45:52 +08:00
overlookmotel
73ec4df61c
chore(benchmark): add radix-ui.jsx as a real world jsx example (#2304)
Following #2297, this adds another benchmark.

This one is from radix-ui website. I've chosen this particular file
because it differs from the other benchmark sources in 3 ways:

1. JSX not TSX (despite the file extension).
2. Contains no logic, only JSX component hierarchy, and content text.
3. Very small (60 LOC).

The last is particularly important, I think. Often developers will be
working on small files (single component per file convention). And some
possible directions for the parser (SIMD etc) involve optimizing chewing
through chunks of text, with a de-opt at the end to process the final
batch of bytes. If that imposes a penalty on short files, this benchmark
will surface it.

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-02-05 13:42:45 +08:00
Boshen
018674c56c
chore(benchmark): add cal.com.tsx as a realword tsx example (#2297)
closes #1884
2024-02-04 22:40:55 +08:00
underfin
2f97b332bd
chore: codegen test skip v8 failed test (#2283)
Because v8 isn't pass some test262 tests, we also need to skip them, you
can find it at
https://chromium.googlesource.com/v8/v8/+/refs/heads/main/test/test262/test262.status.
2024-02-04 14:02:39 +08:00
Boshen
d2f7ea2923
chore: manually clone git modules instead of using submodules (#2274)
closes #2231

Submodules are a blocker for beginners, we should make it clone on
demand.

It is also a blocker for people who wants to target this repo as a crate
for testing purposes, cargo will do a full clone if you specify
oxc_parser = { git = "this repo" } in Cargo.toml
2024-02-02 11:56:18 +00:00
Boshen
28daf83b19
feat(semantic): report no class name error (#2273)
closes #2144
2024-02-02 19:05:00 +08:00
kaykdm
2ceba79dcd
feat(tasks): add eslint-plugin-n rulegen (#2272)
related: https://github.com/oxc-project/oxc/issues/493

Support generate rules from
[eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n).
2024-02-02 18:50:58 +08:00
Boshen
d7feadedb4
chore(lint_rules): deprecated eslint no-dupe-args / no-octal / no-with
These are strict mode errors.

Closes #2257
2024-02-02 17:33:54 +08:00
Dunqing
8e221cb26e
fix(transformer): update snapshot (#2268) 2024-02-02 17:00:44 +08:00
Boshen
650f6c942f
refactor: use our forked version of miette::Reporter for tests (#2266) 2024-02-02 16:15:31 +08:00