diff --git a/.eslintrc b/.eslintrc index 10f5f4cca..ab6c2bfc3 100644 --- a/.eslintrc +++ b/.eslintrc @@ -25,6 +25,7 @@ "files": ["e2e/**/*.ts"], // Update the pattern based on your file structure "rules": { "@typescript-eslint/no-floating-promises": "warn", + "suggest-no-throw/suggest-no-throw": "off", "testing-library/prefer-screen-queries": "off" } }, diff --git a/.github/workflows/build-test-web.yml b/.github/workflows/build-test-web.yml index f42c5a144..d0f7640c7 100644 --- a/.github/workflows/build-test-web.yml +++ b/.github/workflows/build-test-web.yml @@ -44,6 +44,8 @@ jobs: - run: yarn build:wasm - run: yarn xstate:typegen - run: yarn tsc + - name: Lint + run: yarn eslint --max-warnings 0 src e2e check-typos: diff --git a/e2e/playwright/copilot-ghost-test.spec.ts b/e2e/playwright/copilot-ghost-test.spec.ts index 38eeee253..8520dfaa1 100644 --- a/e2e/playwright/copilot-ghost-test.spec.ts +++ b/e2e/playwright/copilot-ghost-test.spec.ts @@ -9,6 +9,7 @@ test.afterEach(async ({ page }, testInfo) => { await tearDown(page, testInfo) }) test.describe('Copilot ghost text', () => { + // eslint-disable-next-line jest/valid-title test.skip(true, 'Needs to get covered again') test('completes code in empty file', async ({ page }) => { diff --git a/e2e/playwright/regression-tests.spec.ts b/e2e/playwright/regression-tests.spec.ts index 2b2db989d..e6730cfbd 100644 --- a/e2e/playwright/regression-tests.spec.ts +++ b/e2e/playwright/regression-tests.spec.ts @@ -337,6 +337,7 @@ const sketch001 = startSketchAt([-0, -0]) }) => { // This is being weird on ubuntu and windows. test.skip( + // eslint-disable-next-line jest/valid-title process.platform === 'linux' || process.platform === 'win32', 'This test is being weird on ubuntu' ) diff --git a/e2e/playwright/sketch-tests.spec.ts b/e2e/playwright/sketch-tests.spec.ts index 5c4cc2fe2..e2e1dd8ec 100644 --- a/e2e/playwright/sketch-tests.spec.ts +++ b/e2e/playwright/sketch-tests.spec.ts @@ -602,7 +602,7 @@ test.describe('Sketch tests', () => { await expect(u.codeLocator).toHaveText(codeStr) // exit the sketch, reset relative clicker - click00r(undefined, undefined) + await click00r(undefined, undefined) await u.openAndClearDebugPanel() await page.getByRole('button', { name: 'Exit Sketch' }).click() await u.expectCmdLog('[data-message-type="execution-done"]') diff --git a/e2e/playwright/snapshot-tests.spec.ts b/e2e/playwright/snapshot-tests.spec.ts index 9e531e0e5..f06df8f37 100644 --- a/e2e/playwright/snapshot-tests.spec.ts +++ b/e2e/playwright/snapshot-tests.spec.ts @@ -53,6 +53,7 @@ test( async ({ page, context }) => { // skip on macos and windows. test.skip( + // eslint-disable-next-line jest/valid-title process.platform === 'darwin' || process.platform === 'win32', 'Skip on macos and windows' ) diff --git a/e2e/playwright/test-utils.ts b/e2e/playwright/test-utils.ts index acf084869..d9a57ec72 100644 --- a/e2e/playwright/test-utils.ts +++ b/e2e/playwright/test-utils.ts @@ -95,6 +95,8 @@ async function expectCmdLog(page: Page, locatorStr: string, timeout = 5000) { await expect(page.locator(locatorStr).last()).toBeVisible({ timeout }) } +// Ignoring the lint since I assume someone will want to use this for a test. +// eslint-disable-next-line @typescript-eslint/no-unused-vars async function waitForDefaultPlanesToBeVisible(page: Page) { await page.waitForFunction( () => @@ -172,7 +174,8 @@ export const wiggleMove = async ( const isElVis = await page.locator(locator).isVisible() if (isElVis) return } - const [x1, y1] = [0, Math.sin((tau / steps) * j * freq) * amplitude] + // x1 is 0. + const y1 = Math.sin((tau / steps) * j * freq) * amplitude const [x2, y2] = [ Math.cos(-ang * deg) * i - Math.sin(-ang * deg) * y1, Math.sin(-ang * deg) * i + Math.cos(-ang * deg) * y1, @@ -453,7 +456,10 @@ export async function getUtils(page: Page) { return page.evaluate('window.tearDown()') } - cdpSession?.send('Network.emulateNetworkConditions', networkOptions) + return cdpSession?.send( + 'Network.emulateNetworkConditions', + networkOptions + ) }, } } diff --git a/e2e/playwright/testing-constraints.spec.ts b/e2e/playwright/testing-constraints.spec.ts index 417b2b644..69bbc85b2 100644 --- a/e2e/playwright/testing-constraints.spec.ts +++ b/e2e/playwright/testing-constraints.spec.ts @@ -72,7 +72,7 @@ test.describe('Testing constraints', () => { page.getByRole('button', { name: 'Exit Sketch' }) ).not.toBeVisible() }) - test(`Test remove constraints`, async ({ page }) => { + test(`Remove constraints`, async ({ page }) => { await page.addInitScript(async () => { localStorage.setItem( 'persistCode', diff --git a/e2e/playwright/testing-segment-overlays.spec.ts b/e2e/playwright/testing-segment-overlays.spec.ts index 90d6d4b3f..2a08b2a9c 100644 --- a/e2e/playwright/testing-segment-overlays.spec.ts +++ b/e2e/playwright/testing-segment-overlays.spec.ts @@ -977,10 +977,6 @@ const part001 = startSketchOn('XZ') const hoverPos = { x: segmentToDelete.x, y: segmentToDelete.y } await page.mouse.move(0, 0) await page.waitForTimeout(1000) - let x = 0, - y = 0 - x = hoverPos.x + Math.cos(ang * deg) * 32 - y = hoverPos.y - Math.sin(ang * deg) * 32 await page.mouse.move(hoverPos.x, hoverPos.y) await wiggleMove( page, diff --git a/e2e/playwright/testing-settings.spec.ts b/e2e/playwright/testing-settings.spec.ts index 7d01ff667..d1f2e3587 100644 --- a/e2e/playwright/testing-settings.spec.ts +++ b/e2e/playwright/testing-settings.spec.ts @@ -4,7 +4,6 @@ import { getUtils, setup, setupElectron, tearDown } from './test-utils' import { SaveSettingsPayload } from 'lib/settings/settingsTypes' import { TEST_SETTINGS_KEY, TEST_SETTINGS_CORRUPTED } from './storageStates' import * as TOML from '@iarna/toml' -import { APP_NAME } from 'lib/constants' test.beforeEach(async ({ context, page }) => { await setup(context, page) @@ -205,7 +204,6 @@ test.describe('Testing settings', () => { }) await page.setViewportSize({ width: 1200, height: 500 }) - const u = await getUtils(page) page.on('console', console.log) diff --git a/e2e/playwright/text-to-cad-tests.spec.ts b/e2e/playwright/text-to-cad-tests.spec.ts index f90828111..e01b87c59 100644 --- a/e2e/playwright/text-to-cad-tests.spec.ts +++ b/e2e/playwright/text-to-cad-tests.spec.ts @@ -1,7 +1,5 @@ import { test, expect, Page } from '@playwright/test' -import * as fsp from 'fs/promises' -import { getUtils, setup, setupElectron, tearDown } from './test-utils' -import { join } from 'path' +import { getUtils, setup, tearDown } from './test-utils' test.beforeEach(async ({ context, page }) => { await setup(context, page) diff --git a/src/Toolbar.tsx b/src/Toolbar.tsx index 9060b0a73..7791368ef 100644 --- a/src/Toolbar.tsx +++ b/src/Toolbar.tsx @@ -185,6 +185,8 @@ export function Toolbar({ maybeIconConfig[0].disabled } name={maybeIconConfig[0].title} + // aria-description is still in ARIA 1.3 draft. + // eslint-disable-next-line jsx-a11y/aria-props aria-description={maybeIconConfig[0].description} onClick={() => maybeIconConfig[0].onClick(configCallbackProps) @@ -225,6 +227,8 @@ export function Toolbar({ (!itemConfig.showTitle ? ' !px-0' : '') } name={itemConfig.title} + // aria-description is still in ARIA 1.3 draft. + // eslint-disable-next-line jsx-a11y/aria-props aria-description={itemConfig.description} aria-pressed={itemConfig.isActive} disabled={ diff --git a/src/lib/createMachineCommand.ts b/src/lib/createMachineCommand.ts index 3cc978477..4d9557c13 100644 --- a/src/lib/createMachineCommand.ts +++ b/src/lib/createMachineCommand.ts @@ -154,10 +154,6 @@ export function buildCommandArgument< } satisfies Omit, 'inputType'> if (arg.inputType === 'options') { - if (!(arg.options || arg.optionsFromContext)) { - throw new Error('Options must be provided for options input type') - } - return { inputType: arg.inputType, ...baseCommandArgument, diff --git a/src/lib/exampleKcl.ts b/src/lib/exampleKcl.ts index 0bd548ec0..335efcb72 100644 --- a/src/lib/exampleKcl.ts +++ b/src/lib/exampleKcl.ts @@ -38,6 +38,9 @@ const bracket = startSketchOn('XY') tags: [getPreviousAdjacentEdge(outerEdge)] }, %)` +/** + * @throws Error if the search text is not found in the example code. + */ function findLineInExampleCode({ searchText, example = bracket, @@ -48,6 +51,8 @@ function findLineInExampleCode({ const lines = example.split('\n') const lineNumber = lines.findIndex((l) => l.includes(searchText)) + 1 if (lineNumber === 0) { + // We are exporting a constant, so we don't want to return an Error. + // eslint-disable-next-line suggest-no-throw/suggest-no-throw throw new Error( `Could not find the line with search text "${searchText}" in the example code. Was it removed?` )