Skip to content

Commit

Permalink
chore: tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Aug 20, 2024
1 parent 65e547c commit aaffc92
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 21 deletions.
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export default vuepress(
// FIXME: Fail positives
'import/no-extraneous-dependencies': 'off',
'no-underscore-dangle': 'off',
'no-labels': 'off',
},
},
vue: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ export const useUmamiAnalytics = ({
hostUrl,
}: UmamiOptions): void => {
// avoid duplicated import
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (window.umami) return
if ('umami' in window) return

const script = document.createElement('script')
script.src = link!
Expand Down
3 changes: 1 addition & 2 deletions plugins/blog/plugin-blog/src/node/category/getCategory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ export const getCategory = (
const categories = getter(page)

for (const category of categories) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!map[category]) {
if (!(category in map)) {
const itemPath = getItemPath(category)

if (itemPath) {
Expand Down
4 changes: 2 additions & 2 deletions plugins/markdown/plugin-prismjs/src/node/loadLanguages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import rawLoadLanguages from 'prismjs/components/index.js'
rawLoadLanguages.silent = true

export const loadLanguages = (languages: string[]): void => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const langsToLoad = languages.filter((item) => !Prism.languages[item])
const langsToLoad = languages.filter((item) => !(item in Prism.languages))

if (langsToLoad.length) {
rawLoadLanguages(langsToLoad)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
*/
export const preconnectToAlgolia = (appId: string): void => {
const id = 'algolia-preconnect'
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const rIC = window.requestIdleCallback || setTimeout
const rIC =
'requestIdleCallback' in window ? window.requestIdleCallback : setTimeout

rIC(() => {
if (document.head.querySelector(`#${id}`)) return
const preconnect = document.createElement('link')
Expand Down
2 changes: 1 addition & 1 deletion plugins/seo/plugin-sitemap/src/node/getInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const getSitemapInfos = (

links = relatedLocales.map((localePrefix) => ({
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
lang: locales[localePrefix]?.lang || 'en',
lang: locales[localePrefix]?.lang ?? 'en',
url: `${base}${removeLeadingSlash(localePrefix)}${rootPath.substring(1)}`,
}))
}
Expand Down
3 changes: 1 addition & 2 deletions plugins/tools/plugin-cache/src/node/renderCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ export const renderCacheWithMemory = async (

const key = hash(input)

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (metadata[filepath] === key && cache[filepath]) {
if (metadata[filepath] === key && filepath in cache) {
const cached = cache[filepath]
Object.assign(env, cached.env)
return cached.content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const setupDevServerRedirect = (): void => {
let matchedLocalePath: string | null = null

// get matched locale
// eslint-disable-next-line no-labels, no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
findLanguage: for (const lang of languages.value)
for (const [localePath, langs] of redirectLocaleEntries)
if (langs.includes(lang)) {
Expand All @@ -49,7 +49,6 @@ export const setupDevServerRedirect = (): void => {
continue

matchedLocalePath = localePath
// eslint-disable-next-line no-labels
break findLanguage
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ export const setupHeaders = (): void => {
}

headersRef.value = getHeaders({
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
selector: [...new Array(6)]
selector: [...new Array<undefined>(6)]
.map((_, i) => `.theme-default-content h${i + 1}`)
.join(','),
levels: [2, levels.value + 1],
Expand Down
9 changes: 4 additions & 5 deletions tools/helper/src/client/utils/getHeaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const resolveHeaders = (

const res: MenuItem[] = []

// eslint-disable-next-line no-labels, no-restricted-syntax
// eslint-disable-next-line no-restricted-syntax
outer: for (let i = 0; i < allowedHeaders.length; i++) {
const cur = allowedHeaders[i]
if (i === 0) {
Expand All @@ -64,7 +64,6 @@ export const resolveHeaders = (
const prev = allowedHeaders[j]
if (prev.level < cur.level) {
;(prev.children ??= []).push(cur)
// eslint-disable-next-line no-labels
continue outer
}
}
Expand All @@ -76,7 +75,6 @@ export const resolveHeaders = (
}

const serializeHeader = (h: Element, ignore: string[] = []): string => {
// eslint-disable-next-line no-useless-assignment
let text = ''

if (ignore.length) {
Expand Down Expand Up @@ -128,8 +126,9 @@ export interface GetHeadersOptions {
}

export const getHeaders = ({
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
selector = [...new Array(6)].map((_, i) => `#vp-content h${i + 1}`).join(','),
selector = [...new Array<undefined>(6)]
.map((_, i) => `#vp-content h${i + 1}`)
.join(','),
levels = 2,
ignore = [],
}: GetHeadersOptions = {}): MenuItem[] => {
Expand Down
1 change: 0 additions & 1 deletion tools/vp-update/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ cli
.example('docs')
.action(async (targetDir = ''): Promise<Error | void> => {
console.log('Bumping deps...')
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const dir = resolve(process.cwd(), targetDir)
const packageJSON = resolve(dir, 'package.json')

Expand Down

0 comments on commit aaffc92

Please sign in to comment.