1
1
<template >
2
2
<div class =" rules-settings" >
3
3
<div class =" tools" >
4
- <div class =" tools-title" @click =" state.toolsClose = !state.toolsClose" >
5
- Tools
6
- <button
7
- class =" tools-button"
8
- :class =" { 'tools-button--close': state.toolsClose }"
9
- >
10
- <svg
11
- xmlns =" http://www.w3.org/2000/svg"
12
- height =" 10"
13
- viewBox =" 0 0 10 10"
14
- width =" 10"
15
- >
16
- <path d =" M2.5 10l5-5-5-5v10z" fill =" #ddd" />
17
- </svg >
18
- </button >
19
- </div >
20
- <template v-if =" ! state .toolsClose " >
21
- <div class =" tool" >
22
- <button class =" tool-button" @click =" onAllOffClick" >
23
- Turn OFF All Rules
24
- </button >
25
- </div >
26
- <div class =" tool" >
27
- <label >
28
- <span class =" tool-label" >Filter:</span >
29
- <input
30
- v-model =" filterValue"
31
- type =" search"
32
- placeholder =" Rule Filter"
33
- class =" tool-form"
34
- />
35
- </label >
36
- </div >
37
- </template >
4
+ <label class =" tool" >
5
+ <span class =" tool-label" >Filter:</span >
6
+ <input
7
+ v-model =" filterValue"
8
+ type =" search"
9
+ placeholder =" Rule Filter"
10
+ class =" tool-form"
11
+ />
12
+ </label >
13
+ <label class =" tool" >
14
+ <input
15
+ :checked ="
16
+ categories.every((category) =>
17
+ category.rules.every((rule) => isErrorState(rule.ruleId)),
18
+ )
19
+ "
20
+ type =" checkbox"
21
+ :indeterminate.prop ="
22
+ categories.some((category) =>
23
+ category.rules.some((rule) => isErrorState(rule.ruleId)),
24
+ ) &&
25
+ categories.some((category) =>
26
+ category.rules.some((rule) => !isErrorState(rule.ruleId)),
27
+ )
28
+ "
29
+ @input =" onAllClick($event)"
30
+ />
31
+ <span class =" tool-label" >All Rules</span >
32
+ </label >
38
33
</div >
39
34
<ul class =" categories" >
40
35
<template v-for =" category in categories " >
74
69
!category.rules.every((rule) => isErrorState(rule.ruleId)) &&
75
70
!category.rules.every((rule) => !isErrorState(rule.ruleId))
76
71
"
77
- @input =" onAllClick (category, $event)"
72
+ @input =" onCategoryClick (category, $event)"
78
73
/>
79
74
{{ category.title }}
80
75
</label >
81
76
</div >
82
77
83
78
<ul v-show =" !categoryState[category.title].close" class =" rules" >
84
79
<li
85
- v-for =" rule in filterRules( category.rules) "
80
+ v-for =" rule in category.rules"
86
81
:key =" rule.ruleId"
87
82
class =" rule"
88
83
:class =" rule.classes"
104
99
viewBox =" 0 0 100 100"
105
100
width =" 15"
106
101
height =" 15"
102
+ class =" icon outbound"
107
103
>
108
104
<path
109
105
fill =" currentColor"
@@ -145,33 +141,32 @@ export default {
145
141
]
146
142
}),
147
143
),
148
- state: {
149
- toolsClose: true ,
150
- },
151
144
filterValue: " " ,
152
145
}
153
146
},
154
147
computed: {
155
148
categories () {
156
149
return categories .map ((c ) => {
157
- let rules = this .filterRules (c .rules )
158
- if (this .filterValue ) {
159
- rules = rules .filter ((r ) => r .ruleId .includes (this .filterValue ))
160
- }
161
150
return {
162
151
... c,
163
- rules,
152
+ rules: this . filterRules ( c . rules ) ,
164
153
}
165
154
})
166
155
},
167
156
},
168
157
methods: {
169
158
filterRules (rules ) {
170
- return rules .filter ((rule ) => rule .ruleId !== " jsonc/auto" )
159
+ let filteredRules = rules
160
+ if (this .filterValue ) {
161
+ filteredRules = filteredRules .filter ((r ) =>
162
+ r .ruleId .includes (this .filterValue ),
163
+ )
164
+ }
165
+ return filteredRules
171
166
},
172
- onAllClick (category , e ) {
167
+ onCategoryClick (category , e ) {
173
168
const rules = Object .assign ({}, this .rules )
174
- for (const rule of this . filterRules ( category .rules ) ) {
169
+ for (const rule of category .rules ) {
175
170
if (e .target .checked ) {
176
171
rules[rule .ruleId ] = " error"
177
172
} else {
@@ -180,8 +175,18 @@ export default {
180
175
}
181
176
this .$emit (" update:rules" , rules)
182
177
},
183
- onAllOffClick () {
184
- this .$emit (" update:rules" , {})
178
+ onAllClick (e ) {
179
+ const rules = Object .assign ({}, this .rules )
180
+ for (const category of this .categories ) {
181
+ for (const rule of category .rules ) {
182
+ if (e .target .checked ) {
183
+ rules[rule .ruleId ] = " error"
184
+ } else {
185
+ delete rules[rule .ruleId ]
186
+ }
187
+ }
188
+ }
189
+ this .$emit (" update:rules" , rules)
185
190
},
186
191
onClick (ruleId , e ) {
187
192
const rules = Object .assign ({}, this .rules )
@@ -206,25 +211,12 @@ export default {
206
211
207
212
.tool {
208
213
display : flex ;
209
- }
210
-
211
- .tool ,
212
- .tools-title {
213
214
padding : 4px ;
214
215
}
215
216
216
- .tool > label {
217
- display : flex ;
218
- width : 100% ;
219
- }
220
-
221
- .tool > button {
222
- margin : auto ;
223
- }
224
-
225
217
.tool-label {
226
- width : 3.5rem ;
227
218
flex-shrink : 0 ;
219
+ padding : 0 4px ;
228
220
}
229
221
230
222
.tool-form {
@@ -244,24 +236,19 @@ export default {
244
236
transform : rotate (90deg );
245
237
}
246
238
247
- .filter .tool-label {
248
- color : #ddd ;
249
- }
250
-
251
239
.categories {
252
240
font-size : 14px ;
253
241
list-style-type : none ;
254
242
}
255
243
256
244
.category {
257
245
position : relative ;
258
- color : #fff ;
259
246
}
260
247
261
248
.category-button {
262
249
position : absolute ;
263
250
left : -12px ;
264
- top : 4 px ;
251
+ top : 2 px ;
265
252
background-color : transparent ;
266
253
color : #ddd ;
267
254
border : none ;
@@ -279,13 +266,11 @@ export default {
279
266
font-weight : bold ;
280
267
}
281
268
282
- .eslint-plugin-svelte__category .category-title ,
283
- .eslint-plugin-svelte__rule a {
269
+ .eslint-plugin-svelte-category .category-title {
284
270
color : #40b3ff ;
285
271
}
286
272
287
- .eslint-category .category-title ,
288
- .eslint-rule a {
273
+ .eslint-core-category .category-title {
289
274
color : #8080f2 ;
290
275
}
291
276
@@ -303,11 +288,17 @@ export default {
303
288
304
289
.rule a {
305
290
margin-left : auto ;
306
- display : inline-flex ;
307
- align-items : center ;
308
291
}
309
292
310
293
a {
311
294
text-decoration : none ;
312
295
}
296
+
297
+ .eslint-core-rule a > svg {
298
+ color : #8080f2 ;
299
+ }
300
+
301
+ .eslint-plugin-svelte-rule a > svg {
302
+ color : #40b3ff ;
303
+ }
313
304
</style >
0 commit comments