Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates #184

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,18 @@
},
"rewrap.wrappingColumn": 100,
"rust-analyzer.cargo.features": "all",
"typescript.tsdk": "frontend/node_modules/typescript/lib"
"typescript.tsdk": "frontend/node_modules/typescript/lib",
"eslint.options": {
"flags": ["unstable_ts_config"]
},
"eslint.workingDirectories": [
"frontend"
],
"eslint.useFlatConfig": true,
"eslint.validate": [
"javascript",
"typescript",
"svelte"
],
"svelte.enable-ts-plugin": true
}
18 changes: 0 additions & 18 deletions frontend/.eslintignore

This file was deleted.

53 changes: 0 additions & 53 deletions frontend/.eslintrc.yml

This file was deleted.

110 changes: 110 additions & 0 deletions frontend/eslint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import js from '@eslint/js';
import ts from 'typescript-eslint';
import {type TSESLint} from '@typescript-eslint/utils';
import svelte from 'eslint-plugin-svelte';
import svelteParser from 'svelte-eslint-parser';
import globals from 'globals';

/** Files that should be ignored globally by eslint. */
const IGNORES = [
// Temporary files, generated files, dependencies
'**/.DS_Store',
'**/node_modules',
'build',
'.svelte-kit',
'package',
'**/.env',
'**/.env.*',
'!**/.env.example',
'**/package-lock.json',

// Certain third party libs
'static/js/elements.flagmeister.min.js',
'static/js/maplibre-gl.js',
'static/js/*.component.js',
];

/** Files that should be ignored globally by typescript-eslint. */
const IGNORES_TS = ['**/*.js', '**/*.mjs', '**/*.cjs'];

/**
* Apply the {@link IGNORES_TS} ignore to the specified config array.
*/
function typescriptOnly(
configArray: TSESLint.FlatConfig.ConfigArray,
): TSESLint.FlatConfig.ConfigArray {
return configArray.map((config) => ({
...config,
ignores: IGNORES_TS,
}));
}

export default ts.config(
// Ignore certain files
{ignores: IGNORES},

// Apply JS base config
js.configs.recommended,

// Apply TS base config (but not to plain-JS files)
...typescriptOnly(ts.configs.recommendedTypeChecked),
//...ts.configs.strictTypeChecked, // TODO
//...ts.configs.stylisticTypeChecked, // TODO

// Apply Svelte config
...svelte.configs['flat/prettier'],

// Configure language options
{
languageOptions: {
ecmaVersion: 2023,
globals: {
...globals.browser,
...globals.node,
},
parserOptions: {
projectService: true,
extraFileExtensions: ['.svelte'],
},
},
},
{
files: ['**/*.svelte'],
languageOptions: {
parser: svelteParser,
ecmaVersion: 2023,
sourceType: 'script',
parserOptions: {
parser: '@typescript-eslint/parser',
},
},
},

// Configure general rules
{
rules: {
// Creates a lot of false positives, e.g. when throwing redirect()
'@typescript-eslint/only-throw-error': 'off',
// Disallows putting unknown caught errors in messages
'@typescript-eslint/restrict-template-expressions': 'off',
},
},

// Configure test rules
{
rules: {
'@typescript-eslint/no-unused-expressions': 'off',
},
files: ['**/*.test.ts'],
},

// Configure SvelteKit rules
{
rules: {
// Lots of false positives, see https://github.com/sveltejs/eslint-plugin-svelte/issues/413
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
},
files: ['**/+page.svelte'],
},
);
Loading
Loading