Commit graph

5312 commits

Author SHA1 Message Date
rzvxa
90facd3657 feat(ast): add ContentHash trait; remove noop Hash implementation from Span (#5451)
closes #5283

Also removes the noop Hash implementation on `Span` in favor of a real implementation.
2024-09-05 07:20:04 +03:30
mysteryven
5187f384cb fix(linter/tree-shaking): detect the correct export symbol resolution (#5467)
fixes: #5455
2024-09-05 03:05:46 +00:00
overlookmotel
cba93f52d0 feat(ast)!: add ThisExpression variants to JSXElementName and JSXMemberExpressionObject (#5466)
Close #5352.

Add to AST:

* `JSXElementName::ThisExpression` (`<this>`)
* `JSXMemberExpressionObject::ThisExpression` (`<this.foo>`, `<this.foo.bar>`)
2024-09-05 02:06:20 +00:00
overlookmotel
82c0a167c4 fix(linter): tree_shaking/no_side_effects_in_initialization handle JSX correctly (#5450)
#5223 altered `JSXElementName` so `JSXElementName::Identifier` is used only for non-reference JSX names (e.g. `<div>`). `JSXElementName::IdentifierReference` is used where the name is a reference (e.g. `<Foo>`). Similarly `JSXMemberExpressionObject`'s `object` is always an `IdentifierReference` now.

So, the net result is that `JSXIdentifier` is now never a reference, it's just the JSX equivalent of `IdentifierName`. So I don't think `JSXIdentifier` can ever have side-effects.

This PR:

1. Removes `impl ListenerMap for JSXIdentifier`
2. Adds `impl ListenerMap for JSXMemberExpression` and makes sure the root `IdentifierReference` (`Foo` in `<Foo.bar.qux>`) is visited.
2024-09-05 02:06:19 +00:00
Dunqing
e4ed41d4fa refactor(semantic): change the reference flag to ReferenceFlags::Type if it is used within a TSTypeQuery (#5444)
So far, the `ReferenceFlags::TSTypeQuery` only used indicates it is referenced by `TSTypeQuery` that we can confirm the reference should be regarded as a type reference, namely `ReferenceFlags::Type`.

This PR adds a `ReferenceFlags::ValueAsType` instead of `ReferenceFlags::TSTypeQuery`.  The new flag has the same behavior as the previous one. But it looks more general and is not only used in `TSTypeQuery`. But now it is a temporary flag. We use it to resolve the symbol correctly and replace `ReferenceFlags::ValueAsTyoe` with `ReferenceFlags::Type` after resolved.

Also, this change eliminates the inconsistency in behavior between the `Reference::is_type` and `ReferenceFlags::is_type` methods.
2024-09-05 01:50:20 +00:00
Dunqing
d8b9909bd8 fix(semantic): IdentifierReference within TSPropertySignature cannot reference type-only import binding (#5441)
close: #5435

The behavior of `IdentifierReference` in `TSPropertySignature` is the same as in `TSTypeQuery`, both allow only reference value bindings and type-only import bindings.

I still use `ReferenceFlags::TSTypeQuery` here because I want to avoid producing many changes unrelated to the bug in this PR. I will refactor it in the follow-up PR soon
2024-09-05 01:50:18 +00:00
DonIsaac
0f50b1ed6d feat(semantic): check for initializers in ambient VariableDeclarations (#5463) 2024-09-05 01:33:11 +00:00
DonIsaac
62f7fff88f feat(semantic): check for non-declared, non-abstract object accessors without bodies (#5461) 2024-09-05 01:33:10 +00:00
DonIsaac
540714393a feat(semantic): check for non-declared, non-abstract class accessors without bodies (#5460)
This should be causing more negative tests to fail than it actually is. This is
because our typescript coverage tests use the "declarations" option to change
the source type to `.d.ts`, which is incorrect. This setting enables `.d.ts`
emits, it does not mean that input files should be treated as `.d.ts`
themselves.
2024-09-05 01:33:09 +00:00
DonIsaac
052e94c94e feat(semantic): check for parameter properties in constructor overloads (#5459)
Adds checks for
```
A parameter property is only allowed in a constructor implementation.ts(2369)
```
2024-09-05 01:33:07 +00:00
overlookmotel
87c5df2226 refactor(ast)!: rename Expression::without_parentheses (#5448)
Rename `without_parenthesized` to `without_parentheses`. Both are hard-to-spell words, but "without parenthesized" does not make sense.
2024-09-05 01:25:00 +00:00
overlookmotel
a43e9512f3 refactor(ast): use loop instead of recursion (#5447)
Use loop instead of recursive function call. Loops are usually cheaper.
2024-09-05 01:24:59 +00:00
overlookmotel
6285a02274 fix(linter): eslint/radix rule correctly check for unbound symbols (#5446)
`SymbolTable::get_symbol_id_from_name(name).is_none()` is not always correct, because it will return `false` if there is a binding *anywhere* in the AST with that name, whereas what we actually want to know is whether *this* `IdentifierReference` is referring to a global or not.

Instead, look up whether this reference is resolved or not using `SymbolTable::is_global_reference`.

The 3 test cases added were not working prior to this change.
2024-09-05 01:18:24 +00:00
overlookmotel
2224cc4e62 refactor(ast): renumber JSXMemberExpressionObject discriminants (#5464)
Number discriminants starting at 0, not 1. This likely makes no difference, but starting numbering at 1 seems odd.
2024-09-04 22:59:53 +00:00
overlookmotel
a952c47265 refactor(ast): use loop not recursion (#5449)
`Expression::get_inner_expression` and `Expression::get_inner_expression_mut` use a loop rather than recursive function calls. Loops are usually cheaper.
2024-09-04 20:24:45 +00:00
overlookmotel
1d3e973f10 refactor(linter): simplify eslint/radix rule (#5445)
Refactor to remove duplicate logic.
2024-09-04 16:52:27 +00:00
Boshen
9c937e06e8 fix(benchmark): do not measure initialization of transformer options (#5442)
relates #5267
2024-09-04 14:52:21 +00:00
Boshen
10279f55d9 feat(parser): add syntax error for hyphen in JSXMemberExpression <Foo.bar-baz /> (#5440)
closes #5355
2024-09-04 14:09:06 +00:00
rzvxa
fdb8857630 refactor(linter): use "parsed pattern" in no_div_regex rule. (#5417)
Part of #5416, Paves the road for upcoming refactors by adding the `oxc_regular_expression` dependency and a helper method for ease of access.
2024-09-04 14:00:47 +00:00
Jelle van der Waa
aff2c71423
feat(linter/react): implement self-closing-comp (#5415)
Rule Detail:


[link](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md)

Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-09-04 10:00:23 -04:00
Boshen
ba4b68cf63 feat(minifier): remove parenthesized expression for dce (#5439)
relates #5436
2024-09-04 12:58:39 +00:00
overlookmotel
d9d7e7c596 refactor(ast): remove IdentifierName from TSThisParameter (#5327)
`TSThisParameter` does not need to include an `IdentifierName` which is always "this". Just storing the `Span` is sufficient.
2024-09-04 12:46:53 +00:00
Jelle van der Waa
81709549d9
perf(linter/react): add should_run conditions for react rules (#5402) 2024-09-04 08:37:15 -04:00
dalaoshu
f89c776ac4
chore(linter/vitest): improve docs for vitest rules (#5428) 2024-09-04 08:29:57 -04:00
rzvxa
23285f431d feat(ast): add ContentEq trait. (#5427)
Part of #5283
2024-09-04 11:53:50 +00:00
Dunqing
c78291600e feat(codegen): print type_parameters in TaggedTemplateExpression (#5438) 2024-09-04 11:24:04 +00:00
IWANABETHATGUY
caf800700d
chore(justfile): bundle wasm with different flag (#5433)
1. wasm-pack with release flag will increase wasm bundling time, which
hurts dx when developing playground.
2. only enable `release` flag when `build-wasm`.
2024-09-04 13:30:48 +08:00
Boshen
f7f63bc3e2
chore(README): update playground link 2024-09-04 12:18:24 +08:00
Boshen
cd0516752c
chore(justfile): build-wasm should build in prod 2024-09-04 08:58:14 +08:00
overlookmotel
e7bd49dae4 refactor(regular_expression): correct typo (#5429)
Just correct a misspelling.
2024-09-04 00:54:22 +00:00
Dunqing
c984219e06 refactor(transformer/typescript): move all entry points to implementation of Traverse trait (#5422) 2024-09-03 18:26:20 +00:00
Dunqing
0617249716 fix(transformer/nullish-coalescing-operator): incorrect reference flags (#5408)
Fixes an obvious problem
2024-09-03 15:29:07 +00:00
overlookmotel
cfe54974f1 fix(transformer): do not create double reference in JSX transform (#5414)
Follow on after #5358. Don't create a new `IdentifierReference` with a new `ReferenceId` when we already have one which is correctly resolved.
2024-09-03 15:06:07 +00:00
overlookmotel
b9ef357868 test(transformer): add tests for nested JSX this member expressions in arrow function transform (#5413)
Follow-up after #5356. Handle nested JSX member expressions with `this` as base object in arrow functions transform (e.g. `<this.foo.bar />`).
2024-09-03 15:06:06 +00:00
Boshen
51b15ca143
ci: set show-progress: false in clone-submodules 2024-09-03 22:03:34 +08:00
overlookmotel
bfabd8facc perf(syntax): further optimize is_identifier_name (#5426)
Follow-on after #5425. Further optimize `oxc_syntax::identifier::is_identifier_name` by processing string in blocks of 8 bytes, and checking if all bytes in a block are ASCII in one go, rather than testing each byte individually.
2024-09-03 13:48:36 +00:00
overlookmotel
aeda84f904 perf(syntax): optimize is_identifier_name (#5425)
Optimize `oxc_syntax::identifier::is_identifier_name`. Add a fast path for ASCII, which will be the common case. Only fall back to iterating over `char`s and using the more expensive test functions e.g. `is_identifier_start_unicode` if non-ASCII chars are found.
2024-09-03 12:48:32 +00:00
IWANABETHATGUY
3ccb065695
ci: make cargo coverage compile faster
It still runs fast
2024-09-03 20:22:37 +08:00
Dunqing
0eb32a6770 fix(traverse): invalid variable name generated by generate_uid_based_on_node (#5407)
close: #5371
2024-09-03 12:13:30 +00:00
IWANABETHATGUY
4cb63fea4d feat(index): impl rayon related to trait for IndexVec (#5421)
1. Impl `rayon` related trait for `oxc_index::IndexVec`
2024-09-03 12:01:57 +00:00
IWANABETHATGUY
00511fd6a8 docs: use oxc_index instead of index_vec in doc comments (#5423) 2024-09-03 11:57:27 +00:00
dalaoshu
4473779074
feat(linter/node): implement no-exports-assign (#5370) 2024-09-03 07:53:14 -04:00
Boshen
0a5780d328
ci: fix broken benchmark (#5424) 2024-09-03 18:21:39 +08:00
Boshen
b1d7440401
chore(deps): update oxc-browserslist to v1.0.3 2024-09-03 14:07:11 +08:00
Boshen
a03b24d94e
ci: add napi tests (#5419) 2024-09-03 12:24:58 +08:00
Boshen
b486a85405
ci: fix broken reusable_prepare_release.yml 2024-09-03 12:20:04 +08:00
Boshen
58bab2b52a
chore(regular_expression): prevent cargo shear wasm-bindgen 2024-09-03 12:16:47 +08:00
Boshen
310e05ca8e
ci: match autofix trigger with ci.yml 2024-09-03 12:05:02 +08:00
Boshen
a834424a41
ci: change commit message to follow conventional commit 2024-09-03 11:29:09 +08:00
Boshen
5a5fbcbec2
chore: format toml 2024-09-03 11:14:49 +08:00