Skip to content

Commit

Permalink
chore: add naming convention lint (#2749)
Browse files Browse the repository at this point in the history
Avoid some bikeshedding that I saw on previous PRs
  • Loading branch information
mscolnick authored Oct 30, 2024
1 parent eaa5054 commit ba4d132
Show file tree
Hide file tree
Showing 23 changed files with 116 additions and 84 deletions.
31 changes: 31 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,37 @@
"noNonNullAssertion": "off",
"noParameterAssign": "off",
"noUnusedTemplateLiteral": "error",
"useNamingConvention": {
"level": "warn",
"options": {
"strictCase": false,
"conventions": [
{
"selector": { "kind": "const", "scope": "global" },
"match": ".*"
},
{
"selector": { "kind": "let", "scope": "global" },
"match": ".*"
},
{
"selector": { "kind": "function" },
"formats": ["camelCase", "PascalCase"]
},
{
"selector": { "kind": "variable" },
"formats": ["camelCase", "PascalCase", "CONSTANT_CASE"]
},
{
"selector": { "kind": "typeLike" },
"formats": ["PascalCase", "CONSTANT_CASE", "camelCase"]
},
{
"match": ".*"
}
]
}
},
"useConsistentArrayType": "off",
"useImportType": "error",
"useNodejsImportProtocol": "error",
Expand Down
44 changes: 22 additions & 22 deletions frontend/e2e-tests/components.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getAppUrl } from "../playwright.config";
import { takeScreenshot } from "./helper";
import { fileURLToPath } from "node:url";

const __filename = fileURLToPath(import.meta.url);
const _filename = fileURLToPath(import.meta.url);

