Thanks to visit codestin.com
Credit goes to github.com

Skip to content

chore: tweak biome config #15864

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

Merged
merged 6 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,6 @@ vpn/vpn.pb.go: vpn/vpn.proto
site/src/api/typesGenerated.ts: $(wildcard scripts/apitypings/*) $(shell find ./codersdk $(FIND_EXCLUSIONS) -type f -name '*.go')
# -C sets the directory for the go run command
go run -C ./scripts/apitypings main.go > $@
(cd ./site && npx biome format --write ./src/api/typesGenerated.ts)
./scripts/pnpm_install.sh

site/e2e/provisionerGenerated.ts: provisionerd/proto/provisionerd.pb.go provisionersdk/proto/provisioner.pb.go
cd site
Expand Down
66 changes: 32 additions & 34 deletions site/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
import turbosnap from "vite-plugin-turbosnap";

module.exports = {
stories: ["../src/**/*.stories.tsx"],
stories: ["../src/**/*.stories.tsx"],

addons: [
"@chromatic-com/storybook",
{
name: "@storybook/addon-essentials",
options: {
backgrounds: false,
},
},
"@storybook/addon-links",
"@storybook/addon-mdx-gfm",
"@storybook/addon-themes",
"@storybook/addon-actions",
"@storybook/addon-interactions",
"storybook-addon-remix-react-router",
],
addons: [
"@chromatic-com/storybook",
{
name: "@storybook/addon-essentials",
options: {
backgrounds: false,
},
},
"@storybook/addon-links",
"@storybook/addon-mdx-gfm",
"@storybook/addon-themes",
"@storybook/addon-actions",
"@storybook/addon-interactions",
"storybook-addon-remix-react-router",
],

staticDirs: ["../static"],
staticDirs: ["../static"],

framework: {
name: "@storybook/react-vite",
options: {},
},
framework: {
name: "@storybook/react-vite",
options: {},
},

async viteFinal(config, { configType }) {
config.plugins = config.plugins || [];
// return the customized config
if (configType === "PRODUCTION") {
// ignore @ts-ignore because it's not in the vite types yet
config.plugins.push(
turbosnap({
rootDir: config.root || "",
}),
);
}
return config;
},
async viteFinal(config, { configType }) {
config.plugins = config.plugins || [];
if (configType === "PRODUCTION") {
config.plugins.push(
turbosnap({
rootDir: config.root || "",
}),
);
}
return config;
},
};
3 changes: 2 additions & 1 deletion site/.storybook/preview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ import CssBaseline from "@mui/material/CssBaseline";
import {
ThemeProvider as MuiThemeProvider,
StyledEngineProvider,
// biome-ignore lint/nursery/noRestrictedImports: we extend the MUI theme
} from "@mui/material/styles";
import { DecoratorHelpers } from "@storybook/addon-themes";
import isChromatic from "chromatic/isChromatic";
import React, { StrictMode } from "react";
import { HelmetProvider } from "react-helmet-async";
import { parseQueryArgs, QueryClient, QueryClientProvider } from "react-query";
import { QueryClient, QueryClientProvider, parseQueryArgs } from "react-query";
import { withRouter } from "storybook-addon-remix-react-router";
import "theme/globalFonts";
import themes from "../src/theme";
Expand Down
14 changes: 9 additions & 5 deletions site/biome.json → site/biome.jsonc
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"files": {
"ignore": [
"e2e/provisionerGenerated.ts",
"e2e/google/protobuf/timestampGenerated.ts",
"src/api/countriesGenerated.ts",
"src/api/rbacresourcesGenerated.ts"
"build/",
"node_modules/",
"out/",
"test-results/",
"e2e/**/*Generated.ts",
"src/api/*Generated.ts",
"pnpm-lock.yaml"
]
},
"linter": {
Expand Down Expand Up @@ -44,5 +47,6 @@
}
}
}
}
},
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json"
Copy link
Member

Choose a reason for hiding this comment

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

Would this need to be manually bumped when @dependabot bumps biome version?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think so.

