forked from gitbutlerapp/gitbutler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
161 lines (158 loc) · 4.21 KB
/
eslint.config.js
File metadata and controls
161 lines (158 loc) · 4.21 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import noRelativeImportPaths from '@gitbutler/no-relative-imports';
import js from '@eslint/js';
import prettier from 'eslint-config-prettier';
import { createNextImportResolver } from 'eslint-import-resolver-next';
import pluginImportX from 'eslint-plugin-import-x';
import svelte from 'eslint-plugin-svelte';
import globals from 'globals';
import ts from 'typescript-eslint';
export default ts.config(
js.configs.recommended,
...ts.configs.recommended,
...svelte.configs.recommended,
prettier,
...svelte.configs.prettier,
{
languageOptions: {
globals: {
...globals.browser,
...globals.node
},
parserOptions: {
projectService: {
// This prevents lint error when running eslint from
// subdirectories, ignoring the root tsconfig.json
allowDefaultProject: [
'svelte.config.js',
'packages/ui/.storybook/*.ts',
'packages/ui/playwright-ct.config.ts'
]
}
}
},
rules: {
'no-console': ['error', { allow: ['warn', 'error'] }],
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_'
}
],
'@typescript-eslint/return-await': ['error', 'always'],
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
eqeqeq: ['error', 'always'],
'import-x/no-cycle': 'error',
'import-x/order': [
'error',
{
alphabetize: {
order: 'asc',
orderImportKind: 'asc',
caseInsensitive: false
},
groups: [
'index',
'sibling',
'parent',
'internal',
'external',
'builtin',
'object',
'type'
],
// Add explicit pathGroups to define what imports go in which groups
pathGroups: [
// Define monorepo paths as internal
{ pattern: 'apps/**', group: 'internal' },
{ pattern: 'packages/**', group: 'internal' },
{ pattern: 'e2e/**', group: 'internal' },
// Add SvelteKit paths
{ pattern: '$lib/**', group: 'internal' },
{ pattern: '$components/**', group: 'internal' },
{ pattern: '$app/**', group: 'internal' }
],
// Ensure certain import types are only categorized by their type
pathGroupsExcludedImportTypes: ['builtin', 'external', 'object', 'type']
}
],
'func-style': [2, 'declaration'],
'no-return-await': 'off',
'svelte/no-at-html-tags': 'off',
'svelte/button-has-type': [
'error',
{
button: true,
submit: true,
reset: true
}
],
'no-relative-import-paths/no-relative-import-paths': 'error',
'no-undef': 'off', // eslint faq advises `no-undef` turned off for typescript projects.
'svelte/require-each-key': 'off',
'svelte/no-inspect': 'error',
'svelte/no-at-debug-tags': 'error',
'svelte/no-unused-props': 'error',
'svelte/prefer-svelte-reactivity': 'off'
},
settings: {
'import-x/extensions': ['.ts', '.js', '.mjs'],
'import-x/parsers': {
'@typescript-eslint/parser': ['.ts', '.js', '.mjs']
},
'import-x/resolver-next': [createNextImportResolver()]
},
plugins: {
'import-x': pluginImportX,
'no-relative-import-paths': noRelativeImportPaths
}
},
{
files: ['**/*.svelte', '**/*.svelte.ts'],
...ts.configs.disableTypeChecked
},
{
files: ['**/*.svelte', '**/*.svelte.ts'],
languageOptions: {
parserOptions: {
parser: ts.parser
}
}
},
{
ignores: [
'**/.*', // dotfiles aren't ignored by default in FlatConfig
'.*', // dotfiles aren't ignored by default in FlatConfig
'**/.DS_Store',
'**/node_modules',
'**/butler/target',
'**/build',
'**/static',
'**/dist',
'**/.svelte-kit',
'**/package',
'**/.env',
'**/.env.*',
'!**/.env.example',
'**/pnpm-lock.yaml',
'**/package-lock.json',
'**/yarn.lock',
'.github',
'.vscode',
'**/.pnpm-store',
'**/vite.config.ts.timestamp-*',
'!**/.storybook',
'target/',
'crates/',
'packages/ui/storybook-static',
// Storybook Meta type wrapper
'packages/ui/src/stories/**/*.stories.ts'
]
}
);