mirror of
https://github.com/immich-app/static-pages.git
synced 2026-09-30 21:27:54 +08:00
136 lines
4.4 KiB
TypeScript
136 lines
4.4 KiB
TypeScript
import js from '@eslint/js';
|
|
import prettier from 'eslint-config-prettier';
|
|
import svelte from 'eslint-plugin-svelte';
|
|
import { defineConfig } from 'eslint/config';
|
|
import globals from 'globals';
|
|
import tseslint from 'typescript-eslint';
|
|
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
|
|
import eslintPluginBetterTailwindcss from 'eslint-plugin-better-tailwindcss';
|
|
import { readdirSync } from 'node:fs';
|
|
import { RulesConfig } from 'eslint';
|
|
|
|
export default defineConfig([
|
|
js.configs.recommended,
|
|
// TODO switch to recommendedTypeChecked
|
|
...tseslint.configs.recommended,
|
|
...svelte.configs['flat/recommended'],
|
|
prettier,
|
|
...svelte.configs['flat/prettier'],
|
|
eslintPluginUnicorn.configs.recommended,
|
|
{
|
|
languageOptions: {
|
|
// apps/survey.immich.app has its own flat config, and ESLint loads it in
|
|
// the same process as this one. typescript-eslint records a candidate
|
|
// tsconfigRootDir per config file it is loaded from and refuses to guess
|
|
// once there is more than one, so both configs pin theirs explicitly.
|
|
parserOptions: {
|
|
tsconfigRootDir: import.meta.dirname,
|
|
},
|
|
globals: {
|
|
...globals.browser,
|
|
...globals.node,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
languageOptions: {
|
|
parserOptions: {
|
|
parser: tseslint.parser,
|
|
extraFileExtensions: ['.svelte'],
|
|
project: true,
|
|
tsconfigRootDir: import.meta.dirname,
|
|
},
|
|
},
|
|
files: ['**/src/**/*.ts', '**/src/**/*.svelte'],
|
|
ignores: ['**/*spec.ts'],
|
|
rules: {
|
|
'svelte/no-navigation-without-resolve': 'off',
|
|
'@typescript-eslint/require-array-sort-compare': 'error',
|
|
},
|
|
},
|
|
...readdirSync('apps').map((name) => ({
|
|
files: ['apps/**/*.svelte'],
|
|
extends: [eslintPluginBetterTailwindcss.configs.recommended],
|
|
settings: {
|
|
'better-tailwindcss': {
|
|
entryPoint: 'src/lib/app.css',
|
|
cwd: `apps/${name}`,
|
|
},
|
|
},
|
|
rules: {
|
|
'better-tailwindcss/enforce-consistent-line-wrapping': 'off',
|
|
'better-tailwindcss/no-unknown-classes': 'off',
|
|
} as Partial<RulesConfig>,
|
|
})),
|
|
{
|
|
rules: {
|
|
curly: 2,
|
|
'no-shadow': 'off',
|
|
'unicorn/require-module-specifiers': 'off',
|
|
'unicorn/consistent-function-scoping': 'off',
|
|
'unicorn/prevent-abbreviations': 'off',
|
|
'unicorn/filename-case': 'off',
|
|
'unicorn/no-null': 'off',
|
|
'unicorn/prefer-top-level-await': 'off',
|
|
'unicorn/prefer-event-target': 'off',
|
|
'unicorn/no-thenable': 'off',
|
|
'unicorn/no-nested-ternary': 'off',
|
|
'unicorn/import-style': 'off',
|
|
'unicorn/prefer-structured-clone': 'off',
|
|
'unicorn/no-for-loop': 'off',
|
|
'unicorn/no-process-exit': 'off',
|
|
'unicorn/no-array-reverse': 'off', // toReversed() is not supported in Chrome 109 or Safari 15.4
|
|
'unicorn/no-useless-undefined': 'off',
|
|
'unicorn/prefer-spread': 'off',
|
|
'unicorn/name-replacements': 'off',
|
|
'unicorn/consistent-boolean-name': 'off',
|
|
'unicorn/consistent-class-member-order': 'off',
|
|
'unicorn/no-unreadable-for-of-expression': 'off',
|
|
'unicorn/no-top-level-assignment-in-function': 'off',
|
|
'unicorn/no-break-in-nested-loop': 'off',
|
|
'unicorn/prefer-simple-condition-first': 'off',
|
|
// prefer the typescript-eslint type-aware version
|
|
'unicorn/require-array-sort-compare': 'off',
|
|
'unicorn/class-reference-in-static-methods': ['error', { preferThis: false, preferSuper: false }],
|
|
'unicorn/prefer-minimal-ternary': 'off',
|
|
'unicorn/no-declarations-before-early-exit': 'off',
|
|
'prettier/prettier': 0,
|
|
'object-shorthand': ['error', 'always'],
|
|
'no-restricted-imports': [
|
|
'error',
|
|
{
|
|
patterns: [
|
|
{
|
|
regex: String.raw`^(src|test)(/.*)?(?<!\.js)$`,
|
|
message: 'Project-internal imports need an explicit .js extension.',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
'@typescript-eslint/no-unused-vars': [
|
|
'error',
|
|
{
|
|
argsIgnorePattern: '^_',
|
|
varsIgnorePattern: '^_',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
{
|
|
ignores: [
|
|
'apps/**/.svelte-kit',
|
|
'apps/**/build',
|
|
'apps/**/backend/dist',
|
|
'apps/**/.wrangler',
|
|
'apps/**/backend/worker-configuration.d.ts',
|
|
'packages/**/build/',
|
|
'packages/**/.svelte-kit/',
|
|
'packages/**/dist/',
|
|
'**/svelte.config.js',
|
|
'**/postcss.config.js',
|
|
'common/',
|
|
'deployment/',
|
|
],
|
|
},
|
|
]);
|