Copy link
Member Author

Choose a reason for hiding this comment

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

unfortunately yeah, but it's worth having for the autocompletion help

}
132 changes: 66 additions & 66 deletions site/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
module.exports = {
// Use a big timeout for CI.
testTimeout: 20_000,
maxWorkers: 8,
projects: [
{
displayName: "test",
roots: ["<rootDir>"],
setupFiles: ["./jest.polyfills.js"],
setupFilesAfterEnv: ["./jest.setup.ts"],
extensionsToTreatAsEsm: [".ts"],
transform: {
"^.+\\.(t|j)sx?$": [
"@swc/jest",
{
jsc: {
transform: {
react: {
runtime: "automatic",
importSource: "@emotion/react",
},
},
experimental: {
plugins: [["jest_workaround", {}]],
},
},
},
],
},
testEnvironment: "jsdom",
testEnvironmentOptions: {
customExportConditions: [""],
},
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
testPathIgnorePatterns: [
"/node_modules/",
"/e2e/",
// TODO: This test is timing out after upgrade a few Jest dependencies
// and I was not able to figure out why. When running it specifically, I
// can see many act warnings that may can help us to find the issue.
"/usePaginatedQuery.test.ts",
],
transformIgnorePatterns: [
"<rootDir>/node_modules/@chartjs-adapter-date-fns",
],
moduleDirectories: ["node_modules", "<rootDir>/src"],
moduleNameMapper: {
"\\.css$": "<rootDir>/src/testHelpers/styleMock.ts",
"^@fontsource": "<rootDir>/src/testHelpers/styleMock.ts",
},
},
],
collectCoverageFrom: [
// included files
"<rootDir>/**/*.ts",
"<rootDir>/**/*.tsx",
// excluded files
"!<rootDir>/**/*.stories.tsx",
"!<rootDir>/_jest/**/*.*",
"!<rootDir>/api.ts",
"!<rootDir>/coverage/**/*.*",
"!<rootDir>/e2e/**/*.*",
"!<rootDir>/jest-runner.eslint.config.js",
"!<rootDir>/jest.config.js",
"!<rootDir>/out/**/*.*",
"!<rootDir>/storybook-static/**/*.*",
],
// Use a big timeout for CI.
testTimeout: 20_000,
maxWorkers: 8,
projects: [
{
displayName: "test",
roots: ["<rootDir>"],
setupFiles: ["./jest.polyfills.js"],
setupFilesAfterEnv: ["./jest.setup.ts"],
extensionsToTreatAsEsm: [".ts"],
transform: {
"^.+\\.(t|j)sx?$": [
"@swc/jest",
{
jsc: {
transform: {
react: {
runtime: "automatic",
importSource: "@emotion/react",
},
},
experimental: {
plugins: [["jest_workaround", {}]],
},
},
},
],
},
testEnvironment: "jsdom",
testEnvironmentOptions: {
customExportConditions: [""],
},
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
testPathIgnorePatterns: [
"/node_modules/",
"/e2e/",
// TODO: This test is timing out after upgrade a few Jest dependencies
// and I was not able to figure out why. When running it specifically, I
// can see many act warnings that may can help us to find the issue.
"/usePaginatedQuery.test.ts",
],
transformIgnorePatterns: [
"<rootDir>/node_modules/@chartjs-adapter-date-fns",
],
moduleDirectories: ["node_modules", "<rootDir>/src"],
moduleNameMapper: {
"\\.css$": "<rootDir>/src/testHelpers/styleMock.ts",
"^@fontsource": "<rootDir>/src/testHelpers/styleMock.ts",
},
},
],
collectCoverageFrom: [
// included files
"<rootDir>/**/*.ts",
"<rootDir>/**/*.tsx",
// excluded files
"!<rootDir>/**/*.stories.tsx",
"!<rootDir>/_jest/**/*.*",
"!<rootDir>/api.ts",
"!<rootDir>/coverage/**/*.*",
"!<rootDir>/e2e/**/*.*",
"!<rootDir>/jest-runner.eslint.config.js",
"!<rootDir>/jest.config.js",
"!<rootDir>/out/**/*.*",
"!<rootDir>/storybook-static/**/*.*",
],
};
44 changes: 22 additions & 22 deletions site/jest.polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,32 @@ const { TextDecoder, TextEncoder } = require("node:util");
const { ReadableStream } = require("node:stream/web");

