Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove paranthesis expression #388

Merged
merged 2 commits into from
Jun 1, 2023
Merged

Conversation

anonrig
Copy link
Contributor

@anonrig anonrig commented May 25, 2023

Work in progress.

Fixes #384

@anonrig anonrig requested a review from Boshen May 25, 2023 13:59
@anonrig anonrig force-pushed the paranthesis-expression branch 2 times, most recently from 8a3d800 to ef180cd Compare May 25, 2023 14:31
@github-actions
Copy link
Contributor

github-actions bot commented May 25, 2023

Benchmark Results

Linux

group                            main                                   pr
-----                            ----                                   --
minifier/antd.js                 1.01    209.2±2.38ms    30.5 MB/sec    1.00    206.9±2.12ms    30.8 MB/sec
minifier/react.development.js    1.01      2.2±0.02ms    30.7 MB/sec    1.00      2.2±0.02ms    31.0 MB/sec
minifier/typescript.js           1.01    334.4±2.68ms    30.9 MB/sec    1.00    330.6±2.59ms    31.2 MB/sec
minifier/vue.js                  1.01     13.5±0.19ms    24.1 MB/sec    1.00     13.4±0.19ms    24.3 MB/sec
parser/antd.js                   1.00     78.5±0.78ms    81.2 MB/sec    1.01     79.0±1.55ms    80.7 MB/sec
parser/react.development.js      1.00    842.4±5.40µs    81.7 MB/sec    1.00    840.0±7.22µs    81.9 MB/sec
parser/typescript.js             1.00    130.1±0.98ms    79.3 MB/sec    1.00    129.5±0.84ms    79.7 MB/sec
parser/vue.js                    1.00      5.5±0.02ms    59.8 MB/sec    1.00      5.4±0.03ms    59.9 MB/sec

Windows

group                            main                                   pr
-----                            ----                                   --
minifier/antd.js                 1.03    243.3±7.10ms    26.2 MB/sec    1.00    237.4±4.91ms    26.9 MB/sec
minifier/react.development.js    1.51      3.8±1.14ms    17.9 MB/sec    1.00      2.5±0.01ms    27.0 MB/sec
minifier/typescript.js           1.01   367.4±11.09ms    28.1 MB/sec    1.00    365.1±9.75ms    28.3 MB/sec
minifier/vue.js                  1.12     16.9±3.00ms    19.3 MB/sec    1.00     15.1±0.31ms    21.6 MB/sec
parser/antd.js                   1.01     78.5±2.31ms    81.2 MB/sec    1.00     78.0±1.98ms    81.8 MB/sec
parser/react.development.js      1.02   810.7±14.00µs    84.9 MB/sec    1.00    797.0±4.87µs    86.3 MB/sec
parser/typescript.js             1.09   140.5±33.16ms    73.4 MB/sec    1.00    129.4±2.21ms    79.7 MB/sec
parser/vue.js                    1.00      5.4±0.03ms    60.4 MB/sec    1.00      5.4±0.04ms    60.6 MB/sec

@Boshen Boshen marked this pull request as draft May 29, 2023 15:10
@Boshen
Copy link
Member

Boshen commented May 29, 2023

I'm working on this in another branch, this is hard than I thought. JavaScript grammar are wild 😭

@Boshen Boshen marked this pull request as ready for review June 1, 2023 12:09
@Boshen
Copy link
Member

Boshen commented Jun 1, 2023

Oh man this took longer than I thought, and I had to juggle a lot of decisions ...

This is currently in a mergeable state, where the bulk of the work is done. Once merged, we'll be able to fix all the smaller issues one by one, instead of trying to fix everything altogether.

I turned off some of the previous optimizations, because they are interfering with each other. I also turned off some of the tests, because the optimizations aren't done yet.

In the next steps, I'll look into the bigger architecture first, mainly separate out the these interfering optimizations into separate ast passes.

During the meantime, you guys can pick up any commented out test and try to learn some JavaScript Grammar 😄

