Skip to content

Commit

Permalink
Migrate to ESLint v9 with strict rules (#39)
Browse files Browse the repository at this point in the history
* Update keywords

* Seems like we are getting somewhere

* This is hard

* Update configs

* Replace app lint with default next strict

* Getting there

* Web is linting

* Make it work finally

* Clean up

* Use types over interfaces
  • Loading branch information
0x80 authored Jan 19, 2025
1 parent 5b1bb79 commit 1f64a28
Show file tree
Hide file tree
Showing 44 changed files with 1,016 additions and 3,085 deletions.
15 changes: 0 additions & 15 deletions apps/web/.eslintrc.cjs

This file was deleted.

34 changes: 34 additions & 0 deletions apps/web/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// @ts-check
/* eslint-disable */
import { FlatCompat } from "@eslint/eslintrc";
import baseConfig from "@repo/eslint-config/base";
import tseslint from "typescript-eslint";

const compat = new FlatCompat({
baseDirectory: import.meta.dirname,
});

export default tseslint.config(
...baseConfig,
...compat.config({
extends: ["next"],
settings: {
next: {
rootDir: "apps/web/", // required for monorepos
},
},
}),
tseslint.configs.strictTypeChecked,
tseslint.configs.stylisticTypeChecked,
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
"@typescript-eslint/use-unknown-in-catch-callback-variable": "off",
},
}
);
17 changes: 0 additions & 17 deletions apps/web/next.config.mjs

This file was deleted.

19 changes: 9 additions & 10 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,25 @@
"@typed-firestore/react": "1.0.0-0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"firebase": "^11.1.0",
"lucide-react": "^0.471.0",
"next": "15.1.4",
"react": "19.0.0",
"react-dom": "19.0.0",
"firebase": "^11.2.0",
"lucide-react": "^0.473.0",
"next": "^15.1.5",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"tailwind-merge": "^2.6.0",
"tailwindcss-animate": "^1.0.7",
"typescript": "^5.7.3"
},
"devDependencies": {
"@codecompose/typescript-config": "^1.2.0",
"@repo/eslint-config": "workspace:*",
"@types/node": "^22.10.5",
"@types/react": "^19.0.6",
"@types/node": "^22.10.7",
"@types/react": "^19.0.7",
"@types/react-dom": "^19.0.3",
"autoprefixer": "^10.4.20",
"del-cli": "^6.0.0",
"eslint": "8.57.0",
"eslint-config-next": "15.1.4",
"postcss": "^8.4.49",
"eslint-config-next": "^15.1.5",
"postcss": "^8.5.1",
"tailwindcss": "^3.4.17"
}
}
4 changes: 3 additions & 1 deletion apps/web/src/app/components/counter-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export function CounterView(props: { counterId: string }) {
/>
);
} else {
return <div>No counter document available. Please press "reset".</div>;
return (
<div>No counter document available. Please press &quot;reset&quot;.</div>
);
}
}
2 changes: 1 addition & 1 deletion apps/web/src/app/components/key-value-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type FsValue = string | number | boolean | null | FsTimestamp;

