-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy patheslint.config.js
More file actions
115 lines (111 loc) · 3.19 KB
/
Copy patheslint.config.js
File metadata and controls
115 lines (111 loc) · 3.19 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
import tseslint from "typescript-eslint";
import svelteParser from "svelte-eslint-parser";
import sveltePlugin from "eslint-plugin-svelte";
const HOOK_NAME_MESSAGE =
"Do not use React-style hook names. Use createX, xQuery, xMutation, or plain utilities.";
const reactSmellRules = {
"no-restricted-syntax": [
"error",
{
selector: "FunctionDeclaration[id.name=/^use[A-Z]/]",
message: HOOK_NAME_MESSAGE,
},
{
selector: "VariableDeclarator[id.name=/^use[A-Z]/]",
message: HOOK_NAME_MESSAGE,
},
],
};
const hygieneRules = {
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/consistent-type-imports": [
"error",
{ prefer: "type-imports", fixStyle: "inline-type-imports" },
],
"no-console": ["warn", { allow: ["warn", "error"] }],
};
export default tseslint.config(
{
ignores: ["dist/**", "node_modules/**", "src-tauri/**", ".cache-tests/**"],
},
{
files: ["src/**/*.ts"],
languageOptions: { parser: tseslint.parser },
plugins: { "@typescript-eslint": tseslint.plugin },
rules: { ...reactSmellRules, ...hygieneRules },
},
{
files: ["src/**/*.svelte"],
plugins: { svelte: sveltePlugin, "@typescript-eslint": tseslint.plugin },
languageOptions: {
parser: svelteParser,
parserOptions: { parser: tseslint.parser },
},
rules: {
...reactSmellRules,
...hygieneRules,
"svelte/no-unused-svelte-ignore": "warn",
},
},
// §7.2 ui mutation discipline: components mutate `ui` only through the
// setters exported by the store — never with direct ui.x = assignments.
// (The setters themselves live in the ui/ slices.)
{
files: ["src/**/*.{ts,svelte}"],
ignores: ["src/shared/stores/ui/**"],
rules: {
"no-restricted-syntax": [
"error",
{
selector: "AssignmentExpression > MemberExpression[object.name='ui']",
message:
"Mutate ui only through the setter functions exported from ui-state.svelte.ts (§7.2).",
},
{
selector: "UpdateExpression > MemberExpression[object.name='ui']",
message:
"Mutate ui only through the setter functions exported from ui-state.svelte.ts (§7.2).",
},
],
},
},
// Dependency boundaries: shared/ is the bottom layer.
{
files: ["src/shared/**/*.{ts,svelte}"],
rules: {
"no-restricted-imports": [
"error",
{
patterns: [
{
group: ["@/features/*", "**/features/*"],
message:
"shared/ must not import from features/ — move the module down a layer or invert the dependency.",
},
{
group: ["@/app/*", "**/app/*"],
message: "shared/ must not import from app/.",
},
],
},
],
},
},
// features/ may not reach up into app/.
{
files: ["src/features/**/*.{ts,svelte}"],
rules: {
"no-restricted-imports": [
"error",
{
patterns: [
{
group: ["@/app/*", "**/app/*"],
message: "features/ must not import from app/.",
},
],
},
],
},
},
);