Skip to content

Commit

Permalink
migrat to new eslint flat config files
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldietzler committed Aug 5, 2024
1 parent dca759d commit d51b730
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 79 deletions.
16 changes: 0 additions & 16 deletions web/.eslintignore

This file was deleted.

61 changes: 0 additions & 61 deletions web/.eslintrc.cjs

This file was deleted.

104 changes: 104 additions & 0 deletions web/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import globals from 'globals';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import parser from 'svelte-eslint-parser';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: [
'**/.DS_Store',
'**/node_modules',
'build',
'.svelte-kit',
'package',
'**/.env',
'**/.env.*',
'!**/.env.example',
'**/pnpm-lock.yaml',
'**/package-lock.json',
'**/yarn.lock',
'src/lib/sdk',
'src/lib/elements/ui',
'eslint.config.mjs',
],
},
...compat.extends(
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
'plugin:unicorn/recommended',
),
{
plugins: {
'@typescript-eslint': typescriptEslint,
},

languageOptions: {
globals: {
...globals.browser,
...globals.node,
NodeJS: true,
},

parser: tsParser,
ecmaVersion: 2022,
sourceType: 'module',

parserOptions: {
extraFileExtensions: ['.svelte'],
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
},

rules: {
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_$',
varsIgnorePattern: '^_$',
},
],

curly: 2,
'unicorn/no-useless-undefined': 'off',
'unicorn/prefer-spread': 'off',
'unicorn/no-null': 'off',
'unicorn/prevent-abbreviations': 'off',
'unicorn/no-nested-ternary': 'off',
'unicorn/consistent-function-scoping': 'off',
'unicorn/prefer-top-level-await': 'off',
'unicorn/import-style': 'off',
'svelte/button-has-type': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/require-await': 'error',
},
},
{
files: ['**/*.svelte'],

languageOptions: {
parser: parser,
ecmaVersion: 5,
sourceType: 'script',

parserOptions: {
parser: '@typescript-eslint/parser',
},
},
},
];
6 changes: 4 additions & 2 deletions web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"sourceMap": true,
"strict": true,
"target": "ES2020",
"types": ["vitest/globals"]
"types": [
"vitest/globals"
]
},
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
// except $lib which is handled by https://kit.svelte.dev/docs/configuration#files
Expand All @@ -35,4 +37,4 @@
"*.ts",
"*.js"
]
}
}

0 comments on commit d51b730

Please sign in to comment.