-
Notifications
You must be signed in to change notification settings - Fork 532
Expand file tree
/
Copy patheslint.config.mjs
More file actions
73 lines (62 loc) · 1.98 KB
/
eslint.config.mjs
File metadata and controls
73 lines (62 loc) · 1.98 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
import { default as eslint, default as js } from '@eslint/js'
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
import vueTsEslintConfig from '@vue/eslint-config-typescript'
import pluginVue from 'eslint-plugin-vue'
import fs from 'node:fs'
import path from 'node:path'
import { pathToFileURL } from 'node:url'
import tseslint from 'typescript-eslint'
async function loadOptionalPackageConfigs() {
const packagesDir = path.resolve('packages')
if (!fs.existsSync(packagesDir)) {
return []
}
const loadedConfigs = []
for (const entry of fs.readdirSync(packagesDir, { withFileTypes: true })) {
if (!entry.isDirectory()) {
continue
}
const configPath = path.join(packagesDir, entry.name, 'eslint.config.mjs')
if (!fs.existsSync(configPath)) {
continue
}
const imported = await import(pathToFileURL(configPath).href)
const config = imported.default ?? imported
if (Array.isArray(config)) {
loadedConfigs.push(...config)
} else if (config) {
loadedConfigs.push(config)
}
}
return loadedConfigs
}
const optionalPackageConfigs = await loadOptionalPackageConfigs()
export default [
{
name: 'app/files-to-lint',
files: ['**/*.{ts,mts,tsx,vue,js,jsx,cjs,mjs,cts}']
},
{
name: 'app/files-to-ignore',
ignores: [
'**/*.config.{js,cjs}',
'**/vite.config.*',
'**/dist/**',
'**/dist-dev/**',
'**/dist-ssr/**',
'**/coverage/**',
'packages/cmk-frontend-vue/ui-component-library/public/mockServiceWorker.js',
'.stylelintrc.js',
'packages/cmk-frontend-vue/scripts/stylelint-vue-bem-naming-convention.js',
// TODO(CMK-32715): Remove once cmk-frontend eslint issues are fixed by the responsible team
'packages/cmk-frontend/**'
]
},
js.configs.recommended,
...pluginVue.configs['flat/recommended'],
eslint.configs.recommended,
...tseslint.configs.recommended,
...vueTsEslintConfig(),
skipFormatting,
...optionalPackageConfigs
]