const appUrl = getAppUrl("components.py");
test.beforeEach(async ({ page }, info) => {
Expand Down Expand Up @@ -47,7 +47,7 @@ test("page renders read only view in read mode", async ({ page }) => {
// Can see output
await expect(page.locator("h1").getByText("UI Elements")).toBeVisible();

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("button", async ({ page }) => {
Expand All @@ -64,7 +64,7 @@ test("button", async ({ page }) => {
// Verify output
await helper.verifyOutput("1");

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("checkbox", async ({ page }) => {
Expand All @@ -85,7 +85,7 @@ test("checkbox", async ({ page }) => {
// Verify output
await helper.verifyOutput("False");

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("date", async ({ page }) => {
Expand All @@ -99,7 +99,7 @@ test("date", async ({ page }) => {
// Verify output
await helper.verifyOutput("2020-01-20");

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("dropdown", async ({ page }) => {
Expand All @@ -117,7 +117,7 @@ test("dropdown", async ({ page }) => {
// Verify output
await helper.verifyOutput("b");

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("file button", async ({ page }) => {
Expand All @@ -130,7 +130,7 @@ test("file button", async ({ page }) => {
// Verify output
await helper.verifyOutput("None");

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("file area", async ({ page }) => {
Expand All @@ -142,7 +142,7 @@ test("file area", async ({ page }) => {
// Verify output
await helper.verifyOutput("None");

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("multiselect", async ({ page }) => {
Expand All @@ -166,7 +166,7 @@ test("multiselect", async ({ page }) => {
// Verify output
await helper.verifyOutput("b, c");

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("number", async ({ page }) => {
Expand All @@ -186,7 +186,7 @@ test("number", async ({ page }) => {
// Verify output
await helper.verifyOutput("5");

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("radio", async ({ page }) => {
Expand All @@ -204,7 +204,7 @@ test("radio", async ({ page }) => {
// Verify output
await helper.verifyOutput("b");

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("slider", async ({ page }) => {
Expand All @@ -221,7 +221,7 @@ test("slider", async ({ page }) => {
// Verify output
await helper.verifyOutput("6");

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("switch", async ({ page }) => {
Expand All @@ -242,7 +242,7 @@ test("switch", async ({ page }) => {
// Verify output
await helper.verifyOutput("False");

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("table", async ({ page }) => {
Expand Down Expand Up @@ -288,7 +288,7 @@ test("table", async ({ page }) => {
{ useInnerText: true },
);

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("text", async ({ page }) => {
Expand All @@ -303,7 +303,7 @@ test("text", async ({ page }) => {
// Verify output
await helper.verifyOutput("hello");

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("text_area", async ({ page }) => {
Expand All @@ -318,7 +318,7 @@ test("text_area", async ({ page }) => {
// Verify output
await helper.verifyOutput("hello");

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("complex - array", async ({ page }) => {
Expand Down Expand Up @@ -351,7 +351,7 @@ test("complex - array", async ({ page }) => {
{ useInnerText: true },
);

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("complex - batch", async ({ page }) => {
Expand Down Expand Up @@ -380,7 +380,7 @@ test("complex - batch", async ({ page }) => {
{ useInnerText: true },
);

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("complex - dictionary", async ({ page }) => {
Expand Down Expand Up @@ -418,7 +418,7 @@ test("complex - dictionary", async ({ page }) => {
{ useInnerText: true },
);

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("complex - form", async ({ page }) => {
Expand All @@ -441,7 +441,7 @@ test("complex - form", async ({ page }) => {
// Verify output
await helper.verifyOutput("something!");

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("complex - reused in json", async ({ page }) => {
Expand Down Expand Up @@ -473,7 +473,7 @@ test("complex - reused in json", async ({ page }) => {
await expect(textbox.first()).toHaveValue("world");
await expect(number.first()).toHaveValue("10");

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("complex - reused in markdown", async ({ page }) => {
Expand Down Expand Up @@ -505,5 +505,5 @@ test("complex - reused in markdown", async ({ page }) => {
await expect(textbox.first()).toHaveValue("world");
await expect(number.first()).toHaveValue("10");

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});
4 changes: 2 additions & 2 deletions frontend/e2e-tests/disabled.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getAppUrl, resetFile } from "../playwright.config";
import { maybeRestartKernel, takeScreenshot } from "./helper";
import { fileURLToPath } from "node:url";

const __filename = fileURLToPath(import.meta.url);
const _filename = fileURLToPath(import.meta.url);

const appUrl = getAppUrl("disabled_cells.py");
test.beforeEach(async ({ page }, info) => {
Expand Down Expand Up @@ -112,5 +112,5 @@ test("disabled cells", async ({ page }) => {
// Check the status
await expect(page.getByTitle("This cell is disabled")).toHaveCount(0);

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});
2 changes: 1 addition & 1 deletion frontend/e2e-tests/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const countsForName: Record<string, number> = {};
/**
* Take a screenshot of the page.
* @example
* await takeScreenshot(page, __filename);
* await takeScreenshot(page, _filename);
*/
export async function takeScreenshot(page: Page, filename: string) {
const clean = path.basename(filename).replace(".spec.ts", "");
Expand Down
6 changes: 3 additions & 3 deletions frontend/e2e-tests/kitchen-sink-wasm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect, test } from "@playwright/test";
import { exportAsHTMLAndTakeScreenshot, takeScreenshot } from "./helper";
import { fileURLToPath } from "node:url";

const __filename = fileURLToPath(import.meta.url);
const _filename = fileURLToPath(import.meta.url);

test.skip("can screenshot and download as html edit", async ({ page }) => {
await page.goto("http://localhost:3000");
Expand All @@ -13,7 +13,7 @@ test.skip("can screenshot and download as html edit", async ({ page }) => {
// See text Welcome
await expect(page.getByText("Welcome").first()).toBeVisible();

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
await exportAsHTMLAndTakeScreenshot(page);
});

Expand All @@ -25,5 +25,5 @@ test.skip("can screenshot and download as html in run", async ({ page }) => {
// See text Welcome
await expect(page.getByText("Welcome").first()).toBeVisible();

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});
4 changes: 2 additions & 2 deletions frontend/e2e-tests/kitchen-sink.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import {
} from "./helper";
import { fileURLToPath } from "node:url";

const __filename = fileURLToPath(import.meta.url);
const _filename = fileURLToPath(import.meta.url);

const appUrl = getAppUrl("kitchen_sink.py");

test("can screenshot and download as html", async ({ page }) => {
await page.goto(appUrl);

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
await exportAsHTMLAndTakeScreenshot(page);
});

Expand Down
8 changes: 4 additions & 4 deletions frontend/e2e-tests/layout-grid.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getAppUrl } from "../playwright.config";
import { takeScreenshot } from "./helper";
import { fileURLToPath } from "node:url";

const __filename = fileURLToPath(import.meta.url);
const _filename = fileURLToPath(import.meta.url);

const runUrl = getAppUrl("layout_grid.py//run");
const runMaxWidthUrl = getAppUrl("layout_grid_max_width.py//run");
Expand All @@ -30,7 +30,7 @@ test("can run Grid layout", async ({ page }) => {
expect(bb1.y).toBe(bb2.y);
expect(bb1.x).toBeGreaterThan(bb2.x);

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("can run Grid layout with max-width", async ({ page }) => {
Expand All @@ -41,7 +41,7 @@ test("can run Grid layout with max-width", async ({ page }) => {
// Verify markdown "Grid Layout"
await expect(page.getByText("Grid Layout")).toBeVisible();

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("can edit Grid layout", async ({ page }) => {
Expand Down Expand Up @@ -81,7 +81,7 @@ test("can edit Grid layout", async ({ page }) => {
expect(bb1.x).toBe(bb2.x);
expect(bb1.y).toBeLessThan(bb2.y);

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

interface BoundingBox {
Expand Down
10 changes: 5 additions & 5 deletions frontend/e2e-tests/mode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { maybeRestartKernel, takeScreenshot } from "./helper";
import { fileURLToPath } from "node:url";

const __filename = fileURLToPath(import.meta.url);
const _filename = fileURLToPath(import.meta.url);

async function gotoPage(
app: ApplicationNames,
Expand Down Expand Up @@ -47,7 +47,7 @@ test("page renders edit feature in edit mode", async ({ context }) => {
// Can see output
await expect(page.locator("h1").getByText("Hello Marimo!")).toBeVisible();

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test.skip("can bring up the find/replace dialog", async ({ context }) => {
Expand All @@ -63,7 +63,7 @@ test.skip("can bring up the find/replace dialog", async ({ context }) => {
// Has placeholder text "Find"
await expect(page.locator("[placeholder='Find']")).toBeVisible();

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("can toggle to presenter mode", async ({ context }) => {
Expand All @@ -88,7 +88,7 @@ test("can toggle to presenter mode", async ({ context }) => {
await expect(page.locator("h1").getByText("Hello Marimo!")).toBeVisible();
await expect(page.getByText("# Hello Marimo!")).toBeVisible();

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});

test("page renders read only view in read mode", async ({ context }) => {
Expand All @@ -102,5 +102,5 @@ test("page renders read only view in read mode", async ({ context }) => {
// Can see output
await expect(page.locator("h1").getByText("UI Elements")).toBeVisible();

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});
4 changes: 2 additions & 2 deletions frontend/e2e-tests/output.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getAppUrl } from "../playwright.config";
import { takeScreenshot } from "./helper";
import { fileURLToPath } from "node:url";

const __filename = fileURLToPath(import.meta.url);
const _filename = fileURLToPath(import.meta.url);

test("it can clear and append output", async ({ page }) => {
const appUrl = getAppUrl("output.py//run");
Expand All @@ -29,5 +29,5 @@ test("it can clear and append output", async ({ page }) => {
await expect(page.getByText("To be replaced.")).not.toBeVisible();
await expect(page.getByText("Replaced by index!")).toBeVisible();

await takeScreenshot(page, __filename);
await takeScreenshot(page, _filename);
});
Loading

0 comments on commit ba4d132

Please sign in to comment.