Boshen
cb4e054eb9
refactor(span): remove Atom::Compact variant ( #2629 )
2024-03-06 20:47:35 +08:00
Boshen
4f9dd98a97
feat(span): remove From<String> and From<Cow> API because they create memory leak ( #2628 )
...
closes #2621
2024-03-06 20:38:21 +08:00
Boshen
240ff19675
refactor(parser): improve parsing of BindingPattern in TypeScript ( #2624 )
...
closes #2622
2024-03-06 16:16:03 +08:00
Dunqing
57ce737b09
feat(semantic): move redeclare varaibles to symbol table ( #2614 )
...
close : #2219
2024-03-06 15:34:12 +08:00
Boshen
798a6dfe46
refactor(span): disallow struct expression constructor for Span ( #2625 )
2024-03-06 15:28:59 +08:00
Boshen
7605cd3ecf
feat(linter): change ban-ts-comment to pedantic
2024-03-06 12:33:47 +08:00
overlookmotel
8001b2f796
refactor: make CompactStr immutable ( #2620 )
...
First step towards #2516 .
This replaces `compact_str::CompactString` with an immutable interface `CompactStr`.
Currently just implemented as a wrapper around `CompactString` which hides all its mutation methods. A more optimized implementation to follow, which shrinks size of `CompactStr` to 16 bytes by removing the `capacity` field.
The rationale for the change of name is: `CompactString` is like `String` in that it's mutable. `CompactStr` is more like `str` - immutable - so its name mirrors `str`.
2024-03-06 12:29:32 +08:00
overlookmotel
0646bf34fa
refactor: rename CompactString to CompactStr ( #2619 )
...
Preparatory step for #2620 .
This PR purely changes names of types and methods:
* `CompactString` -> `CompactStr`
* `Atom::to_compact_string` -> `to_compact_str`
* `Atom::into_compact_string` -> `into_compact_str`
Have split this into a separate PR as the diff is large, but it does absolutely nothing but renaming (I've checked the whole diff twice, so feel free not to check it again!). This should make it easier to see the content of the substantive change in #2620 .
2024-03-06 12:24:23 +08:00
overlookmotel
09d4c7d649
fix(linter): correct example for no-obj-calls rule ( #2618 )
...
I think someone used find-and-replace! 🥲
2024-03-06 11:09:45 +08:00
Boshen
1f14d946aa
chore: update Cargo.toml and deny.yaml
2024-03-05 16:31:05 +08:00
Boshen
32ab1ac89d
wip
2024-03-05 16:25:14 +08:00
Boshen
cca6eb073c
Release crates v0.9.0
2024-03-05 15:57:31 +08:00
Boshen
9c92ecaf07
Release napi oxc-parser@v0.8.0
2024-03-05 15:54:59 +08:00
Boshen
f94c9596e9
Release oxlint and vscode extension v0.2.13
2024-03-05 15:54:25 +08:00
Boshen
fbb7a5a75c
fix: revert Cargo.toml change
2024-03-05 15:51:15 +08:00
Boshen
bf42158ad7
perf(parser): inline end_span and parse_identifier_kind which are on the hot path ( #2612 )
2024-03-05 15:39:53 +08:00
Boshen
49778abb80
fix(ast): temporary fix tsify not generating some typings ( #2611 )
...
seems like a bug in tsify
2024-03-05 14:13:28 +08:00
Boshen
1db307abbf
feat(ast): serialize BindingPattern to estree ( #2610 )
2024-03-05 13:48:43 +08:00
Arnaud Barré
97aa9cfd54
fix(parser): fix span end for TSEmptyBodyFunctionExpression ( #2606 )
...
https://oxc-project.github.io/oxc/playground/?code=3YCAAICXgICAgICAgICxG4jI43W9aqTWr3WzyAs1pNu4fnf%2FXXEB3Yt%2FfiBIgA%3D%3D
The conformance test are going back to initial state. I think the `.asi`
should be smarter, i can rethink that later
---------
Co-authored-by: Boshen <boshenc@gmail.com>
2024-03-05 12:45:11 +08:00
Dunqing
7a12514151
fix(transformer/decorators): missing check private function ( #2607 )
2024-03-05 11:37:00 +08:00
cinchen
35ce3ccdc0
feat(linter): eslint-plugin-jest: prefer-to-have-length ( #2580 )
...
Rule Detail:
[link](https://github.com/jest-community/eslint-plugin-jest/blob/main/src/rules/prefer-to-have-length.ts )
2024-03-05 09:15:19 +08:00
Wenzhe Wang
951297ee59
fix(linter): avoid crash if no members in TSTypeLiteral in typescript/prefer-function-type ( #2604 )
2024-03-04 22:57:02 +08:00
Arnaud Barré
f6709e4737
feat(ast): serialize identifiers to ESTree ( #2521 )
2024-03-04 14:53:33 +00:00
Boshen
e2d2ce3369
feat(parser): parse decorators properly ( #2603 )
...
closes #2562
2024-03-04 19:30:41 +08:00
Boshen
7cc90134d3
fix: broken build from codegen API change
2024-03-04 19:24:06 +08:00
cinchen
212f128b33
feat(linter): eslint-plugin-jest: prefer-strict-equal ( #2581 )
...
Rule detail:
[link](https://github.com/jest-community/eslint-plugin-jest/blob/main/src/rules/prefer-strict-equal.ts )
2024-03-04 16:36:08 +08:00
Boshen
ef932a3c27
refactor(codegen): clean up API around building sourcemaps ( #2602 )
...
closes #2564
2024-03-04 16:03:33 +08:00
Boshen
20c7bf7835
feat(ast): add AssignmentTargetRest ( #2601 )
...
closes #2598
2024-03-04 14:31:22 +08:00
Boshen
9cc960e591
fix(parser): fix duplicated comments during parser rewind ( #2600 )
...
closes #2592
2024-03-04 14:07:33 +08:00
Boshen
6b42233628
feat(playground): display comments ( #2599 )
2024-03-04 14:02:22 +08:00
overlookmotel
b7f5c63833
perf(codegen): speed up generating sourcemap mappings ( #2597 )
...
This PR optimizes the `update_generated_line_and_column` function used in generating source maps.
The main change is that `generated_column` only depends on the last line, so just spin through bytes to find the last line break, and then only convert last line UTF-8 to UTF-16. There's also a fast path for when last line is ASCII, to avoid iterating over the last line twice in that common case.
2024-03-04 12:46:32 +08:00
overlookmotel
42fa8ebbc2
perf(codegen): speed up building sourcemap line tables ( #2591 )
...
Speed up building the line tables for source maps, using same kind of techniques as have been using in the lexer:
* Iterate byte-by-byte not char-by-char (`chars` iterator is slow).
* Fast path for ASCII (common case).
2024-03-04 12:40:39 +08:00
overlookmotel
ea30fd5b12
fix(codegen): fix adding mapping to sourcemaps ( #2590 )
...
Fix creating a sourcemap mapping when last byte of output in `\r`. Currently this panics because it assumes there's another byte after it when checking for `\n`, and reads out of bounds.
2024-03-04 12:33:28 +08:00
Arnaud Barré
24d46bccb5
fix(parser): fix span start for TSModuleDeclaration ( #2593 )
...
[playground](https://oxc-project.github.io/oxc/playground/?code=3YCAAICZgICAgICAgICymcgR7351T2PErukD7UXVyom%2F90VSbC7jSaCgoj9%2BqCyA )
---------
Co-authored-by: Boshen <boshenc@gmail.com>
2024-03-04 04:29:32 +00:00
Arnaud Barré
f66059e91b
fix(ast)!: align TSImportType with ESTree ( #2578 )
...
Implements
https://github.com/typescript-eslint/typescript-eslint/issues/2998
The copy of props feels wrong, but could not get it working otherwise
with the box and borrow things 😅
Also I found that TSImportType was missing some entries for visitors and
codegen.
In the case of codegen I'm not really understand the need as all the
types seems to be dismissed?
2024-03-04 12:28:18 +08:00
overlookmotel
fe29fa4797
fix(codegen): correct sourcemaps when Windows line breaks + unicode ( #2584 )
...
Fix source mapping of Window-style line breaks in presence of Unicode chars.
`content.chars().nth(i + 1)` gets the `i + 1`th *char*, but `i` is a byte offset not a char offset.
The replacement `content.as_bytes().get(i + 1)` gets the `i + 1`th *byte*, and should also be faster as doesn't require iterating through `chars` again.
2024-03-04 12:27:28 +08:00
overlookmotel
517026b1db
fix(codegen): correct sourcemaps when unicode chars ( #2583 )
...
#2565 added source map support in codegen. But there was a bug in creating the line offset tables for Unicode. This PR fixes that.
This function could probably be made more efficient, but I think this at least makes it correct.
2024-03-04 12:22:47 +08:00
Dunqing
c09c602ea0
fix(linter): exclude typescript syntax function in only_used_in_recursion ( #2595 )
...
close : #2559
2024-03-04 11:43:32 +08:00
Arnaud Barré
ac520d01a9
fix(parser): fix span start for TSExportAssignment ( #2594 )
...
[playground](https://oxc-project.github.io/oxc/playground/?code=3YCAAIDRgICAgICAgICymcgR7351T2PErukD7UXVyom%2F90V9gN2l18vERCm6ABJAvuZFDanGfdTjE8wAVsdwZMQHIswA2DgraPxXUAF2ua%2F8b0XoyRw%2FfyXZIIA%3D )
2024-03-04 11:41:23 +08:00
Arnaud Barré
1d657134ea
fix(ast): expose NumericLiteral.raw ( #2588 )
...
This is needed for Prettier to preserve the base when printing numbers.
This is not in the spec but available in both Babel and TSESLint.
2024-03-04 11:34:42 +08:00
Arnaud Barré
9d4e255a73
feat(playground): support TS codegen ( #2587 )
2024-03-04 11:33:48 +08:00
renovate[bot]
9bd1d5b25e
chore(deps): update rust crates ( #2589 )
2024-03-04 11:23:06 +08:00
renovate[bot]
00b9c0b698
chore(deps): update dependency @codemirror/autocomplete to v6.13.0 ( #2586 )
2024-03-04 10:47:51 +08:00
renovate[bot]
00368f3d45
chore(deps): update dependency @types/node to v20.11.24 ( #2585 )
2024-03-04 10:47:42 +08:00
Arnaud Barré
d9cc429d4a
fix(parser): parse empty method declaration as TSEmptyBodyFunctionExpression ( #2574 )
...
That a tricky one, because it's time to decide what does ESTree
compliant means in the TS world (re #2463 )
This code:
```ts
export declare class ByteBuffer {
clear(): void;
// ^^
}
```
- Is parsed by
[Babel](d38530204e )
as `FunctionExpression` with an empty body
- By
[TS-ESLint](4ea4e2feb5 )
as
[TSEmptyBodyFunctionExpression](https://github.com/typescript-eslint/typescript-eslint/pull/1289 )
- By
[OXC](https://oxc-project.github.io/oxc/playground/?code=3YCAAIC1gICAgICAgICyHorESipoTXPdvBaE9wxzlOraoWs19SUxDvdcwSVU0kbBO2b7ppX3x2P5IhQlpGHOYEHNCEfLf38HUICA )
as `TSDeclareFunction`
I'm going the easy way to fix this to the Babel way, but I think
following TS-ESLint would make sense. There is an [open babel
issue](https://github.com/babel/babel/issues/13878 ) about that.
Edit: Ok that not so easy and require updating some logic.
---------
Co-authored-by: Boshen <boshenc@gmail.com>
2024-03-03 13:59:17 +00:00
Boshen
9479865d9b
feat(napi/parser): expose preserveParans option ( #2582 )
...
closes #2576
2024-03-03 15:18:47 +08:00
Arnaud Barré
637cd1dea4
fix(ast): support TSIndexSignature.readonly ( #2579 )
...
[playground](https://oxc-project.github.io/oxc/playground/?code=3YCAAIDKgICAgICAgIC0GwpuZs97oWDqPM4xvCuoRB73mPOSrYb%2BTQEZf3b8RF0G%2B60jF5tYXUE9Me2%2FmMqVEwVy%2FiBIlyIMX6PqBpqsSmIXTJcsRqi4f3%2Bj6ICA )
2024-03-03 14:58:57 +08:00
Boshen
8bb1084863
feat(codegen): add sourcemap ( #2565 )
...
Co-authored-by: underfin <2218301630@qq.com>
2024-03-03 14:44:49 +08:00
Arnaud Barré
258b9b1c14
fix(ast): support FormalParameter.override ( #2577 )
...
This
[code](https://oxc-project.github.io/oxc/playground/?code=3YCAAIC1gICAgICAgICxG4jI43W9aqTWr3WzyA0TqSOjtB34F78iblvTQruFcqR6BUbbiLtWhj5rEL0NnFkDs4pF3dHiw39X7YCA )
can't be represented in the current OXC AST:
```ts
class Foo {
constructor(override bar: string) {}
}
```
2024-03-03 14:41:42 +08:00
Arnaud Barré
78f30bc2db
fix(ast): change TSMappedType.type_annotation from TSTypeAnnotation to TSType ( #2571 )
...
Is ESTree, in that special case, there is no TSTypeAnnotation wrapper:
(See `type X` in each)
- [oxc
playground](https://oxc-project.github.io/oxc/playground/?code=3YCAAIAWgICAgICAgICyHorESipoToAAwTlix58geR2%2Beeu9rZHQZOqK%2B%2BX85ZQ9ldchOoVw2oAm2qi9okF3bJ9o4l78ENP3f%2Bc%2B8cIK6Itp%2B3SIInU72Vk0%2FSqawy1VNV5zTgBr7gOpGtUZsvkc12Yp8MC2shel9fbpgDySpYsWdgDhf3jVlIA%3D )
- [astexplorer TSESLint
parser](9fc767f3a5 )
- [astexplorer Babel
parser](9a4b02fae1 )
---------
Co-authored-by: Boshen <boshenc@gmail.com>
2024-03-03 14:38:45 +08:00