-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.ts
More file actions
93 lines (85 loc) · 3.04 KB
/
eslint.config.ts
File metadata and controls
93 lines (85 loc) · 3.04 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
import { globalIgnores } from 'eslint/config'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import pluginCypress from 'eslint-plugin-cypress'
import simpleImportSort from 'eslint-plugin-simple-import-sort'
import pluginVue from 'eslint-plugin-vue'
import pluginVitest from '@vitest/eslint-plugin'
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
// import { configureVueProject } from '@vue/eslint-config-typescript'
// configureVueProject({ scriptLangs: ['ts', 'tsx'] })
// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup
export default defineConfigWithVueTs(
{
name: 'app/files-to-lint',
files: ['**/*.{ts,mts,tsx,vue}'],
},
globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**', 'docs/.vitepress/**']),
pluginVue.configs['flat/essential'],
vueTsConfigs.recommended,
{
name: 'app/import-sort',
plugins: { 'simple-import-sort': simpleImportSort },
rules: {
'simple-import-sort/imports': ['error', {
groups: [
// 1) External packages (anything not starting with . or @/)
['^[^.@]', '^@(?!/)'],
// 2) Internal @/ alias imports
['^@/'],
// 3) Local ./ and ../ relative imports
['^\\.'],
],
}],
'simple-import-sort/exports': 'error',
},
},
{
name: 'app/sorted-tags-enum',
files: ['src/explorations/TAGS.ts'],
plugins: {
custom: {
rules: {
'sorted-enum-members': {
meta: { type: 'suggestion', messages: { unsorted: 'Enum members must be sorted alphabetically. "{{current}}" should come after "{{previous}}", not before.' } },
create(context: { report: (descriptor: Record<string, unknown>) => void }) {
return {
TSEnumDeclaration(node: { members: Array<{ id: { type: string; name?: string; value?: string } }> }) {
const names = node.members.map((m) =>
m.id.type === 'Identifier' ? m.id.name! : String(m.id.value),
)
for (let i = 1; i < names.length; i++) {
if (names[i].localeCompare(names[i - 1]) < 0) {
context.report({
node: node.members[i],
messageId: 'unsorted',
data: { current: names[i], previous: names[i - 1] },
})
}
}
},
}
},
},
},
},
},
rules: {
'custom/sorted-enum-members': 'error',
},
},
{
...pluginVitest.configs.recommended,
files: ['src/**/__tests__/*'],
},
{
...pluginCypress.configs.recommended,
files: [
'cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}',
'cypress/support/**/*.{js,ts,jsx,tsx}'
],
},
skipFormatting,
)