82 lines
2.4 KiB
JavaScript
82 lines
2.4 KiB
JavaScript
import js from '@eslint/js';
|
|
import svelte from 'eslint-plugin-svelte';
|
|
import globals from 'globals';
|
|
import ts from 'typescript-eslint';
|
|
|
|
/**
|
|
* Lint only. Formatting is deliberately not enforced here — there is no Prettier in
|
|
* this project, so any stylistic rule would fight the existing hand-kept style.
|
|
*
|
|
* Type-aware linting is on (`projectService`), which is what makes
|
|
* `no-floating-promises` able to see that an `async` handler's promise is dropped.
|
|
*/
|
|
export default ts.config(
|
|
js.configs.recommended,
|
|
...ts.configs.recommendedTypeChecked,
|
|
...svelte.configs.recommended,
|
|
{
|
|
languageOptions: {
|
|
globals: { ...globals.browser },
|
|
parserOptions: {
|
|
projectService: true,
|
|
extraFileExtensions: ['.svelte'],
|
|
tsconfigRootDir: import.meta.dirname
|
|
}
|
|
}
|
|
},
|
|
{
|
|
files: ['**/*.svelte', '**/*.svelte.ts'],
|
|
languageOptions: {
|
|
parserOptions: {
|
|
parser: ts.parser
|
|
}
|
|
}
|
|
},
|
|
{
|
|
rules: {
|
|
// The app ships no logging of its own; `hooks.client.ts` is the one exception
|
|
// and opts in explicitly below.
|
|
'no-console': 'error',
|
|
/*
|
|
* Off: this rule wants every href and goto() wrapped in `resolve()`, which
|
|
* matters only for an app served under a base path. This one is served from
|
|
* the root (see nginx.conf) and sets no `base`, so it would be 14 wrappers
|
|
* buying nothing. Revisit if the app ever moves under a sub-path.
|
|
*/
|
|
'svelte/no-navigation-without-resolve': 'off',
|
|
/*
|
|
* The regex placeholders on the event pickers need a literal `{` in an
|
|
* attribute, which in Svelte can only be written as a mustache.
|
|
*/
|
|
'svelte/no-useless-mustaches': ['error', { ignoreStringEscape: true }],
|
|
// This is the rule that catches an `async` function used directly as an
|
|
// event handler, where a rejection becomes an unhandled rejection.
|
|
'@typescript-eslint/no-floating-promises': 'error',
|
|
'@typescript-eslint/no-unused-vars': [
|
|
'error',
|
|
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' }
|
|
]
|
|
}
|
|
},
|
|
{
|
|
files: ['src/hooks.client.ts'],
|
|
rules: { 'no-console': 'off' }
|
|
},
|
|
{
|
|
// This file and the Vite config are build tooling, outside the app's tsconfig
|
|
// project, so type-aware rules cannot resolve them.
|
|
files: ['eslint.config.js', 'vite.config.ts'],
|
|
...ts.configs.disableTypeChecked
|
|
},
|
|
{
|
|
// Generated from openapi.json by `npm run api:types`; not ours to lint.
|
|
ignores: [
|
|
'src/lib/api/schema.d.ts',
|
|
'build/',
|
|
'.svelte-kit/',
|
|
'node_modules/',
|
|
'static/config.js'
|
|
]
|
|
}
|
|
);
|