Skip to content

Commit 3c46cff

Browse files
committed
chore: broken linting
1 parent b27d4ee commit 3c46cff

21 files changed

+64
-53
lines changed

docs/pages/index.vue

+6-4
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ const { $script } = useScript<JSConfettiApi>({
8181
},
8282
})
8383
onMounted(() => {
84-
confettiEl.value && useEventListener(confettiEl.value, 'mouseenter', () => {
85-
$script.then(({ JSConfetti }) => {
86-
new JSConfetti().addConfetti({ emojis: ['🎉', '🎊'] })
84+
if (confettiEl.value) {
85+
useEventListener(confettiEl.value, 'mouseenter', () => {
86+
$script.then(({ JSConfetti }) => {
87+
new JSConfetti().addConfetti({ emojis: ['🎉', '🎊'] })
88+
})
8789
})
88-
})
90+
}
8991
})
9092
9193
const links = [

playground/pages/npm/js-confetti.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface JSConfettiApi {
1111
}
1212
1313
declare global {
14-
interface Window extends JSConfettiApi {}
14+
type Window = JSConfettiApi
1515
}
1616
1717
const { $script } = useScriptNpm<JSConfettiApi>({

playground/scripts/myCustomScript.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import type { Input } from 'valibot'
33
import { useScript } from '#imports'
44
import type { NuxtUseScriptOptions } from '#nuxt-scripts'
55

6-
export interface MyCustomScriptApi {
7-
}
6+
export type MyCustomScriptApi = Record<string, any>
87

98
export const MyCustomScriptOptions = object({
109
id: string(),

scripts/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export async function generateTpcContent(input: TpcDescriptor) {
3535

3636
chunks.push(`
3737
declare global {
38-
interface Window extends ${input.tpcTypeAugmentation} {}
38+
type Window = ${input.tpcTypeAugmentation}
3939
}`)
4040
}
4141

src/devtools.ts

-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ import { useNuxt } from '@nuxt/kit'
55
import type { ModuleOptions } from './module'
66
import { DEVTOOLS_UI_LOCAL_PORT, DEVTOOLS_UI_ROUTE } from './constants'
77

8-
export interface ServerFunctions {}
9-
10-
export interface ClientFunctions {}
11-
128
export function setupDevToolsUI(options: ModuleOptions, resolve: Resolver['resolve'], nuxt: Nuxt = useNuxt()) {
139
const clientPath = resolve('./client')
1410
const isProductionBuild = existsSync(clientPath)

src/module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export default defineNuxtModule<ModuleOptions>({
131131
nuxt.hooks.hook('modules:done', async () => {
132132
const registryScripts = [...scripts]
133133

134-
// @ts-ignore nuxi prepare is broken to generate these types, possibly because of the runtime path
134+
// @ts-expect-error nuxi prepare is broken to generate these types, possibly because of the runtime path
135135
await nuxt.hooks.callHook('scripts:registry', registryScripts)
136136
const registryScriptsWithImport = registryScripts.filter(i => !!i.import?.name) as Required<RegistryScript>[]
137137
addImports(registryScriptsWithImport.map((i) => {

src/runtime/components/ScriptGoogleMaps.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ defineExpose({
135135
136136
onMounted(() => {
137137
watch(ready, (v) => {
138-
v && emits('ready', map)
138+
if (v) {
139+
emits('ready', map)
140+
}
139141
})
140142
watch($script.status, () => {
141143
if ($script.status.value === 'error') {

src/runtime/components/ScriptVimeoPlayer.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ onMounted(() => {
188188
})
189189
190190
watch(() => props.id, (v) => {
191-
v && player?.loadVideo(Number(v))
191+
if (v) {
192+
player?.loadVideo(Number(v))
193+
}
192194
})
193195
watch($script.status, (status) => {
194196
if (status === 'error') {

src/runtime/composables/useScriptEventPage.ts

+15-13
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export function useScriptEventPage(onChange?: (payload: TrackedPage) => void) {
1414
return payload
1515

1616
let lastPayload: TrackedPage = { path: '', title: '' }
17-
let stopDomWatcher: () => void
17+
let stopDomWatcher = () => {}
1818
// TODO make sure useAsyncData isn't running
1919
nuxt.hooks.hook('page:finish', () => {
2020
Promise.race([
@@ -23,18 +23,20 @@ export function useScriptEventPage(onChange?: (payload: TrackedPage) => void) {
2323
new Promise<void>((resolve) => {
2424
stopDomWatcher = head.hooks.hook('dom:rendered', () => resolve())
2525
}),
26-
]).finally(() => {
27-
stopDomWatcher && stopDomWatcher()
28-
}).then(() => {
29-
payload.value = {
30-
path: route.fullPath,
31-
title: document.title,
32-
}
33-
if (lastPayload.path !== payload.value.path || lastPayload.title !== payload.value.title) {
34-
onChange && onChange(payload.value)
35-
lastPayload = payload.value
36-
}
37-
})
26+
])
27+
.finally(stopDomWatcher)
28+
.then(() => {
29+
payload.value = {
30+
path: route.fullPath,
31+
title: document.title,
32+
}
33+
if (lastPayload.path !== payload.value.path || lastPayload.title !== payload.value.title) {
34+
if (onChange) {
35+
onChange(payload.value)
36+
}
37+
lastPayload = payload.value
38+
}
39+
})
3840
})
3941
return payload
4042
}

src/runtime/registry/clarity.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export interface ClarityApi {
3333
}
3434

3535
declare global {
36-
interface Window extends ClarityApi {}
36+
type Window = ClarityApi
3737
}
3838

3939
export const ClarityOptions = object({

src/runtime/registry/cloudflare-web-analytics.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface CloudflareWebAnalyticsApi {
1818
}
1919

2020
declare global {
21-
interface Window extends CloudflareWebAnalyticsApi {}
21+
type Window = CloudflareWebAnalyticsApi
2222
}
2323

2424
export const CloudflareWebAnalyticsOptions = object({

src/runtime/registry/google-adsense.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface GoogleAdsenseApi {
2121
}
2222

2323
declare global {
24-
interface Window extends GoogleAdsenseApi {}
24+
type Window = GoogleAdsenseApi
2525
}
2626

2727
/**

src/runtime/registry/google-maps.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const GoogleMapsOptions = object({
2323

2424
export type GoogleMapsInput = RegistryScriptInput<typeof GoogleMapsOptions>
2525

26-
type MapsNamespace = typeof google.maps
26+
type MapsNamespace = google.maps
2727
export interface GoogleMapsApi {
2828
maps: MapsNamespace | Promise<MapsNamespace>
2929
}

src/runtime/registry/google-tag-manager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { RegistryScriptInput } from '#nuxt-scripts'
66
import { object, string, optional } from '#nuxt-scripts-validator'
77

88
declare global {
9-
interface Window extends GoogleTagManagerApi {}
9+
type Window = GoogleTagManagerApi
1010
}
1111
export const GoogleTagManagerOptions = object({
1212
id: string(),

src/runtime/registry/matomo-analytics.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface MatomoAnalyticsApi {
1717
}
1818

1919
declare global {
20-
interface Window extends MatomoAnalyticsApi {}
20+
type Window = MatomoAnalyticsApi
2121
}
2222

2323
export function useScriptMatomoAnalytics<T extends MatomoAnalyticsApi>(_options?: MatomoAnalyticsInput) {
@@ -42,8 +42,12 @@ export function useScriptMatomoAnalytics<T extends MatomoAnalyticsApi>(_options?
4242
? undefined
4343
: () => {
4444
const _paq = window._paq = window._paq || []
45-
options?.trackPageView !== false && _paq.push(['trackPageView'])
46-
options?.enableLinkTracking !== false && _paq.push(['enableLinkTracking'])
45+
if (options?.trackPageView) {
46+
_paq.push(['trackPageView'])
47+
}
48+
if (options?.enableLinkTracking) {
49+
_paq.push(['enableLinkTracking'])
50+
}
4751
_paq.push(['setTrackerUrl', withBase(`/matomo.php`, withHttps(options?.matomoUrl))])
4852
_paq.push(['setSiteId', options?.siteId || '1'])
4953
},

src/runtime/registry/meta-pixel.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ export interface MetaPixelApi {
3232
}
3333

3434
declare global {
35-
interface Window extends MetaPixelApi {
36-
}
35+
type Window = MetaPixelApi
3736
}
3837

3938
export const MetaPixelOptions = object({
@@ -57,8 +56,12 @@ export function useScriptMetaPixel<T extends MetaPixelApi>(_options?: MetaPixelI
5756
? undefined
5857
: () => {
5958
const fbq: MetaPixelApi['fbq'] = window.fbq = function (...params: any[]) {
60-
// @ts-expect-error untyped
61-
fbq.callMethod ? fbq.callMethod(...params) : fbq.queue.push(params)
59+
if (fbq.callMethod) {
60+
fbq.callMethod(...params)
61+
}
62+
else {
63+
fbq.queue.push(params)
64+
}
6265
} as any as MetaPixelApi['fbq']
6366
if (!window._fbq)
6467
window._fbq = fbq

src/runtime/registry/segment.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ interface AnalyticsApi {
3131
push: (args: any[]) => void
3232
}
3333

34-
export interface SegmentApi extends Pick<AnalyticsApi, 'track' | 'page' | 'identify' | 'group' | 'alias' | 'reset'> {
35-
}
34+
export type SegmentApi = Pick<AnalyticsApi, 'track' | 'page' | 'identify' | 'group' | 'alias' | 'reset'>
3635

3736
declare global {
38-
interface Window extends SegmentApi { }
37+
type Window = SegmentApi
3938
}
4039

4140
const methods = ['track', 'page', 'identify', 'group', 'alias', 'reset']

src/runtime/registry/stripe.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface StripeApi {
1515
}
1616

1717
declare global {
18-
interface Window extends StripeApi {}
18+
type Window = StripeApi
1919
}
2020

2121
export function useScriptStripe<T extends StripeApi>(_options?: StripeInput) {

src/runtime/registry/vimeo-player.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface VimeoPlayerApi {
1515
export type VimeoPlayerInput = RegistryScriptInput
1616

1717
declare global {
18-
interface Window extends VimeoPlayerApi {}
18+
type Window = VimeoPlayerApi
1919
}
2020

2121
export function useScriptVimeoPlayer<T extends VimeoPlayerApi>(_options?: VimeoPlayerInput) {

src/runtime/registry/x-pixel.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ export interface XPixelApi {
3636
}
3737

3838
declare global {
39-
interface Window extends XPixelApi {
40-
}
39+
type Window = XPixelApi
4140
}
4241

4342
export const XPixelOptions = object({
@@ -57,10 +56,13 @@ export function useScriptXPixel<T extends XPixelApi>(_options?: XPixelInput) {
5756
? undefined
5857
: () => {
5958
// @ts-expect-error untyped
60-
const s = window.twq = function () {
61-
// @ts-expect-error untyped
62-
// eslint-disable-next-line prefer-rest-params
63-
s.exe ? s.exe(s, arguments) : s.queue.push(arguments)
59+
const s = window.twq = function (...args) {
60+
if (e.exe) {
61+
s.exe(s, args)
62+
}
63+
else {
64+
s.queue.push(args)
65+
}
6466
}
6567
// @ts-expect-error untyped
6668
s.version = options?.version || '1.1'

src/runtime/types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ export type NuxtConfigScriptRegistry<T extends keyof ScriptRegistry = keyof Scri
132132
[key in T]: NuxtConfigScriptRegistryEntry<ScriptRegistry[key]>
133133
}>
134134

135-
const emptyOptions = object({})
135+
const _emptyOptions = object({})
136136

137-
export type EmptyOptionsSchema = typeof emptyOptions
137+
export type EmptyOptionsSchema = typeof _emptyOptions
138138

139139
type ScriptInput = ScriptBase & DataKeys & SchemaAugmentations['script']
140140

0 commit comments

Comments
 (0)