-
-
Notifications
You must be signed in to change notification settings - Fork 123
/
eslint.config.mjs
173 lines (165 loc) · 5.33 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
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
162
163
164
165
166
167
168
169
170
171
172
173
// @ts-check
import path from 'node:path'
import url from 'node:url'
import { fixupPluginRules } from '@eslint/compat'
// eslint-disable-next-line import-x/namespace
import { FlatCompat } from '@eslint/eslintrc'
import eslintJs from '@eslint/js'
import pluginTS from '@typescript-eslint/eslint-plugin'
import eslintConfigPrettier from 'eslint-config-prettier'
import pluginFunctional from 'eslint-plugin-functional/flat'
import pluginImportX from 'eslint-plugin-import-x'
import pluginReact from 'eslint-plugin-react'
import pluginReactHooks from 'eslint-plugin-react-hooks'
import pluginReactRefresh from 'eslint-plugin-react-refresh'
import pluginVue from 'eslint-plugin-vue'
import globals from 'globals'
import eslintTs from 'typescript-eslint'
import vueParser from 'vue-eslint-parser'
const __dirname = path.dirname(url.fileURLToPath(import.meta.url))
const tsProjects = ['./tsconfig.base.json', './ui/*/tsconfig.json', './docs/*/tsconfig.json']
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: eslintJs.configs.recommended,
})
export default eslintTs.config(
eslintJs.configs.recommended,
...eslintTs.configs.recommended,
// @ts-expect-error the type of `pluginVue` is not compatible with the latest `eslint` v9 package yet
...pluginVue.configs['flat/recommended'],
// FIXME: TypeError SEE https://github.com/amilajack/eslint-plugin-compat/pull/609#issuecomment-2123734301
// ...compat.extends('plugin:compat/recommended'),
// {
// ...pluginFunctional.configs.recommended,
// // FIXME: https://github.com/eslint-functional/eslint-plugin-functional/issues/766#issuecomment-1904715609
// rules: {
// ...pluginFunctional.configs.recommended.rules,
// 'functional/immutable-data': 'off',
// 'functional/no-return-void': 'off',
// },
// },
/* Global Ignores */
{
// `ignores` key must been defined in a separate object without any other keys
// see https://eslint.org/docs/latest/use/configure/ignore#ignoring-files
// and https://github.com/eslint/eslint/discussions/18304
ignores: [
'**/node_modules',
'**/dist',
'public',
'local',
'test',
'**/.vitepress/cache',
'**/*.config.js',
'**/*.config.ts',
'**/*.d.ts',
],
},
/* TypeScript */
{
files: ['**/*.{ts,mts,cts,tsx,js,mjs,cjs,vue}'],
languageOptions: {
parser: vueParser,
parserOptions: {
parser: eslintTs.parser,
project: tsProjects,
tsconfigRootDir: __dirname,
globals: {
...globals.browser,
},
ecmaFeatures: {
jsx: true,
},
sourceType: 'module',
extraFileExtensions: ['.vue'],
},
},
plugins: {
'@typescript-eslint': pluginTS,
'import-x': pluginImportX,
},
rules: {
...pluginImportX.configs.recommended.rules,
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-unsafe-declaration-merging': 'off',
'vue/multi-word-component-names': 'off',
'import-x/no-named-as-default-member': 'off',
'import-x/no-named-as-default': 'off',
'import-x/default': 'off', // fix https://github.com/import-js/eslint-plugin-import/issues/1800
'import-x/order': 'warn',
// 'import-x/no-default-export': 'warn'
},
settings: {
'import-x/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import-x/resolver': {
typescript: {
project: tsProjects,
},
node: true,
},
},
},
/* Vue */
{
files: ['**/*.vue'],
languageOptions: {
globals: {
// Auto Imports Support
// SEE https://eslint.vuejs.org/user-guide/#auto-imports-support
// SEE https://github.com/antfu/eslint-config/blob/e32301ac398896f20e1ec1f4f10a334687f8afc8/src/configs/vue.ts#L40-L55
computed: 'readonly',
defineEmits: 'readonly',
defineExpose: 'readonly',
defineProps: 'readonly',
onMounted: 'readonly',
onUnmounted: 'readonly',
reactive: 'readonly',
ref: 'readonly',
shallowReactive: 'readonly',
shallowRef: 'readonly',
toRef: 'readonly',
toRefs: 'readonly',
watch: 'readonly',
watchEffect: 'readonly',
onUpdated: 'readonly',
onBeforeMount: 'readonly',
onBeforeUnmount: 'readonly',
onBeforeUpdate: 'readonly',
useRoute: 'readonly',
useRouter: 'readonly',
useStore: 'readonly',
useI18n: 'readonly',
nextTick: 'readonly',
},
},
},
/* React */
{
files: ['docs/landing/**/*.tsx'],
plugins: {
react: pluginReact,
// @ts-expect-error SEE https://github.com/facebook/react/issues/28313
'react-hooks': fixupPluginRules(pluginReactHooks),
'react-refresh': pluginReactRefresh,
},
rules: {
...pluginReact.configs.recommended.rules,
...pluginReact.configs['jsx-runtime'].rules,
...pluginReactHooks.configs.recommended.rules,
'react-refresh/only-export-components': 'warn',
'react/prop-types': 'off',
},
languageOptions: {
...pluginReact.configs.recommended.languageOptions,
},
settings: {
react: {
version: '18.3',
},
},
},
eslintConfigPrettier, // disable conflicting rules with Prettier
)