-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy patheslint.config.js
More file actions
139 lines (136 loc) · 4.29 KB
/
eslint.config.js
File metadata and controls
139 lines (136 loc) · 4.29 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import { defineConfig, globalIgnores } from "eslint/config";
import js from "@eslint/js";
import globals from "globals";
import tseslint from "typescript-eslint";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import vitestPlugin from "@vitest/eslint-plugin";
import enforceZodV4 from "./eslint-rules/enforce-zod-v4.js";
const testFiles = [
"tests/**/*.test.ts",
"tests/**/*.test.tsx",
"tests/**/*.ts",
"tests/**/*.tsx",
"packages/**/*.test.ts",
];
const files = [...testFiles, "src/**/*.ts", "src/**/*.tsx", "scripts/**/*.ts", "packages/**/*.ts"];
export default defineConfig([
{ files, plugins: { js }, extends: ["js/recommended"] },
{ files, languageOptions: { globals: globals.node } },
{
files: testFiles,
plugins: {
vitest: vitestPlugin,
},
languageOptions: {
globals: {
...globals.node,
},
},
rules: {
...vitestPlugin.configs.recommended.rules,
"vitest/valid-title": "off",
"vitest/no-conditional-expect": "off",
"vitest/no-standalone-expect": "off",
"vitest/expect-expect": [
"error",
{
assertFunctionNames: ["expect", "expectDefined", "verifyMockCalls"],
},
],
},
},
{
files,
extends: [tseslint.configs.recommendedTypeChecked],
languageOptions: {
parserOptions: {
project: "./tsconfig.json",
tsconfigRootDir: import.meta.dirname,
},
},
},
{
files,
rules: {
"@typescript-eslint/switch-exhaustiveness-check": ["error", { considerDefaultExhaustiveForUnions: true }],
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/consistent-type-imports": ["error", { prefer: "type-imports" }],
"@typescript-eslint/consistent-type-exports": [
"error",
{
fixMixedExportsWithInlineTypeSpecifier: false,
},
],
eqeqeq: "error",
"no-self-compare": "error",
"no-unassigned-vars": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/explicit-function-return-type": "error",
},
},
{
files: ["src/**/*.ts"],
plugins: {
"enforce-zod-v4": {
rules: {
"enforce-zod-v4": enforceZodV4,
},
},
},
rules: {
"enforce-zod-v4/enforce-zod-v4": "error",
"no-restricted-imports": [
"error",
{
paths: [
{
name: "assert",
message:
"Use explicit error handling or test framework assertions (e.g., vitest's expect) instead.",
},
{
name: "node:assert",
message:
"Use explicit error handling or test framework assertions (e.g., vitest's expect) instead.",
},
],
},
],
"no-console": ["error"],
},
},
{
files: testFiles,
rules: {
/** Allow null assertions in test files */
"@typescript-eslint/no-non-null-assertion": "off",
},
},
{
files: ["tests/browser/**/*.ts"],
languageOptions: {
parserOptions: {
project: "./tests/browser/tsconfig.json",
tsconfigRootDir: import.meta.dirname,
},
},
},
globalIgnores([
"node_modules",
"**/dist/**",
"packages/*/dist/**",
"src/common/atlas/openapi.d.ts",
"src/ui/lib",
"coverage",
"global.d.ts",
"eslint.config.js",
"vitest.config.ts",
"vite.ui.config.ts",
"src/types/*.d.ts",
"tests/integration/fixtures/",
"tests/browser/polyfills/**",
"eslint-rules",
".yalc",
]),
eslintPluginPrettierRecommended,
]);