@Boshen Boshen requested a review from mysteryven June 1, 2023 12:17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Things are getting smaller overall! Hooray!

@codecov
Copy link

codecov bot commented Jun 1, 2023

Codecov Report

Merging #388 (f348068) into main (4109c8b) will decrease coverage by 0.13%.
The diff coverage is 94.39%.

@@            Coverage Diff             @@
##             main     #388      +/-   ##
==========================================
- Coverage   89.54%   89.42%   -0.13%     
==========================================
  Files         151      151              
  Lines       28093    28159      +66     
==========================================
+ Hits        25156    25181      +25     
- Misses       2937     2978      +41     
Impacted Files Coverage Δ
crates/oxc_hir/src/hir_builder.rs 87.05% <ø> (-0.12%) ⬇️
crates/oxc_hir/src/visit_mut.rs 84.84% <ø> (-0.09%) ⬇️
crates/oxc_syntax/src/precedence.rs 53.84% <25.00%> (-46.16%) ⬇️
crates/oxc_minifier/src/compressor/mod.rs 81.92% <50.00%> (-17.53%) ⬇️
crates/oxc_hir/src/precedence.rs 70.58% <66.66%> (+11.21%) ⬆️
crates/oxc_minifier/src/printer/gen.rs 88.34% <96.91%> (+0.31%) ⬆️
crates/oxc_ast_lower/src/lib.rs 99.32% <100.00%> (-0.01%) ⬇️
crates/oxc_hir/src/hir.rs 26.73% <100.00%> (-0.04%) ⬇️
crates/oxc_minifier/src/printer/mod.rs 94.70% <100.00%> (+0.78%) ⬆️
crates/oxc_parser/src/js/expression.rs 98.50% <100.00%> (ø)
... and 1 more

... and 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@mysteryven mysteryven left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a great work!

