fix: lint issues

This commit is contained in:
Calum 2025-07-13 15:06:29 +01:00
parent debcb57f47
commit 2f1627c000
5 changed files with 31 additions and 15 deletions

View File

@ -255,8 +255,8 @@ import {
} from "@modrinth/assets"; } from "@modrinth/assets";
import { Multiselect } from "vue-multiselect"; import { Multiselect } from "vue-multiselect";
import { ConfirmModal, Avatar } from "@modrinth/ui"; import { ConfirmModal, Avatar } from "@modrinth/ui";
import FileInput from "~/components/ui/FileInput.vue";
import { MIN_SUMMARY_CHARS } from "@modrinth/moderation"; import { MIN_SUMMARY_CHARS } from "@modrinth/moderation";
import FileInput from "~/components/ui/FileInput.vue";
const props = defineProps({ const props = defineProps({
project: { project: {

View File

@ -14,8 +14,8 @@
</label> </label>
<TriangleAlertIcon <TriangleAlertIcon
v-if="!isIssuesUrlCommon" v-if="!isIssuesUrlCommon"
class="size-6 animate-pulse text-orange"
v-tooltip="`You're using a link which isn't common for this link type.`" v-tooltip="`You're using a link which isn't common for this link type.`"
class="size-6 animate-pulse text-orange"
/> />
<input <input
id="project-issue-tracker" id="project-issue-tracker"
@ -38,8 +38,8 @@
</label> </label>
<TriangleAlertIcon <TriangleAlertIcon
v-if="!isSourceUrlCommon" v-if="!isSourceUrlCommon"
class="size-6 animate-pulse text-orange"
v-tooltip="`You're using a link which isn't common for this link type.`" v-tooltip="`You're using a link which isn't common for this link type.`"
class="size-6 animate-pulse text-orange"
/> />
<input <input
id="project-source-code" id="project-source-code"
@ -76,8 +76,8 @@
</label> </label>
<TriangleAlertIcon <TriangleAlertIcon
v-if="!isDiscordUrlCommon" v-if="!isDiscordUrlCommon"
class="size-6 animate-pulse text-orange"
v-tooltip="`You're using a link which isn't common for this link type.`" v-tooltip="`You're using a link which isn't common for this link type.`"
class="size-6 animate-pulse text-orange"
/> />
<input <input
id="project-discord-invite" id="project-discord-invite"
@ -170,17 +170,17 @@ const wikiUrl = ref(props.project.wiki_url);
const discordUrl = ref(props.project.discord_url); const discordUrl = ref(props.project.discord_url);
const isIssuesUrlCommon = computed(() => { const isIssuesUrlCommon = computed(() => {
if (issuesUrl.value?.trim().length ?? 0 === 0) return true; if (!issuesUrl.value || issuesUrl.value.trim().length === 0) return true;
return isCommonUrl(issuesUrl.value, commonLinkDomains.issues); return isCommonUrl(issuesUrl.value, commonLinkDomains.issues);
}); });
const isSourceUrlCommon = computed(() => { const isSourceUrlCommon = computed(() => {
if (sourceUrl.value?.trim().length ?? 0 === 0) return true; if (!sourceUrl.value || sourceUrl.value.trim().length === 0) return true;
return isCommonUrl(sourceUrl.value, commonLinkDomains.source); return isCommonUrl(sourceUrl.value, commonLinkDomains.source);
}); });
const isDiscordUrlCommon = computed(() => { const isDiscordUrlCommon = computed(() => {
if (discordUrl.value?.trim().length ?? 0 === 0) return true; if (!discordUrl.value || discordUrl.value.trim().length === 0) return true;
return isCommonUrl(discordUrl.value, commonLinkDomains.discord); return isCommonUrl(discordUrl.value, commonLinkDomains.discord);
}); });

View File

@ -122,7 +122,7 @@ export const descriptionNags: Nag[] = [
{ {
id: 'minecraft-title-clause', id: 'minecraft-title-clause',
title: 'Title contains "Minecraft"', title: 'Title contains "Minecraft"',
description: (context: NagContext) => description: () =>
`Please remove "Minecraft" from your title. You cannot use "Minecraft" in your title for legal reasons.`, `Please remove "Minecraft" from your title. You cannot use "Minecraft" in your title for legal reasons.`,
status: 'required', status: 'required',
shouldShow: (context: NagContext) => { shouldShow: (context: NagContext) => {
@ -138,7 +138,7 @@ export const descriptionNags: Nag[] = [
{ {
id: 'title-contains-technical-info', id: 'title-contains-technical-info',
title: 'Title contains loader or version info', title: 'Title contains loader or version info',
description: (context: NagContext) => { description: () => {
return `Removing these helps keep titles clean and makes your project easier to find. Version and loader information is automatically displayed alongside your project.` return `Removing these helps keep titles clean and makes your project easier to find. Version and loader information is automatically displayed alongside your project.`
}, },
status: 'warning', status: 'warning',
@ -147,7 +147,7 @@ export const descriptionNags: Nag[] = [
if (!title) return false if (!title) return false
const loaderNames = const loaderNames =
context.tags.loaders?.map((loader: any) => loader.name?.toLowerCase()) || [] context.tags.loaders?.map((loader: { name: string }) => loader.name?.toLowerCase()) || []
const hasLoader = loaderNames.some((loader) => loader && title.includes(loader.toLowerCase())) const hasLoader = loaderNames.some((loader) => loader && title.includes(loader.toLowerCase()))
const versionPatterns = [/\b1\.\d+(\.\d+)?\b/] const versionPatterns = [/\b1\.\d+(\.\d+)?\b/]
const hasVersionPattern = versionPatterns.some((pattern) => pattern.test(title)) const hasVersionPattern = versionPatterns.some((pattern) => pattern.test(title))
@ -163,7 +163,7 @@ export const descriptionNags: Nag[] = [
{ {
id: 'summary-same-as-title', id: 'summary-same-as-title',
title: 'Summary is project name', title: 'Summary is project name',
description: (context: NagContext) => description: () =>
`Your summary is the same as your project name. Please change it. It's recommended to have a unique summary to provide more context about your project.`, `Your summary is the same as your project name. Please change it. It's recommended to have a unique summary to provide more context about your project.`,
status: 'required', status: 'required',
shouldShow: (context: NagContext) => { shouldShow: (context: NagContext) => {

View File

@ -1,9 +1,17 @@
import type { Project } from '@modrinth/utils'
import type { Nag, NagContext } from '../../types/nags' import type { Nag, NagContext } from '../../types/nags'
function getCategories(project: any, tags: any) { function getCategories(
project: Project & { actualProjectType: string },
tags: {
categories?: {
project_type: string
}[]
},
) {
return ( return (
tags.categories?.filter( tags.categories?.filter(
(category: any) => category.project_type === project.actualProjectType, (category: { project_type: string }) => category.project_type === project.actualProjectType,
) ?? [] ) ?? []
) )
} }
@ -57,14 +65,20 @@ export const tagsNags: Nag[] = [
id: 'all-tags-selected', id: 'all-tags-selected',
title: 'All tags selected', title: 'All tags selected',
description: (context: NagContext) => { description: (context: NagContext) => {
const categoriesForProjectType = getCategories(context.project, context.tags) const categoriesForProjectType = getCategories(
context.project as Project & { actualProjectType: string },
context.tags,
)
console.log('categoriesForProjectType', categoriesForProjectType) console.log('categoriesForProjectType', categoriesForProjectType)
const totalAvailableTags = categoriesForProjectType.length const totalAvailableTags = categoriesForProjectType.length
return `You've selected all ${totalAvailableTags} available tags. This defeats the purpose of tags, which are meant to help users find relevant projects. Please select only the tags that truly apply to your project.` return `You've selected all ${totalAvailableTags} available tags. This defeats the purpose of tags, which are meant to help users find relevant projects. Please select only the tags that truly apply to your project.`
}, },
status: 'required', status: 'required',
shouldShow: (context: NagContext) => { shouldShow: (context: NagContext) => {
const categoriesForProjectType = getCategories(context.project, context.tags) const categoriesForProjectType = getCategories(
context.project as Project & { actualProjectType: string },
context.tags,
)
const totalSelectedTags = const totalSelectedTags =
context.project.categories.length + (context.project.additional_categories?.length || 0) context.project.categories.length + (context.project.additional_categories?.length || 0)
return totalSelectedTags === categoriesForProjectType.length return totalSelectedTags === categoriesForProjectType.length

View File

@ -32,8 +32,10 @@ export interface NagContext {
* The current route in the application. * The current route in the application.
*/ */
currentRoute: string currentRoute: string
/* eslint-disable @typescript-eslint/no-explicit-any */
tags: any tags: any
submitProject: (...any: any) => any submitProject: (...any: any) => any
/* eslint-enable @typescript-eslint/no-explicit-any */
} }
/** /**