overlookmotel
694f032a3d
style: add trailing line breaks to package.json files ( #5542 )
...
For consistency with our `.editorconfig`.
2024-09-06 12:43:44 +00:00
Edwin Lim
2ec2f7d829
feat(linter/eslint): implement no-alert ( #5535 )
...
Contributing to #479 !
Rule Details: [link](https://eslint.org/docs/latest/rules/no-alert )
Am new to the internals of parsers and linters so I kept the
implementation similar to ESLint's source code
Commented out the `globalThis` test cases in the pass array meant for
pre-ES2020 before `globalThis` was introduced, having clarified in the
Discord that it's ok to treat the built-in `globalThis` as always
present.
---------
Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-09-06 08:40:20 -04:00
overlookmotel
9282647e6c
docs(transformer): comment on RegExp transform for potential improvement ( #5514 )
...
I think it's correct that we could do better here. Or is there some difference in behavior between `RegExp(...)` and `new RegExp(...)`?
2024-09-06 12:02:44 +00:00
overlookmotel
758a10c515
refactor(transformer): RegExp transform reuse var ( #5527 )
...
Nit. Use local `flags` var instead of `regexp.regex.flags`.
2024-09-06 12:02:44 +00:00
overlookmotel
9b7ecc7ee7
fix(transformer): RegExp transform only set span on final expression ( #5508 )
2024-09-06 12:02:43 +00:00
overlookmotel
fad0a0548b
refactor(transformer): RegExp transform unbox early ( #5504 )
...
Unbox the `RegExpLiteral` early to avoid all lookups thereafter going through the indirection of a `Box`.
2024-09-06 11:51:38 +00:00
overlookmotel
d1ece197c4
fix(transformer): RegExp transform handle Term::Quantifier ( #5501 )
...
`Term::Quantifier` contains a nested `Term` so we need to recurse into that `Term` to check if it contains any unsupported syntax.
2024-09-06 11:51:35 +00:00
dalaoshu
a540215c91
docs(linter): update docs Examples for linter rules ( #5513 )
2024-09-06 07:23:06 -04:00
oxc-bot
64eb2cccb7
release: crates v0.27.0 ( #5538 )
...
## [0.27.0] - 2024-09-06
- bd820f9 semantic: [**BREAKING**] Remove
`SymbolTable::get_symbol_id_from_name` and
`SymbolTable::get_scope_id_from_name` (#5480 ) (overlookmotel)
- cba93f5 ast: [**BREAKING**] Add `ThisExpression` variants to
`JSXElementName` and `JSXMemberExpressionObject` (#5466 ) (overlookmotel)
- 87c5df2 ast: [**BREAKING**] Rename `Expression::without_parentheses`
(#5448 ) (overlookmotel)
### Features
- e8bdd12 allocator: Add `AsMut` impl for `Box` (#5515 ) (overlookmotel)
- 90facd3 ast: Add `ContentHash` trait; remove noop `Hash`
implementation from `Span` (#5451 ) (rzvxa)
- 23285f4 ast: Add `ContentEq` trait. (#5427 ) (rzvxa)
- 59abf27 ast, parser: Add `oxc_regular_expression` types to the parser
and AST. (#5256 ) (rzvxa)
- 68a1c01 ast_tools: Add dedicated `Derive` trait. (#5278 ) (rzvxa)
- c782916 codegen: Print `type_parameters` in `TaggedTemplateExpression`
(#5438 ) (Dunqing)
- 4cb63fe index: Impl rayon related to trait for IndexVec (#5421 )
(IWANABETHATGUY)
- ba4b68c minifier: Remove parenthesized expression for dce (#5439 )
(Boshen)
- ed8ab6d oxc: Conditional expose `oxc_cfg` in `oxc` crate (#5524 )
(IWANABETHATGUY)
- 91b39c4 oxc_diagnostic: Impl DerefMut for OxcDiagnostic (#5474 )
(IWANABETHATGUY)
- 10279f5 parser: Add syntax error for hyphen in `JSXMemberExpression`
`<Foo.bar-baz />` (#5440 ) (Boshen)
- 0f50b1e semantic: Check for initializers in ambient
`VariableDeclaration`s (#5463 ) (DonIsaac)
- 62f7fff semantic: Check for non-declared, non-abstract object
accessors without bodies (#5461 ) (DonIsaac)
- 5407143 semantic: Check for non-declared, non-abstract class accessors
without bodies (#5460 ) (DonIsaac)
- 052e94c semantic: Check for parameter properties in constructor
overloads (#5459 ) (DonIsaac)
- 32d4bbb transformer: Add `TransformOptions::enable_all` method (#5495 )
(Boshen)
- c59d8b3 transformer: Support all /regex/ to `new RegExp` transforms
(#5387 ) (Dunqing)
- cedf7a4 xtask: Impl `as_ast_kind` method for each variant (#5491 )
(IWANABETHATGUY)
### Bug Fixes
- 0df1d9d ast, codegen, linter: Panics in fixers. (#5431 ) (rzvxa)
- fce549e diagnostics: Ignore `Interrupted` and `BrokenPipe` errors
while printing (#5526 ) (Boshen)
- ea7a52f napi/transform: Fix test (Boshen)
- 9b984b3 regex: Panic on displaying surrogated `UnicodeEscape`
characters. (#5469 ) (rzvxa)
- 88b7ddb regular_expression: Handle unterminated character class
(#5523 ) (leaysgur)
- 7a797ac semantic: Incorrect reference when `MemberExpression` used in
`TSPropertySignature` (#5525 ) (Dunqing)
- d8b9909 semantic: `IdentifierReference` within `TSPropertySignature`
cannot reference type-only import binding (#5441 ) (Dunqing)
- 8f9627d transformer: RegExp transform do not transform invalid regexps
(#5494 ) (overlookmotel)
- 2060efc transformer: RegExp transform don't transform all RegExps
(#5486 ) (overlookmotel)
- cfe5497 transformer: Do not create double reference in JSX transform
(#5414 ) (overlookmotel)
- 0617249 transformer/nullish-coalescing-operator: Incorrect reference
flags (#5408 ) (Dunqing)
- 0eb32a6 traverse: Invalid variable name generated by
`generate_uid_based_on_node` (#5407 ) (Dunqing)- b96bea4 Add back
lifetime (#5507 ) (IWANABETHATGUY)
### Performance
- bfabd8f syntax: Further optimize `is_identifier_name` (#5426 )
(overlookmotel)
- aeda84f syntax: Optimize `is_identifier_name` (#5425 ) (overlookmotel)
- ed8937e transformer: Memoize rope instance (#5518 ) (Dunqing)
- bfab091 transformer: Store needed options only on `RegExp` (#5484 )
(overlookmotel)
- b4765af transformer: Pre-calculate if unsupported patterns in RegExp
transform (#5483 ) (overlookmotel)
- 182ab91 transformer: Pre-calculate unsupported flags in RegExp
transform (#5482 ) (overlookmotel)
### Documentation
- 64db1b4 ast: Clarify docs for `RegExpPattern` (#5497 ) (overlookmotel)
- 3f204a9 span: Update docs about `ContentEq` `Vec` comparison speed
(#5478 ) (overlookmotel)- 00511fd Use `oxc_index` instead of `index_vec`
in doc comments (#5423 ) (IWANABETHATGUY)
### Refactor
- 9f6e0ed ast: Simplify `ContentEq` trait definition. (#5468 ) (rzvxa)
- a43e951 ast: Use loop instead of recursion (#5447 ) (overlookmotel)
- 2224cc4 ast: Renumber `JSXMemberExpressionObject` discriminants
(#5464 ) (overlookmotel)
- a952c47 ast: Use loop not recursion (#5449 ) (overlookmotel)
- d9d7e7c ast: Remove `IdentifierName` from `TSThisParameter` (#5327 )
(overlookmotel)
- ccc8a27 ast, ast_tools: Use full method path for generated derives
trait calls. (#5462 ) (rzvxa)
- fdb8857 linter: Use "parsed pattern" in `no_div_regex` rule. (#5417 )
(rzvxa)
- e7bd49d regular_expression: Correct typo (#5429 ) (overlookmotel)
- e4ed41d semantic: Change the reference flag to `ReferenceFlags::Type`
if it is used within a `TSTypeQuery` (#5444 ) (Dunqing)
- 94a6ac6 span: Use `Hasher` from `std` (#5476 ) (overlookmotel)
- b47aca0 syntax: Use `generate_derive` for `CloneIn` in types outside
of `oxc_ast` crate. (#5280 ) (rzvxa)
- a96866d transformer: Re-order imports (#5499 ) (overlookmotel)
- 6abde0a transformer: Clarify match in RegExp transform (#5498 )
(overlookmotel)
- 09c522a transformer: RegExp transform report pattern parsing errors
(#5496 ) (overlookmotel)
- dd19823 transformer: RegExp transform do not take ownership of
`Pattern` then reallocate it (#5492 ) (overlookmotel)
- 2514cc9 transformer/react: Move all entry points to implementation of
Traverse trait (#5473 ) (Dunqing)
- c984219 transformer/typescript: Move all entry points to
implementation of Traverse trait (#5422 ) (Dunqing)
### Styling
- 2a43fa4 linter: Introduce the writing style from PR #5491 and reduce
the if nesting (#5512 ) (dalaoshu)
### Testing
- 340b535 linter/no-unused-vars: Arrow functions in tagged templates
(#5510 ) (Don Isaac)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-09-06 19:06:29 +08:00
Cam McHenry
ff88c1fc07
fix(linter): Don't mark binding rest elements as unused in TS function overloads ( #5470 )
...
- Fixes https://github.com/oxc-project/oxc/issues/5406
This implements a fix for the `BindingRestElement` symbol, which is
currently unhandled and gets automatically marked as unused. If we
happen to find that it is a child of declaration, then we will
automatically allow the binding rest element.
The code for this was based on what we currently do in
`is_allowed_param_because_of_method`:
5187f384cb/crates/oxc_linter/src/rules/eslint/no_unused_vars/allowed.rs (L258)
I opted not to refactor this to re-use the same code though, as I think
the duplication is still incidental and the implementations could
diverge in the future.
2024-09-06 08:30:28 +01:00
Boshen
fce549e648
fix(diagnostics): ignore Interrupted and BrokenPipe errors while printing ( #5526 )
...
closes #5452
2024-09-06 06:38:47 +00:00
Dunqing
7a797ac635
fix(semantic): incorrect reference when MemberExpression used in TSPropertySignature ( #5525 )
...
close: https://github.com/oxc-project/oxc/issues/5435#issuecomment-2333032168
2024-09-06 06:24:45 +00:00
Dunqing
ed8937e978
perf(transformer): memoize rope instance ( #5518 )
...
Currently only used in `jsx-source`, so memorize rope in JSXSource enough for now.
close : #5500
2024-09-06 06:08:49 +00:00
IWANABETHATGUY
ed8ab6d7c8
feat(oxc): conditional expose oxc_cfg in oxc crate ( #5524 )
...
This is useful when the downside user wants to use `oxc_cfg`, and easy
to reuse `petgraph` in `oxc_cfg`
2024-09-06 14:07:43 +08:00
Boshen
1bed5ce2a5
chore: run cargo +nightly fmt to sort imports ( #5503 )
...
They are never going to be stable are they ... cedf7a4daa/.rustfmt.toml (L8-L16)
2024-09-06 04:04:26 +00:00
Boshen
32d4bbb519
feat(transformer): add TransformOptions::enable_all method ( #5495 )
...
Make it **really** explicit about which transformer options are being
turned on. I also need this in monitor-oxc.
2024-09-06 12:04:06 +08:00
leaysgur
88b7ddb7e0
fix(regular_expression): Handle unterminated character class ( #5523 )
...
`/[/` is reported by `debug_assert!`, but should not.
2024-09-06 03:28:33 +00:00
dalaoshu
2a43fa4efd
style(linter): introduce the writing style from PR #5491 and reduce the if nesting ( #5512 )
...
Related to #5491
2024-09-06 11:19:48 +08:00
Cam McHenry
088733b3c8
fix(linter): handle loops in getter-return rule ( #5517 )
...
- Fixes https://github.com/oxc-project/oxc/issues/3935
Prior to this, it didn't seem like we were correctly continuing to
search the graph after we encountered a backedge (loop). Now, when
encountering a cycle, we will not automatically break or prune the
search.
2024-09-06 06:29:04 +03:30
overlookmotel
e8bdd12438
feat(allocator): add AsMut impl for Box ( #5515 )
2024-09-05 23:52:56 +00:00
Don Isaac
340b535715
test(linter/no-unused-vars): arrow functions in tagged templates ( #5510 )
...
Closes #5391
2024-09-05 14:55:39 -04:00
IWANABETHATGUY
b96bea4f0d
fix: add back lifetime ( #5507 )
...
closed #5506
2024-09-05 17:47:58 +00:00
renovate
d9a1b610a7
chore(deps): update dependency rust to v1.81.0 ( #5502 )
...
This PR contains the following updates:
| Package | Update | Change |
|---|---|---|
| [rust](https://redirect.github.com/rust-lang/rust ) | minor | `1.80.1` -> `1.81.0` |
---
### Release Notes
<details>
<summary>rust-lang/rust (rust)</summary>
### [`v1.81.0`](https://redirect.github.com/rust-lang/rust/blob/HEAD/RELEASES.md#Version-1810-2024-09-05 )
[Compare Source](https://redirect.github.com/rust-lang/rust/compare/1.80.1...1.81.0 )
\==========================
<a id="1.81.0-Language"></a>
## Language
- [Abort on uncaught panics in `extern "C"` functions.](https://redirect.github.com/rust-lang/rust/pull/116088/ )
- [Fix ambiguous cases of multiple `&` in elided self lifetimes.](https://redirect.github.com/rust-lang/rust/pull/117967/ )
- [Stabilize `#[expect]` for lints (RFC 2383),](https://redirect.github.com/rust-lang/rust/pull/120924/ ) like `#[allow]` with a warning if the lint is *not* fulfilled.
- [Change method resolution to constrain hidden types instead of rejecting method candidates.](https://redirect.github.com/rust-lang/rust/pull/123962/ )
- [Bump `elided_lifetimes_in_associated_constant` to deny.](https://redirect.github.com/rust-lang/rust/pull/124211/ )
- [`offset_from`: always allow pointers to point to the same address.](https://redirect.github.com/rust-lang/rust/pull/124921/ )
- [Allow constraining opaque types during subtyping in the trait system.](https://redirect.github.com/rust-lang/rust/pull/125447/ )
- [Allow constraining opaque types during various unsizing casts.](https://redirect.github.com/rust-lang/rust/pull/125610/ )
- [Deny keyword lifetimes pre-expansion.](https://redirect.github.com/rust-lang/rust/pull/126762/ )
<a id="1.81.0-Compiler"></a>
## Compiler
- [Make casts of pointers to trait objects stricter.](https://redirect.github.com/rust-lang/rust/pull/120248/ )
- [Check alias args for well-formedness even if they have escaping bound vars.](https://redirect.github.com/rust-lang/rust/pull/123737/ )
- [Deprecate no-op codegen option `-Cinline-threshold=...`.](https://redirect.github.com/rust-lang/rust/pull/124712/ )
- [Re-implement a type-size based limit.](https://redirect.github.com/rust-lang/rust/pull/125507/ )
- [Properly account for alignment in `transmute` size checks.](https://redirect.github.com/rust-lang/rust/pull/125740/ )
- [Remove the `box_pointers` lint.](https://redirect.github.com/rust-lang/rust/pull/126018/ )
- [Ensure the interpreter checks bool/char for validity when they are used in a cast.](https://redirect.github.com/rust-lang/rust/pull/126265/ )
- [Improve coverage instrumentation for functions containing nested items.](https://redirect.github.com/rust-lang/rust/pull/127199/ )
- Target changes:
- [Add Tier 3 `no_std` Xtensa targets:](https://redirect.github.com/rust-lang/rust/pull/125141/ ) `xtensa-esp32-none-elf`, `xtensa-esp32s2-none-elf`, `xtensa-esp32s3-none-elf`
- [Add Tier 3 `std` Xtensa targets:](https://redirect.github.com/rust-lang/rust/pull/126380/ ) `xtensa-esp32-espidf`, `xtensa-esp32s2-espidf`, `xtensa-esp32s3-espidf`
- [Add Tier 3 i686 Redox OS target:](https://redirect.github.com/rust-lang/rust/pull/126192/ ) `i686-unknown-redox`
- [Promote `arm64ec-pc-windows-msvc` to Tier 2.](https://redirect.github.com/rust-lang/rust/pull/126039/ )
- [Promote `wasm32-wasip2` to Tier 2.](https://redirect.github.com/rust-lang/rust/pull/126967/ )
- [Promote `loongarch64-unknown-linux-musl` to Tier 2 with host tools.](https://redirect.github.com/rust-lang/rust/pull/126298/ )
- [Enable full tools and profiler for LoongArch Linux targets.](https://redirect.github.com/rust-lang/rust/pull/127078/ )
- [Unconditionally warn on usage of `wasm32-wasi`.](https://redirect.github.com/rust-lang/rust/pull/126662/ ) (see compatibility note below)
- Refer to Rust's \[platform support page]\[platform-support-doc] for more information on Rust's tiered platform support.
<a id="1.81.0-Libraries"></a>
## Libraries
- [Split core's `PanicInfo` and std's `PanicInfo`.](https://redirect.github.com/rust-lang/rust/pull/115974/ ) (see compatibility note below)
- [Generalize `{Rc,Arc}::make_mut()` to unsized types.](https://redirect.github.com/rust-lang/rust/pull/116113/ )
- [Replace sort implementations with stable `driftsort` and unstable `ipnsort`.](https://redirect.github.com/rust-lang/rust/pull/124032/ ) All `slice::sort*` and `slice::select_nth*` methods are expected to see significant performance improvements. See the [research project](https://redirect.github.com/Voultapher/sort-research-rs ) for more details.
- [Document behavior of `create_dir_all` with respect to empty paths.](https://redirect.github.com/rust-lang/rust/pull/125112/ )
- [Fix interleaved output in the default panic hook when multiple threads panic simultaneously.](https://redirect.github.com/rust-lang/rust/pull/127397/ )
<a id="1.81.0-Stabilized-APIs"></a>
## Stabilized APIs
- [`core::error`](https://doc.rust-lang.org/stable/core/error/index.html )
- [`hint::assert_unchecked`](https://doc.rust-lang.org/stable/core/hint/fn.assert_unchecked.html )
- [`fs::exists`](https://doc.rust-lang.org/stable/std/fs/fn.exists.html )
- [`AtomicBool::fetch_not`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.AtomicBool.html#method.fetch_not )
- [`Duration::abs_diff`](https://doc.rust-lang.org/stable/core/time/struct.Duration.html#method.abs_diff )
- [`IoSlice::advance`](https://doc.rust-lang.org/stable/std/io/struct.IoSlice.html#method.advance )
- [`IoSlice::advance_slices`](https://doc.rust-lang.org/stable/std/io/struct.IoSlice.html#method.advance_slices )
- [`IoSliceMut::advance`](https://doc.rust-lang.org/stable/std/io/struct.IoSliceMut.html#method.advance )
- [`IoSliceMut::advance_slices`](https://doc.rust-lang.org/stable/std/io/struct.IoSliceMut.html#method.advance_slices )
- [`PanicHookInfo`](https://doc.rust-lang.org/stable/std/panic/struct.PanicHookInfo.html )
- [`PanicInfo::message`](https://doc.rust-lang.org/stable/core/panic/struct.PanicInfo.html#method.message )
- [`PanicMessage`](https://doc.rust-lang.org/stable/core/panic/struct.PanicMessage.html )
These APIs are now stable in const contexts:
- [`char::from_u32_unchecked`](https://doc.rust-lang.org/stable/core/char/fn.from_u32\_unchecked.html ) (function)
- [`char::from_u32_unchecked`](https://doc.rust-lang.org/stable/core/primitive.char.html#method.from_u32\_unchecked ) (method)
- [`CStr::count_bytes`](https://doc.rust-lang.org/stable/core/ffi/c_str/struct.CStr.html#method.count_bytes )
- [`CStr::from_ptr`](https://doc.rust-lang.org/stable/core/ffi/c_str/struct.CStr.html#method.from_ptr )
<a id="1.81.0-Cargo"></a>
## Cargo
- [Generated `.cargo_vcs_info.json` is always included, even when `--allow-dirty` is passed.](https://redirect.github.com/rust-lang/cargo/pull/13960/ )
- [Disallow `package.license-file` and `package.readme` pointing to non-existent files during packaging.](https://redirect.github.com/rust-lang/cargo/pull/13921/ )
- [Disallow passing `--release`/`--debug` flag along with the `--profile` flag.](https://redirect.github.com/rust-lang/cargo/pull/13971/ )
- [Remove `lib.plugin` key support in `Cargo.toml`. Rust plugin support has been deprecated for four years and was removed in 1.75.0.](https://redirect.github.com/rust-lang/cargo/pull/13902/ )
<a id="1.81.0-Compatibility-Notes"></a>
## Compatibility Notes
- Usage of the `wasm32-wasi` target will now issue a compiler warning and request users switch to the `wasm32-wasip1` target instead. Both targets are the same, `wasm32-wasi` is only being renamed, and this [change to the WASI target](https://blog.rust-lang.org/2024/04/09/updates-to-rusts-wasi-targets.html ) is being done to enable removing `wasm32-wasi` in January 2025.
- We have renamed `std::panic::PanicInfo` to `std::panic::PanicHookInfo`. The old name will continue to work as an alias, but will result in a deprecation warning starting in Rust 1.82.0.
`core::panic::PanicInfo` will remain unchanged, however, as this is now a *different type*.
The reason is that these types have different roles: `std::panic::PanicHookInfo` is the argument to the [panic hook](https://doc.rust-lang.org/stable/std/panic/fn.set_hook.html ) in std context (where panics can have an arbitrary payload), while `core::panic::PanicInfo` is the argument to the [`#[panic_handler]`](https://doc.rust-lang.org/nomicon/panic-handler.html ) in no_std context (where panics always carry a formatted *message*). Separating these types allows us to add more useful methods to these types, such as `std::panic::PanicHookInfo::payload_as_str()` and `core::panic::PanicInfo::message()`.
- The new sort implementations may panic if a type's implementation of [`Ord`](https://doc.rust-lang.org/std/cmp/trait.Ord.html ) (or the given comparison function) does not implement a [total order](https://en.wikipedia.org/wiki/Total_order ) as the trait requires. `Ord`'s supertraits (`PartialOrd`, `Eq`, and `PartialEq`) must also be consistent. The previous implementations would not "notice" any problem, but the new implementations have a good chance of detecting inconsistencies, throwing a panic rather than returning knowingly unsorted data.
<a id="1.81.0-Internal-Changes"></a>
## Internal Changes
These changes do not affect any public interfaces of Rust, but they represent
significant improvements to the performance or internals of rustc and related
tools.
- [Add a Rust-for Linux `auto` CI job to check kernel builds.](https://redirect.github.com/rust-lang/rust/pull/125209/ )
</details>
---
### Configuration
📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 **Automerge**: Enabled.
♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 **Ignore**: Close this PR and you won't be reminded about this update again.
---
- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box
---
This PR was generated by [Mend Renovate](https://mend.io/renovate/ ). View the [repository job log](https://developer.mend.io/github/oxc-project/oxc ).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC41OS4yIiwidXBkYXRlZEluVmVyIjoiMzguNTkuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
2024-09-05 16:57:47 +00:00
IWANABETHATGUY
cedf7a4daa
feat(xtask): impl as_ast_kind method for each variant ( #5491 )
2024-09-05 16:17:08 +00:00
overlookmotel
a96866d951
refactor(transformer): re-order imports ( #5499 )
...
Style nit. Re-order imports to make it clearer what types are external/internal to crate.
2024-09-05 16:04:42 +00:00
overlookmotel
6abde0a69f
refactor(transformer): clarify match in RegExp transform ( #5498 )
...
Refactor match on `Term` in RegExp transform.
This is personal taste, really. I prefer this style:
```rs
match enum {
Enum::Variant(x) => x.is_something(),
_ => false,
}
```
over:
```rs
match enum {
Enum::Variant(x) if x.is_something() => true,
_ => false,
}
```
because then you don't have to reason about what happens when the `if` is false and it "falls through" to the next match arm. The compiler *might* also find the former easier to optimize, though likely in most cases it can figure out that they're equivalent.
Also rename a couple of vars for clarity.
2024-09-05 16:04:42 +00:00
overlookmotel
09c522aa5b
refactor(transformer): RegExp transform report pattern parsing errors ( #5496 )
...
If RegExp transform parses the regexp pattern and finds it to be invalid, output that error.
2024-09-05 16:04:42 +00:00
overlookmotel
8f9627d1a1
fix(transformer): RegExp transform do not transform invalid regexps ( #5494 )
...
Treat invalid regexps the same regardless of whether they have unsupported flags or not - don't transform them.
2024-09-05 16:04:42 +00:00
overlookmotel
dd198231dc
refactor(transformer): RegExp transform do not take ownership of Pattern then reallocate it ( #5492 )
...
Previously `try_parse_pattern` took ownership of an existing pattern and then reallocated it back into arena, even if it wasn't changed.
Rust's borrow-checker makes it quite hard to avoid this. Only way I could find is to move some of the logic out of `try_parse_pattern`.
2024-09-05 16:04:41 +00:00
overlookmotel
64db1b4c40
docs(ast): clarify docs for RegExpPattern ( #5497 )
...
Make it clearer what difference between `RegExpPattern::Raw` and `RegExpPattern::Invalid` is.
2024-09-05 15:51:20 +00:00
overlookmotel
3f204a9af5
docs(span): update docs about ContentEq Vec comparison speed ( #5478 )
...
Update the docs for `impl ContentEq for Vec` to state in what circumstances `PartialEq` is faster. See https://github.com/oxc-project/oxc/pull/5427#discussion_r1744290058 .
2024-09-05 15:34:17 +00:00
overlookmotel
94a6ac63cf
refactor(span): use Hasher from std ( #5476 )
...
Use `std:#️⃣ :Hasher` instead of `core:#️⃣ :Hasher`.
I don't actually know if importing `core` as well as `std` has any compile time perf impact, but as we're using `std` anyway, we may as well use it for everything.
Import into the `auto_impl_content_hash` module to make the macro a little easier to read.
2024-09-05 14:18:01 +00:00
overlookmotel
bd820f9c16
refactor(semantic)!: remove SymbolTable::get_symbol_id_from_name and SymbolTable::get_scope_id_from_name ( #5480 )
...
Close #5456 .
2024-09-05 13:57:55 +00:00
heygsc
7414190ada
docs(linter): update docs Example for linter rules ( #5479 )
...
fix : #5458
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-09-05 21:54:20 +08:00
overlookmotel
2060efc801
fix(transformer): RegExp transform don't transform all RegExps ( #5486 )
...
Previously `RegExp` transform would transform every `RegExp`, even if it had no unsupported flags/patterns.
2024-09-05 13:50:21 +00:00
Jelle van der Waa
a786acff41
feat(linter/import): add no-dynamic-require rule ( #5389 )
...
Rule Detail:
[link](https://github.com/import-js/eslint-plugin-import/blob/v2.29.1/docs/rules/no-dynamic-require.md )
2024-09-05 09:39:25 -04:00
IWANABETHATGUY
979c16c486
refactor(linter): reduce nested if statements in eslint/no_this_before_super ( #5485 )
2024-09-05 13:21:18 +00:00
dalaoshu
bc7be70077
chore(linter/react_perf): improve docs for react_perf rules ( #5481 )
...
Please fill in the "why this is bad" section
_Originally posted by @DonIsaac in
https://github.com/oxc-project/oxc/pull/5360#discussion_r1739617907_
2024-09-05 09:20:55 -04:00
overlookmotel
bfab0914fa
perf(transformer): store needed options only on RegExp ( #5484 )
...
#5482 makes most of the `RegExpOptions` not be needed outside `new` method. So only store the remaining options which are actually needed on `RegExp`. This reduces size of `RegExp`.
(this is micro-optimization, and unlikely to make a measurable difference, but why not?)
2024-09-05 12:47:36 +00:00
overlookmotel
b4765af82a
perf(transformer): pre-calculate if unsupported patterns in RegExp transform ( #5483 )
...
Similar to #5482 . Calculate whether any unsupported RegExp patterns at start, to make checking if need to check for patterns cheaper (a single comparison operation, rather than 3 comparisons and ORs).
2024-09-05 12:47:35 +00:00
overlookmotel
182ab91570
perf(transformer): pre-calculate unsupported flags in RegExp transform ( #5482 )
...
Calculate unsupported RegExp flags at start, to make checking flags on each RegExp during traversal cheaper (a single OR operation). i.e. do work once at the start, rather than over and over each time you find a `RegExp`.
2024-09-05 12:47:34 +00:00
Dunqing
2514cc92e5
refactor(transformer/react): move all entry points to implementation of Traverse trait ( #5473 )
2024-09-05 11:04:45 +00:00
Dunqing
c59d8b3c9b
feat(transformer): support all /regex/ to new RegExp transforms ( #5387 )
...
related: #4754
The implementation port from [esbuild](332727499e/internal/js_parser/js_parser.go (L12820-L12840) ). And cover all babel's regexp plugins
---
## The following description was generated by `Graphite` 😋
### TL;DR
Added support for transforming various RegExp features to ensure compatibility with older JavaScript environments.
### What changed?
- Implemented a new `RegExp` transformer to handle unsupported RegExp literal features
- Added options to control different RegExp transformations (e.g., sticky flag, unicode flag, dot-all flag, etc.)
- Updated the transformer to convert unsupported RegExp literals into `new RegExp()` constructor calls
- Added test cases for different RegExp transformations
- Integrated the new RegExp transformer into the existing transformation pipeline
### How to test?
1. Run the existing test suite to ensure no regressions
2. Execute the new RegExp-specific tests in the `tasks/transform_conformance/tests/esbuild-tests/test/fixtures/regexp/` directory
3. Try transforming code with various RegExp features using different target environments to verify correct transformations
2024-09-05 11:04:45 +00:00
IWANABETHATGUY
91b39c4b82
feat(oxc_diagnostic): impl DerefMut for OxcDiagnostic ( #5474 )
...
1. Impl `DerefMut` for `OxcDiagnositc` so downstream user could move `OxcDiagnostic` rather clone it,
40ae24d597/crates/rolldown_ecmascript/src/ecma_compiler.rs (L36-L48)
2024-09-05 08:55:52 +00:00
rzvxa
9b984b31bd
fix(regex): panic on displaying surrogated UnicodeEscape characters. ( #5469 )
...
fixes https://github.com/oxc-project/oxc/pull/5387#issuecomment-2330534180
2024-09-05 06:18:11 +00:00
rzvxa
0df1d9d97b
fix(ast, codegen, linter): panics in fixers. ( #5431 )
...
Closes #5434
https://github.com/oxc-project/oxlint-ecosystem-ci/actions/runs/10685877915/job/29619941099
2024-09-05 05:59:22 +00:00
rzvxa
9f6e0ed099
refactor(ast): simplify ContentEq trait definition. ( #5468 )
...
Addresses the concerns brought up in #5427
2024-09-05 05:36:51 +00:00
rzvxa
ccc8a27e4f
refactor(ast, ast_tools): use full method path for generated derives trait calls. ( #5462 )
...
As of now if we remove the implementation of a trait for a type and implement the method on that type directly it wouldn't break while it isn't the original trait anymore so that method might do something entirely different.
This change is more explicit on trait calls so we hit compile errors on these kinds of changes.
2024-09-05 05:36:50 +00:00
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