Skip to content

Commit fdb4beb

Browse files
NicolappsConvex, Inc.
authored andcommitted
react-query: fix ESLint (#42381)
GitOrigin-RevId: 4fae24c609ac6de1beef9d0f91eaf6167c5c09d0
1 parent cde6f2f commit fdb4beb

File tree

7 files changed

+64
-35
lines changed

7 files changed

+64
-35
lines changed

npm-packages/@convex-dev/react-query/convex/messages.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { mutation } from "./_generated/server.js";
22
import { query } from "./_generated/server.js";
3-
import { Doc, Id } from "./_generated/dataModel.js";
43
import { v } from "convex/values";
5-
import schema, { vv } from "./schema.js";
4+
import { vv } from "./schema.js";
65

76
export const list = query({
7+
args: {},
88
returns: v.array(
99
v.object({
1010
...vv.doc("messages").fields,
@@ -27,6 +27,7 @@ export const list = query({
2727
});
2828

2929
export const count = query({
30+
args: {},
3031
returns: v.string(),
3132
handler: async (ctx) => {
3233
const messages = await ctx.db.query("messages").take(1001);

npm-packages/@convex-dev/react-query/convex/user.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Doc } from "./_generated/dataModel";
33
import { query } from "./_generated/server";
44

55
export const getCurrent = query({
6+
args: {},
67
handler: async (ctx): Promise<Doc<"users"> | null> => {
78
const userId = await getAuthUserId(ctx);
89
if (!userId) {
Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import { action } from "./_generated/server.js";
22

3-
export const getSFWeather = action(async () => {
4-
const stationUrl = "https://api.weather.gov/stations/SFOC1";
5-
const observationData = await (
6-
await fetch(`${stationUrl}/observations/latest`, {
7-
headers: { "User-Agent": "Convex/1.0" },
8-
})
9-
).json();
10-
const celsius = observationData.properties.temperature.value;
11-
return {
12-
fahrenheit: Math.round(((celsius * 9) / 5 + 32) * 100) / 100,
13-
fetchedAt: Date.now(),
14-
timestamp: observationData.properties.timestamp,
15-
};
3+
export const getSFWeather = action({
4+
args: {},
5+
handler: async () => {
6+
const stationUrl = "https://api.weather.gov/stations/SFOC1";
7+
const observationData = await (
8+
await fetch(`${stationUrl}/observations/latest`, {
9+
headers: { "User-Agent": "Convex/1.0" },
10+
})
11+
).json();
12+
const celsius = observationData.properties.temperature.value;
13+
return {
14+
fahrenheit: Math.round(((celsius * 9) / 5 + 32) * 100) / 100,
15+
fetchedAt: Date.now(),
16+
timestamp: observationData.properties.timestamp,
17+
};
18+
},
1619
});

npm-packages/@convex-dev/react-query/eslint.config.mjs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import path from "node:path";
44
import { fileURLToPath } from "node:url";
55
import js from "@eslint/js";
66
import { FlatCompat } from "@eslint/eslintrc";
7+
import convexPlugin from "@convex-dev/eslint-plugin";
8+
import tseslint from "typescript-eslint";
79

810
const __filename = fileURLToPath(import.meta.url);
911
const __dirname = path.dirname(__filename);
@@ -23,5 +25,22 @@ export default defineConfig([
2325
),
2426
),
2527
},
26-
globalIgnores(["convex/_generated/**"]),
28+
globalIgnores(["convex/_generated/**", "dist"]),
29+
...tseslint.configs.recommended,
30+
...convexPlugin.configs.recommended,
31+
{
32+
rules: {
33+
// allow (_arg: number) => {}
34+
"@typescript-eslint/no-unused-vars": [
35+
"error",
36+
{
37+
argsIgnorePattern: "^_",
38+
varsIgnorePattern: "^_",
39+
},
40+
],
41+
42+
"@typescript-eslint/no-explicit-any": "off",
43+
"@typescript-eslint/no-empty-object-type": "off",
44+
},
45+
},
2746
]);

npm-packages/@convex-dev/react-query/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
},
4141
"devDependencies": {
4242
"@convex-dev/auth": "^0.0.90",
43+
"@convex-dev/eslint-plugin": "workspace:*",
4344
"@eslint/compat": "~1.3.0",
4445
"@eslint/eslintrc": "^3",
4546
"@eslint/js": "~9.34.0",
@@ -59,6 +60,7 @@
5960
"react-dom": "^18.0.0",
6061
"tshy": "^3.0.0",
6162
"typescript": "~5.0.3",
63+
"typescript-eslint": "^8.45.0",
6264
"vite": "^6.4.1",
6365
"vitest": "^3.2.4"
6466
},

npm-packages/@convex-dev/react-query/src/example.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
/* eslint-disable jsx-a11y/anchor-is-valid */
21
import {
32
QueryClient,
43
QueryClientProvider,
54
useMutation,
65
useQuery,
7-
useSuspenseQuery,
86
} from "@tanstack/react-query";
97
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
108
import {
119
Authenticated,
1210
AuthLoading,
13-
ConvexProvider,
1411
ConvexReactClient,
1512
Unauthenticated,
1613
} from "convex/react";
@@ -156,8 +153,8 @@ function App() {
156153
});
157154
const {
158155
data: user,
159-
error: userError,
160-
isPending: userIsPending,
156+
error: _userError,
157+
isPending: _userIsPending,
161158
} = useQuery({
162159
...convexQuery(api.user.getCurrent, {}),
163160
initialData: null,

0 commit comments

Comments
 (0)