Skip to content

Commit 6d919cf

Browse files
authored
chore(playground): fix lint warning (#4421)
1 parent cb75dbd commit 6d919cf

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

packages/playground/testUtils.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import fs from 'fs'
66
import path from 'path'
77
import colors from 'css-color-names'
88
import { ElementHandle } from 'playwright-chromium'
9+
import type { Manifest } from 'vite'
910

1011
export function slash(p: string): string {
1112
return p.replace(/\\/g, '/')
@@ -51,18 +52,18 @@ async function toEl(el: string | ElementHandle): Promise<ElementHandle> {
5152
return el
5253
}
5354

54-
export async function getColor(el: string | ElementHandle) {
55+
export async function getColor(el: string | ElementHandle): Promise<string> {
5556
el = await toEl(el)
5657
const rgb = await el.evaluate((el) => getComputedStyle(el as Element).color)
5758
return hexToNameMap[rgbToHex(rgb)] || rgb
5859
}
5960

60-
export async function getBg(el: string | ElementHandle) {
61+
export async function getBg(el: string | ElementHandle): Promise<string> {
6162
el = await toEl(el)
6263
return el.evaluate((el) => getComputedStyle(el as Element).backgroundImage)
6364
}
6465

65-
export function readFile(filename: string) {
66+
export function readFile(filename: string): string {
6667
return fs.readFileSync(path.resolve(testDir, filename), 'utf-8')
6768
}
6869

@@ -78,20 +79,20 @@ export function editFile(
7879
fs.writeFileSync(filename, modified)
7980
}
8081

81-
export function addFile(filename: string, content: string) {
82+
export function addFile(filename: string, content: string): void {
8283
fs.writeFileSync(path.resolve(testDir, filename), content)
8384
}
8485

85-
export function removeFile(filename: string) {
86+
export function removeFile(filename: string): void {
8687
fs.unlinkSync(path.resolve(testDir, filename))
8788
}
8889

89-
export function listAssets(base = '') {
90+
export function listAssets(base = ''): string[] {
9091
const assetsDir = path.join(testDir, 'dist', base, 'assets')
9192
return fs.readdirSync(assetsDir)
9293
}
9394

94-
export function findAssetFile(match: string | RegExp, base = '') {
95+
export function findAssetFile(match: string | RegExp, base = ''): string {
9596
const assetsDir = path.join(testDir, 'dist', base, 'assets')
9697
const files = fs.readdirSync(assetsDir)
9798
const file = files.find((file) => {
@@ -100,7 +101,7 @@ export function findAssetFile(match: string | RegExp, base = '') {
100101
return file ? fs.readFileSync(path.resolve(assetsDir, file), 'utf-8') : ''
101102
}
102103

103-
export function readManifest(base = '') {
104+
export function readManifest(base = ''): Manifest {
104105
return JSON.parse(
105106
fs.readFileSync(path.join(testDir, 'dist', base, 'manifest.json'), 'utf-8')
106107
)
@@ -113,7 +114,7 @@ export async function untilUpdated(
113114
poll: () => string | Promise<string>,
114115
expected: string,
115116
runInBuild = false
116-
) {
117+
): Promise<void> {
117118
if (isBuild && !runInBuild) return
118119
const maxTries = process.env.CI ? 100 : 50
119120
for (let tries = 0; tries < maxTries; tries++) {

0 commit comments

Comments
 (0)