Commit graph

6571 commits

Author SHA1 Message Date
Boshen
4bef99c80b
chore(coverage): update runtime snapshot 2024-11-01 13:05:42 +08:00
tomoya yanagibashi
0601271b2c
fix(ast): Fix StaticMemberExpression.get_first_object (#6969)
I think `get_first_object` does not return expected expression.

For example, in case of `foo.bar.a`, it doesn't return `foo` but
`foo.bar`.

**Expected**
```
{
  "type": "Identifier",
  "start": 0,
  "end": 3,
  "name": "foo"
}
```

**Actual**
```
{
   "type":"StaticMemberExpression",
   "start":0,
   "end":7,
   "object":{
      "type":"Identifier",
      "start":0,
      "end":3,
      "name":"foo"
   },
   "property":{
      "type":"Identifier",
      "start":4,
      "end":7,
      "name":"bar"
   },
   "optional":false
}
```

---------

Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-11-01 12:28:48 +08:00
overlookmotel
e23f7e6bc1 refactor(transformer/common): VarDeclarations insert either var or let statements (#7043)
Add ability for `VarDeclarations` to insert `let` declarations as well as `var` declarations. This is required for class properties transform.

Implementation note: `var` and `let` declarators are stored in 2 separate `ArenaVec`s. This allows using those `ArenaVec<Declarator<'a>>`s directly in the AST, rather storing all `Declarator`s in a single `Vec` and having to loop through it when inserting the `var` / `let` statements to split it into 2 `ArenaVec`s of `var` / `let` declarators. I'm not completely sure this is better than using a single `Vec` for both, but I think *probably* it is.
2024-11-01 04:08:59 +00:00
camchenry
1f2a6c666f feat(linter)!: report unmatched rules with error exit code (#7027)
- closes https://github.com/oxc-project/oxc/issues/6988

we now return an error exit code when there are unmatched rules. previously, we would print an error to stderr and continue running. however, this masked errors in some tests that actually had unmatched rules in them. these test cases now trigger a panic (in tests only, not at runtime), and help ensure that we are reporting an error message to the user for unknown rules, which we did not have any tests cases for before.

- fixes https://github.com/oxc-project/oxc/issues/7025

this also fixes https://github.com/oxc-project/oxc/issues/7025, where we were reporting rules as unmatched simply because they had been disabled prior to being configured. similar to https://github.com/oxc-project/oxc/issues/7009.
2024-11-01 03:27:25 +00:00
overlookmotel
86ab091e42 style(transformer/common): Split up StatementInjectorStore methods into blocks (#7042)
Pure refactor. Split up the `impl`s into multiple blocks with comments for each block, to make it clearer.
2024-10-31 19:23:28 +00:00
Boshen
fcaba4a92a feat(transformer): add TransformerOptions::env with EnvOptions (#7037) 2024-10-31 12:30:32 +00:00
Boshen
e921df6199 refactor(transformer): rename EnvOptions to BabelEnvOptions (#7036) 2024-10-31 10:00:52 +00:00
overlookmotel
1d906c64e7 feat(transformer): class properties transform skeleton (#7038)
Skeleton of class properties transform. #7011 contains WIP implementation.
2024-10-31 09:55:41 +00:00
Dunqing
934cb5e746 feat(transformer): add async_generator_functions plugin (#6573)
Passed 15/19 tests. The remaining 4 failed tests related to `this` expression, the problem same as I mentioned in #6658. I will fix them in follow-up PRs.
2024-10-31 09:14:17 +00:00
Boshen
af5140fc3d refactor(transformer): isolate babel options logic (#7034) 2024-10-31 08:04:52 +00:00
Boshen
12aa910508 refactor(transformer): clean up env/targets/query.rs (#7033) 2024-10-31 03:30:08 +00:00
overlookmotel
2a57a66753 test(transformer): support exec tests in Oxc folder (#7030)
Fix error when `tasks/transform_conformance/tests` contains exec tests.
2024-10-31 01:18:09 +00:00
Boshen
3d174bb953 refactor(transformer): clean up BabelOptions (#7029)
part of #6982
2024-10-30 17:14:18 +00:00
Boshen
6284f84f58 refactor(transformer): use Browserslist::Version (#7028) 2024-10-30 14:32:50 +00:00
Boshen
76947e2aec refactor(transform): refactor Babel Targets (#7026)
Found a trick from serde to get us from `BabelTargets` to `Targets`.
2024-10-30 14:08:19 +00:00
overlookmotel
b02114783a refactor(data_structures): make all methods of NonNull shim #[inline(always)] (#7024)
All these methods are trivial and should always be inlined.
2024-10-30 13:00:24 +00:00
overlookmotel
fb1710a8cc refactor(data_structures): add #[repr(transparent)] to NonNull shim (#7023)
Ensure `NonNull` shim is a pure wrapper around `std::ptr::NonNull`. This should be the case anyway, but make sure.
2024-10-30 13:00:22 +00:00
overlookmotel
f1fc8db2fb refactor(data_structures): add read method to NonNull shim (#7022)
Emulate [`NonNull::read`](https://doc.rust-lang.org/beta/std/ptr/struct.NonNull.html#method.read) method in `NonNull` shim. This is more ergonomic, and will be ideal usage once our MSRV reaches 1.80.0 and we can remove the shim.
2024-10-30 13:00:22 +00:00
overlookmotel
c58ec89b81 perf(data_structures): optimize NonEmptyStack::pop (#7021)
Shave a few bytes off `NonEmptyStack::pop`.
2024-10-30 13:00:21 +00:00
Boshen
b8daab3663 refactor(transformer)!: API to TryFrom<&EnvOptions> for TransformOptions and TryFrom<&BabelOptions> TransformOptions (#7020)
…ions` and `TryFrom<&BabelOptions> TransformOptions`
2024-10-30 09:40:09 +00:00
Boshen
17a938ee1f
refactor(parser): use function parse_type_member_semicolon (#7018) 2024-10-30 17:20:03 +08:00
Boshen
aa1b29c0cf
refactor(parser): remove parse_ts_index_signature_member function (#7017) 2024-10-30 17:20:02 +08:00
Boshen
5b11cdf611 refactor(transformer): clean up TransformerOptions (#7005)
This is a work towards https://github.com/oxc-project/oxc/issues/6982

Next PR will try and make sense of env options vs babel options vs targets and bugfixes, I'm super confused right now.
2024-10-30 09:09:38 +00:00
Boshen
caaf00e081 fix(parser): fix incorrect parsed TSIndexSignature (#7016)
closes #6985
2024-10-30 07:34:22 +00:00
Boshen
a786dc2449
chore(.ignore): ignore snapshots 2024-10-30 13:30:19 +08:00
Boshen
0ae4cd6630
chore(justfile): improve watch command 2024-10-30 11:51:31 +08:00
ottomated
854870e296 feat(ast): Label AST fields with #[ts] (#6987)
I think I found all of the AST fields that are typescript-only but I could be wrong. I did label decorators as `#[ts]` but not sure if that's correct.
2024-10-30 03:44:05 +00:00
camchenry
147e2e4858 fix(linter): allow replacing rule when none are enabled yet (#7014)
fixes https://github.com/oxc-project/oxc/issues/7009

allows rules to be replaced properly when the `rules_for_override` array is empty (e.g., if you initially disable all rules, then configure them) by checking the `all_rules` array if the first `find` call fails
2024-10-30 03:39:03 +00:00
renovate
4b3e1223fe chore(deps): update npm packages (#6861)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@types/node](https://redirect.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node) ([source](https://redirect.github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node)) | [`22.8.1` -> `22.8.4`](https://renovatebot.com/diffs/npm/@types%2fnode/22.8.1/22.8.4) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@types%2fnode/22.8.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@types%2fnode/22.8.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@types%2fnode/22.8.1/22.8.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@types%2fnode/22.8.1/22.8.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@types/vscode](https://redirect.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/vscode) ([source](https://redirect.github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/vscode)) | [`1.80.0` -> `1.95.0`](https://renovatebot.com/diffs/npm/@types%2fvscode/1.80.0/1.95.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@types%2fvscode/1.95.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@types%2fvscode/1.95.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@types%2fvscode/1.80.0/1.95.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@types%2fvscode/1.80.0/1.95.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [pnpm](https://pnpm.io) ([source](https://redirect.github.com/pnpm/pnpm/tree/HEAD/pnpm)) | [`9.12.1` -> `9.12.3`](https://renovatebot.com/diffs/npm/pnpm/9.12.1/9.12.3) | [![age](https://developer.mend.io/api/mc/badges/age/npm/pnpm/9.12.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/pnpm/9.12.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/pnpm/9.12.1/9.12.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/pnpm/9.12.1/9.12.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>pnpm/pnpm (pnpm)</summary>

### [`v9.12.3`](https://redirect.github.com/pnpm/pnpm/blob/HEAD/pnpm/CHANGELOG.md#9123)

[Compare Source](https://redirect.github.com/pnpm/pnpm/compare/v9.12.2...v9.12.3)

##### Patch Changes

-   Don't purge `node_modules`, when typing "n" in the prompt that asks whether to remove `node_modules` before installation [#&#8203;8655](https://redirect.github.com/pnpm/pnpm/pull/8655).
-   Fix a bug causing pnpm to infinitely spawn itself when `manage-package-manager-versions=true` is set and the `.tools` directory is corrupt.
-   Use `crypto.hash`, when available, for improved performance [#&#8203;8629](https://redirect.github.com/pnpm/pnpm/pull/8629).
-   Fixed a race condition in temporary file creation in the store by including worker thread ID in filename. Previously, multiple worker threads could attempt to use the same temporary file. Temporary files now include both process ID and thread ID for uniqueness [#&#8203;8703](https://redirect.github.com/pnpm/pnpm/pull/8703).
-   All commands should read settings from the `package.json` at the root of the workspace [#&#8203;8667](https://redirect.github.com/pnpm/pnpm/issues/8667).
-   When `manage-package-manager-versions` is set to `true`, errors spawning a self-managed version of `pnpm` will now be shown (instead of being silent).
-   Pass the find command to npm, it is an alias for npm search

### [`v9.12.2`](https://redirect.github.com/pnpm/pnpm/blob/HEAD/pnpm/CHANGELOG.md#9122)

[Compare Source](https://redirect.github.com/pnpm/pnpm/compare/v9.12.1...v9.12.2)

##### Patch Changes

-   When checking whether a file in the store has executable permissions, the new approach checks if at least one of the executable bits (owner, group, and others) is set to 1. Previously, a file was incorrectly considered executable only when all the executable bits were set to 1. This fix ensures that files with any executable permission, regardless of the user class, are now correctly identified as executable [#&#8203;8546](https://redirect.github.com/pnpm/pnpm/issues/8546).

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 10am on monday" in timezone Asia/Shanghai, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://redirect.github.com/renovatebot/renovate/discussions) if that's undesired.

---

 - [ ] <!-- 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:eyJjcmVhdGVkSW5WZXIiOiIzOC4xMjAuMSIsInVwZGF0ZWRJblZlciI6IjM4LjEzMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
2024-10-30 03:31:05 +00:00
Boshen
d15e408256 fix(napi/transform): fix 'typescript.declaration' option not working (#7012)
fixes #7010
2024-10-30 03:21:08 +00:00
Dmitry Zakharov
a6fcd812b3
feat(linter): add import/no-commonjs rule (#6978) 2024-10-29 22:15:30 -04:00
Boshen
55637c248e
chore: remove assignee from linter bug report 2024-10-30 09:39:53 +08:00
Boshen
f0c87d453d refactor(transformer): mark all EnvOptions as not implemented (#7004) 2024-10-29 15:05:18 +00:00
Dunqing
562bb9af7f refactor(transformer/async-to-generator): move transform methods to AsyncGeneratorExecutor and make it public (#6992)
The `AsyncGeneratorExecutor` contains many transform methods which both can used in `async-to-generator` and `async-generator-functions` plugins, because their implementations are almost the same. I am still not sure where is the best place to place it.
2024-10-29 13:54:22 +00:00
Boshen
d9edef6ae1 refactor(transformer): combine ObjectRestSpread into a single file (#7002) 2024-10-29 13:21:46 +00:00
overlookmotel
e5ecbb9bf1 refactor(transformer/jsx): return &mut T not &mut ArenaBox<T> (#7001)
`&mut ArenaBox<T>` is a double-reference. `&mut T` is shorter and easier to read.
2024-10-29 13:00:50 +00:00
overlookmotel
ae226710f2 refactor(transformer/typescript): pass &mut T not &mut ArenaBox<T> (#7000)
`&mut ArenaBox<T>` is a double-reference. `&mut T` is shorter and easier to read.
2024-10-29 13:00:49 +00:00
overlookmotel
c945fe71b3 refactor(transformer): import oxc_allocator::Box as ArenaBox (#6999)
Closes #6996.
2024-10-29 13:00:49 +00:00
overlookmotel
fc1af2e9da refactor(transformer): import oxc_allocator::Vec as ArenaVec (#6998)
Part of #6996.
2024-10-29 13:00:48 +00:00
overlookmotel
63e8bfeeec refactor(transformer): rename AString to ArenaString (#6997)
Part of #6996.
2024-10-29 13:00:48 +00:00
Boshen
9fd9f4f5b9 feat(linter)!: sync sindresorhus/globals; removed Object.prototype properties from builtin and es* globals (#6991) 2024-10-29 04:13:20 +00:00
Boshen
8cbf3f09d6
chore: replace bacon with watchexec 2024-10-29 11:50:58 +08:00
DonIsaac
8f1460eba3 refactor(linter): move LintPlugins from LintOptions to LintConfig (#6932)
Pure refactor. Moves plugin settings from linter options (which control the linter's behavior on a global level) and linter config ("which may or may not get adjusted on each file).
2024-10-29 01:28:21 +00:00
DonIsaac
1691cab507 feat(linter): support user-configurable secrets for oxc-security/api-keys (#5938) 2024-10-28 18:55:19 +00:00
Boshen
4b450cc985 chore(transformer): mark all CompilerAssumptions as not Implemented (#6984) 2024-10-28 15:35:32 +00:00
Boshen
4551baaf4a docs(linter): document rules (#6983)
closes #6370
2024-10-28 14:49:16 +00:00
Boshen
46e5360372
chore(deps): update crate-ci/typos action to v1.26.8 (#6981)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-28 22:02:05 +08:00
Boshen
b518670582
chore(coverage): remove known runtime issues 2024-10-28 21:38:37 +08:00
camchenry
c35d3f2ea2 test(linter): improve test failure output (#6975)
Improves the test output when a test fails, based on the type of expectation. The output now includes the config that was passed, as well as the source code that failed. Additional formatting makes it a little bit easier to parse.

Before:

<img width="818" alt="Screenshot 2024-10-27 at 11 54 02 PM" src="https://github.com/user-attachments/assets/bac4079c-566a-403b-adde-acdc709baceb">

&nbsp;

<img width="792" alt="Screenshot 2024-10-27 at 11 54 56 PM" src="https://github.com/user-attachments/assets/16074216-00ad-4cdc-9f47-09142242111d">

---

After:

<img width="784" alt="Screenshot 2024-10-27 at 11 49 36 PM" src="https://github.com/user-attachments/assets/5d687562-55f4-4e4f-aa3a-c90b90b714e8">

&nbsp;

<img width="820" alt="Screenshot 2024-10-27 at 11 58 56 PM" src="https://github.com/user-attachments/assets/0725d362-7aed-4fd0-9fab-93a7687aca6d">
2024-10-28 12:55:24 +00:00
Boshen
fa9a4ecd4a perf(parser): check . before [ in parse_member_expression_rest (#6979) 2024-10-28 11:00:28 +00:00