Repository navigation
Expand file tree
/
Copy patheslint.config.js
More file actions
119 lines (117 loc) · 4.6 KB
/
Copy patheslint.config.js
File metadata and controls
119 lines (117 loc) · 4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import js from "@eslint/js";
import globals from "globals";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import tseslint from "typescript-eslint";
// The AI core and feature files behind src/lib/ai/client.ts, by alias or
// relative path, with or without an extension. The server's same-named
// modules under supabase/functions/ai/ stay importable.
const aiInternalImport = String.raw`^(?!.*supabase/functions/)(.*/)?ai/(request|errors|sources|text|features(/.*)?)(\.[cm]?[jt]sx?)?/?$`;
const aiInternalMessage = "Import AI requests and errors from @/lib/ai/client.";
export default tseslint.config(
{ ignores: ["dist", "coverage", ".remember", "packages/**/node_modules", "packages/**/dist"] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ["**/*.{ts,tsx}"],
ignores: ["packages/**"],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
"@typescript-eslint/no-unused-vars": "off",
},
},
{
// Shared packages run on the web and in React Native, so they get no
// browser globals and no web-only libraries. See packages/core/README.md.
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ["packages/**/*.ts"],
languageOptions: {
ecmaVersion: 2022,
globals: globals.es2021,
},
rules: {
"@typescript-eslint/no-unused-vars": "off",
"no-restricted-globals": [
"error",
...["window", "document", "localStorage", "sessionStorage", "navigator", "location", "self"].map((name) => ({
name,
message: "Shared packages cannot use browser globals. Take the value as a parameter.",
})),
],
"no-restricted-syntax": [
"error",
{ selector: "MetaProperty[meta.name='import']", message: "Shared packages cannot use import.meta. Take the value as a parameter." },
],
"no-restricted-imports": [
"error",
{
paths: [
"react", "react-dom", "react-native", "react-i18next", "zustand", "@supabase/supabase-js", "posthog-js",
"sonner", "react-router-dom", "reactflow", "lucide-react", "framer-motion", "jspdf", "docx",
].map((name) => ({ name, message: "Shared packages stay platform-neutral; keep this in the app." })),
patterns: [
{ group: ["@sentry/*", "@radix-ui/*"], message: "Shared packages stay platform-neutral; keep this in the app." },
],
},
],
},
},
{
// A promise nobody awaits or catches turns a failed write into an
// unhandled rejection with no message for the user. Type-aware, so it
// runs on the client app and the shared packages only.
files: ["src/**/*.{ts,tsx}", "packages/**/src/**/*.ts"],
ignores: ["src/test/**"],
languageOptions: {
parserOptions: { projectService: true, tsconfigRootDir: import.meta.dirname },
},
rules: {
"@typescript-eslint/no-floating-promises": [
"error",
{ allowForKnownSafeCalls: [{ from: "package", name: "NavigateFunction", package: "react-router" }] },
],
"@typescript-eslint/no-misused-promises": [
"error",
{ checksConditionals: false, checksVoidReturn: { attributes: false } },
],
},
},
{
// App code imports AI requests and errors through src/lib/ai/client.ts
// only. The core and feature files behind it are internal.
files: ["src/**/*.{ts,tsx}", "e2e/**/*.ts", "agentic/**/*.ts"],
ignores: ["src/lib/ai/**"],
rules: {
"no-restricted-imports": [
"error",
{ patterns: [{ regex: aiInternalImport, message: aiInternalMessage }] },
],
"no-restricted-syntax": [
"error",
{
// esquery ends a regex at "/", so the pattern spells it as \x2F.
selector: `ImportExpression[source.value=/${aiInternalImport.replaceAll("/", "\\x2F")}/]`,
message: aiInternalMessage,
},
],
},
},
{
// Fixed sleeps pass or fail with machine speed. Wait for a condition.
files: ["e2e/**/*.ts", "agentic/**/*.ts", ".claude/skills/verify-debatelab/**/*.ts"],
rules: {
"no-restricted-properties": [
"error",
{ property: "waitForTimeout", message: "Wait for a condition (expect(...).toBeVisible(), waitForResponse, expect.poll) instead of a fixed sleep." },
],
},
},
);