Commit graph

4949 commits

Author SHA1 Message Date
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
overlookmotel
5f4c9ab38e refactor(semantic)!: rename SymbolTable::get_flag to get_flags (#5030)
Part of #4991.
2024-08-21 00:19:58 +00:00
overlookmotel
ca70cc7c03 refactor(linter, mangler, parser, semantic, transformer, traverse, wasm): rename various flag vars to flags (#5028)
Part of #4991.
2024-08-21 00:19:58 +00:00
overlookmotel
3b7de18eb2 refactor(semantic): rename SemanticBuilder::current_reference_flags field (#5027)
Part of #4991.
2024-08-21 00:19:58 +00:00
overlookmotel
0bacdd8102 refactor(semantic): rename Reference::flag field to flags (#5026)
Part of #4991.
2024-08-21 00:19:57 +00:00
overlookmotel
58bf21531e refactor(semantic)!: rename Reference::flag and flag_mut methods to plural (#5025)
Part of #4991.
2024-08-21 00:19:57 +00:00
overlookmotel
c4c08a7433 refactor(ast)!: rename IdentifierReference::reference_flags field (#5024)
Part of #4991.
2024-08-21 00:19:57 +00:00
overlookmotel
d262a58eb5 refactor(syntax)!: rename ReferenceFlag to ReferenceFlags (#5023)
Part of #4991.
2024-08-21 00:19:56 +00:00
DonIsaac
9354779ad4 fix(linter/no-unused-vars): give argsIgnorePattern the same default behavior as varsIgnorePattern (#5018) 2024-08-21 00:15:10 +00:00
DonIsaac
5a55dcf39b fix(linter/no-unused-vars): type specifier not deleted for type imports (#5029)
fixes a bug in eslint/no-unused-vars where, when unused type imports were deleted, the `type` modifier was not.
2024-08-21 00:11:45 +00:00
overlookmotel
c30e2e9cce refactor(semantic)!: Reference::flag method return ReferenceFlag (#5019)
Closes #4992.
2024-08-20 22:02:08 +00:00
camc314
2292606a1f feat(linter): typescript-eslint/no-wrapper-object-types (#5022) 2024-08-20 21:45:38 +00:00
Don Isaac
c43945c808
fix(linter/consistent-function-scoping): allow functions passed as arguments (#5011) 2024-08-20 17:00:50 -04:00
Dunqing
4425b177d4 docs(transformer): add documentation for logical-assignment-operators plugin (#5012)
follow-up #4881
2024-08-20 16:32:37 +00:00
DonIsaac
86d0c0cb62 fix(linter): change consistent-function-scoping to suspicious (#5010) 2024-08-20 16:22:30 +00:00
overlookmotel
896b92f272 refactor(semantic): correct typo in doc comment (#5009)
Correct a typo in doc comment, and capitalize "ID" in couple of places.
2024-08-20 15:27:51 +00:00
Boshen
b4407c4e9a
refactor(oxc,mangler): oxc crate add mangler; mangler use options API 2024-08-20 22:58:59 +08:00
IWANABETHATGUY
0f64d106a0 refactor(minifier): remove duplicated helper move_out_expression (#5007) 2024-08-20 14:00:33 +00:00
overlookmotel
8d15e65a78 refactor(transformer): use into_member_expression (#5006)
Use new `into_member_expression` API introduced in #5005 in TS transforms.
2024-08-20 13:39:26 +00:00
overlookmotel
714373dc5e feat(ast): inherit_variants! macro add into_* methods (#5005)
`inherit_variants!` macro generate `into_*` methods for owned objects. e.g.:

```rs
let expr: Expression = get_expr();
match expr {
  match_member_expression!(Expression) => {
    let member_expr: MemberExpression = expr.into_member_expression();
  },
  _ => {},
}
```
2024-08-20 12:11:54 +00:00
overlookmotel
7f3129efd1 fix(ast): correct code comment (#5004)
Comment showing macro expansion did not match the actual macro output.
2024-08-20 11:56:29 +00:00
IWANABETHATGUY
b7db235065
fix: comments gen regression (#5003)
try to fix: https://github.com/rolldown/rolldown/issues/2013
1. Before we only considering the ast is untouched, but considering the
scenario.
```js

const a = /*__PURE__*/ test(),
//    ^^^              ^^^^^^ is removed during transform
	b = a();

```
Then according to the previous algorithm, `PURE` will attach to `b =
a()`
2. Now, we try to attach comments as much as possible unless the
comments are separated by comments, for the case above, `PURE` will not
be attached to `a()` since the content between `b = a()` and `/*
__PURE__*/` is not all whitespace.
3. we added back `MoveMap`, for the special case 
```js
/*__NODE_SIDE_EFFECTS__*/ export const c = 100;
// ^^^^^^^^^^^^^^^^^^^^^         should be attached to first declarator,
//                        ^^^^^^ are not whitespace

```
2024-08-20 18:57:12 +08:00
Boshen
cd9cf5efd8
refactor(oxc): remove remove_whitespace 2024-08-20 18:27:59 +08:00
Boshen
1f6b107339 chore(coverage): ignore test262 stage3 json-modules (#5002)
stage 3 https://github.com/tc39/proposal-json-modules

Ignoring due to https://github.com/tc39/proposal-json-modules/issues/27
2024-08-20 08:50:27 +00:00
Boshen
ce4d4698b4 feat(codegen)!: remove const generic MINIFY (#5001)
This is a premature optimization, makes the code complicated, and bloats the final binary size.

The minify option is moved to `CodegenOptions`
2024-08-20 08:13:27 +00:00
Boshen
b2ff2df5af refactor(parser)!: remove builder pattern from Parser struct (#5000)
part of #4455

use `with_options(ParseOptions { ..ParseOptions::default() })` API instead.
2024-08-20 07:40:25 +00:00
Boshen
081e2a37d9
refactor(regular_expression): s/RegExpLiteral/RegularExpression 2024-08-20 14:26:32 +08:00
dalaoshu
ed9a1c499b
feat(linter/eslint-plugin-vitest): implement require-local-test-context-for-concurrent-snapshots (#4951)
Related to #4656

---------

Co-authored-by: Wang Wenzhe <mysteryven@gmail.com>
2024-08-20 13:41:35 +08:00
Boshen
8d3f61bb54
chore(oxc_regular_expression): rename crate 2024-08-20 10:59:00 +08:00
leaysgur
368364d47b feat(regex_parser): Implement RegExp parser (#3824)
Part of #1164

## Progress updates 🗞️

Waiting for the review and advice, while thinking how to handle escaped string when `new RegExp(pat)`.

## TODOs

- [x] `RegExp(Literal = Body + Flags)#parse()` structure
- [x] Base `Reader` impl to handle both unicode(u32) and utf-16(u16) units
- [x] Global `Span` and local offset conversion
- [x] Design AST shapes
  - [x] Keep `enum` size small by `Box<'a, T>`
  - [x] Rework AST shapes
- [x] Split body and flags w/ validating literal
- [x] Parse `RegExpFlags`
- [x] Parse `RegExpBody` = `Pattern`
- [x] Parse `Pattern` > `Disjunction`
- [x] Parse `Disjunction` > `Alternative`
- [x] Parse `Alternative` > `Term`
- [x] Parse `Term` > `Assertion`
	- [x] Parse `BoundaryAssertion`
	- [x] Parse `LookaroundAssertion`
- [x] Parse `Term` > `Quantifier`
- [x] Parse `Term` > `Atom`
	- [x] Parse `Atom` > `PatternCharacter`
	- [x] Parse `Atom` > `.`
	- [x] Parse `Atom` > `\AtomEscape`
		- [x] Parse `\AtomEscape` > `DecimalEscape`
		- [x] Parse `\AtomEscape` > `CharacterClassEscape`
			- [x] Parse `CharacterClassEscape` > `\d, \D, \s, \S, \w, \W`
			- [x] Parse `CharacterClassEscape` > `\p{UnicodePropertyValueExpression}, \P{UnicodePropertyValueExpression}`
		- [x] Parse `\AtomEscape` > `CharacterEscape`
			- [x] Parse `CharacterEscape` > `ControlEscape`
			- [x] Parse `CharacterEscape` > `c AsciiLetter`
			- [x] Parse `CharacterEscape` > `0`
			- [x] Parse `CharacterEscape` > `HexEscapeSequence`
			- [x] Parse `CharacterEscape` > `RegExpUnicodeEscapeSequence`
			- [x] Parse `CharacterEscape` > `IdentityEscape`
		- [x] Parse `\AtomEscape` > `kGroupName`
	- [x] Parse `Atom` > `[CharacterClass]`
    	- [x] Parse `[CharacterClass]` > `ClassContents` > `[~UnicodeSetsMode] NonemptyClassRanges`
    	- [x] Parse `[CharacterClass]` > `ClassContents` > `[+UnicodeSetsMode] ClassSetExpression`
          - [x] Parse `ClassSetExpression` > `ClassUnion`
          - [x] Parse `ClassSetExpression` > `ClassIntersection`
          - [x] Parse `ClassSetExpression` > `ClassSubtraction`
          - [x] Parse `ClassSetExpression` > `ClassSetOperand`
          - [x] Parse `ClassSetExpression` > `ClassSetRange`
          - [x] Parse `ClassSetExpression` > `ClassSetCharacter`
	- [x] Parse `Atom` > `(GroupSpecifier)`
	- [x] Parse `Atom` > `(?:Disjunction)`
- [x] Annex B
    - [x] Parse `QuantifiableAssertion`
	- [x] Parse `ExtendedAtom`
      - [x] Parse `ExtendedAtom` > `\ [lookahead = c]`
      - [x] Parse `ExtendedAtom` > `InvalidBracedQuantifier`
      - [x] Parse `ExtendedAtom` > `ExtendedPatternCharacter`
      - [x] Parse `ExtendedAtom` > `\AtomEscape` > `CharacterEscape` > `LegacyOctalEscapeSequence`
- [x] Early errors
	- [x] Pattern :: Disjunction(1/2)
	- [x] Pattern :: Disjunction(2/2)
	- [x] QuantifierPrefix :: { DecimalDigits , DecimalDigits }
	- [x] ExtendedAtom :: InvalidBracedQuantifier (Annex B)
	- [x] AtomEscape :: k GroupName
	- [x] AtomEscape :: DecimalEscape
	- [x] NonemptyClassRanges :: ClassAtom - ClassAtom ClassContents(1/2)
	- [x] NonemptyClassRanges :: ClassAtom - ClassAtom ClassContents(2/2)
	- [x] NonemptyClassRanges :: ClassAtom - ClassAtom ClassContents(Annex B)
	- [x] NonemptyClassRangesNoDash :: ClassAtomNoDash - ClassAtom ClassContents(1/2)
	- [x] NonemptyClassRangesNoDash :: ClassAtomNoDash - ClassAtom ClassContents(2/2)
	- [x] NonemptyClassRangesNoDash :: ClassAtomNoDash - ClassAtom ClassContents(Annex B)
	- [x] RegExpIdentifierStart :: \ RegExpUnicodeEscapeSequence
	- [x] RegExpIdentifierStart :: UnicodeLeadSurrogate UnicodeTrailSurrogate
	- [x] RegExpIdentifierPart :: \ RegExpUnicodeEscapeSequence
	- [x] RegExpIdentifierPart :: UnicodeLeadSurrogate UnicodeTrailSurrogate
	- [x] UnicodePropertyValueExpression :: UnicodePropertyName = UnicodePropertyValue(1/2)
	- [x] UnicodePropertyValueExpression :: UnicodePropertyName = UnicodePropertyValue(2/2)
	- [x] UnicodePropertyValueExpression :: LoneUnicodePropertyNameOrValue(1/2)
	- [x] UnicodePropertyValueExpression :: LoneUnicodePropertyNameOrValue(2/2)
	- [x] CharacterClassEscape :: P{ UnicodePropertyValueExpression }
	- [x] CharacterClass :: [^ ClassContents ]
	- [x] NestedClass :: [^ ClassContents ]
	- [x] ClassSetRange :: ClassSetCharacter - ClassSetCharacter
- [x] Add `Span` to `Err(OxcDiagnostic::error())` calls
- [x] Perf improvement
	- [x] `Reader#peek()` should avoid `iter.next()` equivalent
	- [x] ~~Use `char` everywhere and split and push 2 surrogates(pair) for `Character`?~~
	- [x] ~~Try 1(+1) loop parsing for capturing groups?~~

## Follow up

- [x] @Boshen Test suite > #4242
  - [x] Investigate CI errors...
- Next...
  - Support ES2025 Duplicate named capturing groups?
  - Support ES20XX Stage3 Modifiers?
2024-08-20 02:19:24 +00:00
Burlin
f88970bc79
refactor(ast)!: Change order of fields in CallExpression (#4859)
fix: #4821

---------

Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-08-20 09:47:12 +08:00
Dunqing
38d4434473 refactor(transformer/nullish-coalescing-operator): move internal methods to bottom of the file (#4996)
follow-up #4993
2024-08-20 01:06:38 +00:00
Dunqing
f51d3f9169 feat(transformer/nullish-coalescing-operator): handles nullish coalescing expression in the FormalParamter (#4975)
### What I did in this PR
1. Replace `self.clone_identifier_reference` with `ctx.clone_identifier.reference`
2. Remove the usage of `ast.copy`
3. Handle below example correctly

### Example

```js
// Input
var foo = object.foo ?? "default";

// Output
var _object$foo;
var foo =
(_object$foo = object.foo) !== null && _object$foo !== void 0
  ? _object$foo
  : "default";
```
2024-08-20 01:06:37 +00:00
Dunqing
f794870dd4 feat(transformer/nullish-coalescing-operator): generate the correct binding name (#4974)
match Babel's [implementation](440fe41333/packages/babel-plugin-transform-nullish-coalescing-operator/src/index.ts (L40))
2024-08-20 01:06:36 +00:00
Dunqing
9df2f80cab refactor(transformer/es2020): move all entry points to implementation of Traverse trait (#4973)
part of #4881
2024-08-20 01:06:36 +00:00
Dunqing
72ff2c67b9 feat(transformer/nullish-coalescing-operator): add comments in top of file (#4972)
part of #4881
2024-08-20 01:06:35 +00:00
DonIsaac
e331ca0a9d docs(linter): improve documentation for several rules (#4997) 2024-08-20 00:55:48 +00:00
overlookmotel
cca7440d4b refactor(ast): replace AstBuilder::move_statement_vec with move_vec (#4988)
Replace `AstBuilder::move_statement_vec` with a general `move_vec` method which handles any kind of `Vec`.
2024-08-19 21:09:14 +00:00
overlookmotel
6ffbd78947 fix(transformer): remove an AstBuilder::copy call from TS namespace transform (#4987)
Replace an unsafe `AstBuilder::copy` call with `AstBuilder::move_expression` in TS namespace transform.
2024-08-19 21:09:12 +00:00
overlookmotel
a8dfddaeab fix(transformer): remove an AstBuilder::copy call from TS module transform (#4986)
Remove an unsafe `AstBuilder::copy` call from TS module transform. `IdentifierReference` is `Clone`, so we can just clone it rather than copy. Same result, but safe.

Also shorten the surrounding code a bit, using `.unwrap()` instead of an `unreachable!()` branch.
2024-08-19 21:09:11 +00:00
overlookmotel
1467eb306c fix(transformer): remove an AstBuilder::copy call from TS enum transform (#4985)
Replace an unsafe `AstBuilder::copy` call with `AstBuilder::move_expression` in TS enum transform.
2024-08-19 21:09:10 +00:00