Skip to content

Commit

Permalink
chore: apply lint
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jul 28, 2024
1 parent 8c983ea commit 9a69fb7
Show file tree
Hide file tree
Showing 21 changed files with 48 additions and 41 deletions.
3 changes: 1 addition & 2 deletions packages/devtools-kit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ export function startSubprocess(
try {
process?.kill()
}
catch (e) {
}
catch {}
nuxt.callHook('devtools:terminal:remove', { id })
}

Expand Down
4 changes: 2 additions & 2 deletions packages/devtools-kit/src/runtime/iframe-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export function onDevtoolsClientConnected(fn: (client: NuxtDevtoolsIframeClient)
if (typeof window === 'undefined')
return

// eslint-disable-next-line ts/prefer-ts-expect-error
// eslint-disable-next-line ts/ban-ts-comment
// @ts-ignore injection
if (window.__NUXT_DEVTOOLS__) {
// eslint-disable-next-line ts/prefer-ts-expect-error
// eslint-disable-next-line ts/ban-ts-comment
// @ts-ignore injection
fns.forEach(fn => fn(window.__NUXT_DEVTOOLS__))
}
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools-ui-kit/src/components/NButton.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
// eslint-disable-next-line ts/prefer-ts-expect-error
// eslint-disable-next-line ts/ban-ts-comment
// @ts-ignore tsconfig
import { NuxtLink } from '#components'
Expand Down
4 changes: 2 additions & 2 deletions packages/devtools-ui-kit/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ export default defineNuxtModule<ModuleOptions>({
if (!options.dev)
nuxt.options.unocss = extendUnocssOptions(nuxt.options.unocss)

// eslint-disable-next-line ts/prefer-ts-expect-error
// eslint-disable-next-line ts/ban-ts-comment
// @ts-ignore - module options
nuxt.options.vueuse = nuxt.options.vueuse || {}
// eslint-disable-next-line ts/prefer-ts-expect-error
// eslint-disable-next-line ts/ban-ts-comment
// @ts-ignore - module options
nuxt.options.colorMode = defu(nuxt.options.colorMode, { classSuffix: '' })

Expand Down
2 changes: 1 addition & 1 deletion packages/devtools-wizard/src/builtin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async function toggleConfig(cwd: string, value?: boolean) {
await fsp.writeFile(nuxtConfig, `${generated.trimEnd()}\n`, 'utf-8')
}
}
catch (err) {
catch {
consola.error(colors.red('Unable to update Nuxt config file automatically'))
process.exitCode = 1
printOutManual(true)
Expand Down
15 changes: 10 additions & 5 deletions packages/devtools/client/components/AssetDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const textContent = computedAsync(async () => {
if (asset.value.type !== 'text')
return undefined
// eslint-disable-next-line no-unused-expressions
// eslint-disable-next-line ts/no-unused-expressions
textContentCounter.value
const content = await rpc.getTextAssetContent(await ensureDevAuthToken(), asset.value.filePath)
Expand All @@ -47,6 +47,7 @@ async function saveTextContent() {
})
}
catch (error) {
console.error(error)
devtoolsUiShowNotification({
message: 'Something went wrong!',
icon: 'i-carbon-warning',
Expand All @@ -71,10 +72,12 @@ const codeSnippets = computed(() => {
items.push(
{ lang: 'vue-html', code: `<img${attrs}\n src="${asset.value.publicPath}"\n/>`, name: 'Plain Image' },
)
hasNuxtImage.value && items.push(
{ lang: 'vue-html', code: `<NuxtImg${attrs}\n src="${asset.value.publicPath}"\n/>`, name: 'Nuxt Img', docs: 'https://image.nuxt.com/usage/nuxt-img' },
{ lang: 'vue-html', code: `<NuxtPicture${attrs}\n src="${asset.value.publicPath}"\n/>`, name: 'Nuxt Picture', docs: 'https://image.nuxt.com/usage/nuxt-picture' },
)
if (hasNuxtImage.value) {
items.push(
{ lang: 'vue-html', code: `<NuxtImg${attrs}\n src="${asset.value.publicPath}"\n/>`, name: 'Nuxt Img', docs: 'https://image.nuxt.com/usage/nuxt-img' },
{ lang: 'vue-html', code: `<NuxtPicture${attrs}\n src="${asset.value.publicPath}"\n/>`, name: 'Nuxt Picture', docs: 'https://image.nuxt.com/usage/nuxt-picture' },
)
}
return items
}
Expand Down Expand Up @@ -135,6 +138,7 @@ async function deleteAsset() {
})
}
catch (error) {
console.error(error)
devtoolsUiShowNotification({
message: 'Something went wrong!',
icon: 'i-carbon-warning',
Expand Down Expand Up @@ -170,6 +174,7 @@ async function renameAsset() {
})
}
catch (error) {
console.error(error)
devtoolsUiShowNotification({
message: 'Something went wrong!',
icon: 'i-carbon-warning',
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/client/components/DataSchemaDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const language = computed(() => languages.find(l => l.displayName === selectedLa
const options = ref(language.value?.optionDefinitions.filter(o => typeof o.defaultValue === 'boolean'))
const generatedJson = computedAsync(async () => {
// eslint-disable-next-line no-unused-expressions
// eslint-disable-next-line ts/no-unused-expressions
counter.value
if (!input.value)
Expand Down
4 changes: 1 addition & 3 deletions packages/devtools/client/components/ServerRouteDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,7 @@ async function fetchData() {
},
})
}
catch (err: any) {
}
catch {}
fetching.value = false
response.fetchTime = Date.now() - start
Expand Down
4 changes: 1 addition & 3 deletions packages/devtools/client/components/ServerTaskDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ async function fetchData() {
},
})
}
catch (err: any) {
}
catch {}
fetching.value = false
response.fetchTime = Date.now() - start
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/client/components/StacktraceList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function urlToFilepath(url: string) {
return `/${pathname.split('/@fs/')[1]}`
return (config.value?.rootDir || '') + pathname
}
catch (e) {
catch {
return url
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/client/components/TimelineTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const scale = ref(1.5)
const segments = computed(() => segmentTimelineEvents(props.data.events))
const scrollWidth = computed(() => {
// eslint-disable-next-line no-unused-expressions
// eslint-disable-next-line ts/no-unused-expressions
props.data.events.length
return scroller.value?.scrollWidth || window.innerWidth
})
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/client/pages/modules/open-graph.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const counter = ref(0)
const head = useClientHead()
const headTags = computedAsync(async () => {
// eslint-disable-next-line no-unused-expressions
// eslint-disable-next-line ts/no-unused-expressions
counter.value // for force refresh
const tags = await head.value?.resolveTags()
return tags.map((tag): NormalizedHeadTag => {
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/client/pages/modules/pages.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const count = ref(0)
const currentRoute = computed(() => {
// Additionall reactivity tracker
// eslint-disable-next-line no-unused-expressions
// eslint-disable-next-line ts/no-unused-expressions
(middleware.value, routeInput.value, layouts.value, count.value)
return router.value?.currentRoute?.value?.path
})
Expand Down
3 changes: 2 additions & 1 deletion packages/devtools/client/pages/modules/server-routes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ const filterByCollection = computed(() => {
const indexOfDist = filepathParts.indexOf('dist')
if (indexOfDist !== -1) {
prefix = filepathParts[indexOfDist - 1]
prefix && collectionNames.splice(1, 0, prefix)
if (prefix)
collectionNames.splice(1, 0, prefix)
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/src/runtime/function-metrics-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function __nuxtTimelineWrap(name: string, fn: any) {
return result
}
}
catch (e) {}
catch {}
event.end = Date.now()
return result
}
Expand Down
6 changes: 3 additions & 3 deletions packages/devtools/src/runtime/plugins/devtools.client.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { shallowReactive, watchEffect } from 'vue'

import type { Router } from 'vue-router'
import { setupHooksDebug } from '../shared/hooks'
import type { TimelineServerState } from '../../types'

// eslint-disable-next-line ts/prefer-ts-expect-error
import { setupHooksDebug } from '../shared/hooks'
// eslint-disable-next-line ts/ban-ts-comment
// @ts-ignore tsconfig
import type { TimelineServerState } from '../../types'
import { defineNuxtPlugin, useRouter, useState } from '#imports'

export default defineNuxtPlugin((nuxt: any) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/src/runtime/plugins/view/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ const panelStyle = computed(() => {
const { width: frameWidth, height: frameHeight } = useElementBounding(frameBox)
const iframeStyle = computed(() => {
// eslint-disable-next-line no-unused-expressions, no-sequences
// eslint-disable-next-line no-sequences, ts/no-unused-expressions
mousePosition.x, mousePosition.y
const halfHeight = (panelEl.value?.clientHeight || 0) / 2
Expand Down
8 changes: 5 additions & 3 deletions packages/devtools/src/runtime/plugins/view/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { initTimelineMetrics } from '../../function-metrics-helpers'
import Main from './Main.vue'
import { popupWindow, state } from './state'

// eslint-disable-next-line ts/prefer-ts-expect-error
// eslint-disable-next-line ts/ban-ts-comment
// @ts-ignore tsconfig
import { useAppConfig, useRuntimeConfig } from '#imports'

Expand Down Expand Up @@ -58,7 +58,7 @@ export async function setupDevToolsClient({
try {
popupWindow.value.close()
}
catch (e) {
catch {
}
popupWindow.value = null
}
Expand Down Expand Up @@ -115,7 +115,7 @@ export async function setupDevToolsClient({
try {
iframe?.contentWindow?.__NUXT_DEVTOOLS_VIEW__?.setClient(client)
}
catch (e) {
catch {
// cross-origin
}
return client
Expand Down Expand Up @@ -257,6 +257,8 @@ export async function setupDevToolsClient({
`
pip.__NUXT_DEVTOOLS_DISABLE__ = true
pip.__NUXT_DEVTOOLS_IS_POPUP__ = true
// eslint-disable-next-line ts/ban-ts-comment
// @ts-ignore Missing types
pip.__NUXT__ = window.parent?.__NUXT__ || window.__NUXT__
pip.document.title = 'Nuxt DevTools'
pip.document.head.appendChild(style)
Expand Down
16 changes: 10 additions & 6 deletions packages/devtools/src/runtime/plugins/view/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export function useTransform<F, T>(data: Ref<F>, to: (data: F) => T, from: (data

export function useEventListener(target: EventTarget, type: string, listener: any, options?: boolean | AddEventListenerOptions) {
target.addEventListener(type, listener, options)
getCurrentScope() && onScopeDispose(() => target.removeEventListener(type, listener, options))
if (getCurrentScope())
onScopeDispose(() => target.removeEventListener(type, listener, options))
}

/**
Expand Down Expand Up @@ -108,16 +109,19 @@ export function useElementBounding(target: Ref<HTMLElement | null | undefined>)
cleanup()
if (window) {
observer = new ResizeObserver(update)
el && observer!.observe(el)
if (el)
observer!.observe(el)
}
},
{ immediate: true, flush: 'post', deep: true },
)

getCurrentScope() && onScopeDispose(() => {
cleanup()
stopWatch()
})
if (getCurrentScope()) {
onScopeDispose(() => {
cleanup()
stopWatch()
})
}

return {
height,
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/src/server-rpc/analyze-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function setupAnalyzeBuildRPC({ nuxt, refresh, ensureDevAuthToken }: Nuxt
return `${branchName}#${sha}`
return `${branchName}#${sha}-dirty`
}
catch (e) {
catch {
// if the git is not available, fallback to iso string
return new Date().toISOString().replace(/:/g, '-')
}
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/src/server-rpc/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export function setupAssetsRPC({ nuxt, ensureDevAuthToken, refresh, options }: N
i++
finalPath = `${base}-${i}.${ext}`
}
catch (err) {
catch {
// Ignore error if file doesn't exist
}
}
Expand Down

0 comments on commit 9a69fb7

Please sign in to comment.