-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy patheslint.config.js
More file actions
109 lines (108 loc) · 4.27 KB
/
eslint.config.js
File metadata and controls
109 lines (108 loc) · 4.27 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
import js from '@eslint/js';
import globals from 'globals';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import tseslint from 'typescript-eslint';
import eslintPluginPrettier from 'eslint-plugin-prettier';
import eslintConfigPrettier from 'eslint-config-prettier';
export default tseslint.config(
{
ignores: [
'dist',
'.netlify/',
'node_modules/',
'coverage/',
'**/*.generated.*',
'public/',
'lighthouse-reports/',
'supabase/functions/',
'tests/',
'app/',
'.eslintcache',
],
},
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
prettier: eslintPluginPrettier,
},
rules: {
...reactHooks.configs.recommended.rules,
'prettier/prettier': 'error',
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
// Prevent nested ternaries that break Rollup tree shaking
// See: https://github.com/rollup/rollup/issues/5747
'no-nested-ternary': 'error',
// Allow single ternaries but encourage helper functions for complex conditions
'multiline-ternary': ['warn', 'always-multiline'],
// Prevent usage of 'any' type - enforce proper TypeScript typing
'@typescript-eslint/no-explicit-any': 'error',
// Prevent usage of .single() from Supabase to avoid 406 errors
// Use .maybeSingle() instead which returns null instead of throwing
// See: /docs/postmortems/406-error-resolution.md
'no-restricted-syntax': [
'error',
{
selector: 'CallExpression[callee.property.name="single"]',
message:
'Use .maybeSingle() instead of .single() to prevent 406 errors. .single() throws when no rows are found, while .maybeSingle() returns null safely.',
},
],
},
},
// Bulletproof testing rules - prevent async/await in unit test files
// Excludes integration tests, API tests, and E2E tests which may legitimately need async
{
files: ['**/*.test.{ts,tsx}', '**/__tests__/**/*.{ts,tsx}'],
ignores: [
'netlify/functions/**/*.test.{ts,tsx}', // API function tests
'actions/**/*.test.{ts,tsx}', // GitHub action tests
'e2e/**/*.test.{ts,tsx}', // E2E tests
'src/services/**/*.test.{ts,tsx}', // Service integration tests
'**/integration/**/*.test.{ts,tsx}', // Explicit integration tests
'**/*integration*.test.{ts,tsx}', // Integration test files
'**/*e2e*.test.{ts,tsx}', // E2E test files
'**/*api*.test.{ts,tsx}', // API test files
'src/lib/llm/**/*.test.{ts,tsx}', // LLM service tests (integration with external APIs)
],
rules: {
// Prevent async/await in test functions to avoid CI hangs
'no-restricted-syntax': [
'error',
{
selector: 'FunctionDeclaration[async=true]',
message:
'Async functions are forbidden in unit tests. Use synchronous patterns only. See docs/testing/BULLETPROOF_TESTING_GUIDELINES.md',
},
{
selector: 'ArrowFunctionExpression[async=true]',
message:
'Async arrow functions are forbidden in unit tests. Use synchronous patterns only. See docs/testing/BULLETPROOF_TESTING_GUIDELINES.md',
},
{
selector: 'AwaitExpression',
message:
'await expressions are forbidden in unit tests. Use synchronous mocks instead. See docs/testing/BULLETPROOF_TESTING_GUIDELINES.md',
},
{
selector: 'CallExpression[callee.name="waitFor"]',
message:
'waitFor() is forbidden in unit tests as it can hang indefinitely. Use synchronous assertions only. See docs/testing/BULLETPROOF_TESTING_GUIDELINES.md',
},
{
selector: 'CallExpression[callee.name="waitForElementToBeRemoved"]',
message:
'waitForElementToBeRemoved() is forbidden in unit tests as it can hang indefinitely. Use synchronous assertions only. See docs/testing/BULLETPROOF_TESTING_GUIDELINES.md',
},
],
},
},
eslintConfigPrettier
);