KCL: No 'let' or 'const' required when declaring vars (#4063)

Previously variable declaration required a keyword, e.g.

```kcl
let x = 4
const x = 4
var x = 4
```

These were all valid, and did the exact same thing. As of this PR, they're all still valid, but the KCL formatter will change them all to just:

```kcl
x = 4
```

which is the new preferred way to declare a constant. 

But the formatter will remove the var/let/const keywords.

Closes https://github.com/KittyCAD/modeling-app/issues/3985
This commit is contained in:
Adam Chalmers
2024-10-02 14:19:40 -05:00
committed by GitHub
parent a24789c236
commit 0c478680cb
160 changed files with 1357 additions and 1360 deletions

View File

@ -182,7 +182,7 @@ test.describe('Testing segment overlays', () => {
await page.addInitScript(async () => {
localStorage.setItem(
'persistCode',
`const part001 = startSketchOn('XZ')
`part001 = startSketchOn('XZ')
|> startProfileAt([5 + 0, 20 + 0], %)
|> line([0.5, -14 + 0], %)
|> angledLine({ angle: 3 + 0, length: 32 + 0 }, %)
@ -343,14 +343,14 @@ test.describe('Testing segment overlays', () => {
await page.addInitScript(async () => {
localStorage.setItem(
'persistCode',
`const yRel001 = -14
const xRel001 = 0.5
const angle001 = 3
const len001 = 32
const yAbs001 = 11.5
const xAbs001 = 33
const xAbs002 = 4
const part001 = startSketchOn('XZ')
`yRel001 = -14
xRel001 = 0.5
angle001 = 3
len001 = 32
yAbs001 = 11.5
xAbs001 = 33
xAbs002 = 4
part001 = startSketchOn('XZ')
|> startProfileAt([0, 0], %)
|> line([0.5, yRel001], %)
|> angledLine({ angle: angle001, length: len001 }, %)
@ -420,7 +420,7 @@ const part001 = startSketchOn('XZ')
await page.addInitScript(async () => {
localStorage.setItem(
'persistCode',
`const part001 = startSketchOn('XZ')
`part001 = startSketchOn('XZ')
|> startProfileAt([0, 0], %)
|> line([0.5, -14 + 0], %)
|> angledLine({ angle: 3 + 0, length: 32 + 0 }, %)
@ -548,7 +548,7 @@ const part001 = startSketchOn('XZ')
await page.addInitScript(async () => {
localStorage.setItem(
'persistCode',
`const part001 = startSketchOn('XZ')
`part001 = startSketchOn('XZ')
|> startProfileAt([0, 0], %)
|> line([0.5, -14 + 0], %)
|> angledLine({ angle: 3 + 0, length: 32 + 0 }, %)
@ -704,7 +704,7 @@ const part001 = startSketchOn('XZ')
await page.addInitScript(async () => {
localStorage.setItem(
'persistCode',
`const part001 = startSketchOn('XZ')
`part001 = startSketchOn('XZ')
|> startProfileAt([0, 0], %)
|> line([0.5, -14 + 0], %)
|> angledLine({ angle: 3 + 0, length: 32 + 0 }, %)
@ -778,7 +778,7 @@ const part001 = startSketchOn('XZ')
await page.addInitScript(async () => {
localStorage.setItem(
'persistCode',
`const part001 = startSketchOn('XZ')
`part001 = startSketchOn('XZ')
|> circle({ center: [1 + 0, 0], radius: 8 }, %)
`
)
@ -891,7 +891,7 @@ const part001 = startSketchOn('XZ')
await page.addInitScript(async () => {
localStorage.setItem(
'persistCode',
`const part001 = startSketchOn('XZ')
`part001 = startSketchOn('XZ')
|> startProfileAt([0, 0], %)
|> line([0.5, -14 + 0], %)
|> angledLine({ angle: 3 + 0, length: 32 + 0 }, %)
@ -1123,12 +1123,12 @@ const part001 = startSketchOn('XZ')
async ({ lineToBeDeleted, extraLine }) => {
localStorage.setItem(
'persistCode',
`const part001 = startSketchOn('XZ')
`part001 = startSketchOn('XZ')
|> startProfileAt([5, 6], %)
|> ${lineToBeDeleted}
|> line([-10, -15], %)
|> angledLine([-176, segLen(seg01)], %)
${extraLine ? 'const myVar = segLen(seg01)' : ''}`
${extraLine ? 'myVar = segLen(seg01)' : ''}`
)
},
{
@ -1283,7 +1283,7 @@ ${extraLine ? 'const myVar = segLen(seg01)' : ''}`
async ({ lineToBeDeleted }) => {
localStorage.setItem(
'persistCode',
`const part001 = startSketchOn('XZ')
`part001 = startSketchOn('XZ')
|> startProfileAt([5, 6], %)
|> ${lineToBeDeleted}
|> line([-10, -15], %)