Commit graph

7101 commits

Author SHA1 Message Date
camc314
f029090d65 docs(linter): update rule documentation (#7684) 2024-12-05 16:17:46 +00:00
camc314
be9863a415 test(linter): add more tests fo rules-of-hooks (#7683)
closes #6651
2024-12-05 15:18:14 +00:00
overlookmotel
1925ddc59b refactor(transformer): rename VarDeclarationsStore methods (#7682)
Follow-on after #7668. Rename `create_var*` methods to `create_uid_var*`.

Previous method name `create_var` might suggest that it creates a binding with the provided name. But actually it creates a UID with name *based on* the name provided.
2024-12-05 15:09:24 +00:00
Dunqing
583b36b6bf docs(transformer/class-properties): remove oudated todo (#7669) 2024-12-05 14:46:56 +00:00
Dunqing
3d593ec2eb refactor(var-declarations): remove unnecessary init parameter from insert_var (#7668)
If we want to pass `init`, we should use `insert_var_with_init`
2024-12-05 14:38:40 +00:00
Dunqing
e8518e942c feat(transformer/var-declarations): add insert_var_with_init method (#7667)
part of #7668
2024-12-05 14:38:39 +00:00
Dunqing
0ca10e270a refactor(transformer): use ctx.var_declarations.create_var* methods (#7666)
It turns out these APIs are very useful, we remove many boilerplate code.
2024-12-05 14:31:20 +00:00
camc314
4e489bdf0a docs(linter): update rule documentation (#7681)
part of #6050
2024-12-05 14:09:30 +00:00
Dunqing
8705a291e2 feat(transformer/var-declaration): add a series of create_var* methods (#7665)
part of #7666.

These methods aim to combine generate binding and insert var into one method.
2024-12-05 13:52:58 +00:00
Dunqing
ff73c7ffde feat(traverse): add TraverseCtx::generate_uid_in_current_hoist_scope_based_on_node (#7642)
We have a lot of usage for this API in `class-properties`
2024-12-05 13:41:43 +00:00
overlookmotel
3de4a43761 test(minifier): reformat minsize table (#7678)
Reformat the table which `minsize` task outputs. I always found the column headings confusing previously.
2024-12-05 12:16:29 +00:00
Cameron
56fe5f8bb9
docs(linter): update rule documentation (#7680)
part of #6050
2024-12-05 20:14:42 +08:00
Boshen
00fea9285b feat(napi/parser): expose span positions of import.meta (#7677) 2024-12-05 11:03:52 +00:00
Boshen
e64fd9556d feat(linter): map .js to .ts when resolving with tsconfig.json (#7675)
fixes #6913
closes #6906
2024-12-05 09:07:23 +00:00
Boshen
b8dc333ed4 feat(syntax): add ExportEntry::is_type (#7676) 2024-12-05 09:02:18 +00:00
Kevin Deng 三咲智子
245d7d922c
fix(oxc_transformer): alias es2015 to es6 (#7673)
Supported in
[esbuild](https://esbuild.github.io/try/#dAAwLjI0LjAALS10YXJnZXQ9ZXM2ADEqKjI)
2024-12-05 16:26:05 +08:00
Boshen
d0b78f7361 feat(codegen): minify whitespace for some expressions (#7671)
part of #7638
2024-12-05 06:59:17 +00:00
Boshen
6ae178e0b9 fix(linter): ignore type references in no-undef (#7670)
fixes #7007
fixes #7008
2024-12-05 05:36:54 +00:00
overlookmotel
a0973dcb5a refactor(linter): use BigIntLiteral::raw field (#7660)
No need to slice source text to get raw value of `BigIntLiteral`. It already has a `raw` field.
2024-12-05 04:23:14 +00:00
camc314
3711a8e342 refactor(linter): rename is_same_reference to is_same_expression (#7654) 2024-12-05 04:15:15 +00:00
overlookmotel
2179b93729 fix(estree): make type of BigIntLiteral::raw prop in ESTree AST optional (#7663)
`BigIntLiteral`'s `raw` field is not an `Option` on Rust side, but this is an internal implementation detail - we may parse bigints to a `BigInt` in future (as we did in the past before we hit a memory leak problem), and make `raw` an `Option`.

So at present, the `raw` field is always non-null in JS-side AST. But update the TS type def to reflect that it should be an optional property. This aligns with ESTree.
2024-12-05 04:00:57 +00:00
overlookmotel
cbba26c237 fix(estree): raw: null in ESTree AST for generated NullLiterals (#7662)
In JS-side AST, leave `raw` field as `null` for `NullLiteral`s, if they are generated and have no raw representation in source text.
2024-12-05 04:00:56 +00:00
overlookmotel
1d59fc8353 fix(estree): raw: null in ESTree AST for generated BooleanLiterals (#7661)
In JS-side AST, leave `raw` field as `null` for `BooleanLiteral`s, if they are generated and have no raw representation in source text.
2024-12-05 04:00:55 +00:00
overlookmotel
8993e893a0 refactor(ast): shorten code (#7659)
Pure refactor. Shorten code - `Vec` instead of `std::vec::Vec`.
2024-12-05 01:16:16 +00:00
overlookmotel
746c8aaa4f refactor(ast): rename vars (#7658)
Pure refactor. Rename vars in serialization code. `value.value` is a bit confusing.
2024-12-05 01:16:15 +00:00
overlookmotel
ad76d1d72d fix(transformer/class-properties): transform delete chain expression in static prop initializers (#7656)
Follow-on after #7575. Annoyingly, we have to transform private fields in static prop initializers separately, to make sure the stack of private properties is in sync while visiting them.
2024-12-05 01:07:18 +00:00
overlookmotel
44fe854231 refactor(transformer/class-properties): move logic for handling delete of chain expression into transform_unary_expression (#7655)
Follow-on after #7575. Pure refactor. Move all logic for transforming `delete <chain expression>` into the handler `transform_unary_expression`. Aim is to keep logic in one place and keep the main visitor as simple as possible.
2024-12-05 01:07:17 +00:00
overlookmotel
6c82589daf perf(transformer/class-properties): replace recursion with loop (#7652)
Follow-on after #7575. Small optimization. Replace recursive function calls with a loop.
2024-12-05 01:01:11 +00:00
overlookmotel
0c9cc48806 style(ast): import Atom (#7657)
Code style refactor. Import `Atom` at top of file to shorten code.
2024-12-05 00:53:38 +00:00
Song Gao
ebc80f6749
refactor(ast)!: change 'raw' from &str to Option<Atom> (#7547)
Fix #7254 

Changed all "raw" properties of literal types (if they have this property) to `Option<Atom>`.

---------

Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
2024-12-05 00:34:45 +00:00
overlookmotel
e5145b0083 style(transformer/class-properties): reformat doc comments (#7653)
Follow-on after #7575. By convention we use backticks for code snippets in doc comments.
2024-12-04 20:43:02 +00:00
Boshen
c523ccb7ef feat(codegen): better whitespace minification for import / export statements (#7650)
part of #7638
2024-12-04 19:24:03 +00:00
Dunqing
c793d71a78 feat(transformer/class-properties): transform ChainExpression (#7575)
Fully support transforming ChainExpression in class properties. Our implementation has some differences in execution order compared to Babel, but we have passed all execution-related tests.
2024-12-04 16:52:57 +00:00
tbashiyy
bd9d38a9a0
feat(linter): Implement eslint:yoda (#7559)
In this PR, implement
[eslint:yoda](https://eslint.org/docs/latest/rules/yoda)

ref: https://github.com/oxc-project/oxc/issues/479
2024-12-04 15:58:21 +00:00
Boshen
690fc54cdb
ci(deny.yml): check for deny.toml 2024-12-04 23:41:31 +08:00
Boshen
8c0b0ee2bd fix(parser): better diagnostic for invalid for await syntax (#7649) 2024-12-04 15:18:29 +00:00
Boshen
1de2842f8e feat(napi/parser): return EcmaScriptModule::hasModuleSyntax (#7647) 2024-12-04 13:00:47 +00:00
Boshen
36d14932ff refactor(parser): use ModuleRecord::has_module_syntax for setting sourceType (#7646) 2024-12-04 12:52:21 +00:00
Boshen
d503a84d57 perf(parser): reorder parse_statement match conditions (#7645)
For performance reasons, match orders are:
1. plain if check
2. check current token
3. peek token
2024-12-04 12:31:48 +00:00
Boshen
e923e4ee46 perf(parser): inline all token kind checks (#7644) 2024-12-04 12:23:51 +00:00
oxc-bot
fee2143f4c
release(crates): v0.39.0 (#7643) 2024-12-04 19:43:22 +08:00
IWANABETHATGUY
64f92e9cb4
fix(oxc_transform): oxc dot define is postfix of some MemberExpr (#7640)
Closed https://github.com/oxc-project/oxc/issues/7598
2024-12-04 19:18:19 +08:00
Yuji Sugiura
0ce7ce7ff4
refactor(prettier): Revive doc macro (#7639)
As @Boshen advised, reintroduced the macro.


https://github.com/oxc-project/oxc/pull/7639/files#diff-18e08d6e3a6853a2ae1a973ab1615ee04ed585638eef92c8c1e49f7814f6193f

It feels addictive...! 🤩
2024-12-04 16:58:00 +08:00
Boshen
e787e9d41a fix(codegen): print parentheses correctly for ClassHeritage (#7637)
closes #7631
2024-12-04 06:43:32 +00:00
Boshen
d2767bea62 feat(semantic): syntax error for delete object?.#a (#7636)
closes #7603
2024-12-04 05:33:05 +00:00
Boshen
1486849ec2 fix(semantic): syntax error for undeclared private field access (#7635)
closes #7582
2024-12-04 05:33:04 +00:00
camc314
a14e76aade feat(linter): report identical logical expressions in const-comparisons (#7630) 2024-12-04 03:10:17 +00:00
camc314
afe1e9b929 feat(linter): enhance const-comparisons for more cases (#7628) 2024-12-04 02:59:56 +00:00
camc314
b445654fbd refactor(linter): use get_inner_expression in const-comparisons (#7627) 2024-12-04 02:59:55 +00:00
overlookmotel
3b1e63ecab perf(transformer/jsx): no string comparisons generating pragma expression (#7620)
#7553 introduced support for some unusual JSX pragmas e.g. `this.foo` and `import.meta.foo`. We want to support these to pass tests, but they're very unlikely to be used in practice.

Identify these strange patterns when parsing the pragma (which happens only once per file), and encode them as an enum. The removes expensive string comparisons from `Pragma::create_expression` (which is called for every JSX element), and keeps the path for common cases fast.
2024-12-04 02:47:28 +00:00