Skip to content

Commit 6e987a9

Browse files
NicolappsConvex, Inc.
authored andcommitted
system-udfs: migrate to ESLint 9 (#42396)
GitOrigin-RevId: 2365ec2947eb2aa0a7a5c248ac33b16a4430663d
1 parent c142858 commit 6e987a9

File tree

9 files changed

+191
-86
lines changed

9 files changed

+191
-86
lines changed

npm-packages/common/config/rush/pnpm-lock.yaml

Lines changed: 69 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

npm-packages/system-udfs/convex/.eslintrc.cjs

Lines changed: 0 additions & 58 deletions
This file was deleted.

npm-packages/system-udfs/convex/_system/frontend/fileStorageV2.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ export const fileMetadata = queryGeneric({
5656

5757
const newPage = await Promise.all(
5858
files.page.map(async (file) => {
59-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
6059
const url = (await storage.getUrl(file._id))!;
6160
return {
6261
url,

npm-packages/system-udfs/convex/_system/frontend/getById.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default queryGeneric({
1111
const id = args.id as GenericId<string>;
1212
try {
1313
return await db.get(id);
14-
} catch (e) {
14+
} catch {
1515
return await db.system.get(id as GenericId<SystemTableNames>);
1616
}
1717
},

npm-packages/system-udfs/convex/_system/frontend/lib/filters.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ export async function findErrorsInFilters(
263263
if (filter.value) {
264264
try {
265265
jsonToConvex(filter.value);
266-
} catch (e) {
266+
} catch {
267267
errors.push({
268268
filter: i,
269269
error: `Invalid value: ${JSON.stringify(filter.value)}.`,
@@ -619,7 +619,7 @@ function jsonToConvexOrValue(
619619
}
620620
try {
621621
return jsonToConvex(value);
622-
} catch (e) {
622+
} catch {
623623
return value;
624624
}
625625
}

npm-packages/system-udfs/convex/_system/frontend/paginatedTableDocuments.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ export default queryGeneric({
6464
// This will throw an error if parsedFilters does not match the filter expression schema,
6565
// which should only happens if a dashboard user manually edits the `filters` query parameter
6666
// the dashboard should not allow this to happen by deleting the query parameter if it is invalid.
67-
parsedFilters && FilterExpressionSchema.parse(parsedFilters);
67+
if (parsedFilters) {
68+
FilterExpressionSchema.parse(parsedFilters);
69+
}
6870

6971
if (parsedFilters && parsedFilters.clauses?.length) {
7072
const errors = await findErrorsInFilters(parsedFilters);
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import { defineConfig, globalIgnores } from "eslint/config";
2+
3+
import eslint from "@eslint/js";
4+
import reactHooks from "eslint-plugin-react-hooks";
5+
import react from "eslint-plugin-react";
6+
import tseslint, { parser as tsParser } from "typescript-eslint";
7+
8+
import { fileURLToPath } from "node:url";
9+
import { dirname, join } from "node:path";
10+
11+
import { fixupPluginRules } from "@eslint/compat";
12+
13+
import js from "@eslint/js";
14+
15+
import { FlatCompat } from "@eslint/eslintrc";
16+
17+
const __filename = fileURLToPath(import.meta.url);
18+
const __dirname = dirname(__filename);
19+
20+
const compat = new FlatCompat({
21+
baseDirectory: __dirname,
22+
recommendedConfig: js.configs.recommended,
23+
allConfig: js.configs.all,
24+
});
25+
26+
export default defineConfig([
27+
eslint.configs.recommended,
28+
tseslint.configs.recommended,
29+
{
30+
languageOptions: {
31+
parser: tsParser,
32+
33+
parserOptions: {
34+
project: join(__dirname, "tsconfig.json"),
35+
tsconfigRootDir: __dirname,
36+
},
37+
},
38+
39+
plugins: {
40+
"react-hooks": fixupPluginRules(reactHooks),
41+
react,
42+
},
43+
44+
extends: compat.extends("prettier"),
45+
46+
rules: {
47+
// we use any to access internal-only APIs in Convex functions
48+
"@typescript-eslint/no-explicit-any": "off",
49+
50+
"@typescript-eslint/no-unused-vars": [
51+
"error",
52+
{
53+
varsIgnorePattern: "_.*",
54+
},
55+
],
56+
57+
"@typescript-eslint/no-floating-promises": "error",
58+
59+
// system UDF argument validation
60+
"no-restricted-imports": [
61+
"error",
62+
{
63+
patterns: [
64+
{
65+
group: ["**/_generated/server"],
66+
67+
importNames: [
68+
"query",
69+
"mutation",
70+
"action",
71+
"internalQuery",
72+
"internalMutation",
73+
"internalAction",
74+
],
75+
76+
message:
77+
"Use the query wrappers from convex/_system/server.ts instead for system UDF argument validation.",
78+
},
79+
{
80+
group: ["convex/server"],
81+
82+
importNames: [
83+
"queryGeneric",
84+
"mutationGeneric",
85+
"actionGeneric",
86+
"internalQueryGeneric",
87+
"internalMutationGeneric",
88+
"internalActionGeneric",
89+
],
90+
91+
message:
92+
"Use the query wrappers from convex/_system/server.ts instead for system UDF argument validation.",
93+
},
94+
],
95+
},
96+
],
97+
},
98+
},
99+
globalIgnores([
100+
"**/node_modules",
101+
"**/dist",
102+
"**/_generated",
103+
"eslint.config.mjs",
104+
]),
105+
]);

npm-packages/system-udfs/package.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"build": "rm -rf dist && tsc",
99
"clean": "rm -rf dist",
10-
"lint": "tsc && cd convex && eslint .",
10+
"lint": "tsc && eslint .",
1111
"prepare": "npm run build",
1212
"test": "vitest run --pass-with-no-tests"
1313
},
@@ -25,18 +25,20 @@
2525
"udf-syscall-ffi": "workspace:*"
2626
},
2727
"devDependencies": {
28+
"@eslint/compat": "~1.3.0",
29+
"@eslint/eslintrc": "~3.3.0",
30+
"@eslint/js": "~9.34.0",
2831
"@types/object-inspect": "^1.8.1",
2932
"@types/lodash": "~4.17.0",
3033
"@types/node": "^18.17.0",
3134
"convex-test": "^0.0.38",
32-
"eslint": "^8.29.0",
33-
"eslint-plugin-react-hooks": "^5.1.0-beta-26f2496093-20240514",
34-
"eslint-plugin-react": "^7.37.2",
35-
"vitest": "^3.2.4",
36-
"@typescript-eslint/eslint-plugin": "^6.7.4",
37-
"@typescript-eslint/parser": "^6.7.4",
35+
"eslint": "^9.37.0",
3836
"eslint-config-prettier": "^10.0.0",
3937
"eslint-plugin-prettier": "^5.0.0",
40-
"typescript": "~5.0.3"
38+
"eslint-plugin-react": "^7.37.2",
39+
"eslint-plugin-react-hooks": "^4.6.2",
40+
"typescript": "~5.0.3",
41+
"typescript-eslint": "^8.45.0",
42+
"vitest": "^3.2.4"
4143
}
4244
}

0 commit comments

Comments
 (0)