11<template >
22 <div class =" rules-settings" >
33 <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 >
3833 </div >
3934 <ul class =" categories" >
4035 <template v-for =" category in categories " >
7469 !category.rules.every((rule) => isErrorState(rule.ruleId)) &&
7570 !category.rules.every((rule) => !isErrorState(rule.ruleId))
7671 "
77- @input =" onAllClick (category, $event)"
72+ @input =" onCategoryClick (category, $event)"
7873 />
7974 {{ category.title }}
8075 </label >
8176 </div >
8277
8378 <ul v-show =" !categoryState[category.title].close" class =" rules" >
8479 <li
85- v-for =" rule in filterRules( category.rules) "
80+ v-for =" rule in category.rules"
8681 :key =" rule.ruleId"
8782 class =" rule"
8883 :class =" rule.classes"
10499 viewBox =" 0 0 100 100"
105100 width =" 15"
106101 height =" 15"
102+ class =" icon outbound"
107103 >
108104 <path
109105 fill =" currentColor"
@@ -145,33 +141,32 @@ export default {
145141 ]
146142 }),
147143 ),
148- state: {
149- toolsClose: true ,
150- },
151144 filterValue: " " ,
152145 }
153146 },
154147 computed: {
155148 categories () {
156149 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- }
161150 return {
162151 ... c,
163- rules,
152+ rules: this . filterRules ( c . rules ) ,
164153 }
165154 })
166155 },
167156 },
168157 methods: {
169158 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
171166 },
172- onAllClick (category , e ) {
167+ onCategoryClick (category , e ) {
173168 const rules = Object .assign ({}, this .rules )
174- for (const rule of this . filterRules ( category .rules ) ) {
169+ for (const rule of category .rules ) {
175170 if (e .target .checked ) {
176171 rules[rule .ruleId ] = " error"
177172 } else {
@@ -180,8 +175,18 @@ export default {
180175 }
181176 this .$emit (" update:rules" , rules)
182177 },
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)
185190 },
186191 onClick (ruleId , e ) {
187192 const rules = Object .assign ({}, this .rules )
@@ -206,25 +211,12 @@ export default {
206211
207212.tool {
208213 display : flex ;
209- }
210-
211- .tool ,
212- .tools-title {
213214 padding : 4px ;
214215}
215216
216- .tool > label {
217- display : flex ;
218- width : 100% ;
219- }
220-
221- .tool > button {
222- margin : auto ;
223- }
224-
225217.tool-label {
226- width : 3.5rem ;
227218 flex-shrink : 0 ;
219+ padding : 0 4px ;
228220}
229221
230222.tool-form {
@@ -244,24 +236,19 @@ export default {
244236 transform : rotate (90deg );
245237}
246238
247- .filter .tool-label {
248- color : #ddd ;
249- }
250-
251239.categories {
252240 font-size : 14px ;
253241 list-style-type : none ;
254242}
255243
256244.category {
257245 position : relative ;
258- color : #fff ;
259246}
260247
261248.category-button {
262249 position : absolute ;
263250 left : -12px ;
264- top : 4 px ;
251+ top : 2 px ;
265252 background-color : transparent ;
266253 color : #ddd ;
267254 border : none ;
@@ -279,13 +266,11 @@ export default {
279266 font-weight : bold ;
280267}
281268
282- .eslint-plugin-svelte__category .category-title ,
283- .eslint-plugin-svelte__rule a {
269+ .eslint-plugin-svelte-category .category-title {
284270 color : #40b3ff ;
285271}
286272
287- .eslint-category .category-title ,
288- .eslint-rule a {
273+ .eslint-core-category .category-title {
289274 color : #8080f2 ;
290275}
291276
@@ -303,11 +288,17 @@ export default {
303288
304289.rule a {
305290 margin-left : auto ;
306- display : inline-flex ;
307- align-items : center ;
308291}
309292
310293a {
311294 text-decoration : none ;
312295}
296+
297+ .eslint-core-rule a > svg {
298+ color : #8080f2 ;
299+ }
300+
301+ .eslint-plugin-svelte-rule a > svg {
302+ color : #40b3ff ;
303+ }
313304 </style >
0 commit comments