-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheslint.config.js
More file actions
119 lines (108 loc) · 3.82 KB
/
eslint.config.js
File metadata and controls
119 lines (108 loc) · 3.82 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
// @ts-check
// Workspace-level ESLint configuration for all JS/TS projects.
// Uses flat config cascading: broad configs first, narrow overrides after.
import js from "@eslint/js";
import tseslint from "@typescript-eslint/eslint-plugin";
import tsparser from "@typescript-eslint/parser";
import sveltePlugin from "eslint-plugin-svelte";
import svelteParser from "svelte-eslint-parser";
import importPlugin from "eslint-plugin-import-x";
import react from "eslint-plugin-react";
import globals from "globals";
// All project source directories (add new TS/Svelte projects here)
const projectGlobs = [
"props/frontend/src/**",
"x/agent_server/web/src/**",
"x/rspcache/admin_ui/src/**",
"airlock/frontend/**",
];
const tsFiles = projectGlobs.map((g) => `${g}/*.{ts,tsx}`);
const svelteFiles = projectGlobs.map((g) => `${g}/*.svelte`);
const svelteTsFiles = projectGlobs.map((g) => `${g}/*.svelte.ts`);
// Import ordering (TS equivalent of ruff's isort)
const importRules = {
"import/first": "error",
"import/order": [
"error",
{
groups: ["builtin", "external", "internal", ["parent", "sibling"], "index", "type"],
"newlines-between": "always",
alphabetize: { order: "asc", caseInsensitive: true },
},
],
"import/newline-after-import": "error",
"import/no-duplicates": "error",
};
// Shared quality + TS rules applied everywhere
const coreRules = {
"prefer-const": "error",
eqeqeq: ["error", "always", { null: "ignore" }],
"no-console": ["warn", { allow: ["warn", "error"] }],
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }],
"no-unused-vars": "off",
...importRules,
};
export default [
// Global ignores
{
ignores: [
"**/node_modules/**",
"**/dist/**",
"**/build/**",
"**/.svelte-kit/**",
"**/playwright-report/**",
"**/*.config.mjs",
],
},
js.configs.recommended,
// ── All TypeScript files ───────────────────────────────────────────────
{
files: tsFiles,
ignores: svelteTsFiles,
languageOptions: {
parser: tsparser,
parserOptions: { ecmaVersion: "latest", sourceType: "module" },
globals: { ...globals.browser },
},
plugins: {
"@typescript-eslint": tseslint,
import: importPlugin,
},
rules: coreRules,
},
// ── All Svelte files ───────────────────────────────────────────────────
// Svelte plugin recommended config (scoped to our projects)
...sveltePlugin.configs["flat/recommended"].map((config) => ({
...config,
files: svelteFiles,
})),
{
files: svelteFiles,
languageOptions: {
parser: svelteParser,
parserOptions: { parser: tsparser, ecmaVersion: "latest", sourceType: "module" },
globals: { ...globals.browser },
},
plugins: {
"@typescript-eslint": tseslint,
import: importPlugin,
},
rules: {
...coreRules,
// import/order crashes under Bazel's sandboxed execution (null file path
// in getFilePackagePath). Affects both eslint-plugin-import and import-x.
"import/order": "off",
"svelte/no-unused-svelte-ignore": "warn",
},
},
// ── Per-project overrides ──────────────────────────────────────────────
// RSPCache admin UI: React/JSX
{
files: ["x/rspcache/admin_ui/src/**/*.{ts,tsx}"],
languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
plugins: { react },
settings: { react: { version: "18.3" } },
rules: { "react/react-in-jsx-scope": "off" },
},
];