From ace554fb198694ae85fb99becab81ae70456a335 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Fri, 5 Apr 2024 14:46:18 +0200 Subject: [PATCH] feat: add more filters --- app/components/OptionSelectGroup.vue | 8 +++-- app/composables/state.ts | 4 +-- app/pages/rules.vue | 52 ++++++++++++++++++++++++---- 3 files changed, 54 insertions(+), 10 deletions(-) diff --git a/app/components/OptionSelectGroup.vue b/app/components/OptionSelectGroup.vue index 7db2efc..b437d37 100644 --- a/app/components/OptionSelectGroup.vue +++ b/app/components/OptionSelectGroup.vue @@ -27,11 +27,15 @@ const value = defineModel('modelValue', { >
{{ titles?.[idx] ?? i }}
+ > + + {{ titles?.[idx] ?? i }} + + ({ export const filtersRules = reactive({ plugin: '', search: '', - state: 'using' as 'using' | 'unused' | 'overloads' | '', - status: 'active' as 'deprecated' | 'active' | 'recommended' | '', + state: 'using' as 'using' | 'unused' | 'overloads' | 'error' | 'warn' | 'off' | 'off-only' | '', + status: 'active' as 'deprecated' | 'active' | 'recommended' | 'fixable' | '', fixable: null as boolean | null, }) diff --git a/app/pages/rules.vue b/app/pages/rules.vue index 7f1e769..a7532e2 100644 --- a/app/pages/rules.vue +++ b/app/pages/rules.vue @@ -31,6 +31,23 @@ const conditionalFiltered = computed(() => { case 'overloads': conditional = conditional.filter(rule => (payload.value.ruleStateMap.get(rule.name)?.length || 0) > 1) break + case 'error': + conditional = conditional.filter(rule => payload.value.ruleStateMap.get(rule.name)?.some(i => i.level === 'error')) + break + case 'warn': + conditional = conditional.filter(rule => payload.value.ruleStateMap.get(rule.name)?.some(i => i.level === 'warn')) + break + case 'off': + conditional = conditional.filter(rule => payload.value.ruleStateMap.get(rule.name)?.some(i => i.level === 'off')) + break + case 'off-only': + conditional = conditional.filter((rule) => { + const states = payload.value.ruleStateMap.get(rule.name) + if (!states?.length) + return false + return states.every(i => i.level === 'off') + }) + break } switch (filters.status) { @@ -40,6 +57,9 @@ const conditionalFiltered = computed(() => { case 'recommended': conditional = conditional.filter(rule => rule.docs?.recommended) break + case 'fixable': + conditional = conditional.filter(rule => rule.fixable) + break case 'deprecated': conditional = conditional.filter(rule => rule.deprecated) break @@ -110,17 +130,37 @@ function resetFilters() { + :options="['', 'using', 'unused', 'error', 'warn', 'off', 'overloads', 'off-only']" + :titles="['All', 'Using', 'Unused', 'Error', 'Warn', 'Off', 'Overloaded', 'Off Only']" + > + +
State
+ :options="['', 'active', 'recommended', 'fixable', 'deprecated']" + :titles="['All', 'Active', 'Recommended', 'Fixable', 'Deprecated']" + > + +