@@ -24,7 +25,7 @@ impl<'a> GetPrecedence for Expression<'a> {
Self::NewExpression(expr) => expr.precedence(),
Self::CallExpression(expr) => expr.precedence(),
Self::MemberExpression(expr) => expr.precedence(),
_ => Precedence::Lowest,
_ => Precedence::highest(),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for this change? @Boshen

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest are primary expressions, which has the highest precedence.

@Boshen Boshen merged commit f8125af into main Jun 1, 2023
@Boshen Boshen deleted the paranthesis-expression branch June 1, 2023 14:45
Brooooooklyn referenced this pull request in toeverything/AFFiNE Jan 7, 2024
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [oxlint](https://oxc-project.github.io) ([source](https://togithub.com/oxc-project/oxc/tree/HEAD/npm/oxlint)) | [`0.0.22` -> `0.1.2`](https://renovatebot.com/diffs/npm/oxlint/0.0.22/0.1.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/oxlint/0.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/oxlint/0.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/oxlint/0.0.22/0.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/oxlint/0.0.22/0.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>oxc-project/oxc (oxlint)</summary>

### [`v0.1.2`](https://togithub.com/oxc-project/oxc/releases/tag/oxlint_v0.1.2): oxlint v0.1.2

[Compare Source](https://togithub.com/oxc-project/oxc/compare/821cc8e9c7cfb326ff546483bb2a32d12e018e4c...4a9e0c4bf4179bf5839b690be3690163ff00e2ef)

#### Try it out!

-   Run `npx --yes oxlint@latest` from your terminal
-   Install the Vscode extension https://marketplace.visualstudio.com/items?itemName=oxc.oxc-vscode
-   Read the [usage guide](https://oxc-project.github.io/docs/guide/usage/linter.html)

#### Svelte support

`<script>` tag is linted by default.

#### Features

-   feat(linter): <script> part of svelte file by [@&#8203;Boshen](https://togithub.com/Boshen) in [https://github.com/oxc-project/oxc/pull/1918](https://togithub.com/oxc-project/oxc/pull/1918)
-   feat(linter): disable no-unused-labels for svelte by [@&#8203;Boshen](https://togithub.com/Boshen) in [https://github.com/oxc-project/oxc/pull/1919](https://togithub.com/oxc-project/oxc/pull/1919)

### Fixes

-   fix(linter): change no-var to restriction [`bb6128b`](https://togithub.com/oxc-project/oxc/commit/bb6128b)
-   chore: add some useful informantion log by [@&#8203;IWANABETHATGUY](https://togithub.com/IWANABETHATGUY) in [https://github.com/oxc-project/oxc/pull/1912](https://togithub.com/oxc-project/oxc/pull/1912)
-   fix(linter) fix eslint config for filename case by [@&#8203;camc314](https://togithub.com/camc314) in [https://github.com/oxc-project/oxc/pull/1913](https://togithub.com/oxc-project/oxc/pull/1913)

**Full Changelog**: oxc-project/oxc@oxlint_v0.1.1...oxlint_v0.1.2

### [`v0.1.1`](https://togithub.com/oxc-project/oxc/releases/tag/oxlint_v0.1.1): oxlint v0.1.1

[Compare Source](https://togithub.com/oxc-project/oxc/compare/v0.1.0...821cc8e9c7cfb326ff546483bb2a32d12e018e4c)

#### Try it out!

-   Run `npx --yes oxlint@latest` from your terminal
-   Install the Vscode extension https://marketplace.visualstudio.com/items?itemName=oxc.oxc-vscode
-   Read the [usage guide](https://oxc-project.github.io/docs/guide/usage/linter.html)

#### Vue support

`<script>` and `<script setup>` are linted by default.

#### Astro support

Frontmatter component script `---` and all `<script>` tags are linted by default.

#### Configuration files (experimental)

`-c ./eslintrc.json` will use the `rules` field for rule configuration, as documented in [ESLint's documentation](https://eslint.org/docs/latest/use/configure/rules#using-configuration-files).

Unfortunately, only the `json` format is supported right now.

The `extends` field will not take effect; normal `-D` and `-A` flags still apply.

#### New Rules

##### Correctness

-   deepscan: bad object literal comparison by [@&#8203;camc314](https://togithub.com/camc314) in [https://github.com/oxc-project/oxc/pull/1844](https://togithub.com/oxc-project/oxc/pull/1844)
-   oxc: erasing op by [@&#8203;camc314](https://togithub.com/camc314) in [https://github.com/oxc-project/oxc/pull/1834](https://togithub.com/oxc-project/oxc/pull/1834)
-   oxc: only used in recursion by [@&#8203;camc314](https://togithub.com/camc314) in [https://github.com/oxc-project/oxc/pull/1833](https://togithub.com/oxc-project/oxc/pull/1833)
-   eslint: no irregular whitespace by [@&#8203;DeividAlmeida](https://togithub.com/DeividAlmeida) in [https://github.com/oxc-project/oxc/pull/1877](https://togithub.com/oxc-project/oxc/pull/1877)
-   eslint: no-unused-private-class-members rule by [@&#8203;Dunqing](https://togithub.com/Dunqing) in [https://github.com/oxc-project/oxc/pull/1820](https://togithub.com/oxc-project/oxc/pull/1820)
-   eslint: no-var by [@&#8203;zhangrunzhao](https://togithub.com/zhangrunzhao) in [https://github.com/oxc-project/oxc/pull/1890](https://togithub.com/oxc-project/oxc/pull/1890)
-   eslint-plugin-react: jsx-no-undef for by [@&#8203;XantreGodlike](https://togithub.com/XantreGodlike) in [https://github.com/oxc-project/oxc/pull/1862](https://togithub.com/oxc-project/oxc/pull/1862)
-   eslint-plugin-jsx-a11y: aria-role by [@&#8203;msdlisper](https://togithub.com/msdlisper) in [https://github.com/oxc-project/oxc/pull/1849](https://togithub.com/oxc-project/oxc/pull/1849)
-   eslint-plugin-jsx-a11y: lang by [@&#8203;msdlisper](https://togithub.com/msdlisper) in [https://github.com/oxc-project/oxc/pull/1812](https://togithub.com/oxc-project/oxc/pull/1812)
-   eslint-plugin-jsx-a11y: media-has-caption by [@&#8203;poteboy](https://togithub.com/poteboy) in [https://github.com/oxc-project/oxc/pull/1822](https://togithub.com/oxc-project/oxc/pull/1822)
-   eslint-plugin-jsx-a11y: mouse-events-have-key-events(correctness) by [@&#8203;Ken-HH24](https://togithub.com/Ken-HH24) in [https://github.com/oxc-project/oxc/pull/1867](https://togithub.com/oxc-project/oxc/pull/1867)
-   eslint-plugin-jsx-a11y: prefer-tag-over-role rule by [@&#8203;yossydev](https://togithub.com/yossydev) in [https://github.com/oxc-project/oxc/pull/1831](https://togithub.com/oxc-project/oxc/pull/1831)
-   eslint-plugin-jsx-a11y: aria-unsupported-elements by [@&#8203;re-taro](https://togithub.com/re-taro) in [https://github.com/oxc-project/oxc/pull/1855](https://togithub.com/oxc-project/oxc/pull/1855)
-   eslint-plugin-jsx-a11y: html_has_lang by [@&#8203;msdlisper](https://togithub.com/msdlisper) in [https://github.com/oxc-project/oxc/pull/1843](https://togithub.com/oxc-project/oxc/pull/1843)

##### Suspicious

-   oxc: approx constant by [@&#8203;camc314](https://togithub.com/camc314) in [https://github.com/oxc-project/oxc/pull/1818](https://togithub.com/oxc-project/oxc/pull/1818)
-   oxc: misrefactored assign op by [@&#8203;camc314](https://togithub.com/camc314) in [https://github.com/oxc-project/oxc/pull/1832](https://togithub.com/oxc-project/oxc/pull/1832)

##### Restriction

-   react: button has type by [@&#8203;camc314](https://togithub.com/camc314) in [https://github.com/oxc-project/oxc/pull/1785](https://togithub.com/oxc-project/oxc/pull/1785)
-   unicorn: prefer modern math apis by [@&#8203;camc314](https://togithub.com/camc314) in [https://github.com/oxc-project/oxc/pull/1620](https://togithub.com/oxc-project/oxc/pull/1620)

#### Fixes

-   fix(linter): ignore anonymous functional components in arrays for eslint-plugin-react(jsx-key) by [@&#8203;maurice](https://togithub.com/maurice) in [https://github.com/oxc-project/oxc/pull/1858](https://togithub.com/oxc-project/oxc/pull/1858)
-   Prioritize ignored paths when linting by [@&#8203;clarkf](https://togithub.com/clarkf) in [https://github.com/oxc-project/oxc/pull/1878](https://togithub.com/oxc-project/oxc/pull/1878)
-   feat(linter): handle more cases for `const-comparisons` by [@&#8203;camc314](https://togithub.com/camc314) in [https://github.com/oxc-project/oxc/pull/1817](https://togithub.com/oxc-project/oxc/pull/1817)
-   feat(semantic): allow reserved keyword defined in ts module block by [@&#8203;Dunqing](https://togithub.com/Dunqing) in [https://github.com/oxc-project/oxc/pull/1907](https://togithub.com/oxc-project/oxc/pull/1907)
-   fix(parser): error on source larger than 4 GiB by [@&#8203;overlookmotel](https://togithub.com/overlookmotel) in [https://github.com/oxc-project/oxc/pull/1860](https://togithub.com/oxc-project/oxc/pull/1860)
-   fix(parser): fix incorrectly identified directives by [@&#8203;overlookmotel](https://togithub.com/overlookmotel) in [https://github.com/oxc-project/oxc/pull/1885](https://togithub.com/oxc-project/oxc/pull/1885)
-   fix(parser): terminate parsing if an EmptyParenthesizedExpression error occurs by [@&#8203;Dunqing](https://togithub.com/Dunqing) in [https://github.com/oxc-project/oxc/pull/1874](https://togithub.com/oxc-project/oxc/pull/1874)
-   fix(semantic): remove duplicate errors in ModuleDeclaration::ImportDeclaration by [@&#8203;Dunqing](https://togithub.com/Dunqing) in [https://github.com/oxc-project/oxc/pull/1846](https://togithub.com/oxc-project/oxc/pull/1846)
-   perf(linter): reduce the number of diagnostics for no_sparse_arrays by [@&#8203;camc314](https://togithub.com/camc314) in [https://github.com/oxc-project/oxc/pull/1895](https://togithub.com/oxc-project/oxc/pull/1895)

#### New Contributors

-   [@&#8203;maurice](https://togithub.com/maurice) made their first contribution in [https://github.com/oxc-project/oxc/pull/1858](https://togithub.com/oxc-project/oxc/pull/1858)
-   [@&#8203;re-taro](https://togithub.com/re-taro) made their first contribution in [https://github.com/oxc-project/oxc/pull/1855](https://togithub.com/oxc-project/oxc/pull/1855)
-   [@&#8203;DeividAlmeida](https://togithub.com/DeividAlmeida) made their first contribution in [https://github.com/oxc-project/oxc/pull/1835](https://togithub.com/oxc-project/oxc/pull/1835)
-   [@&#8203;XantreGodlike](https://togithub.com/XantreGodlike) made their first contribution in [https://github.com/oxc-project/oxc/pull/1862](https://togithub.com/oxc-project/oxc/pull/1862)
-   [@&#8203;Qix-](https://togithub.com/Qix-) made their first contribution in [https://github.com/oxc-project/oxc/pull/1861](https://togithub.com/oxc-project/oxc/pull/1861)
-   [@&#8203;yossydev](https://togithub.com/yossydev) made their first contribution in [https://github.com/oxc-project/oxc/pull/1831](https://togithub.com/oxc-project/oxc/pull/1831)
-   [@&#8203;clarkf](https://togithub.com/clarkf) made their first contribution in [https://github.com/oxc-project/oxc/pull/1878](https://togithub.com/oxc-project/oxc/pull/1878)
-   [@&#8203;zhangrunzhao](https://togithub.com/zhangrunzhao) made their first contribution in [https://github.com/oxc-project/oxc/pull/1890](https://togithub.com/oxc-project/oxc/pull/1890)

**Full Changelog**: oxc-project/oxc@oxlint_v0.0.22...oxlint_v0.1.1

### [`v0.1.0`](https://togithub.com/oxc-project/oxc/releases/tag/v0.1.0): CLI v0.1.0 Ezno Type Checker

[Compare Source](https://togithub.com/oxc-project/oxc/compare/a1accdca7f83694a6ea520d5cbfd090ea5dd271a...v0.1.0)

`npx oxidation-compiler@latest check ./test.ts`

![image](https://togithub.com/Boshen/oxc/assets/1430279/c7308395-1856-43fa-b4b8-b239886ec259)

#### New Contributors

-   [@&#8203;anonrig](https://togithub.com/anonrig) made their first contribution in [https://github.com/Boshen/oxc/pull/388](https://togithub.com/Boshen/oxc/pull/388)
-   [@&#8203;kaleidawave](https://togithub.com/kaleidawave) made their first contribution in [https://github.com/Boshen/oxc/pull/413](https://togithub.com/Boshen/oxc/pull/413)

**Full Changelog**: https://github.com/Boshen/oxc/compare/v0.0.7...

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **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/toeverything/AFFiNE).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMjEuMCIsInVwZGF0ZWRJblZlciI6IjM3LjEyMS4wIiwidGFyZ2V0QnJhbmNoIjoiY2FuYXJ5In0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(minifier): expression parentheses removal
3 participants