2026-05-19 16:05:09 +08:00
|
|
|
import js from '@eslint/js'
|
|
|
|
|
import prettier from 'eslint-config-prettier'
|
|
|
|
|
import pluginReactConfig from 'eslint-plugin-react/configs/recommended.js'
|
|
|
|
|
import tseslint from 'typescript-eslint'
|
|
|
|
|
|
|
|
|
|
const baseNamingConvention = [
|
|
|
|
|
'error',
|
|
|
|
|
{
|
|
|
|
|
selector: 'property',
|
|
|
|
|
modifiers: ['requiresQuotes'],
|
|
|
|
|
format: null,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
selector: 'objectLiteralProperty',
|
|
|
|
|
modifiers: ['requiresQuotes'],
|
|
|
|
|
format: null,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
selector: ['property'],
|
|
|
|
|
format: ['strictCamelCase', 'UPPER_CASE'],
|
|
|
|
|
leadingUnderscore: 'allow',
|
|
|
|
|
filter: {
|
|
|
|
|
// Allow CSS variables, common HTTP headers, library-specific names, paths, and hyphenated/numeric keys
|
|
|
|
|
regex:
|
2026-09-07 16:49:00 +08:00
|
|
|
'^(Authorization|Content-Type|Accept|--.*|string_contains|disableCSRFCheck|X-Frameio-.*|/.*|field-.*|class-name|icon-.*|[0-9]+|@typescript-eslint/.*|Variables|Read|Edit|Admin|Bucket|Key|Body|ContentLength|ContentType|Prefix|ContinuationToken|Signature|CopySource|Delete|Objects|Quiet|ResponseContentDisposition|UploadId|PartNumber)$',
|
2026-05-19 16:05:09 +08:00
|
|
|
match: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
selector: ['parameter'],
|
|
|
|
|
format: ['strictCamelCase', 'StrictPascalCase'],
|
|
|
|
|
leadingUnderscore: 'allow',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
selector: ['accessor'],
|
|
|
|
|
format: ['strictCamelCase'],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
selector: ['classProperty'],
|
|
|
|
|
format: ['strictCamelCase', 'UPPER_CASE'],
|
|
|
|
|
leadingUnderscore: 'allow',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
selector: ['typeLike'],
|
|
|
|
|
format: ['StrictPascalCase'],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
selector: 'typeParameter',
|
|
|
|
|
format: ['StrictPascalCase'],
|
|
|
|
|
prefix: ['T'],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
selector: ['function'],
|
|
|
|
|
format: ['strictCamelCase', 'StrictPascalCase'],
|
|
|
|
|
leadingUnderscore: 'allow',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
selector: ['classMethod'],
|
|
|
|
|
format: ['strictCamelCase'],
|
|
|
|
|
leadingUnderscore: 'allow',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
selector: ['variable'],
|
|
|
|
|
format: ['strictCamelCase', 'StrictPascalCase', 'UPPER_CASE'],
|
|
|
|
|
leadingUnderscore: 'allow',
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
export default tseslint.config(
|
|
|
|
|
{
|
|
|
|
|
ignores: [
|
|
|
|
|
'**/dist/**',
|
|
|
|
|
'**/node_modules/**',
|
2026-06-01 23:35:00 +08:00
|
|
|
'**/packages/db/src/generated/**',
|
|
|
|
|
'**/packages/core/src/generated/**',
|
2026-05-19 16:05:09 +08:00
|
|
|
'**/data/**',
|
2026-09-03 21:01:14 +08:00
|
|
|
'**/packages/core/src/provider/generator/**',
|
2026-06-01 23:35:00 +08:00
|
|
|
'**/packages/webui/components/ui/**',
|
2026-06-26 13:34:02 +08:00
|
|
|
'**/packages/webui/paraglide/**',
|
2026-07-18 13:08:55 +08:00
|
|
|
'**/packages/webui/public/**',
|
2026-05-19 16:05:09 +08:00
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
js.configs.recommended,
|
|
|
|
|
...tseslint.configs.recommended,
|
|
|
|
|
prettier,
|
|
|
|
|
{
|
|
|
|
|
...pluginReactConfig,
|
|
|
|
|
rules: {
|
|
|
|
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
|
|
|
'@typescript-eslint/no-explicit-any': 'error',
|
|
|
|
|
'@typescript-eslint/ban-ts-comment': 'off',
|
|
|
|
|
'@typescript-eslint/naming-convention': baseNamingConvention,
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-10-27 08:09:09 +08:00
|
|
|
{
|
|
|
|
|
// Operations hold policy and orchestration only; data access belongs in core services.
|
|
|
|
|
files: ['packages/core/src/operations/**/*.ts'],
|
|
|
|
|
ignores: ['**/*.test.ts'],
|
|
|
|
|
rules: {
|
|
|
|
|
'@typescript-eslint/no-restricted-imports': [
|
|
|
|
|
'error',
|
|
|
|
|
{
|
|
|
|
|
paths: [
|
|
|
|
|
{
|
|
|
|
|
name: '@shumai/db',
|
|
|
|
|
importNames: ['prisma'],
|
|
|
|
|
message: 'Operations must call core services instead of the Prisma client.',
|
|
|
|
|
allowTypeImports: true,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-05-19 16:05:09 +08:00
|
|
|
{
|
|
|
|
|
files: ['**/*.test.ts', '**/*.test.tsx'],
|
|
|
|
|
rules: {
|
|
|
|
|
'@typescript-eslint/naming-convention': baseNamingConvention.map((q) => {
|
|
|
|
|
if (
|
|
|
|
|
typeof q === 'object' &&
|
|
|
|
|
(q.selector === 'property' ||
|
|
|
|
|
(Array.isArray(q.selector) && q.selector.includes('property'))) &&
|
|
|
|
|
Array.isArray(q.format)
|
|
|
|
|
) {
|
|
|
|
|
return {
|
|
|
|
|
...q,
|
|
|
|
|
format: [...q.format, 'StrictPascalCase'],
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return q
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
)
|