-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.mjs
112 lines (109 loc) · 3.14 KB
/
eslint.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// @ts-check
import path from 'path';
import { fileURLToPath } from 'url';
import { FlatCompat } from '@eslint/eslintrc';
import eslint from '@eslint/js';
import eslintPluginSvelte from 'eslint-plugin-svelte';
import globals from 'globals';
import svelteEslintParser from 'svelte-eslint-parser';
import tseslint from 'typescript-eslint';
const dirname = path.dirname(fileURLToPath(import.meta.url));
const compat = new FlatCompat({
resolvePluginsRelativeTo: dirname,
baseDirectory: dirname,
recommendedConfig: eslint.configs.recommended,
allConfig: eslint.configs.all
});
export default tseslint.config(
eslint.configs.recommended,
...compat.plugins('import'),
...compat.extends('prettier'),
...eslintPluginSvelte.configs['flat/recommended'].map(({ rules, ...rest }) => ({
// Workaround since svelte-eslint's typings are mismatched with ts-eslint's
rules: {
...rules
},
...rest
})),
{
files: ['**/*.ts'],
plugins: {
'@typescript-eslint': tseslint.plugin
},
languageOptions: {
parser: tseslint.parser,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
extraFileExtensions: ['.svelte']
},
globals: {
...globals.browser
}
},
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^(_|\\$\\$Props)',
varsIgnorePattern: '^(_|\\$\\$Props)',
caughtErrorsIgnorePattern: '^_'
}
],
'@typescript-eslint/consistent-type-imports': 'error',
'arrow-body-style': ['error', 'as-needed'],
'import/extensions': ['error', 'ignorePackages', { '': 'never', tsx: 'never', ts: 'never' }],
'import/export': 2,
'import/no-unresolved': 'off',
'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal', ['parent', 'sibling'], 'index', 'object'],
pathGroups: [{ pattern: '\\$*/**', group: 'internal' }],
pathGroupsExcludedImportTypes: ['builtin'],
'newlines-between': 'always',
alphabetize: { order: 'asc' }
}
],
'import/no-duplicates': ['error', { considerQueryString: true }],
'no-empty-function': ['error', { allow: ['arrowFunctions'] }],
'no-unused-vars': 'off',
'sort-imports': ['error', { ignoreDeclarationSort: true }]
}
},
{
files: ['**/*.svelte'],
languageOptions: {
parser: svelteEslintParser,
parserOptions: {
parser: '@typescript-eslint/parser',
svelteFeatures: {
// Whether to parse the `generics` attribute.
// See https://github.com/sveltejs/rfcs/pull/38
experimentalGenerics: true
}
}
},
rules: {
// FIXME: Temporary fix to be able to use $t
// https://github.com/sveltejs/eslint-plugin-svelte/issues/652
'svelte/valid-compile': 'off'
}
},
{
ignores: [
'!.env.example',
'.DS_Store',
'.env.*',
'.git',
'.svelte-kit',
'.vercel',
'./src/app.html',
'build',
'node_modules',
'package',
'postcss.config.js',
'tsconfig.tsbuildinfo'
]
}
);