-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.js
163 lines (159 loc) · 4.78 KB
/
vue.js
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
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 2022,
},
reportUnusedDisableDirectives: true,
overrides: [
{
files: ['*.js'],
// For now, require .js files (like .eslintrc.js) only to be formatted using Prettier.
plugins: ['prettier'],
extends: ['plugin:prettier/recommended'],
rules: {
'prettier/prettier': 'warn',
},
},
{
files: ['*.ts', '*.vue'],
parserOptions: {
project: './tsconfig.json',
},
extends: [
'eslint:recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:prettier/recommended',
],
rules: {
'prettier/prettier': 'warn',
'@typescript-eslint/consistent-type-assertions': [
'error',
{
assertionStyle: 'as',
},
],
'@typescript-eslint/consistent-type-definitions': [
'error',
'interface',
],
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
accessibility: 'no-public',
},
],
'@typescript-eslint/member-ordering': [
'warn',
{
classes: ['field', 'constructor', 'method'],
},
],
'@typescript-eslint/naming-convention': [
'error',
{
selector: ['class', 'interface', 'typeAlias'],
format: ['PascalCase'],
},
],
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/strict-boolean-expressions': 'error',
'@typescript-eslint/switch-exhaustiveness-check': 'warn',
'accessor-pairs': 'error',
'array-callback-return': 'error',
curly: 'error',
'default-case-last': 'error',
'default-param-last': 'error',
'dot-notation': 'warn',
eqeqeq: ['error', 'always', { null: 'never' }],
'guard-for-in': 'error',
'no-constructor-return': 'error',
'no-else-return': 'error',
'no-extra-bind': 'error',
'no-lone-blocks': 'error',
'no-new-wrappers': 'error',
'no-nested-ternary': 'error',
'no-restricted-globals': [
'error',
{ name: 'parseInt', message: `Use 'Number.parseInt()' instead.` },
{ name: 'parseFloat', message: `Use 'Number.parseFloat()' instead.` },
],
'no-self-compare': 'error',
'no-throw-literal': 'error',
'no-useless-rename': 'error',
'no-useless-return': 'error',
'import/first': 'warn',
'import/newline-after-import': 'warn',
'import/no-cycle': 'error',
'import/no-unresolved': ['error'],
'import/order': [
'warn',
{
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
warnOnUnassignedImports: true,
},
],
'no-unreachable-loop': 'error',
radix: 'error',
'require-atomic-updates': 'error',
'sort-imports': [
'warn',
{
ignoreDeclarationSort: true,
},
],
'spaced-comment': ['warn', 'always'],
'valid-typeof': [
'error',
{
requireStringLiterals: true,
},
],
},
},
{
// This part of the config specifically targets Vue files only. It gets merged with the previous one.
files: ['*.vue'],
parser: 'vue-eslint-parser',
env: {
'vue/setup-compiler-macros': true,
},
extends: [
'plugin:vue/vue3-recommended',
'@vue/typescript/recommended',
'plugin:prettier/recommended',
],
rules: {
'prettier/prettier': 'warn',
// In Vue components and UI development in general, it is relatively common to first read/write an object (e.g. current State), then to make an HTTP request and then to assign some properties of this object based on the response.
'require-atomic-updates': [
'error',
{
allowProperties: true,
},
],
'vue/html-button-has-type': 'error',
'vue/html-self-closing': [
'warn',
{
html: {
void: 'always',
normal: 'never',
component: 'always',
},
},
],
},
},
],
};