Skip to content

Commit 5fb658a

Browse files
committed
component api
1 parent e8887e4 commit 5fb658a

24 files changed

+543
-474
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ node_modules
1414
frontend/package.json
1515
# npm pack output
1616
*.tgz
17+
*.tsbuildinfo

.prettierrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"trailingComma": "es5"
3+
}

commonjs.json

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

convex.json

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

eslint.config.js

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,45 @@
11
import globals from "globals";
22
import pluginJs from "@eslint/js";
33
import tseslint from "typescript-eslint";
4+
import reactHooks from "eslint-plugin-react-hooks";
5+
import reactRefresh from "eslint-plugin-react-refresh";
46

57
export default [
6-
{ files: ["src/**/*.{js,mjs,cjs,ts,tsx}"] },
78
{
89
ignores: [
910
"dist/**",
1011
"eslint.config.js",
12+
"vitest.config.ts",
1113
"**/_generated/",
1214
"node10stubs.mjs",
1315
],
1416
},
1517
{
18+
files: ["src/**/*.{js,mjs,cjs,ts,tsx}", "example/**/*.{js,mjs,cjs,ts,tsx}"],
1619
languageOptions: {
17-
globals: globals.worker,
1820
parser: tseslint.parser,
19-
2021
parserOptions: {
21-
project: true,
22-
tsconfigRootDir: ".",
22+
project: [
23+
"./tsconfig.json",
24+
"./example/tsconfig.json",
25+
"./example/convex/tsconfig.json",
26+
],
27+
tsconfigRootDir: import.meta.dirname,
2328
},
2429
},
2530
},
2631
pluginJs.configs.recommended,
2732
...tseslint.configs.recommended,
33+
// Convex code - Worker environment
2834
{
35+
files: ["src/**/*.{ts,tsx}", "example/convex/**/*.{ts,tsx}"],
36+
ignores: ["src/react/**"],
37+
languageOptions: {
38+
globals: globals.worker,
39+
},
2940
rules: {
3041
"@typescript-eslint/no-floating-promises": "error",
31-
"eslint-comments/no-unused-disable": "off",
32-
33-
// allow (_arg: number) => {} and const _foo = 1;
42+
"@typescript-eslint/no-explicit-any": "off",
3443
"no-unused-vars": "off",
3544
"@typescript-eslint/no-unused-vars": [
3645
"warn",
@@ -39,6 +48,52 @@ export default [
3948
varsIgnorePattern: "^_",
4049
},
4150
],
51+
"@typescript-eslint/no-unused-expressions": [
52+
"error",
53+
{
54+
allowShortCircuit: true,
55+
allowTernary: true,
56+
allowTaggedTemplates: true,
57+
},
58+
],
59+
},
60+
},
61+
// React app code - Browser environment
62+
{
63+
files: ["src/react/**/*.{ts,tsx}", "example/src/**/*.{ts,tsx}"],
64+
languageOptions: {
65+
ecmaVersion: 2020,
66+
globals: globals.browser,
67+
},
68+
plugins: {
69+
"react-hooks": reactHooks,
70+
"react-refresh": reactRefresh,
71+
},
72+
rules: {
73+
...reactHooks.configs.recommended.rules,
74+
"react-refresh/only-export-components": [
75+
"warn",
76+
{ allowConstantExport: true },
77+
],
78+
"@typescript-eslint/no-explicit-any": "off",
79+
"no-unused-vars": "off",
80+
"@typescript-eslint/no-unused-vars": [
81+
"warn",
82+
{
83+
argsIgnorePattern: "^_",
84+
varsIgnorePattern: "^_",
85+
},
86+
],
87+
},
88+
},
89+
// Example config files (vite.config.ts, etc.) - Node environment
90+
{
91+
files: ["example/vite.config.ts", "example/**/*.config.{js,ts}"],
92+
languageOptions: {
93+
globals: {
94+
...globals.node,
95+
...globals.browser,
96+
},
4297
},
4398
},
4499
];

esm.json

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

example/convex/_generated/api.d.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* prettier-ignore-start */
2-
31
/* eslint-disable */
42
/**
53
* Generated `api` utility.
@@ -18,26 +16,35 @@ import type {
1816
FilterApi,
1917
FunctionReference,
2018
} from "convex/server";
19+
20+
declare const fullApi: ApiFromModules<{
21+
example: typeof example;
22+
http: typeof http;
23+
}>;
24+
2125
/**
22-
* A utility for referencing Convex functions in your app's API.
26+
* A utility for referencing Convex functions in your app's public API.
2327
*
2428
* Usage:
2529
* ```js
2630
* const myFunctionReference = api.myModule.myFunction;
2731
* ```
2832
*/
29-
declare const fullApi: ApiFromModules<{
30-
example: typeof example;
31-
http: typeof http;
32-
}>;
33-
declare const fullApiWithMounts: typeof fullApi;
34-
3533
export declare const api: FilterApi<
36-
typeof fullApiWithMounts,
34+
typeof fullApi,
3735
FunctionReference<any, "public">
3836
>;
37+
38+
/**
39+
* A utility for referencing Convex functions in your app's internal API.
40+
*
41+
* Usage:
42+
* ```js
43+
* const myFunctionReference = internal.myModule.myFunction;
44+
* ```
45+
*/
3946
export declare const internal: FilterApi<
40-
typeof fullApiWithMounts,
47+
typeof fullApi,
4148
FunctionReference<any, "internal">
4249
>;
4350

@@ -346,5 +353,3 @@ export declare const components: {
346353
};
347354
};
348355
};
349-
350-
/* prettier-ignore-end */

example/convex/_generated/api.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* prettier-ignore-start */
2-
31
/* eslint-disable */
42
/**
53
* Generated `api` utility.
@@ -23,5 +21,3 @@ import { anyApi, componentsGeneric } from "convex/server";
2321
export const api = anyApi;
2422
export const internal = anyApi;
2523
export const components = componentsGeneric();
26-
27-
/* prettier-ignore-end */

example/convex/_generated/dataModel.d.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* prettier-ignore-start */
2-
31
/* eslint-disable */
42
/**
53
* Generated data model types.
@@ -58,5 +56,3 @@ export type Id<TableName extends TableNames = TableNames> =
5856
* `mutationGeneric` to make them type-safe.
5957
*/
6058
export type DataModel = AnyDataModel;
61-
62-
/* prettier-ignore-end */

example/convex/_generated/server.d.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* prettier-ignore-start */
2-
31
/* eslint-disable */
42
/**
53
* Generated utilities for implementing server-side Convex query and mutation functions.
@@ -149,5 +147,3 @@ export type DatabaseReader = GenericDatabaseReader<DataModel>;
149147
* for the guarantees Convex provides your functions.
150148
*/
151149
export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
152-
153-
/* prettier-ignore-end */

0 commit comments

Comments
 (0)