Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: label non-existent rule as invalid #96

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions app/components/RuleItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function capitalize(str?: string) {
<div v-if="shown" max-h="50vh">
<div flex="~ items-center gap-2" p3>
<NuxtLink
v-if="!rule.invalid"
btn-action-sm
:to="rule.docs?.url" target="_blank" rel="noopener noreferrer"
title="Docs"
Expand Down Expand Up @@ -115,23 +116,24 @@ function capitalize(str?: string) {
<div
:class="[
rule.deprecated ? 'line-through' : '',
rule.invalid ? 'text-red' : '',
gridView ? 'op50 text-sm' : 'op75 ws-nowrap of-hidden text-ellipsis line-clamp-1',
]"
>
{{ capitalize(rule.docs?.description) }}
{{ rule.invalid ? 'Invalid rule has no description' : capitalize(rule.docs?.description) }}
</div>
<div v-if="!gridView && rule.deprecated" border="~ red/25 rounded" bg-red:5 px1 text-xs text-red>
DEPRECATED
<div v-if="!gridView && (rule.invalid || rule.deprecated)" border="~ red/25 rounded" bg-red:5 px1 text-xs text-red>
{{ rule.invalid ? 'INVALID' : 'DEPRECATED' }}
</div>
</div>

<div
v-if="gridView && (rule.deprecated || rule.fixable || rule.docs?.recommended)"
v-if="gridView && (rule.invalid || rule.deprecated || rule.fixable || rule.docs?.recommended)"
flex flex-auto flex-col items-start justify-end
>
<div flex="~ gap-2" mt1>
<div v-if="rule.deprecated" border="~ red/25 rounded" bg-red:5 px1 text-xs text-red>
DEPRECATED
<div v-if="rule.invalid || rule.deprecated" border="~ red/25 rounded" bg-red:5 px1 text-xs text-red>
{{ rule.invalid ? 'INVALID' : 'DEPRECATED' }}
</div>
<div
v-if="rule.docs?.recommended"
Expand Down
7 changes: 5 additions & 2 deletions app/composables/payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ export function ensureDataFetch() {

export const payload = computed(() => Object.freeze(resolvePayload(data.value!)))

export function getRuleFromName(name: string): RuleInfo | undefined {
return payload.value.rules[name]
export function getRuleFromName(name: string): RuleInfo {
return payload.value.rules[name] || {
name,
invalid: true,
}
}

export function getRuleStates(name: string): RuleConfigStates | undefined {
Expand Down
4 changes: 4 additions & 0 deletions shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ export interface PayloadMeta {
export interface RuleInfo extends RuleMetaData<any, any> {
name: string
plugin: string
/**
* The rule may be removed
*/
invalid?: boolean
}

export interface FiltersConfigsPage {
Expand Down