Object.defineProperties(globalThis, {
TextDecoder: { value: TextDecoder },
TextEncoder: { value: TextEncoder },
ReadableStream: { value: ReadableStream },
TextDecoder: { value: TextDecoder },
TextEncoder: { value: TextEncoder },
ReadableStream: { value: ReadableStream },
});

const { Blob, File } = require("node:buffer");
const { fetch, Headers, FormData, Request, Response } = require("undici");

Object.defineProperties(globalThis, {
fetch: { value: fetch, writable: true },
Blob: { value: Blob },
File: { value: File },
Headers: { value: Headers },
FormData: { value: FormData },
Request: { value: Request },
Response: { value: Response },
matchMedia: {
value: (query) => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(),
removeListener: jest.fn(),
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
}),
},
fetch: { value: fetch, writable: true },
Blob: { value: Blob },
File: { value: File },
Headers: { value: Headers },
FormData: { value: FormData },
Request: { value: Request },
Response: { value: Response },
matchMedia: {
value: (query) => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(),
removeListener: jest.fn(),
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
}),
},
});
4 changes: 2 additions & 2 deletions site/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import "@testing-library/jest-dom";
import "jest-location-mock";
import { cleanup } from "@testing-library/react";
import crypto from "node:crypto";
import { useMemo } from "react";
import { cleanup } from "@testing-library/react";
import type { Region } from "api/typesGenerated";
import type { ProxyLatencyReport } from "contexts/useProxyLatency";
import { useMemo } from "react";
import { server } from "testHelpers/server";

// useProxyLatency does some http requests to determine latency.
Expand Down
20 changes: 8 additions & 12 deletions site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
"license": "AGPL-3.0",
"scripts": {
"build": "NODE_ENV=production pnpm vite build",
"check": "biome check --error-on-warnings e2e/ src/",
"check:fix": "biome check --error-on-warnings --fix e2e/ src/",
"check": "biome check --error-on-warnings .",
"check:fix": "biome check --error-on-warnings --fix .",
"check:all": "pnpm check && pnpm test",
"chromatic": "chromatic",
"dev": "vite",
"format": "biome format --write e2e/ src/",
"format:check": "biome format e2e/ src/",
"format": "biome format --write .",
"format:check": "biome format .",
"lint": "pnpm run lint:check && pnpm run lint:types",
"lint:check": " biome lint --error-on-warnings e2e/ src/",
"lint:fix": " biome lint --error-on-warnings --write e2e/ src/",
"lint:check": " biome lint --error-on-warnings .",
"lint:fix": " biome lint --error-on-warnings --write .",
"lint:types": "tsc -p .",
"playwright:install": "playwright install --with-deps chromium",
"playwright:test": "playwright test --config=e2e/playwright.config.ts",
Expand Down Expand Up @@ -115,7 +115,7 @@
"yup": "1.4.0"
},
"devDependencies": {
"@biomejs/biome": "1.9.3",
"@biomejs/biome": "1.9.4",
"@chromatic-com/storybook": "3.2.2",
"@octokit/types": "12.3.0",
"@playwright/test": "1.47.2",
Expand Down Expand Up @@ -182,11 +182,7 @@
"vite-plugin-checker": "0.8.0",
"vite-plugin-turbosnap": "1.0.3"
},
"browserslist": [
"chrome 110",
"firefox 111",
"safari 16.0"
],
"browserslist": ["chrome 110", "firefox 111", "safari 16.0"],
"resolutions": {
"optionator": "0.9.3",
"semver": "7.6.2"
Expand Down
Loading
Loading