-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheslint.config.js
More file actions
135 lines (133 loc) · 4.16 KB
/
Copy patheslint.config.js
File metadata and controls
135 lines (133 loc) · 4.16 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
import eslint from '@eslint/js'
import tseslint from 'typescript-eslint'
import pluginVue from 'eslint-plugin-vue'
import prettierConfig from 'eslint-config-prettier/flat'
import globals from 'globals'
// Performance note: we deliberately use `eslint-config-prettier` (turns off
// conflicting stylistic rules) instead of `eslint-plugin-prettier` (runs
// Prettier as an ESLint rule). The plugin approach roughly doubles lint time
// on large repos because Prettier has to re-parse every file. Prettier is
// run separately via `npm run format:check`. See
// https://prettier.io/docs/integrating-with-linters and
// https://typescript-eslint.io/troubleshooting/typed-linting/performance/
export default [
{
ignores: [
'out/**',
'dist/**',
'release/**',
'node_modules/**',
'**/*.d.ts',
'docs/**',
'tests/e2e/**',
'tests/web-smoke/**',
'e2e-*.mjs',
'.planning/**',
// Third-party bundles shipped directly to the renderer's public
// folder — not authored in this repo, never meant to be linted.
'src/renderer/public/**'
]
},
eslint.configs.recommended,
...tseslint.configs.recommended,
...pluginVue.configs['flat/recommended'],
prettierConfig,
{
// Type-aware linting: only applies to src/**. This is the expensive
// pipeline (projectService loads the TS program and rules like
// strict-boolean-expressions request type info per file). Tests and
// scripts deliberately skip it so they lint in milliseconds, not seconds.
files: ['src/**/*.{ts,tsx,vue}'],
languageOptions: {
parserOptions: {
parser: tseslint.parser,
projectService: true,
tsconfigRootDir: import.meta.dirname,
extraFileExtensions: ['.vue']
}
},
rules: {
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/strict-boolean-expressions': 'error',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-empty-object-type': ['error', { allowObjectTypes: 'always' }],
'vue/multi-word-component-names': 'off'
}
},
{
files: ['src/renderer/**/*.{ts,tsx,vue}'],
languageOptions: {
globals: {
...globals.browser
}
}
},
{
files: ['src/main/**/*.ts', 'src/preload/**/*.ts'],
languageOptions: {
globals: {
...globals.node
}
}
},
{
files: ['scripts/**/*.{js,mjs,ts}'],
languageOptions: {
globals: {
...globals.node
}
}
},
{
files: ['**/*.config.{js,ts}', 'eslint.config.js'],
rules: {
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-argument': 'off'
}
},
// Ban renderer -> main process imports
{
files: ['src/renderer/**/*.{ts,tsx,vue}'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['**/main/**'],
message: 'Renderer must not import from main process. Use src/shared/ re-exports.'
}
]
}
]
}
},
// Ban raw window.api access (enforce useApiService) and ad-hoc IPC error checks
{
files: ['src/renderer/**/*.{ts,tsx,vue}'],
ignores: [
'src/renderer/src/composables/useApiService.ts',
'src/renderer/src/services/LogService.ts',
'src/renderer/src/stores/externalLinksStore.ts',
'src/renderer/src/stores/databaseStore.ts'
],
rules: {
'no-restricted-syntax': [
'error',
{
selector: "MemberExpression[object.property.name='api'][object.object.name='window']",
message: 'Use useApiService() for API access. Direct window.api usage is not allowed.'
},
{
selector: "BinaryExpression[operator='in'][left.value='error'][right.type='Identifier']",
message:
"Use isIpcError() from shared/types/errors instead of ad-hoc 'error' in result checks."
}
]
}
}
]