Skip to content

Commit bb692bb

Browse files
committed
chore: lint
1 parent f02ad53 commit bb692bb

21 files changed

+52
-52
lines changed

packages/core/cluster.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { EventEmitter } from 'node:events'
21
import type { LaunchOptions, Page, PuppeteerNodeLaunchOptions } from 'puppeteer-core'
2+
import { EventEmitter } from 'node:events'
33

44
export interface ResourceData {
55
page: Page

packages/core/src/build.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { dirname, join, resolve } from 'node:path'
2-
import fs from 'fs-extra'
3-
import { pick } from 'lodash-es'
4-
import { withLeadingSlash, withTrailingSlash } from 'ufo'
5-
import { createScanMeta } from './data'
6-
import { useLogger, useUnlighthouse } from './unlighthouse'
71
import type {
82
ClientOptionsPayload,
93
GenerateClientOptions,
104
ScanMeta,
115
UnlighthouseContext,
126
UnlighthouseRouteReport,
137
} from './types'
8+
import { dirname, join, resolve } from 'node:path'
9+
import fs from 'fs-extra'
10+
import { pick } from 'lodash-es'
11+
import { withLeadingSlash, withTrailingSlash } from 'ufo'
12+
import { createScanMeta } from './data'
13+
import { useLogger, useUnlighthouse } from './unlighthouse'
1414

1515
/**
1616
* Copies the file contents of the @unlighthouse/client package and does transformation based on the provided configuration.

packages/core/src/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import type { UnlighthouseColumn, UnlighthouseTabs, UserConfig } from './types'
12
import os from 'node:os'
23
import { Cluster } from 'puppeteer-cluster'
3-
import type { UnlighthouseColumn, UnlighthouseTabs, UserConfig } from './types'
44

55
export const AppName = 'Unlighthouse'
66
export const ClientPkg = '@unlighthouse/client'

packages/core/src/data/scanMeta.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { useUnlighthouse } from '../unlighthouse'
21
import type { ScanMeta } from '../types'
2+
import { useUnlighthouse } from '../unlighthouse'
33

44
export function createScanMeta(): ScanMeta {
55
const { worker } = useUnlighthouse()

packages/core/src/discovery/robotsTxt.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import type { ResolvedUserConfig } from '../types'
2+
import type { RobotsGroupResolved } from '../util/robotsTxtParser'
13
import { $URL } from 'ufo'
24
import { useLogger } from '../logger'
35
import { useUnlighthouse } from '../unlighthouse'
46
import { fetchUrlRaw } from '../util'
5-
import type { ResolvedUserConfig } from '../types'
6-
import type { RobotsGroupResolved } from '../util/robotsTxtParser'
77

88
export interface RobotsTxtParsed {
99
sitemaps: string[]

packages/core/src/discovery/routeDefinitions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import type { RouteDefinition } from '../types'
12
import { join } from 'node:path'
23
import { useLogger } from '../logger'
34
import { useUnlighthouse } from '../unlighthouse'
45
import { createRoutes } from '../util/createRoutes'
5-
import type { RouteDefinition } from '../types'
66

77
/**
88
* Using the configuration discovery details will try and resolve the route definitions using the file system.

packages/core/src/discovery/routes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import type { NormalisedRoute } from '../types'
12
import { groupBy, map, sampleSize } from 'lodash-es'
23
import { useLogger } from '../logger'
34
import { isScanOrigin, normaliseRoute } from '../router'
45
import { useUnlighthouse } from '../unlighthouse'
56
import { parseRobotsTxt } from '../util/robotsTxtParser'
67
import { fetchRobotsTxt, mergeRobotsTxtConfig } from './robotsTxt'
78
import { extractSitemapRoutes } from './sitemap'
8-
import type { NormalisedRoute } from '../types'
99

1010
let warnedAboutSampling = false
1111

packages/core/src/logger.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import type { ConsolaInstance } from 'consola'
12
import { createConsola } from 'consola'
23
import { createContext } from 'unctx'
3-
import type { ConsolaInstance } from 'consola'
44
import { AppName } from './constants'
55

66
const loggerCtx = createContext<ConsolaInstance>()

packages/core/src/process/lighthouse.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import type { Flags } from 'lighthouse'
2+
import type { UnlighthouseRouteReport } from '../types'
13
import { setMaxListeners } from 'node:events'
24
import fs from 'node:fs'
35
import { join } from 'node:path'
46
import lighthouse from 'lighthouse/core/index.cjs'
57
import minimist from 'minimist'
6-
import type { Flags } from 'lighthouse'
7-
import type { UnlighthouseRouteReport } from '../types'
88

99
setMaxListeners(0);
1010

packages/core/src/puppeteer/cluster.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import type { UnlighthousePuppeteerCluster } from '../types'
12
import { Cluster } from 'puppeteer-cluster'
23
import { useUnlighthouse } from '../unlighthouse'
3-
import type { UnlighthousePuppeteerCluster } from '../types'
44

55
/**
66
* Create an instance of puppeteer-cluster

packages/core/src/puppeteer/tasks/html.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
import type { CheerioAPI } from 'cheerio'
2+
import type { Page } from 'puppeteer-core'
3+
import type { HTMLExtractPayload, PuppeteerTask } from '../../types'
14
import { join } from 'node:path'
25
import { load as cheerio } from 'cheerio'
36
import fs from 'fs-extra'
47
import { withoutTrailingSlash } from 'ufo'
5-
import type { CheerioAPI } from 'cheerio'
6-
import type { Page } from 'puppeteer-core'
78
import { useLogger } from '../../logger'
89
import { normaliseRoute } from '../../router'
910
import { useUnlighthouse } from '../../unlighthouse'
1011
import { fetchUrlRaw, ReportArtifacts, trimSlashes } from '../../util'
1112
import { setupPage } from '../util'
12-
import type { HTMLExtractPayload, PuppeteerTask } from '../../types'
1313

1414
export const extractHtmlPayload: (page: Page, route: string) => Promise<{ success: boolean, redirected?: false | string, message?: string, payload?: string }> = async (page, route) => {
1515
const { worker, resolvedConfig } = useUnlighthouse()

packages/core/src/puppeteer/tasks/lighthouse.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
import type { Result } from 'lighthouse'
2+
import type { LighthouseReport, PuppeteerTask, UnlighthouseRouteReport } from '../../types'
13
import { join } from 'node:path'
24
import fs from 'fs-extra'
35
import { computeMedianRun } from 'lighthouse/core/lib/median-run.js'
46
import { map, pick, sumBy } from 'lodash-es'
57
import { relative } from 'pathe'
68
import { withQuery } from 'ufo'
7-
import type { Result } from 'lighthouse'
89
import { useLogger } from '../../logger'
910
import { useUnlighthouse } from '../../unlighthouse'
1011
import { base64ToBuffer, ReportArtifacts } from '../../util'
1112
import { setupPage } from '../util'
12-
import type { LighthouseReport, PuppeteerTask, UnlighthouseRouteReport } from '../../types'
1313

1414
export function normaliseLighthouseResult(route: UnlighthouseRouteReport, result: Result): LighthouseReport {
1515
const { resolvedConfig, runtimeSettings } = useUnlighthouse()

packages/core/src/puppeteer/worker.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1+
import type { TaskFunction } from 'puppeteer-cluster/dist/Cluster'
2+
import type {
3+
NormalisedRoute,
4+
PuppeteerTaskArgs,
5+
PuppeteerTaskReturn,
6+
UnlighthouseRouteReport,
7+
UnlighthouseTask,
8+
UnlighthouseWorker,
9+
UnlighthouseWorkerStats,
10+
} from '../types'
111
import fs from 'node:fs'
212
import { join } from 'node:path'
313
import chalk from 'chalk'
414
import { get, sortBy, uniqBy } from 'lodash-es'
5-
import type { TaskFunction } from 'puppeteer-cluster/dist/Cluster'
615
import { useLogger } from '../logger'
716
import { useUnlighthouse } from '../unlighthouse'
817
import { createTaskReportFromRoute, formatBytes, ReportArtifacts } from '../util'
918
import { createFilter } from '../util/filter'
1019
import {
1120
launchPuppeteerCluster,
1221
} from './cluster'
13-
import type {
14-
NormalisedRoute,
15-
PuppeteerTaskArgs,
16-
PuppeteerTaskReturn,
17-
UnlighthouseRouteReport,
18-
UnlighthouseTask,
19-
UnlighthouseWorker,
20-
UnlighthouseWorkerStats,
21-
} from '../types'
2222

2323
let warnedMaxRoutesExceeded = false
2424

packages/core/src/resolveConfig.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { InstallOptions } from '@puppeteer/browsers'
2+
import type { ResolvedUserConfig, UnlighthouseTabs, UserConfig } from './types'
13
import { Buffer } from 'node:buffer'
24
import { existsSync } from 'node:fs'
35
import { homedir } from 'node:os'
@@ -10,11 +12,9 @@ import { pick } from 'lodash-es'
1012
import { resolve as resolveModule } from 'mlly'
1113
import puppeteer from 'puppeteer-core'
1214
import { PUPPETEER_REVISIONS } from 'puppeteer-core/lib/cjs/puppeteer/revisions.js'
13-
import type { InstallOptions } from '@puppeteer/browsers'
1415
import { defaultConfig } from './constants'
1516
import { useLogger } from './logger'
1617
import { normaliseHost, withSlashes } from './util'
17-
import type { ResolvedUserConfig, UnlighthouseTabs, UserConfig } from './types'
1818

1919
/**
2020
* A provided configuration from the user may require runtime transformations to avoid breaking app functionality.

packages/core/src/router/broadcasting.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Buffer } from 'node:buffer'
2-
import { WebSocketServer } from 'ws'
31
import type { IncomingMessage } from 'node:http'
42
import type { Socket } from 'node:net'
3+
import { Buffer } from 'node:buffer'
4+
import { WebSocketServer } from 'ws'
55
import { useUnlighthouse } from '../unlighthouse'
66

77
/**

packages/core/src/router/mockRouter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import type { MockRouter, RouteDefinition } from '../types'
12
import { parse } from 'regexparam'
23
import { useLogger } from '../logger'
3-
import type { MockRouter, RouteDefinition } from '../types'
44

55
/**
66
* The default mock router using regexparam as the matcher

packages/core/src/router/util.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import type { NormalisedRoute } from '../types'
12
import { basename } from 'node:path'
23
import { hasProtocol, isRelative, withBase, withLeadingSlash } from 'ufo'
34
import { useUnlighthouse } from '../unlighthouse'
45
import { hashPathName, trimSlashes } from '../util'
5-
import type { NormalisedRoute } from '../types'
66

77
export function isScanOrigin(url: string): boolean {
88
if (isRelative(url) || (url.startsWith('/') && !url.startsWith('//')))

packages/core/src/unlighthouse.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
import type { IncomingMessage } from 'node:http'
2+
import type { Socket } from 'node:net'
3+
import type {
4+
Provider,
5+
ResolvedUserConfig,
6+
RuntimeSettings,
7+
UnlighthouseContext,
8+
UnlighthouseHooks,
9+
UserConfig,
10+
} from './types'
111
import { existsSync } from 'node:fs'
212
import { isAbsolute, join } from 'node:path'
313
import chalk from 'chalk'
@@ -10,8 +20,6 @@ import { $fetch } from 'ofetch'
1020
import { $URL, joinURL } from 'ufo'
1121
import { loadConfig } from 'unconfig'
1222
import { createContext } from 'unctx'
13-
import type { IncomingMessage } from 'node:http'
14-
import type { Socket } from 'node:net'
1523
import { version } from '../package.json'
1624
import { generateClient } from './build'
1725
import { AppName, ClientPkg } from './constants'
@@ -22,14 +30,6 @@ import { resolveUserConfig } from './resolveConfig'
2230
import { createApi, createBroadcastingEvents, createMockRouter, WS } from './router'
2331
import { normaliseHost } from './util'
2432
import { successBox } from './util/cliFormatting'
25-
import type {
26-
Provider,
27-
ResolvedUserConfig,
28-
RuntimeSettings,
29-
UnlighthouseContext,
30-
UnlighthouseHooks,
31-
UserConfig,
32-
} from './types'
3333

3434
const engineContext = createContext<UnlighthouseContext>()
3535

packages/core/src/util.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'
2+
import type { NormalisedRoute, ResolvedUserConfig, UnlighthouseRouteReport } from './types'
13
import { Buffer } from 'node:buffer'
24
import { createHash } from 'node:crypto'
35
import dns from 'node:dns'
@@ -9,9 +11,7 @@ import { ensureDirSync } from 'fs-extra'
911
import sanitize from 'sanitize-filename'
1012
import slugify from 'slugify'
1113
import { joinURL, withLeadingSlash, withoutLeadingSlash, withoutTrailingSlash, withTrailingSlash } from 'ufo'
12-
import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'
1314
import { useLogger, useUnlighthouse } from './unlighthouse'
14-
import type { NormalisedRoute, ResolvedUserConfig, UnlighthouseRouteReport } from './types'
1515

1616
export const ReportArtifacts = {
1717
html: 'payload.html',

packages/core/src/util/createRoutes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import type { RouteDefinition } from '../types'
12
import { resolve } from 'pathe'
23
import { normalizeURL, withoutTrailingSlash, withTrailingSlash } from 'ufo'
3-
import type { RouteDefinition } from '../types'
44

55
/**
66
* From https://github.com/nuxt/nuxt.js/blob/dev/packages/utils/src/route.js

packages/core/test/robots.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import type { ResolvedUserConfig } from '../src'
12
import { describe, expect, it } from 'vitest'
23
import { mergeRobotsTxtConfig } from '../src/discovery'
34
import { asRegExp } from '../src/util'
45
import { parseRobotsTxt } from '../src/util/robotsTxtParser'
5-
import type { ResolvedUserConfig } from '../src'
66

77
describe('robots', () => {
88
it ('parses example #1', () => {

0 commit comments

Comments
 (0)