Skip to content

Commit 8f9ea0a

Browse files
Add some Vue 3 Eslint rules (#3322)
* Enable some Vue 3 Eslint rules Signed-off-by: Olga Bulat <obulat@gmail.com> * Update packages/eslint-plugin/src/configs/vue.ts Co-authored-by: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com> * Update packages/eslint-plugin/src/configs/vue.ts --------- Signed-off-by: Olga Bulat <obulat@gmail.com> Co-authored-by: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com>
1 parent 6f6aac3 commit 8f9ea0a

File tree

16 files changed

+81
-0
lines changed

16 files changed

+81
-0
lines changed

frontend/src/components/VBanner/VAnalyticsNotice.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,18 @@
2020
import { computed, defineComponent } from "vue"
2121
import { useContext } from "@nuxtjs/composition-api"
2222
23+
import { defineEvent } from "~/types/emits"
24+
2325
import VLink from "~/components/VLink.vue"
2426
import VNotificationBanner from "~/components/VBanner/VNotificationBanner.vue"
2527
2628
export default defineComponent({
2729
name: "VAnalyticsNotice",
2830
components: { VLink, VNotificationBanner },
2931
inheritAttrs: false,
32+
emits: {
33+
close: defineEvent(),
34+
},
3035
setup() {
3136
const { app } = useContext()
3237
const privacyPath = computed(() => app.localePath("/privacy"))

frontend/src/components/VBanner/VTranslationStatusBanner.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import { useUiStore } from "~/stores/ui"
2929
3030
import { createTranslationLink } from "~/utils/translation-banner"
3131
32+
import { defineEvent } from "~/types/emits"
33+
3234
import VLink from "~/components/VLink.vue"
3335
import VNotificationBanner from "~/components/VBanner/VNotificationBanner.vue"
3436
@@ -45,6 +47,9 @@ export default defineComponent({
4547
required: true,
4648
},
4749
},
50+
emits: {
51+
close: defineEvent(),
52+
},
4853
setup() {
4954
const uiStore = useUiStore()
5055

frontend/src/components/VContentReport/VReportDescForm.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import { computed, defineComponent, PropType } from "vue"
2525
2626
import { reasons, OTHER, ReportReason } from "~/constants/content-report"
27+
import { defineEvent } from "~/types/emits"
2728
2829
export default defineComponent({
2930
name: "VReportDescForm",
@@ -47,6 +48,9 @@ export default defineComponent({
4748
validator: (val: ReportReason) => reasons.includes(val),
4849
},
4950
},
51+
emits: {
52+
input: defineEvent<[string]>(),
53+
},
5054
setup(props, { emit }) {
5155
const text = computed({
5256
get: () => props.content,

frontend/src/components/VContentSwitcher/VSearchTypeButton.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import type { SearchType } from "~/constants/media"
2222
2323
import { warn } from "~/utils/console"
2424
25+
import { defineEvent } from "~/types/emits"
26+
2527
import VIcon from "~/components/VIcon/VIcon.vue"
2628
import VButton from "~/components/VButton.vue"
2729
@@ -52,6 +54,9 @@ export default defineComponent({
5254
required: true,
5355
},
5456
},
57+
emits: {
58+
click: defineEvent(),
59+
},
5560
setup(_, { attrs }) {
5661
if (!attrs["aria-haspopup"] || attrs["aria-expanded"] === undefined) {
5762
warn(

frontend/src/components/VContentSwitcher/VSearchTypeItem.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import { BETA, contentStatus, SearchType } from "~/constants/media"
2323
import { isSearchTypeSupported, useSearchStore } from "~/stores/search"
2424
import useSearchType from "~/composables/use-search-type"
2525
26+
import { defineEvent } from "~/types/emits"
27+
2628
import VIcon from "~/components/VIcon/VIcon.vue"
2729
import VItem from "~/components/VItemGroup/VItem.vue"
2830
import VPill from "~/components/VPill.vue"
@@ -75,6 +77,9 @@ export default defineComponent({
7577
default: "small",
7678
},
7779
},
80+
emits: {
81+
click: defineEvent<[SearchType]>(),
82+
},
7883
setup(props) {
7984
const searchStore = useSearchStore()
8085
const { getSearchTypeProps } = useSearchType()

frontend/src/components/VContentSwitcher/VSearchTypePopover.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import useSearchType from "~/composables/use-search-type"
3131
3232
import type { SearchType } from "~/constants/media"
3333
34+
import { defineEvent } from "~/types/emits"
35+
3436
import VPopover from "~/components/VPopover/VPopover.vue"
3537
import VSearchTypeButton from "~/components/VContentSwitcher/VSearchTypeButton.vue"
3638
import VSearchTypes from "~/components/VContentSwitcher/VSearchTypes.vue"
@@ -52,6 +54,9 @@ export default defineComponent({
5254
default: "header",
5355
},
5456
},
57+
emits: {
58+
select: defineEvent<[SearchType]>(),
59+
},
5560
setup(_, { emit }) {
5661
const contentMenuPopover = ref<InstanceType<typeof VPopover> | null>(null)
5762

frontend/src/components/VHeader/VHeaderMobile/VContentSettingsModalContent.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ import { useSearchStore } from "~/stores/search"
8585
8686
import useSearchType from "~/composables/use-search-type"
8787
88+
import { defineEvent } from "~/types/emits"
89+
90+
import { SearchType } from "~/constants/media"
91+
8892
import VButton from "~/components/VButton.vue"
8993
import VFilterTab from "~/components/VHeader/VHeaderMobile/VFilterTab.vue"
9094
import VIcon from "~/components/VIcon/VIcon.vue"
@@ -138,6 +142,9 @@ export default defineComponent({
138142
default: true,
139143
},
140144
},
145+
emits: {
146+
select: defineEvent<[SearchType]>(),
147+
},
141148
setup(props) {
142149
const searchStore = useSearchStore()
143150
const content = useSearchType()

frontend/src/components/VHeader/VHeaderMobile/VShowResultsButton.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
<script lang="ts">
4646
import { computed, defineComponent } from "vue"
4747
48+
import { defineEvent } from "~/types/emits"
49+
4850
import VButton from "~/components/VButton.vue"
4951
5052
/**
@@ -63,6 +65,9 @@ export default defineComponent({
6365
default: false,
6466
},
6567
},
68+
emits: {
69+
click: defineEvent(),
70+
},
6671
setup() {
6772
const diameter = 8 // px
6873
const spacing = 8 // px

frontend/src/components/VHeader/VPageLinks.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ import { type PropType, defineComponent, computed } from "vue"
5555
5656
import usePages from "~/composables/use-pages"
5757
58+
import { defineEvent } from "~/types/emits"
59+
5860
import VItemGroup from "~/components/VItemGroup/VItemGroup.vue"
5961
import VItem from "~/components/VItemGroup/VItem.vue"
6062
import VIcon from "~/components/VIcon/VIcon.vue"
@@ -97,6 +99,9 @@ export default defineComponent({
9799
default: false,
98100
},
99101
},
102+
emits: {
103+
close: defineEvent(),
104+
},
100105
setup(props, { emit }) {
101106
const { all: allPages, current: currentPage } = usePages()
102107

frontend/src/components/VHideButton.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@
2828
import { computed, defineComponent } from "@nuxtjs/composition-api"
2929
3030
import { useUiStore } from "~/stores/ui"
31+
import { defineEvent } from "~/types/emits"
3132
3233
export default defineComponent({
34+
emits: {
35+
click: defineEvent(),
36+
},
3337
setup() {
3438
const uiStore = useUiStore()
3539
const isMd = computed(() => uiStore.isBreakpoint("md"))

frontend/src/components/VLink.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ import { useContext } from "@nuxtjs/composition-api"
4848
4949
import { useAnalytics } from "~/composables/use-analytics"
5050
51+
import { defineEvent } from "~/types/emits"
52+
5153
import VIcon from "~/components/VIcon/VIcon.vue"
5254
5355
type InternalLinkProps = { to: string }
@@ -93,6 +95,13 @@ export default defineComponent({
9395
default: true,
9496
},
9597
},
98+
emits: {
99+
mousedown: defineEvent<[MouseEvent]>(),
100+
click: defineEvent<[MouseEvent]>(),
101+
blur: defineEvent<[FocusEvent]>(),
102+
focus: defineEvent<[FocusEvent]>(),
103+
keydown: defineEvent<[KeyboardEvent]>(),
104+
},
96105
setup(props) {
97106
const { app } = useContext()
98107
function checkHref(p: typeof props): p is {

frontend/src/components/VMediaInfo/VMetadataValue.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
<script lang="ts">
2121
import type { Metadata } from "~/types/media"
2222
23+
import { defineEvent } from "~/types/emits"
24+
2325
import VLink from "~/components/VLink.vue"
2426
2527
import VIcon from "~/components/VIcon/VIcon.vue"
@@ -35,5 +37,8 @@ export default {
3537
required: true,
3638
},
3739
},
40+
emits: {
41+
click: defineEvent<[string | undefined]>(),
42+
},
3843
}
3944
</script>

frontend/src/components/VRadio/VRadio.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
<script lang="ts">
2424
import { computed, defineComponent } from "vue"
2525
26+
import { defineEvent } from "~/types/emits"
27+
2628
import VSvg from "~/components/VSvg/VSvg.vue"
2729
/**
2830
* Renders a radio input field, useful for choosing one of a few options that
@@ -64,6 +66,9 @@ export default defineComponent({
6466
default: "",
6567
},
6668
},
69+
emits: {
70+
change: defineEvent<[string]>(),
71+
},
6772
setup(props, { emit }) {
6873
const isChecked = computed(() => props.value_ === props.modelValue)
6974
const handleInput = () => {

frontend/src/components/VSafetyWall/VSafetyWall.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ import { useAnalytics } from "~/composables/use-analytics"
6363
import { camelCase } from "~/utils/case"
6464
import type { AudioDetail, ImageDetail } from "~/types/media"
6565
66+
import { defineEvent } from "~/types/emits"
67+
6668
import VLink from "~/components/VLink.vue"
6769
import VButton from "~/components/VButton.vue"
6870
import VIcon from "~/components/VIcon/VIcon.vue"
@@ -80,6 +82,9 @@ export default defineComponent({
8082
required: true,
8183
},
8284
},
85+
emits: {
86+
reveal: defineEvent(),
87+
},
8388
setup(props, { emit }) {
8489
const searchStore = useSearchStore()
8590
const backToSearchPath = computed(() => searchStore.backToSearchPath)

frontend/test/unit/setup.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Vue.use(VueI18n)
2020
*/
2121
config.stubs["nuxt-link"] = Vue.component("NuxtLink", {
2222
props: ["to"],
23+
emits: ["click", "mousedown"],
2324
methods: {
2425
handleClick() {
2526
// This is an adaptation to mimic NuxtLink's behavior,

packages/eslint-plugin/src/configs/vue.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ const i18nDestructureRules = ["t", "tc", "te", "td", "d", "n"].map(
1010
export = {
1111
extends: [
1212
"plugin:vue/recommended",
13+
"plugin:vue/vue3-recommended",
1314
"plugin:vuejs-accessibility/recommended",
1415
"plugin:@intlify/vue-i18n/recommended",
1516
],
1617
plugins: ["vue", "vuejs-accessibility", "@intlify/vue-i18n"],
1718
rules: {
19+
// Enable these rules after the Nuxt 3 migration
20+
"vue/no-deprecated-dollar-listeners-api": "off",
21+
"vue/no-v-for-template-key-on-child": "off",
22+
"vue/no-deprecated-v-on-native-modifier": "off",
23+
1824
"vue/max-attributes-per-line": "off",
1925
"vue/require-prop-types": "off",
2026
"vue/require-default-prop": "off",

0 commit comments

Comments
 (0)