-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheslint.config.js
More file actions
204 lines (202 loc) · 5.85 KB
/
eslint.config.js
File metadata and controls
204 lines (202 loc) · 5.85 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
import eslint from '@eslint/js'
import tseslint from 'typescript-eslint'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
tseslint.configs.strictTypeChecked,
tseslint.configs.stylisticTypeChecked,
eslintPluginPrettierRecommended,
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname
}
},
linterOptions: {
reportUnusedDisableDirectives: 'error'
}
},
{
ignores: [
'node_modules',
'dist',
'coverage',
'*.md',
'docs',
'bin',
'*.lock',
'eslint.config.js',
'**/.bunup-dts-*',
'**/*.d.ts',
'**/tsconfig.tsbuildinfo',
'**/bun.lockb',
'packages/site/.astro/**',
'**/.astro/**',
'**/.netlify/**',
'**/public/**',
'**/.ladle/**',
'**/__tests__/fixtures/dist/**',
'**/__tests__/fixtures/*.ts',
'**/*.generated.ts'
]
},
{
rules: {
'@typescript-eslint/no-misused-spread': 'off',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_'
}
],
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'interface',
format: ['PascalCase']
},
{
selector: 'typeAlias',
format: ['PascalCase']
},
{
selector: 'enum',
format: ['PascalCase']
},
{
selector: 'enumMember',
format: ['UPPER_CASE']
}
],
'@typescript-eslint/explicit-function-return-type': [
'error',
{
allowExpressions: true,
allowTypedFunctionExpressions: true,
allowHigherOrderFunctions: true
}
],
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
accessibility: 'explicit',
overrides: {
accessors: 'no-public',
constructors: 'no-public',
methods: 'explicit',
properties: 'explicit',
parameterProperties: 'explicit'
}
}
],
'@typescript-eslint/prefer-readonly': 'error',
'@typescript-eslint/prefer-readonly-parameter-types': 'off',
'@typescript-eslint/consistent-type-imports': [
'error',
{
prefer: 'type-imports',
fixStyle: 'separate-type-imports'
}
],
'@typescript-eslint/consistent-type-exports': 'error',
// Note: consistent-type-assertions intentionally omitted - policy is to prefer type guards
// The dangerous `as unknown as T` pattern is banned by no-restricted-syntax below
// Code quality and best practices
'func-names': ['error', 'as-needed'],
'no-restricted-exports': 'error',
'no-console': ['warn', { allow: ['warn', 'error'] }],
'no-debugger': 'error',
'no-alert': 'error',
'prefer-const': 'error',
'no-var': 'error',
'object-shorthand': 'error',
'prefer-arrow-callback': 'error',
'sort-imports': [
'error',
{
ignoreCase: false,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
allowSeparatedGroups: true
}
],
'no-eval': 'error',
'no-implied-eval': 'error',
'no-new-func': 'error',
'no-script-url': 'error',
'no-await-in-loop': 'warn',
'prefer-object-spread': 'error',
'no-restricted-syntax': [
'error',
{
selector: 'TSAsExpression > TSUnknownKeyword',
message: 'Avoid `as unknown as T` pattern. Use type guards instead.'
},
{
selector: 'VariableDeclaration[kind="let"]',
message: 'Use `const` instead of `let`. Prefer immutable bindings.'
}
],
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['*/src/lib/*', '*/src/internal/*', '*/src/roll/*'],
message: 'Import from the package public API instead (e.g. @randsum/roller, not internal paths).'
}
]
}
]
}
},
{
// Override for .mjs files (Node.js config files)
files: ['**/*.mjs'],
languageOptions: {
globals: {
process: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
Buffer: 'readonly',
global: 'readonly',
console: 'readonly',
module: 'readonly',
require: 'readonly',
exports: 'readonly'
}
}
},
{
// Override for test files and test-utils package
// ESLint's type-aware rules can't resolve types from workspace packages properly
// Internal path imports are allowed in tests to enable unit testing of internals
files: ['**/__tests__/**/*.ts', '**/test-utils/**/*.ts'],
rules: {
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'no-restricted-imports': 'off'
}
},
{
// Override for build scripts — internal imports, sequential IO, and console output are expected
files: ['**/build.ts'],
rules: {
'no-restricted-imports': 'off',
'no-await-in-loop': 'off',
'no-console': 'off'
}
}
)