KittyCAD / modeling-app

The KittyCAD modeling app.
https://kittycad.io/modeling-app/download
MIT License
426 stars 36 forks source link

KCL: Object literals like {x} as shorthand for {x: x} #4521

Closed adamchalmers closed 5 days ago

adamchalmers commented 5 days ago

If the key and value in an object literal use the same identifier, allow abbreviating it.

Basically these two are now equivalent:

x = 2
obj = { x: x, y: 3}
x = 2
- obj = { x: x, y: 3}
+ obj = { x, y: 3}

This syntax is used in JS, Rust and probably elsewhere too.

Here's a more realistic example. Before:

radius = 10

startSketchAt([0, 0])
|> circle({center: [0, 0], radius: radius}, %)

After:

radius = 10

startSketchAt([0, 0])
- |> circle({center: [0, 0], radius: radius}, %)
+ |> circle({center: [0, 0], radius}, %)
qa-wolf[bot] commented 5 days ago

QA Wolf here! As you write new code it's important that your test coverage is keeping up. Click here to request test coverage for this PR!

vercel[bot] commented 5 days ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
modeling-app ✅ Ready (Inspect) Visit Preview Nov 20, 2024 3:23pm
codecov[bot] commented 5 days ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 86.06%. Comparing base (986675f) to head (6dbf486). Report is 3 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #4521 +/- ## ======================================= Coverage 86.06% 86.06% ======================================= Files 80 80 Lines 29557 29575 +18 ======================================= + Hits 25437 25455 +18 Misses 4120 4120 ``` | [Flag](https://app.codecov.io/gh/KittyCAD/modeling-app/pull/4521/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=KittyCAD) | Coverage Δ | | |---|---|---| | [wasm-lib](https://app.codecov.io/gh/KittyCAD/modeling-app/pull/4521/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=KittyCAD) | `86.06% <100.00%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=KittyCAD#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.


🚨 Try these New Features: