Commit graph

3550 commits

Author SHA1 Message Date
overlookmotel
fdb31c39c9
perf(parser): more efficient number parsing (#3342)
Follow-on after #3296.

Make parsing binary/octal/hex numeric literals a little more efficient.

These changes all rely on that we know more than the compiler does -
that strings passed to these `parse_*` functions can only contain a
certain set of characters.
2024-05-21 10:53:52 +08:00
overlookmotel
e7a6595cd8
refactor(transformer): correct spelling of var name (#3369)
Just correct a typo.
2024-05-21 01:03:40 +08:00
Jelle van der Waa
74be8b146c
feat(linter/eslint): Implement no-new (#3368)
Rule Detail:
[link](https://eslint.org/docs/latest/rules/no-new)
2024-05-21 00:28:04 +08:00
overlookmotel
2b5b3fd22a refactor(traverse): split context code into multiple files (#3367)
Pure refactor. Split `TraverseAncestry` and `TraverseScoping` into separate file, in preparation for adding more methods to `TraverseScoping`.
2024-05-20 15:54:23 +00:00
Jelle van der Waa
c588e5205c
feat(linter/eslint): Implement prefer-exponentiation-operator (#3365)
Rule Detail:

[link](https://eslint.org/docs/latest/rules/prefer-exponentiation-operator)
2024-05-20 23:04:25 +08:00
Jelle van der Waa
283d6c7bb4
feat(linter/eslint): Implement symbol-description (#3364)
Rule Detail:
[link](https://eslint.org/docs/latest/rules/symbol-description)
2024-05-20 22:51:23 +08:00
underfin
e879685a25
refactor(sourcemap): using binary search to search original position (#3360)
The ast span is not ordering at rolldown, eg the module original ast is
`a,b,c`, after mutate could be `b,c,a`. So here revert changes from
[here](https://github.com/oxc-project/oxc/pull/2728).
2024-05-20 22:35:25 +08:00
underfin
90d2d09022
feat(sourcemap): add Sourcemap#from_json method (#3361)
The rolldown plugin hook could return an object map, cast it to string
at node, and decode it has unnecessary json overhead at rust. So here
export an new function to let rolldown could using `JSONSourceMap` to
generate `Sourcemap`.
2024-05-20 22:35:14 +08:00
Boshen
16d8dcda76
ci: allow branch renovate/** 2024-05-20 13:35:31 +08:00
cinchen
aec613bec2
feat(linter): eslint-plugin-jest/no-duplicate-hooks (#3358)
part of https://github.com/oxc-project/oxc/issues/492

Rule Detail:
[link](https://github.com/jest-community/eslint-plugin-jest/blob/main/src/rules/no-duplicate-hooks.ts)
2024-05-20 12:13:34 +08:00
renovate[bot]
d453917d00
chore(deps): update dependency axios to v1.7.0 (#3357)
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [axios](https://axios-http.com)
([source](https://togithub.com/axios/axios)) | [`1.6.8` ->
`1.7.0`](https://renovatebot.com/diffs/npm/axios/1.6.8/1.7.0) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/axios/1.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/axios/1.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/axios/1.6.8/1.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/axios/1.6.8/1.7.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>axios/axios (axios)</summary>

###
[`v1.7.0`](https://togithub.com/axios/axios/blob/HEAD/CHANGELOG.md#170-2024-05-19)

[Compare
Source](https://togithub.com/axios/axios/compare/v1.6.8...v1.7.0)

##### Features

- **adapter:** add fetch adapter;
([#&#8203;6371](https://togithub.com/axios/axios/issues/6371))
([a3ff99b](a3ff99b59d))

##### Bug Fixes

- **core/axios:** handle un-writable error stack
([#&#8203;6362](https://togithub.com/axios/axios/issues/6362))
([81e0455](81e0455b7b))

##### Contributors to this release

- <img
src="https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;18"
alt="avatar" width="18"/> [Dmitriy
Mozgovoy](https://togithub.com/DigitalBrainJS "+1015/-127 (#&#8203;6371
)")
- <img
src="https://avatars.githubusercontent.com/u/4814473?v&#x3D;4&amp;s&#x3D;18"
alt="avatar" width="18"/> [Jay](https://togithub.com/jasonsaayman
"+30/-14 ()")
- <img
src="https://avatars.githubusercontent.com/u/16711696?v&#x3D;4&amp;s&#x3D;18"
alt="avatar" width="18"/> [Alexandre
ABRIOUX](https://togithub.com/alexandre-abrioux "+56/-6 (#&#8203;6362
)")

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 8am on monday" in timezone
Asia/Shanghai, 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 has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/oxc-project/oxc).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNjMuNSIsInVwZGF0ZWRJblZlciI6IjM3LjM2My41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-19 21:42:22 +00:00
renovate[bot]
41ece8188c
chore(deps): update pnpm to v9.1.1 (#3356)
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [pnpm](https://pnpm.io) ([source](https://togithub.com/pnpm/pnpm)) |
[`9.1.0` -> `9.1.1`](https://renovatebot.com/diffs/npm/pnpm/9.1.0/9.1.1)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/pnpm/9.1.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/pnpm/9.1.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/pnpm/9.1.0/9.1.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/pnpm/9.1.0/9.1.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

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

### [`v9.1.1`](https://togithub.com/pnpm/pnpm/compare/v9.1.0...v9.1.1)

[Compare Source](https://togithub.com/pnpm/pnpm/compare/v9.1.0...v9.1.1)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 8am on monday" in timezone
Asia/Shanghai, 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 has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/oxc-project/oxc).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNjMuNSIsInVwZGF0ZWRJblZlciI6IjM3LjM2My41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-19 21:41:37 +00:00
mysteryven
d7849f8865 refactor(linter): find return statement by using CFG in react/require-render-return (#3353)
Maybe currently Class components are relatively few in quantity, didn't performance changed.
2024-05-19 14:59:12 +00:00
Dunqing
8a30a98465 fix(semantic) incorrect reference flag caused by MemberExpression (#3354)
fix: https://github.com/oxc-project/oxc/issues/3326#issuecomment-2118858837
2024-05-19 14:55:18 +00:00
Boshen
89a1f97320
refactor(parser): improve expression parsing (#3352) 2024-05-19 21:28:16 +08:00
Boshen
e818fba21c refactor(parser): improve parse_simple_arrow_function_expression (#3349) 2024-05-19 06:05:39 +00:00
Boshen
d2e1dbc82a perf(coverage): run test cases in parallel (#3348) 2024-05-19 03:24:08 +00:00
overlookmotel
938ae12203 refactor(ast): fix clippy lint on nightly (#3346)
Clippy on nightly produces a warning for `&t as *const _`.

This warning is spurious in this case - we know `t` is valid, because we just created it. But change it, to keep Clippy happy!
2024-05-18 17:43:51 +00:00
Boshen
1e802c71d5
refactor(parser): clean up ParserState (#3345) 2024-05-19 01:30:16 +08:00
Dunqing
e2c6fe0cb1
feat(transformer): report errors when options have unknown fields (#3322) 2024-05-19 01:19:40 +08:00
Boshen
46cb5f97a0
perf(parser): use FxHashSet for not_parenthesized_arrow (#3344) 2024-05-19 01:13:56 +08:00
Boshen
899a52bf28
fix: fix some nightly warnings 2024-05-19 00:54:52 +08:00
Boshen
0742081921 refactor(parser): improve is_parenthesized_arrow_function_expression (#3343) 2024-05-18 16:39:51 +00:00
Boshen
6b3d019631 refactor(paresr): move some structs to js module (#3341) 2024-05-18 14:41:32 +00:00
Boshen
9ced605487
refactor(parser): start porting arrow function parsing from tsc (#3340)
relates #3320
2024-05-18 22:35:29 +08:00
Boshen
17f4b199b9 feat(cli): add --silent to disable all diagnostics printing (#3338) 2024-05-18 10:22:51 +00:00
Boshen
c9d84af44e
refactor(diagnostics): s/warning/warn 2024-05-18 17:55:05 +08:00
Boshen
f13fe8a18b
feat!(linter): enforce rule severity from the cli and configuration file (#3337)
closes #2059

Breaking change:

* `--deny` / `-D` from the CLI and `error` from configuration file will
report diagnostics as severity "error".
* `--warn` / `-W` from the CLI and `warn` from configuration file will
report diagnostics as severity "warning".
2024-05-18 17:45:19 +08:00
Boshen
8388c7bd21
perf(linter): use usize for RuleEnum hash (#3336) 2024-05-18 14:12:32 +08:00
Boshen
8383b6e046 refactor(linter): remove with_rule_name from the tight loop (#3335) 2024-05-18 01:43:08 +00:00
Boshen
e4b3a3c06a feat(linter): backward compability for react-hooks and deepscan plugins (#3334)
closes #3317
2024-05-17 16:09:20 +00:00
mysteryven
a23bbf9016 fix(linter): avoid infinite loop in jest/expect-expect (#3332)
fix: #3324

I just replace `name` with a `set`, feel like this can catch more cases. And this rule needs to be [rewritten](https://github.com/oxc-project/oxc/issues/3323#issuecomment-2117623621).
2024-05-17 14:45:22 +00:00
Boshen
6c3d99a951 fix(linter/jsx-no-undef): check for globals when an identifier is undefined (#3331)
closes #3319
2024-05-17 14:20:08 +00:00
mysteryven
385965f2ff fix(linter): avoid infinite loop when traverse ancestors in jest/no_conditional_expect (#3330)
closes: #3325
2024-05-17 14:12:28 +00:00
Boshen
e241136f91 feat(cli,linter): add --disable-oxc-plugin (#3328)
closes #3316
2024-05-17 12:11:17 +00:00
Boshen
4f76cb6f38 refactor(linter): merge deepscan rules into oxc rules (#3327) 2024-05-17 11:56:06 +00:00
Boshen
95e9b6986c fix(linter): fix panic in jest/expect-expect (#3324)
closes #3323
2024-05-17 07:56:02 +00:00
Don Isaac
27030b9eb4
perf(lexer): use bitshifting when parsing known integers (#3296)
## What This PR Does

- perf(lexer): use bit shifting when parsing hex, octal, and binary
integers instead of `mul_add`-ing on `f64`s. Check out the difference in
assembly generated [here](https://godbolt.org/z/zMEKaeYzh)
- perf(lexer): skip redundant utf8 check when parsing BigInts
- refactor(lexer): remove `unsafe` usage (as per @overlookmotel's
request
[here](https://github.com/oxc-project/oxc/pull/3283#issuecomment-2111814598))
- test(lexer): add numeric parsing unit tests

I don't expect this PR to have a large performance improvement, since
the most common case (`Kind::Decimal`) is not affected. We could do
this, however, by splitting `Kind::Decimal` into `Kind::DecimalFloat`
and `Kind::DecimalInt` when the lexer encounters a `.`
2024-05-17 09:39:10 +08:00
rzvxa
712ee0dde8 fix(linter/react): fix false positives for async components in rules_of_hooks (#3307)
related to #3257
2024-05-16 16:38:16 +00:00
rzvxa
0864cd0115 fix(linter/react): better detection for hooks in the rules_of_hooks. (#3306)
related to #3257
2024-05-16 16:38:14 +00:00
rzvxa
95944419ec fix(linter/react): rules_of_hooks add support for property hooks/components. (#3300)
related to #3257
2024-05-16 16:38:12 +00:00
overlookmotel
0c09047111 feat(traverse): mutable access to scopes tree + symbol table (#3314)
Allow mutable access to scopes tree and symbol table.

Closes #3189.

This completes the v1 scopes-in-traverse implementation, and provides all the primitives required to implement the missing APIs listed in https://github.com/oxc-project/oxc/discussions/3251.

Performance is abysmal, as noted in #3304, but we can fix that later on by taking `Semantic` out of the picture, or optimizing it.
2024-05-16 16:21:24 +00:00
overlookmotel
421107aa82 feat(traverse): pass &mut TraverseCtx to visitors (#3312)
Pass `&mut TraverseCtx` to `Traverse::enter_*` and `Traverse::exit_*` visitor methods. Previously was immutable `&TraverseCtx`.

This is a step towards exposing mutable scope tree + symbol table to visitors.
2024-05-16 16:21:23 +00:00
overlookmotel
f8b5e1e2c9 refactor(traverse): move parent method etc into TraverseAncestry (#3308)
Move the ancestry stack into it's own type `TraverseAncestry`, and expose it via `ctx.ancestry` "namespace".

The "namespaced" way of getting parent etc (`ctx.ancestry.parent()` rather than just `ctx.parent()`) will come in useful once we introduce methods which require a `&mut TraverseCtx`.
2024-05-16 16:21:22 +00:00
overlookmotel
05c71d20b1 refactor(traverse): Traverse produce scopes tree using Semantic (#3304)
`Traverse` use `Semantic` to construct scopes tree and expose it to visitors via `TraverseCtx`.

Currently scopes tree is immutable. Will expose it as a mutable in a follow-on.

This is extremely inefficient. Semantic does all kinds of stuff (control flow graph etc) which `Traverse` doesn't need, and `Traverse` just throws away all that work after semantic has done it. Intent here is to get a working implementation first, and then to do another pass later on to improve performance.
2024-05-16 16:21:20 +00:00
overlookmotel
6f3b1c8724 refactor(semantic): semantic populate scope_id fields in AST (#3303)
`oxc_semantic` populate `scope_id` fields in AST nodes as it walks the tree.

This does produce some duplication - scope IDs are stored both in the AST itself, and in `AstNode`. Will clean this up later on.
2024-05-16 16:21:19 +00:00
overlookmotel
723a46fcc0 refactor(ast): store ScopeId in AST nodes (#3302)
Add `scope_id` field to all AST nodes which can constitute a scope (`Program`, `Function`, `BlockStatement` etc).
2024-05-16 16:21:17 +00:00
rzvxa
c8f1f79d27 fix(linter/react): rules_of_hooks resolve false positives with conditional hooks. (#3299)
related to #3071
2024-05-16 16:16:52 +00:00
Yuji Sugiura
7f9d8b71ee
fix(tasks/lint_rules): Integrate react and react-hooks rules (#3315)
Fixes #2174 , now `react-hooks` plugin and its rules are managed by
`react` plugin issue.
2024-05-16 23:22:02 +08:00
Boshen
6dcfc13e02
Publish oxc_module_lexer v0.13.0 2024-05-16 22:14:47 +08:00