forked from intlify/vue-i18n
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
97 lines (91 loc) · 2.63 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
import globals from 'globals'
import js from '@eslint/js'
import { FlatCompat } from '@eslint/eslintrc'
import ts from 'typescript-eslint'
import eslintConfigPrettier from 'eslint-config-prettier'
const vue = extendVuePlugin('plugin:vue/vue3-recommended', ts.parser)
/** @type { import("eslint").Linter.FlatConfig[] } */
export default [
// ignore globally
{
ignores: [
'**/dist/**',
'**/fixtures/**',
'**/coverage/**',
'**/.vitepress/**',
'**/.vuepress/**',
'**/test/**',
'**/examples/**',
'shim.d.ts',
'.eslintcache',
'.eslintrc.cjs'
]
},
js.configs.recommended,
...ts.configs.recommended,
eslintConfigPrettier,
...vue,
// globals
{
// files: ['**/*.js', '**/*.ts', '**/*.vue', '**/*.json'],
languageOptions: {
globals: {
__DEV__: true,
__COMMIT__: true,
page: true,
browser: true,
context: true,
...globals.node
},
parserOptions: { sourceType: 'module' }
}
},
// custom rules
{
rules: {
'object-curly-spacing': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/member-delimiter-style': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'vue/one-component-per-file': 'off',
'vue/multi-word-component-names': 'off',
'vue/experimental-script-setup-vars': 'off',
'vue/no-deprecated-props-default-this': 'off'
}
}
]
/**
* extend eslint-plugin-vue with @typescript-eslint/parser
* (NOTE: eslint-plugin-vue flat config WIP currently https://github.com/vuejs/eslint-plugin-vue/issues/1291)
*
* @param { 'plugin:vue/vue3-essential' | 'plugin:vue/vue3-strongly-recommended' | 'plugin:vue/vue3-recommended' } vueConfigPattern
* @param { import("typescript-eslint").Config.parser } tsParser
*
* @return { import("eslint").Linter.FlatConfig[] }
*/
function extendVuePlugin(vueConfigPattern, tsParser) {
const compat = new FlatCompat()
const vuePlugin = compat.extends(vueConfigPattern)
const vueLangOptions = vuePlugin[2]
vueLangOptions.files = [
'**/*.vue',
'**/*.ts',
'**/*.tsx',
'**/*.mts',
'**/*.cts'
]
vueLangOptions.languageOptions = {
// NOTE:
// https://eslint.vuejs.org/user-guide/#how-to-use-a-custom-parser
parserOptions: {
parser: tsParser
},
ecmaVersion: 'latest'
}
return vuePlugin
}