refactor: remove unnecessary optional chaining (#1991)

This commit is contained in:
Xin Du (Clark) 2021-11-17 14:37:34 +00:00 committed by GitHub
parent 4ba637a5ea
commit a08b435f51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 6 deletions

View File

@ -42,7 +42,7 @@ export default defineComponent({
const { $docus } = useContext()
const route = useRoute()
const currentSlug = computed(() => {
return route.value.path !== '/' && route?.value?.params?.pathMatch
return route.value.path !== '/' && route.value.params?.pathMatch
? route.value.params.pathMatch.split('/')[0]
: null
})

View File

@ -20,7 +20,7 @@ export default defineComponent({
const { $menu } = useContext()
const route = useRoute()
const currentSlug = computed(() => {
return route.value.path !== '/' && route?.value?.params?.pathMatch
return route.value.path !== '/' && route.value.params?.pathMatch
? route.value.params.pathMatch.split('/')[0]
: null
})

View File

@ -74,5 +74,5 @@ export const useNuxtApp = () => {
return currentNuxtAppInstance
}
return vm?.proxy.$_nuxtApp
return vm.proxy.$_nuxtApp
}

View File

@ -95,7 +95,7 @@ export const getRollupConfig = (nitroContext: NitroContext) => {
prefix = 'nuxt'
} else if (lastModule.startsWith(nitroContext._internal.runtimeDir)) {
prefix = 'nitro'
} else if (!prefix && nitroContext.middleware.find(m => lastModule.startsWith(m.handle as string))) {
} else if (nitroContext.middleware.find(m => lastModule.startsWith(m.handle as string))) {
prefix = 'middleware'
} else if (lastModule.includes('assets')) {
prefix = 'assets'

View File

@ -76,7 +76,7 @@ for (const [dirname, dirOpts] of Object.entries(dirs)) {
}
function normalizeKey (key) {
return key.replace(/[/\\\\]/g, ':').replace(/^:|:$/g, '')
return key.replace(/[/\\]/g, ':').replace(/^:|:$/g, '')
}
function getAssetProd (assets: Record<string, Asset>) {

View File

@ -44,7 +44,7 @@ export default defineNuxtCommand({
const isNuxt3 = nuxtVersion.startsWith('3')
const useVite = isNuxt3
? nuxtConfig.vite !== false
: (nuxtConfig?.buildModules?.find(m => m === 'nuxt-vite'))
: (nuxtConfig.buildModules?.find(m => m === 'nuxt-vite'))
let packageManager = getPackageManager(rootDir)
if (packageManager) {