Commit graph

4989 commits

Author SHA1 Message Date
Dunqing
a9fcf292fe refactor(transformer/es2016): move all entry points to implementation of Traverse trait (#5085)
follow-up #4881
2024-08-22 21:02:32 +00:00
Dunqing
178d1bd986 docs(transformer): add documentation for exponentiation-operator plugin (#5084)
follow-up #4881
2024-08-22 20:45:41 +00:00
Boshen
4b49cf8ce4 feat(transformer): always pass in symbols and scopes (#5087)
We no longer need to build semantic data inside the transformer.

The caller should be responsible for handling semantic data and its
errors.

The best way to achieve this in via `CompilerInterface`.

closes #3565
2024-08-22 16:06:31 +00:00
Don Isaac
841174f73c
feat(linter/no-unused-vars): delete non-root arrows, skip await (#5083)
This PR updates no-unused-var's fixer for `VariableDeclarator`s in two
ways:
1. Unused function expressions and arrow functions not declared in the
top scope
   will now be removed.
   ```ts
   // not deleted, no change
   const x = function() {}
   const y = (a) => a
   function z() {}

   // new behavior
   function foo() {            // <- not deleted
       const x = () => {}      // <- deleted
       const y = function() {} // <- this too
   }
   ```
2. Variables initialized to an `await` expression will not be deleted.
   ```ts
// unused await-initialized variables are often API calls with side
effects
   // in the real world; we don't want to delete these.
   const res = await createUser(data)
   ```
2024-08-22 11:48:27 -04:00
Boshen
2a5e15d03e
fix(npm): libc field should not be null
closes #4952
2024-08-22 23:29:22 +08:00
overlookmotel
a00bf18b9f refactor(semantic): add IdMapping to transform checker (#5079)
`IdMapping<Id>` wraps `FxHashMap<Id, Id>` for ease in dealing with ID types which are `Copy`.
2024-08-22 15:08:49 +00:00
overlookmotel
4a57086d79 fix(semantic): transform checker check symbol IDs (#5078) 2024-08-22 15:08:48 +00:00
overlookmotel
ea7d2163e3 fix(semantic): transform checker check symbol spans (#5076) 2024-08-22 15:08:47 +00:00
overlookmotel
b14a302ed0 refactor(semantic): transform checker: change symbol name mismatch error (#5075) 2024-08-22 15:08:46 +00:00
overlookmotel
1b6b27a6de fix(semantic): transform checker check symbol flags (#5074) 2024-08-22 15:08:45 +00:00
Boshen
78f135d686 refactor(ast)!: remove ReferenceFlag from IdentifierReference (#5077)
closes #4512
2024-08-22 14:30:50 +00:00
overlookmotel
b8c6ce5317 refactor(semantic): rename vars in transform checker (#5072)
Pure refactor. Just rename some vars for consistency.
2024-08-22 13:41:35 +00:00
Boshen
6d87b0f1f2 fix(semantic): fix error message for duplicated label (#5071) 2024-08-22 12:30:04 +00:00
Boshen
efbdced597 fix(parser): only show flow error if it's a flow file (#5069)
Otherwise we get a mixture of confusing error messages.
2024-08-22 12:19:45 +00:00
leaysgur
96f57984eb refactor(regular_expression): Misc refactoring for body_parser (#5062)
- Add examples to list all `RegExp`s in source code
- Refactor `MayContainStrings` related part
2024-08-22 11:21:41 +00:00
Dunqing
3b353321ad fix(transformer/logical-assignment-operators): fix semantic errors (#5047)
Fix semantic error caused by `clone_in` causing `reference_id` to not exist.

In this PR, I try to use `move_expression` as much as possible instead of `expr.clone_in`. But in some cases, we need to reuse the same expression in multiple places. I have added a `clone_expression` to workaround it

I felt a bit painful we missing a [clone_in_scope](https://github.com/oxc-project/oxc/issues/4804) API
2024-08-22 08:41:31 +00:00
Dunqing
deda6ac136 refactor(transformer/es2019): move all entry points to implementation of Traverse trait (#5065)
follow-up #4881
2024-08-22 08:34:44 +00:00
Dunqing
d50eb72399 docs(transformer): add documentation for optional-catch-binding plugin (#5064)
follow-up #4881
2024-08-22 08:34:42 +00:00
overlookmotel
f73d486d25 refactor: correct typos and standardize capitalization in Cargo.toml (#5063)
Nitty. Purely alters comments in `Cargo.toml`.
2024-08-22 07:42:55 +00:00
overlookmotel
f2b8d82499 refactor(semantic)!: ScopeTree::get_child_ids + get_child_ids_mut return value not Option (#5058)
Previously `ScopeTree::get_child_ids` and `ScopeTree::get_child_ids_mut` returned an `Option`. Instead return the unwrapped value, in line with other methods e.g. `get_flags`.
2024-08-22 05:57:55 +00:00
Boshen
afe728a73a feat(parser): parse regular expression with regex parser (#4998)
Many false positives and incorrect errors. @leaysgur Enjoy 😁

Run `just conformance` to update the snapshot.
2024-08-22 03:09:55 +00:00
overlookmotel
05fff16d55 fix(semantic): transform checker compare binding symbol IDs (#5057) 2024-08-22 02:34:44 +00:00
overlookmotel
f187b71877 fix(semantic): transform checker compare scope children (#5056) 2024-08-22 02:34:44 +00:00
overlookmotel
b52c6a4269 fix(semantic): transform checker compare scope parents (#5055) 2024-08-22 02:34:43 +00:00
overlookmotel
da64014a6c fix(semantic): transform checker catch more scope flags mismatches (#5054)
There was a bug previously where scope flags were only checked if there was also a bindings mismatch.
2024-08-22 02:34:43 +00:00
overlookmotel
7156fd2f91 refactor(semantic): transform checker Pair structure (#5053)
Introduce `Pair` structure containing a pair values from the "after transform" and "rebuilt" semantics, to reduce repetitive code.
2024-08-22 02:34:42 +00:00
overlookmotel
67d1a96391 fix(semantic): transform checker compare scope flags (#5052) 2024-08-22 02:34:41 +00:00
overlookmotel
0ba6f50f00 refactor(semantic): simplify raising errors in transform checker (#5051)
Simplify creating errors in transformer checker.
2024-08-22 02:34:41 +00:00
dalaoshu
f1e46116de
feat(linter/eslint-plugin-vitest): implement no-conditional-in-test (#4971)
Related to #4656
2024-08-22 08:15:32 +08:00
dalaoshu
14bf5d5177
feat(linter/eslint-plugin-vitest): implement no-restricted-vi-methods (#4956)
Related to #4656
2024-08-22 08:07:53 +08:00
Earl Chase
ddf83ff1b9
fix(linter/react): Fixed false positive with missing key inside React.Children.toArray() (#4945)
Closes: #4421 

Added three new functions in order to check if an element is inside of
React.Children.toArray.
Tests added for this fix are exactly the same as those used by
eslint-plugin-react.
2024-08-22 08:05:14 +08:00
overlookmotel
ee7ac8b0b7 refactor(semantic): store all data in PostTransformChecker in transform checker (#5050)
Pure refactor of transform checker. Store all scope data in `PostTransformChecker` so it doesn't need to be passed around. `SemanticData` contains a full set of all semantic data for semantic pass, so we have 2 instances of it for 1. after transform and 2. rebuilt semantic.
2024-08-21 17:04:48 +00:00
overlookmotel
4e1f4abf89 refactor(semantic): add SemanticIds to transformer checker (#5048)
Transformer checker use `SemanticIds` to store collected IDs. `SemanticIds` only contains the IDs, without the `Vec` of errors which is only used temporarily.
2024-08-21 15:49:07 +00:00
overlookmotel
c1da5741f4 refactor(semantic): add comments to transformer checker (#5045)
Just add comments.
2024-08-21 15:22:08 +00:00
overlookmotel
8cded08eb8 refactor(semantic): rename error labels in transformer checker snapshots (#5044)
Rename labels in transformer checker snapshots "after transform" vs "rebuilt".
2024-08-21 14:33:19 +00:00
overlookmotel
602244f440 refactor(semantic): rename vars in transformer checker (#5043)
Pure refactor. Rename vars in transformer checker - "transformer"/"rebuild" instead of "previous"/"current".
2024-08-21 13:47:37 +00:00
IWANABETHATGUY
2b21be31ff feat(oxc_minifier): define plugin with postfix wildcard (#4979)
1. support `import.meta.env.*` in `ReplaceGlobalDefine`
2024-08-21 13:27:09 +00:00
overlookmotel
ae94b9a890 refactor(semantic): remove unused function params in transformer checker (#5042)
Pure refactor, just tidying code.
2024-08-21 13:05:43 +00:00
overlookmotel
863b9cb921 fix(semantic): transform checker handle conditional scopes (#5040)
Some scopes are conditional e.g. `ForStatement` only gets a scope when initializer has a binding (`for (let i = 0; ...)` vs `for (i = 0; ...)`).

Make transform compare this between post-transform and fresh semantics.
2024-08-21 12:07:14 +00:00
overlookmotel
586e15c814 refactor(semantic): reformat transform checker errors (#5039)
Reformat transform checker error output - shorter and consistent capitalization.
2024-08-21 12:07:11 +00:00
overlookmotel
47029c4d45 fix(semantic): transform checker output symbol names in errors (#5038)
Transform checker: For symbol mismatch errors, output symbol names.
2024-08-21 12:07:09 +00:00
overlookmotel
d69e34e983 refactor(semantic): fix indentation (#5037)
Small follow-on after #5035. Not sure why rustfmt didn't correct indentation here.
2024-08-21 09:48:43 +00:00
Boshen
1bd9365bd0 fix(coverage): correctly check semantic data after transform (#5035)
closes #4999
2024-08-21 09:35:04 +00:00
Dunqing
bcc8da96ae refactor(transformer/logical-assignment-operator): use ctx.clone_identifier_reference (#5014)
Use TraverseCtx's built-in `clone_identifier_reference`
2024-08-21 09:19:38 +00:00
Dunqing
3f9433ce3b refactor(transformer/es2021): move all entry points to implementation of Traverse trait (#5013)
follow-up: #4881
2024-08-21 08:04:43 +00:00
overlookmotel
a4247e9353 refactor(allocator): move Box and Vec into separate files (#5034)
Pure refactor. Split `Box` and `Vec` definitions into separate files. Definitions are completely unchanged.
2024-08-21 01:08:08 +00:00
DonIsaac
cd9f1cd278 docs(linter/consistent-function-scoping): improve rule documentation (#5015) 2024-08-21 00:47:17 +00:00
overlookmotel
79c2493223 refactor(website): rename fields in Playground from flag to flags (#5033)
Part of #4991.
2024-08-21 00:19:59 +00:00
overlookmotel
4336a3275c refactor(semantic): rename fields in snapshots from flag to flags (#5032)
Part of #4991.
2024-08-21 00:19:59 +00:00
overlookmotel
83dfb1484e refactor(semantic): rename vars from flag to flags (#5031)
Part of #4991.
2024-08-21 00:19:59 +00:00