overlookmotel
c8fa2eb17a
docs(codegen): correct and reformat doc comments for CodeBuffer ( #6504 )
...
Comment about `take_source_text` was erroneous. Clean up and reformat other doc comments.
2024-10-13 11:10:09 +00:00
Boshen
6f2253886d
feat(ecmascript): add ToBoolean, ToNumber, ToString ( #6502 )
2024-10-13 11:03:08 +00:00
overlookmotel
fc536a5648
refactor(codegen): inline CodeBuffer methods ( #6501 )
...
These methods are all either trivial, or delegate to another method.
2024-10-13 10:55:07 +00:00
overlookmotel
40d1ee4588
docs(codegen): fix and reformat CodeBuffer examples ( #6499 )
...
Fix examples which would not compile.
2024-10-13 10:49:37 +00:00
overlookmotel
c45723be77
refactor(parser): fix typo in var name ( #6500 )
2024-10-13 10:14:37 +00:00
overlookmotel
74206204dd
refactor(codegen): add CodeBuffer::as_bytes method ( #6498 )
...
`as_bytes` is clearer than `as_ref` (what kind of ref?)
2024-10-13 10:05:10 +00:00
overlookmotel
d816b0bd0e
test(codegen): add test for CodeBuffer::print_byte_unchecked ( #6497 )
...
Add test, and rename the rest of the test functions for `CodeBuffer`.
2024-10-13 09:51:50 +00:00
overlookmotel
8ae174bd36
refactor(codegen): rename CodeBuffer::print_byte_unchecked method ( #6496 )
...
Pure refactor. `*_unchecked` is the conventional name for unsafe methods, not `*_unsafe`.
2024-10-13 09:51:49 +00:00
overlookmotel
5843e01bed
refactor(codegen): shorten CodeBuffer::take_source_text ( #6495 )
...
Pure refactor.
2024-10-13 09:51:47 +00:00
overlookmotel
951def6e35
refactor(codegen): clarify safety comments in CodeBuffer ( #6494 )
2024-10-13 09:36:40 +00:00
overlookmotel
84a51ee576
refactor(codegen): rename vars in CodeBuffer ( #6493 )
...
Pure refactor. Just rename vars.
2024-10-13 09:36:39 +00:00
overlookmotel
05bd616d88
refactor(codegen): add line break ( #6492 )
2024-10-13 09:27:42 +00:00
DonIsaac
204bf5533e
refactor(codegen): add CodeBuffer to fix soundness hole ( #6148 )
...
# What This PR Does
Adds `CodeBuffer`, a simple wrapper over a `Vec<u8>` with a protective and reduced API for upholding UTF-8 validity guarantees. Closes #6147 .
Note that this struct is actually quite small. Most of the added lines are doc comments.
2024-10-13 09:14:48 +00:00
Dunqing
8fe1b0a0f8
feat(transformer): support helper loader ( #6162 )
...
Close : #4753
2024-10-13 08:09:08 +00:00
Dunqing
ab51c2ae90
feat(transformer): support DefaultImport in ModuleImports ( #6434 )
...
Support import like `import React from 'react';` by `ModuleImports`
The usage is:
```rs
self.ctx.module_imports.add_import(
Atom::from("react"),
ImportKind::new_default(Atom::from("React")),
symbol_id
)
2024-10-13 08:09:07 +00:00
Dunqing
02bfbfeef5
fix(codegen): preserve parenthesis for ChainExpression ( #6430 )
...
close : #6385
The fixing way was referenced from `esbuild`, it is according to these [states](332727499e/internal/js_ast/js_ast.go (L590-L604)
)(determined in the parser) to determine whether to print parenthesis
Due to differences in implementation details, we are unable to record certain information like `esbuild` does in its parser. But fortunately, The `ParenthesisExpression` AST is actually like what `esbuild` stored states.
2024-10-13 08:03:37 +00:00
Boshen
c56343d1f3
feat(linter): promote no_unsafe_optional_chaining to correctness ( #6491 )
...
It's in the eslint recommended list https://eslint.org/docs/latest/rules/no-unsafe-optional-chaining
2024-10-13 07:58:01 +00:00
IWANABETHATGUY
1a93033b7b
feat(oxc_language_server): add diagnostic code with link ( #6487 )
...
1. follow #6479
2. Adding related doc link to lsp diagnostic code.
## Preview

**after click**

The UI looks a little wired, due to aba9ea3f1d/crates/oxc_diagnostics/src/lib.rs (L113-L120) ,
I suggest change the code above to
```rs
format!("{scope}/{number}")
```
2024-10-13 07:07:43 +00:00
camc314
2ade16ece5
fix(codegen): invalid codegen when in inside bin expr in or loop ( #6431 )
...
https://github.com/oxc-project/monitor-oxc/actions/runs/11278829870 ??
2024-10-13 06:47:10 +00:00
camc314
6896efc00c
fix(codegen): fix in in sequence expr in for loops ( #6428 )
...
not sure if this is right, but it doesn't break any existing tests so hopefully?
2024-10-13 06:47:09 +00:00
camc314
096e590483
feat(minifier): implement folding charAt string fns ( #6436 )
2024-10-13 06:41:05 +00:00
camc314
e5a6f5de6a
feat(minifier): implement converting template literals to strings ( #6486 )
...
basically:
```
`hello ${"world"}`
```
now becomes:
```
"hello world"
```
2024-10-13 06:26:32 +00:00
camc314
14d0590b0b
feat(minifier): implement folding of simple function calls (Boolean) ( #6484 )
...
Basically `Boolean(true)` -> `true` or `Boolean(foo)` -> `!!foo`
2024-10-13 06:26:32 +00:00
camc314
7fbc7b6dae
feat(minifier): implement folding of simple function calls (String) ( #6483 )
...
basically `String(foo)` -> `foo + ''`
2024-10-13 06:26:31 +00:00
Tapan Prakash
bae5b7da27
chore(editors/vscode): Remove Prettier dependency entirely ( #6480 )
...
Previous PR removed the Prettier commands
(https://github.com/oxc-project/oxc/pull/6412 ), but the prettier
dependency was not fully removed. This PR aims to remove the dependency
from package.json entirely.
---------
Co-authored-by: Boshen <boshenc@gmail.com>
2024-10-13 14:25:49 +08:00
DonIsaac
58467a53a1
feat(parser): better handling of invalid modifiers ( #6482 )
...
## What This PR Does
1. Recover on, and provide a better message for, invalid `export` modifier on constructor parameters. Before, an `unexpected token` error would be produced and the parser would panic. Now, the parser recovers and produces a message saying `'export' modifier cannot appear on a parameter.`
```ts
class Foo {
constructor(export x: number) {}
}
```
2. Recover on, and provide a better message for, invalid modifiers on index signatures. Same recovery/message characteristics as above.
```ts
class Foo {
public [x: string]: string;
}
```
2024-10-13 03:16:02 +00:00
DonIsaac
8ea6b721b8
feat(parser): better errors for reserved words used as identifier names ( #6478 )
...
## What This PR Does
Provide better error messages when a reserved word is used as a `BindingIdentifier`
```ts
var const = 1;
export enum const {}
const if = 1;
```
2024-10-13 03:16:01 +00:00
IWANABETHATGUY
66dccc0584
feat(oxc_language_server): add related code for lsp_types::Diagnostic#source ( #6479 )
...
Closed #6477
# Before
# After


Compare to eslint:

we could polish in the feature and link to
`lsp_types::Diagnostic#source`
2024-10-13 01:53:05 +08:00
dalaoshu
0784e74791
fix(linter): error fixer of switch-case-braces ( #6474 )
...
Related to #6466
This PR does not fundamentally solve the problem, we need to implement
`raw` or `value` for `RegExpLiteral`.
1ba2a247e1/crates/oxc_codegen/src/gen.rs (L1194-L1198)
1ba2a247e1/crates/oxc_ast/src/ast/literal.rs (L94-L101)
2024-10-13 00:15:08 +08:00
Boshen
bbca743689
refactor(minifier): move string methods to oxc_ecmascript ( #6472 )
2024-10-12 09:40:43 +00:00
Boshen
856cab5000
refactor(ecmascript): move ToInt32 from oxc_syntax to oxc_ecmascript ( #6471 )
2024-10-12 09:29:46 +00:00
Boshen
1ba2a247e1
refactor(ecmascript): remove HasProto which is not part of the spec ( #6470 )
2024-10-12 08:48:45 +00:00
Boshen
455dab4900
chore(oxc): rename crate oxc_syntax_operations to oxc_ecmascript ( #6469 )
2024-10-12 08:34:42 +00:00
7086cmd
702c049ebc
refactor(minifier): move compress block to dce ( #6468 )
2024-10-12 07:59:44 +00:00
Boshen
91c87dd380
refactor(codegen)!: remove Codegen::enableSourceMap API ( #6452 )
2024-10-12 04:56:43 +00:00
camc314
a4f57a42e8
feat(minifier): implement folding indexOf and lastIndexOf string fns ( #6435 )
2024-10-12 04:36:13 +00:00
DonIsaac
5ee1ef3d92
feat(allocator): add Vec::into_boxed_slice ( #6195 )
...
Note that this PR does not implement the inverse operation (`Box::to_vec` for `[T]`).
2024-10-12 04:29:43 +00:00
Alexander S.
7240ee23fc
refactor(linter): make advertised fix kinds consistent ( #6461 )
2024-10-11 19:25:32 -04:00
overlookmotel
b48c3683d6
refactor(linter): no_global_assign rule: reduce name lookups ( #6460 )
...
2 small optimizations to this lint rule:
1. Get the name for the symbol only once, rather than on each turn of the inner loop (every reference to a symbol has the same name by definition).
2. Avoid creating temporary `CompactStr`s, which causes an allocation if the string is longer than 24 bytes.
2024-10-11 20:53:35 +00:00
Boshen
7645e5c34b
refactor(codegen)!: remove CommentOptions API ( #6451 )
2024-10-11 13:53:28 +00:00
7086cmd
3677ef81e9
feat(minifier): dce ExpressionStatements with no side effect ( #6457 )
...
Not sure about the performance. Just have a try.
2024-10-11 13:40:44 +00:00
dalaoshu
e81181261d
fix(linter): error diagnostic message based on parameter length of valid-expect ( #6455 )
2024-10-11 09:16:17 -04:00
overlookmotel
073b02af14
refactor(ast): type params field before params in TS function declaration types ( #6391 )
...
Our convention is that AST type fields are ordered in order they appear in source. Move `type_parameters` fields in TS function declaration types to before `this_param` and formal parameters.
2024-10-11 09:57:28 +00:00
7086cmd
06ea1216af
feat(minifier): fold for statement ( #6450 )
2024-10-11 08:33:23 +00:00
overlookmotel
85d93ed713
fix(transformer): arrow function transform: correctly resolve this in class accessor properties ( #6386 )
...
Correctly resolve scope of `this` in class accessor properties.
The omission of this case became clear from examining Babel's `environmentVisitor`:
f343c499b0/packages/babel-traverse/src/visitors.ts (L398-L436)
2024-10-11 07:09:56 +00:00
Boshen
cb8f4210c3
refactor(prettier)!: remove source_text argument from constructor ( #6448 )
2024-10-11 06:27:33 +00:00
Boshen
520096030a
refactor(oxc)!: remove passing Trivias around ( #6446 )
...
part of #6426
2024-10-11 06:09:25 +00:00
Boshen
2808973af3
feat(ast)!: add Program::comments ( #6445 )
2024-10-11 04:47:36 +00:00
Boshen
2b7be08af4
feat(ast)! add source_text to Program ( #6444 )
2024-10-11 04:13:41 +00:00
Boshen
4d8bc8c8af
perf(parser): precompute is_typescript ( #6443 )
2024-10-11 03:39:38 +00:00