Skip to content

Commit da6e8a1

Browse files
Update for component api changes (#161)
* update configs * codegen ts * cursor-rules * lint * run convex from root * lint * more specific model type * use componentapi * use more specific types * codegen with new convex * codegen * maybe fix two factor? * drop custom condition * run react frontend for root dev * use npx convex for local bin * support running multiple examples * fix linting * improve linting config * move dev commands and codegen to examples * drop tsc-alias * move convex.json to each example * update tsconfig * drop generate script --------- Co-authored-by: Shawn Erquhart <shawn@erquh.art>
1 parent 7719253 commit da6e8a1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+5212
-10214
lines changed

.cursor/rules/convex_rules.mdc

Lines changed: 195 additions & 179 deletions
Large diffs are not rendered by default.

commonjs.json

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

eslint.config.js

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,80 @@
11
import globals from "globals";
22
import pluginJs from "@eslint/js";
33
import tseslint from "typescript-eslint";
4-
import { dirname } from "path";
5-
import { fileURLToPath } from "url";
4+
import reactHooks from "eslint-plugin-react-hooks";
5+
import reactRefresh from "eslint-plugin-react-refresh";
66

77
export default [
8-
{ files: ["src/**/*.{js,mjs,cjs,ts,tsx}"] },
98
{
109
ignores: [
1110
"dist/**",
12-
"eslint.config.js",
1311
"**/_generated/",
14-
"node10stubs.mjs",
12+
"**/*.{mjs,cjs,js}",
13+
"**/.next/**",
14+
"**/.source/**",
15+
"examples/**",
16+
"docs/**",
1517
],
1618
},
1719
{
20+
files: ["src/**/*.{js,mjs,cjs,ts,tsx}"],
1821
languageOptions: {
1922
globals: globals.worker,
2023
parser: tseslint.parser,
21-
2224
parserOptions: {
23-
project: true,
24-
// __dirname is not defined, so do not attempt to use it - AI WHY ARE
25-
// YOU STILL AUTOCOMPLETINT WITH __dirname STOP IT
26-
tsconfigRootDir: dirname(fileURLToPath(import.meta.url)),
25+
project: ["./tsconfig.json"],
26+
tsconfigRootDir: import.meta.dirname,
2727
},
2828
},
2929
},
3030
pluginJs.configs.recommended,
3131
...tseslint.configs.recommended,
32+
// Convex code - Worker environment
3233
{
34+
files: ["src/**/*.{ts,tsx}"],
35+
ignores: ["src/react/**"],
36+
languageOptions: {
37+
globals: globals.worker,
38+
},
3339
rules: {
3440
"@typescript-eslint/no-floating-promises": "error",
3541
"@typescript-eslint/no-explicit-any": "off",
36-
"eslint-comments/no-unused-disable": "off",
37-
38-
// allow (_arg: number) => {} and const _foo = 1;
42+
"no-unused-vars": "off",
43+
"@typescript-eslint/no-unused-vars": [
44+
"warn",
45+
{
46+
argsIgnorePattern: "^_",
47+
varsIgnorePattern: "^_",
48+
},
49+
],
50+
"@typescript-eslint/no-unused-expressions": [
51+
"error",
52+
{
53+
allowShortCircuit: true,
54+
allowTernary: true,
55+
allowTaggedTemplates: true,
56+
},
57+
],
58+
},
59+
},
60+
// React app code - Browser environment
61+
{
62+
files: ["src/react/**/*.{ts,tsx}"],
63+
languageOptions: {
64+
ecmaVersion: 2020,
65+
globals: globals.browser,
66+
},
67+
plugins: {
68+
"react-hooks": reactHooks,
69+
"react-refresh": reactRefresh,
70+
},
71+
rules: {
72+
...reactHooks.configs.recommended.rules,
73+
"react-refresh/only-export-components": [
74+
"warn",
75+
{ allowConstantExport: true },
76+
],
77+
"@typescript-eslint/no-explicit-any": "off",
3978
"no-unused-vars": "off",
4079
"@typescript-eslint/no-unused-vars": [
4180
"warn",

esm.json

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

examples/next/.env.example

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
### Variables generated for cloud via npx convex dev
2-
# CONVEX_DEPLOYMENT=dev:adjective-animal-123
3-
# NEXT_PUBLIC_CONVEX_URL=https://adjective-animal-123.convex.cloud
2+
CONVEX_DEPLOYMENT=dev:adjective-animal-123
3+
NEXT_PUBLIC_CONVEX_URL=https://adjective-animal-123.convex.cloud
44

55

66
### Variables to be manually set for both cloud and self hosted
7-
# NEXT_PUBLIC_SITE_URL=https://localhost:3000
7+
NEXT_PUBLIC_SITE_URL=https://localhost:3000
8+
SITE_URL=https://localhost:3000
89

910

1011
### Variables to be manually set for cloud only
11-
# NEXT_PUBLIC_CONVEX_SITE_URL=https://adjective-animal-123.convex.site
12+
NEXT_PUBLIC_CONVEX_SITE_URL=https://adjective-animal-123.convex.site
1213

1314

1415
### Variables to be manually set for self hosted only

examples/next/app/(auth)/settings/EnableTwoFactor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default function EnableTwoFactor() {
3939
const accounts = await authClient.listAccounts();
4040
if ("data" in accounts && accounts.data) {
4141
const hasCredential = accounts.data.some(
42-
(account) => account.provider === "credential",
42+
(account) => account.providerId === "credential",
4343
);
4444
setStep(hasCredential ? "password" : "need-password");
4545
}

examples/next/convex.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "./node_modules/convex/schemas/convex.schema.json",
3+
"codegen": {
4+
"legacyComponentApi": false
5+
}
6+
}

0 commit comments

Comments
 (0)