Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

Make any typing linting opt-out instead of opt-in (#6542)

James Bruntone79f4a044ff2
diff --git a/.taskfiles/frontend.yml b/.taskfiles/frontend.yml
index b2fc9d45d1..1cb1c01529 100644
--- a/.taskfiles/frontend.yml
+++ b/.taskfiles/frontend.yml
@@ -187,12 +187,23 @@ tasks:
lint:
desc: "Run linting"
deps: [install]
+ cmds:
+ - task: lint:eslint
+ - task: lint:dpdm
+
+ lint:eslint:
+ desc: "Run ESLint linting"
+ deps: [install]
cmds:
- npx eslint --max-warnings=0
- # Globs (not a bare dir) so dpdm walks the whole tree — `editor/src`
- # alone matched only 2 files. dpdm expands the braces itself, so this is
+
+ lint:dpdm:
+ desc: "Run circular import linting"
+ deps: [install]
+ cmds:
+ # Globs so dpdm walks the whole tree. dpdm expands the braces itself, so this is
# shell-agnostic. Covers editor, portal, and the shared design system.
- - 'npx dpdm "editor/src/**/*.{ts,tsx}" "portal/src/**/*.{ts,tsx}" "shared/**/*.{ts,tsx}" --circular --no-warning --no-tree --exit-code circular:1'
+ - npx dpdm "editor/src/**/*.{ts,tsx}" "portal/src/**/*.{ts,tsx}" "shared/**/*.{ts,tsx}" --circular --no-warning --no-tree --exit-code circular:1
lint:fix:
desc: "Auto-fix lint issues"
diff --git a/frontend/editor/scripts/generate-icons.js b/frontend/editor/scripts/generate-icons.js
index fb9ecd71ec..7e6da2740e 100644
--- a/frontend/editor/scripts/generate-icons.js
+++ b/frontend/editor/scripts/generate-icons.js
@@ -225,7 +225,7 @@ export type MaterialSymbolIcon = ${usedIcons.map((icon) => `'${icon}'`).join(" |
export interface IconSet {
prefix: string;
- icons: Record<string, any>;
+ icons: Record<string, unknown>;
width?: number;
height?: number;
}
diff --git a/frontend/editor/src/core/setupTests.js b/frontend/editor/src/core/setupTests.js
deleted file mode 100644
index 1dd407a63e..0000000000
--- a/frontend/editor/src/core/setupTests.js
+++ /dev/null
@@ -1,5 +0,0 @@
-// jest-dom adds custom jest matchers for asserting on DOM nodes.
-// allows you to do things like:
-// expect(element).toHaveTextContent(/react/i)
-// learn more: https://github.com/testing-library/jest-dom
-import "@testing-library/jest-dom";
diff --git a/frontend/editor/src/core/setupTests.ts b/frontend/editor/src/core/setupTests.ts
index d49589a035..bd6e083253 100644
--- a/frontend/editor/src/core/setupTests.ts
+++ b/frontend/editor/src/core/setupTests.ts
@@ -99,12 +99,12 @@ Object.defineProperty(globalThis, "crypto", {
subtle: {
digest: vi
.fn()
- .mockImplementation(async (_algorithm: string, _data: any) => {
+ .mockImplementation(async (_algorithm: string, _data: BufferSource) => {
// Always return the mock hash buffer regardless of input
return mockHashBuffer.slice();
}),
},
- getRandomValues: vi.fn().mockImplementation((array: any) => {
+ getRandomValues: vi.fn().mockImplementation((array: Uint8Array) => {
// Mock getRandomValues if needed
for (let i = 0; i < array.length; i++) {
array[i] = Math.floor(Math.random() * 256);
diff --git a/frontend/editor/src/core/theme/mantineTheme.ts b/frontend/editor/src/core/theme/mantineTheme.ts
index ac36eb515f..9bc66d9426 100644
--- a/frontend/editor/src/core/theme/mantineTheme.ts
+++ b/frontend/editor/src/core/theme/mantineTheme.ts
@@ -1,4 +1,9 @@
-import { createTheme, MantineColorsTuple } from "@mantine/core";
+import {
+ createTheme,
+ MantineColorsTuple,
+ MantineTheme,
+ MantineThemeComponent,
+} from "@mantine/core";
// Define color tuples using CSS variables
const primary: MantineColorsTuple = [
@@ -113,7 +118,7 @@ export const mantineTheme = createTheme({
},
variants: {
// Custom button variant for PDF tools
- pdfTool: (_theme: any) => ({
+ pdfTool: (_theme: MantineTheme) => ({
root: {
backgroundColor: "var(--bg-surface)",
border: "1px solid var(--border-default)",
@@ -125,7 +130,7 @@ export const mantineTheme = createTheme({
},
}),
},
- } as any,
+ } as MantineThemeComponent,
Paper: {
styles: {
@@ -146,7 +151,7 @@ export const mantineTheme = createTheme({
},
},
Textarea: {
- styles: (_theme: any) => ({
+ styles: (_theme: MantineTheme) => ({
input: {
backgroundColor: "var(--bg-surface)",
borderColor: "var(--border-default)",
@@ -164,7 +169,7 @@ export const mantineTheme = createTheme({
},
TextInput: {
- styles: (_theme: any) => ({
+ styles: (_theme: MantineTheme) => ({
input: {
backgroundColor: "var(--bg-surface)",
borderColor: "var(--border-default)",
@@ -182,7 +187,7 @@ export const mantineTheme = createTheme({
},
PasswordInput: {
- styles: (_theme: any) => ({
+ styles: (_theme: MantineTheme) => ({
input: {
backgroundColor: "var(--bg-surface)",
borderColor: "var(--border-default)",
@@ -223,7 +228,7 @@ export const mantineTheme = createTheme({
color: "var(--text-primary)",
"--combobox-option-hover": "var(--hover-bg)",
"--combobox-option-selected": "var(--color-primary-100)",
- } as any,
+ },
},
},
@@ -251,7 +256,7 @@ export const mantineTheme = createTheme({
color: "var(--text-primary)",
"--combobox-option-hover": "var(--hover-bg)",
"--combobox-option-selected": "var(--color-primary-100)",
- } as any,
+ },
},
},
Tooltip: {
diff --git a/frontend/editor/src/global.d.ts b/frontend/editor/src/global.d.ts
index 979a857355..b31330902d 100644
--- a/frontend/editor/src/global.d.ts
+++ b/frontend/editor/src/global.d.ts
@@ -5,7 +5,7 @@ declare module "*.module.css";
declare module "assets/material-symbols-icons.json" {
const value: {
prefix: string;
- icons: Record<string, any>;
+ icons: Record<string, unknown>;
width?: number;
height?: number;
};
diff --git a/frontend/editor/src/index.tsx b/frontend/editor/src/index.tsx
index 5a7b6272fb..251f42e1f3 100644
--- a/frontend/editor/src/index.tsx
+++ b/frontend/editor/src/index.tsx
@@ -30,8 +30,7 @@ posthog.init(import.meta.env.VITE_PUBLIC_POSTHOG_KEY, {
function updatePosthogConsent() {
if (!posthog.__loaded) return;
const optIn =
- (window.CookieConsent as any)?.acceptedService?.("posthog", "analytics") ||
- false;
+ window.CookieConsent?.acceptedService?.("posthog", "analytics") || false;
if (optIn) {
posthog.set_config({ persistence: "localStorage+cookie" });
posthog.opt_in_capturing();
diff --git a/frontend/editor/src/reportWebVitals.js b/frontend/editor/src/reportWebVitals.js
deleted file mode 100644
index 9ecd33f9ca..0000000000
--- a/frontend/editor/src/reportWebVitals.js
+++ /dev/null
@@ -1,13 +0,0 @@
-const reportWebVitals = (onPerfEntry) => {
- if (onPerfEntry && onPerfEntry instanceof Function) {
- import("web-vitals").then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
- getCLS(onPerfEntry);
- getFID(onPerfEntry);
- getFCP(onPerfEntry);
- getLCP(onPerfEntry);
- getTTFB(onPerfEntry);
- });
- }
-};
-
-export default reportWebVitals;
diff --git a/frontend/eslint.config.mjs b/frontend/eslint.config.mjs
index 372ad36858..65e97d4969 100644
--- a/frontend/eslint.config.mjs
+++ b/frontend/eslint.config.mjs
@@ -143,15 +143,20 @@ export default defineConfig(
],
},
},
- // Folders that have been cleaned up and are now conformant - stricter rules enforced here
+ // Stricter rules that not all sub-folders are conformant to yet
{
- files: [
- "editor/src/desktop/**/*.{js,mjs,jsx,ts,tsx}",
- "editor/src/proprietary/**/*.{js,mjs,jsx,ts,tsx}",
- "editor/src/saas/**/*.{js,mjs,jsx,ts,tsx}",
- "editor/src/prototypes/**/*.{js,mjs,jsx,ts,tsx}",
- "portal/src/**/*.{js,mjs,jsx,ts,tsx}",
- "shared/**/*.{js,mjs,jsx,ts,tsx}",
+ files: srcGlobs,
+ ignores: [
+ "editor/src/core/components/**/*.{js,mjs,jsx,ts,tsx}",
+ "editor/src/core/contexts/**/*.{js,mjs,jsx,ts,tsx}",
+ "editor/src/core/data/**/*.{js,mjs,jsx,ts,tsx}",
+ "editor/src/core/hooks/**/*.{js,mjs,jsx,ts,tsx}",
+ "editor/src/core/pages/**/*.{js,mjs,jsx,ts,tsx}",
+ "editor/src/core/services/**/*.{js,mjs,jsx,ts,tsx}",
+ "editor/src/core/tests/**/*.{js,mjs,jsx,ts,tsx}",
+ "editor/src/core/tools/**/*.{js,mjs,jsx,ts,tsx}",
+ "editor/src/core/types/**/*.{js,mjs,jsx,ts,tsx}",
+ "editor/src/core/utils/**/*.{js,mjs,jsx,ts,tsx}",
],
languageOptions: {
parserOptions: {