export default function KeyValueList(props: {
data: Record<string, FsValue>;
labels: Array<[string, string]>;
labels: [string, string][];
}) {
const rows = props.labels.map(([key, label]) => (
<TableRow className="bg-white" key={key}>
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/lib/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const endpoint = process.env.NEXT_PUBLIC_DEMO_API_ENDPOINT;
const endpoint =
process.env.NEXT_PUBLIC_DEMO_API_ENDPOINT ?? "__missing_demo_api_endpoint";

/**
* In a real application you would typically not embed an API key like this, as
Expand Down
24 changes: 0 additions & 24 deletions apps/web/src/lib/firestore.ts

This file was deleted.

16 changes: 9 additions & 7 deletions apps/web/src/lib/utils/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export async function fetchJson<T>(
endpoint: string,
queryParams: { [key: string]: string | number | boolean | undefined } = {},
queryParams: Record<string, string | number | boolean | undefined> = {},
options: RequestInit = {}
) {
const queryString = makeQueryString(queryParams);
Expand All @@ -17,27 +17,29 @@ export async function fetchJson<T>(

if (!response.ok) {
throw new Error(
`Fetch to ${url} failed with status ${
`Fetch to ${url} failed with status ${String(
response.status
}. Response text: ${await response.text()}`
)}. Response text: ${await response.text()}`
);
}

try {
return response.json() as Promise<T>;
} catch (err) {
return (await response.json()) as T;
} catch {
throw new Error(`Failed to parse JSON from response of ${url}`);
}
}

function makeQueryString(
params: { [key: string]: string | number | boolean | undefined } = {}
params: Record<string, string | number | boolean | undefined> = {}
) {
const queryString = new URLSearchParams();

Object.entries(params)
.filter(([, value]) => value !== undefined)
.forEach(([name, value]) => queryString.append(name, String(value)));
.forEach(([name, value]) => {
queryString.append(name, String(value));
});

return queryString.toString();
}
15 changes: 14 additions & 1 deletion apps/web/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
{
"extends": "@codecompose/typescript-config/nextjs.json",
"include": ["src", ".next/types/**/*.ts"],
"compilerOptions": {
"plugins": [
{
"name": "next" // plugin comes installed with nextjs
}
]
},
"include": [
"${configDir}",
"${configDir}/**/*.json",
"${configDir}/next-env.d.ts",
"${configDir}/.next/types/**/*.ts",
".next/types/**/*.ts"
],
"references": [
{
"path": "../../packages/common"
Expand Down
1 change: 1 addition & 0 deletions apps/web/vendor.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module "@eslint/eslintrc";
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
"typescript",
"monorepo",
"firebase",
"firestore",
"isolate-package",
"typed-firestore",
"esm",
"turbo",
"turborepo",
"nextjs"
],
Expand Down Expand Up @@ -47,7 +48,7 @@
"prettier-plugin-jsdoc": "^1.3.2",
"turbo": "^2.3.3",
"typescript": "^5.7.3",
"vercel": "^39.2.6",
"vitest": "^2.1.8"
"vercel": "^39.3.0",
"vitest": "^3.0.2"
}
}
3 changes: 0 additions & 3 deletions packages/common/.eslintignore

This file was deleted.

5 changes: 0 additions & 5 deletions packages/common/.eslintrc.cjs

This file was deleted.

15 changes: 15 additions & 0 deletions packages/common/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// @ts-check
import base from "@repo/eslint-config/base";
import tseslint from "typescript-eslint";

export default tseslint.config([
...base,
{
languageOptions: {
parserOptions: {
tsconfigRootDir: import.meta.dirname,
allowDefaultProject: true,
},
},
},
]);
16 changes: 9 additions & 7 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,26 @@
"scripts": {
"compile": "tsc --noEmit",
"test": "vitest",
"lint": "eslint . --max-warnings 0",
"build": "tsup && tsc --emitDeclarationOnly",
"clean": "del-cli dist tsconfig.tsbuildinfo",
"coverage": "vitest run --coverage "
"lint": "eslint src --flag unstable_config_lookup_from_file --max-warnings 0",
"coverage": "vitest run --coverage"
},
"license": "MIT",
"dependencies": {
"firebase": "^11.1.0",
"remeda": "^2.19.0"
"firebase": "^11.2.0",
"remeda": "^2.19.2"
},
"devDependencies": {
"@codecompose/typescript-config": "^1.2.0",
"@eslint/js": "^9.18.0",
"@repo/eslint-config": "workspace:*",
"eslint": "^8.57.1",
"eslint-plugin-require-extensions": "^0.1.3",
"del-cli": "^6.0.0",
"eslint": "^9.18.0",
"prettier": "^3.4.2",
"tsup": "^8.3.5",
"typescript": "^5.7.3",
"vitest": "^2.1.8"
"typescript-eslint": "^8.20.0",
"vitest": "^3.0.2"
}
}
3 changes: 1 addition & 2 deletions packages/common/src/utils/is-present.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/** Copied from ts-is-present */
export function isPresent<T>(t: T | undefined | null | void): t is T {
export function isPresent<T>(t: T | undefined | null): t is T {
return t !== undefined && t !== null;
}

Expand Down
3 changes: 0 additions & 3 deletions packages/core/.eslintignore

This file was deleted.

5 changes: 0 additions & 5 deletions packages/core/.eslintrc.cjs

This file was deleted.

17 changes: 17 additions & 0 deletions packages/core/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// @ts-check
import baseConfig from "@repo/eslint-config/base";
import tseslint from "typescript-eslint";

export default tseslint.config([
...baseConfig,
{
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: ["*.js"],
},
tsconfigRootDir: import.meta.dirname,
},
},
},
]);
13 changes: 8 additions & 5 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"scripts": {
"compile": "tsc --noEmit",
"lint": "eslint . --max-warnings 0",
"lint": "eslint src --flag unstable_config_lookup_from_file --max-warnings 0 ",
"test": "vitest",
"build": "tsup && tsc --emitDeclarationOnly && tsc-alias --verbose",
"clean": "del-cli dist tsconfig.tsbuildinfo",
Expand All @@ -25,18 +25,21 @@
"@repo/common": "workspace:*",
"@sindresorhus/is": "^7.0.1",
"firebase-admin": "^13.0.2",
"firebase-functions": "^6.2.0"
"firebase-functions": "^6.2.0",
"get-or-throw": "^1.4.0"
},
"devDependencies": {
"@codecompose/typescript-config": "^1.2.0",
"@eslint/js": "^9.18.0",
"@repo/eslint-config": "workspace:*",
"@types/node": "^22.10.5",
"@types/node": "^22.10.7",
"del-cli": "^6.0.0",
"eslint": "^8.57.1",
"eslint": "^9.18.0",
"npm-run-all": "^4.1.5",
"tsc-alias": "^1.8.10",
"tsup": "^8.3.5",
"typescript": "^5.7.3",
"vitest": "^2.1.8"
"typescript-eslint": "^8.20.0",
"vitest": "^3.0.2"
}
}
4 changes: 1 addition & 3 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export const isProduction = false;

export const region = isProduction ? "us-central1" : "europe-west3";
export const region = "europe-west3";

export const retryEventMaxAgeMs = 30000;
Loading

0 comments on commit 1f64a28

Please sign in to comment.