-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
111 lines (110 loc) · 3.26 KB
/
eslint.config.js
File metadata and controls
111 lines (110 loc) · 3.26 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
import js from '@eslint/js';
import { defineConfig } from 'eslint/config';
import globals from 'globals';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import tseslint from 'typescript-eslint';
/**
* Root ESLint for monorepo. Applies to apps/web and apps/api.
*/
export default defineConfig(
{
ignores: [
'**/node_modules/**',
'**/dist/**',
'**/prisma/migrations/**',
'apps/web/public/example/**',
],
},
{
languageOptions: {
parserOptions: {
tsconfigRootDir: import.meta.dirname,
},
},
},
js.configs.recommended,
...tseslint.configs.recommended,
// Type-safety rules (aligned with .cursor/rules/typescript-type-safety.mdc)
// Explicit project paths so type-aware rules resolve correctly (root tsconfig has "files": []).
{
files: ['apps/web/**/*.{ts,tsx}', 'apps/api/src/**/*.ts'],
languageOptions: {
parserOptions: {
project: [
'./apps/web/tsconfig.app.json',
'./apps/web/tsconfig.node.json',
'./apps/api/tsconfig.json',
],
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
'@typescript-eslint/explicit-function-return-type': [
'error',
{
allowExpressions: true,
allowTypedFunctionExpressions: true,
allowHigherOrderFunctions: true,
},
],
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/consistent-type-assertions': [
'error',
{ assertionStyle: 'never' },
],
'@typescript-eslint/no-non-null-assertion': 'warn',
// Type-aware: flag any in assignments, member access, calls, returns
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
},
},
// apps/web (React)
{
files: ['apps/web/**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: { ...globals.browser, ...globals.node },
},
plugins: { 'react-hooks': reactHooks, 'react-refresh': reactRefresh },
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': 'off',
},
},
// apps/api (Node)
{
files: ['apps/api/src/**/*.ts'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: { ...globals.node },
},
rules: {
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
},
},
// app.ts: allow type assertions for OpenAPIHono handler wiring (library type mismatch)
{
files: ['apps/api/src/app.ts'],
rules: {
'@typescript-eslint/consistent-type-assertions': 'off',
},
},
// Web: allow type assertions / unsafe assignment where necessary (env, API response, form attrs)
{
files: [
'apps/web/src/api/client.ts',
'apps/web/src/api/errorHandler.ts',
'apps/web/src/main.tsx',
'apps/web/src/views/Products/index.tsx',
],
rules: {
'@typescript-eslint/consistent-type-assertions': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
},
},
);