-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy patheslint.config.ts
161 lines (158 loc) · 4.98 KB
/
eslint.config.ts
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
import configPrettier from '@vue/eslint-config-prettier';
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript';
import pluginVitest from '@vitest/eslint-plugin';
import { globalIgnores } from 'eslint/config';
// @ts-ignore
import pluginImport from 'eslint-plugin-import';
import pluginPlaywright from 'eslint-plugin-playwright';
import pluginVue from 'eslint-plugin-vue';
import pluginVueA11y from 'eslint-plugin-vuejs-accessibility';
// @ts-ignore
import pluginVuetify from 'eslint-plugin-vuetify';
// 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
/**
* ESLint Config
*/
export default defineConfigWithVueTs(
{
name: 'app/files-to-lint',
files: ['**/*.{ts,mts,tsx,vue}']
},
globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),
pluginVue.configs['flat/recommended'],
...pluginVueA11y.configs['flat/recommended'],
vueTsConfigs.recommended,
pluginImport.flatConfigs.recommended,
pluginImport.flatConfigs.typescript,
{
name: 'Vuetify',
files: ['*.vue', '**/*.vue'],
plugins: {
vuetify: pluginVuetify
},
rules: {
...pluginVuetify.configs.base.rules
}
},
{
settings: {
// This will do the trick
'import/parsers': {
espree: ['.js', '.cjs', '.mjs', '.jsx'],
'@typescript-eslint/parser': ['.ts', '.tsx'],
'vue-eslint-parser': ['.vue']
},
'import/resolver': {
// You will also need to install and configure the TypeScript resolver
// See also https://github.com/import-js/eslint-import-resolver-typescript#configuration
typescript: true,
node: true,
'eslint-import-resolver-custom-alias': {
alias: {
'@': './src',
'~': './node_modules'
},
extensions: ['.js', '.ts', '.jsx', '.tsx', '.vue']
}
}
},
rules: {
'no-unused-vars': 'off',
// const lines: string[] = []; style
'@typescript-eslint/array-type': [
'error',
{
default: 'array'
}
],
// Enable @ts-ignore etc.
'@typescript-eslint/ban-ts-comment': 'off',
// Left-hand side style
'@typescript-eslint/consistent-generic-constructors': ['error', 'type-annotation'],
// Enable import sort order, see bellow.
'@typescript-eslint/consistent-type-imports': [
'off',
{
prefer: 'type-imports'
}
],
// Fix for pinia
'@typescript-eslint/explicit-function-return-type': 'off',
// Exclude variables with leading underscores
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true
}
],
// Fix for vite import.meta.env
'@typescript-eslint/strict-boolean-expressions': 'off',
// Fix for vite env.d.ts.
'@typescript-eslint/triple-slash-reference': 'off',
// Fix for Vue setup style
'import/default': 'off',
// Fix for vite
'import/namespace': 'off',
'import/no-default-export': 'off',
'import/no-named-as-default-member': 'off',
'import/no-named-as-default': 'off',
// Sort Import Order.
// see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md#importorder-enforce-a-convention-in-module-import-order
'import/order': [
'error',
{
groups: ['builtin', 'external', 'parent', 'sibling', 'index', 'object', 'type'],
pathGroups: [
// Vue Core
{
pattern:
'{vue,vue-router,vuex,@/store,vue-i18n,pinia,vite,vitest,vitest/**,@vitejs/**,@vue/**}',
group: 'external',
position: 'before'
},
// Internal Codes
{
pattern: '{@/**}',
group: 'internal',
position: 'before'
}
],
pathGroupsExcludedImportTypes: ['builtin'],
alphabetize: {
order: 'asc'
},
'newlines-between': 'always'
}
],
// A tag with no content should be written like <br />.
'vue/html-self-closing': [
'error',
{
html: {
void: 'always'
}
}
],
// Mitigate non-multiword component name errors to warnings.
'vue/multi-word-component-names': 'warn'
}
},
{
...pluginVitest.configs.recommended,
files: ['src/**/__tests__/*']
},
{
...pluginPlaywright.configs['flat/recommended'],
files: ['e2e/**/*.{test,spec}.{js,ts,jsx,tsx}']
},
configPrettier
);