-
Notifications
You must be signed in to change notification settings - Fork 8
/
eslint.config.mjs
105 lines (97 loc) 路 2.27 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
// @ts-check
import tseslint from 'typescript-eslint'
import eslintConfig3YD from '@3yourmind/eslint-config'
import { fileURLToPath } from 'url'
import path from 'node:path'
/**
* Find the project root in a way that is compatible with most javascript engines (e.g. node, vscode's node, bun)
*/
const root = (() => {
const cause = []
try {
const result = __dirname
if (result) return result
} catch (error) {
cause.push(error)
}
try {
const result = import.meta.dirname
if (result) return result
} catch (error) {
cause.push(error)
}
try {
const result = path.dirname(fileURLToPath(import.meta.url))
if (result) return result
} catch (error) {
cause.push(error)
}
throw new Error('could not determine project root', { cause })
})()
const config = tseslint.config(
/**
* DO NOT ADD ANY OTHER KEYS TO THIS FIRST OBJECT
*
* @see {@link https://eslint.org/docs/latest/use/configure/ignore#ignoring-files}
*/
{
ignores: [
'**/dist/**',
'**/.nuxt/**',
'**/.turbo/**',
'**/*.js',
'**/vite.config.ts.timestamp-*', // used by vite to interpret vite.config.ts
],
},
...eslintConfig3YD.configs.global,
{
languageOptions: {
ecmaVersion: 2022,
parserOptions: {
project: [
'./tsconfig.json',
'./internals/*/tsconfig.json',
'./packages/*/tsconfig.json',
'./packages/kotti-ui/tsconfig.node.json',
],
tsconfigRootDir: root,
},
sourceType: 'module',
},
},
...eslintConfig3YD.configs.default.map((config) => ({
...config,
files: ['packages/**/*.ts', 'packages/**/*.tsx'],
})),
...eslintConfig3YD.configs.untyped,
...eslintConfig3YD.configs.json,
...eslintConfig3YD.configs.tests.map((config) => ({
...config,
files: [...config.files, 'packages/kotti-ui/source/test-utils/**/*.ts'],
})),
{
extends: eslintConfig3YD.configs.vue,
rules: {
'vue/no-deprecated-dollar-listeners-api': 'error',
},
},
{
rules: {
'@typescript-eslint/no-restricted-imports': [
'error',
{
message:
"Avoid direct imports from lodash; e.g. import foo from 'lodash/foo' instead of import { foo } from 'lodash'",
name: 'lodash',
},
],
},
},
{
files: ['packages/kotti-ui/source/*/index.ts'],
rules: {
'@typescript-eslint/naming-convention': 'off',
},
},
)
export default config