-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy patheslint.config.mjs
More file actions
126 lines (111 loc) · 3.71 KB
/
eslint.config.mjs
File metadata and controls
126 lines (111 loc) · 3.71 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
import { defineConfig } from "eslint/config";
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
import reactLint from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import tanstackQueryLint from "@tanstack/eslint-plugin-query";
import perfectionist from "eslint-plugin-perfectionist";
import eslintConfigPrettier from "eslint-config-prettier";
import { includeIgnoreFile } from "@eslint/compat";
import { fileURLToPath } from "node:url";
const gitignorePath = fileURLToPath(new URL(".gitignore", import.meta.url));
export default defineConfig(
// Ignored files
includeIgnoreFile(gitignorePath, "Imported .gitignore patterns"),
{
ignores: ["**/*.config.{js,ts,mjs}", "**/vitest.workspace.ts"],
},
// JavaScript files
pluginJs.configs.recommended,
tseslint.configs.recommendedTypeChecked,
// TypeScript files - all packages
{
languageOptions: {
parserOptions: {
projectService: true,
},
},
rules: {
// Disallow use of console.log
"no-console": ["error", { allow: ["warn", "error"] }],
// Force all switches to be exhaustive
"@typescript-eslint/switch-exhaustiveness-check": "error",
// Ensure imports are marked with type when appropriate
"@typescript-eslint/consistent-type-imports": [
"error",
{ fixStyle: "inline-type-imports" },
],
// Allow unused vars with modifier
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
// Ensure no type imports contain side effects
"@typescript-eslint/no-import-type-side-effects": "error",
// Disable overly strict rules (we should eliminate these over time)
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-misused-promises": "off",
},
},
// React files - frontend only
{
files: ["packages/graph-explorer/**/*.{ts,tsx}"],
plugins: {
react: reactLint,
"react-hooks": reactHooks,
"@tanstack/query": tanstackQueryLint,
},
languageOptions: {
globals: globals.browser,
parserOptions: { ecmaFeatures: { jsx: true } },
},
settings: {
react: { version: "19" },
},
rules: {
...reactLint.configs.flat.recommended.rules,
...reactHooks.configs.flat.recommended.rules,
...tanstackQueryLint.configs.recommended.rules,
// React optimizations
"react/react-in-jsx-scope": "off",
"react/prop-types": "off",
"react/display-name": "off",
"react/jsx-curly-brace-presence": "error",
// TanStack Query
"@tanstack/query/exhaustive-deps": "error",
"@tanstack/query/no-rest-destructuring": "warn",
"@tanstack/query/stable-query-client": "error",
},
},
// Node.js backend files
{
files: ["packages/graph-explorer-proxy-server/**/*.{ts,js}"],
languageOptions: {
globals: globals.node,
},
},
{
plugins: {
perfectionist,
},
rules: {
"perfectionist/sort-imports": ["error", { type: "natural" }],
"perfectionist/sort-named-imports": ["error", { type: "natural" }],
},
},
// Prettier must be last
eslintConfigPrettier,
);