forked from Farm-credit/stellar-app-os
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
138 lines (123 loc) · 5 KB
/
eslint.config.mjs
File metadata and controls
138 lines (123 loc) · 5 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
import { defineConfig, globalIgnores } from 'eslint/config';
import nextVitals from 'eslint-config-next/core-web-vitals';
import nextTs from 'eslint-config-next/typescript';
import tsPlugin from '@typescript-eslint/eslint-plugin';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import prettierPlugin from 'eslint-plugin-prettier';
import prettierConfig from 'eslint-config-prettier';
const eslintConfig = defineConfig([
// ─── Base Next.js configs ────────────────────────────────────────────────
...nextVitals,
...nextTs,
prettierConfig,
// ─── Main rule set ────────────────────────────────────────────────────────
{
plugins: {
'@typescript-eslint': tsPlugin,
react: reactPlugin,
'react-hooks': reactHooksPlugin,
prettier: prettierPlugin,
},
settings: {
react: {
version: 'detect',
},
},
rules: {
'prettier/prettier': 'error',
// Use TypeScript-aware rule instead of base
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
// ── TypeScript ─────────────────────────────────────────────────────────
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports', fixStyle: 'inline-type-imports' },
],
'@typescript-eslint/no-non-null-assertion': 'warn',
'no-console': ['warn', { allow: ['warn', 'error', 'info'] }],
// ── React ──────────────────────────────────────────────────────────────
'react/react-in-jsx-scope': 'off',
'react/jsx-no-target-blank': 'error',
'react/self-closing-comp': ['error', { component: true, html: false }],
'react/display-name': 'warn',
'react/no-array-index-key': 'off',
// ── React Hooks ────────────────────────────────────────────────────────
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'error',
'react-hooks/purity': 'off',
'react-hooks/set-state-in-effect': 'off',
'react-hooks/preserve-manual-memoization': 'off',
'react-hooks/incompatible-library': 'off',
// ── General ────────────────────────────────────────────────────────────
eqeqeq: ['error', 'always', { null: 'ignore' }],
'no-var': 'error',
'prefer-const': 'error',
'no-throw-literal': 'error',
'no-return-await': 'error',
'require-await': 'error',
},
},
// ─── Relaxed rules for config / tooling files ─────────────────────────────
{
files: ['*.config.{js,mjs,ts}', '*.config.*.{js,mjs,ts}'],
rules: {
'no-console': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
},
// ─── Overrides for generated types and placeholder async functions ────────
{
files: ['lib/types/**/*.ts'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'no-unused-vars': 'off',
},
},
{
files: ['lib/stellar/**/*.ts', 'lib/services/**/*.ts', 'lib/certificate.ts'],
rules: {
'require-await': 'off',
},
},
// ─── Relaxed rules for test files ─────────────────────────────────────────
{
files: ['**/*.test.{ts,tsx}', '**/*.spec.{ts,tsx}', '**/__tests__/**/*.{ts,tsx}'],
rules: {
'no-console': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
},
},
// ─── Ignores ───────────────────────────────────────────────────────────────
globalIgnores([
'.next/**',
'out/**',
'build/**',
'next-env.d.ts',
'node_modules/**',
'scripts/**',
'public/**',
'coverage/**',
'*.min.js',
'*.md',
'!README.md',
'fix-*.js',
'fix-*.bat',
'fix-*.ps1',
'emergency-*.ps1',
'emergency-*.cmd',
'generate-*.bat',
'.github/Multistep/**',
'farm Guage/**',
]),
]);
export default eslintConfig;