11import globals from "globals" ;
22import pluginJs from "@eslint/js" ;
33import tseslint from "typescript-eslint" ;
4+ import reactHooks from "eslint-plugin-react-hooks" ;
5+ import reactRefresh from "eslint-plugin-react-refresh" ;
46
57export 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] ;
0 commit comments