Skip to content

Commit

Permalink
doc: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Jul 10, 2023
1 parent ed7fd09 commit f60a5a2
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 54 deletions.
2 changes: 1 addition & 1 deletion docs/content/1.guide/guides/0.config.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ configuration types.

```ts unlighthouse.config.ts
/// <reference types="unlighthouse" />
import {defineConfig} from 'unlighthouse'
import { defineConfig } from 'unlighthouse'

export default defineConfig({
// examplebtn-basic
Expand Down
26 changes: 13 additions & 13 deletions docs/content/1.guide/guides/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ To use basic authentication, provide the `auth` option in your configuration fil

```ts
// unlighthouse.config.ts
export default{
export default {
auth: {
username: 'username',
password: 'password',
},
};
}
```

Alternatively, you can provide the `--auth` flag to the CLI.
Expand All @@ -28,7 +28,7 @@ If you can authenticate your session using cookies, use the `cookies` option in

```ts
// unlighthouse.config.ts
export default{
export default {
cookies: [
{
name: 'my-jwt-token',
Expand All @@ -41,7 +41,7 @@ export default{
sameSite: 'Lax',
},
],
};
}
```

Alternatively, you can provide the `--cookies` flag to the CLI.
Expand All @@ -64,11 +64,11 @@ To use custom headers, provide the `extraHeaders` option in your configuration f

```ts
// unlighthouse.config.ts
export default{
export default {
extraHeaders: {
'x-custom-auth': '<token>>',
},
};
}
```

Alternatively, you can provide the `--extra-headers` flag to the CLI.
Expand Down Expand Up @@ -117,24 +117,24 @@ You can see an example here:
export default {
puppeteerOptions: {
// slow down slightly so input is not missed
slowMo: 50,
slowMo: 50,
},
lighthouseOptions: {
// allow storage to persist between pages
disableStorageReset: true,
},
hooks: {
'puppeteer:before-goto': async (page) => {
// login to the page
// login to the page
await page.goto('https://example.com/login')
const emailInput = await page.$('input[type="email"]');
await emailInput.type('admin@example.com');
const passwordInput = await page.$('input[type="password"]');
await passwordInput.type('password');
const emailInput = await page.$('input[type="email"]')
await emailInput.type('admin@example.com')
const passwordInput = await page.$('input[type="password"]')
await passwordInput.type('password')
await Promise.all([
page.$eval('.login-form', form => form.submit()),
page.waitForNavigation(),
]);
])
},
},
}
Expand Down
16 changes: 8 additions & 8 deletions docs/content/1.guide/guides/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ You will need to remove the Chrome sandbox in a Docker environment, this will re
// unlighthouse.config.ts
export default {
puppeteerOptions: {
args: ["--no-sandbox", "--disable-setuid-sandbox"],
args: ['--no-sandbox', '--disable-setuid-sandbox'],
},
}
```
Expand All @@ -27,14 +27,14 @@ the reports are finished.
```ts
// unlighthouse.config.ts
export default {
server: {
open: false,
},
hooks: {
'worker-finished': async () => {
process.exit(0);
}
server: {
open: false,
},
hooks: {
'worker-finished': async () => {
process.exit(0)
}
}
}
```

Expand Down
4 changes: 2 additions & 2 deletions docs/content/1.guide/guides/generating-static-reports.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ jobs:
- name: Deploy report to Netlify
uses: nwtgck/actions-netlify@v1.2
with:
publish-dir: './.unlighthouse'
publish-dir: ./.unlighthouse
production-branch: main
production-deploy: true
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "New Release Deploy from GitHub Actions"
deploy-message: New Release Deploy from GitHub Actions
enable-pull-request-comment: false
enable-commit-comment: true
overwrites-pull-request-comment: true
Expand Down
24 changes: 12 additions & 12 deletions docs/content/1.guide/guides/puppeteer.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ let token
export default {
hooks: {
'puppeteer:before-goto': async (page) => {
if (!token) {
if (!token)
token = await generateToken()
}

// set authentication token when we load a new page
await page.evaluateOnNewDocument(token => {
localStorage.clear()
localStorage.setItem('token', token)
}, token
)
await page.evaluateOnNewDocument((token) => {
localStorage.clear()
localStorage.setItem('token', token)
}, token
)
},
},
}
Expand All @@ -49,14 +49,14 @@ export default {
export default {
hooks: {
'puppeteer:before-goto': async (page) => {
let deleteSelector= ".VPNav";
const deleteSelector = '.VPNav'
page.waitForNavigation().then(async () => {
await page.waitForTimeout(1000)
await page.evaluate((sel) => {
const elements = document.querySelectorAll(sel);
for(let i=0; i< elements.length; i++){
elements[i].parentNode.removeChild(elements[i]);
}
const elements = document.querySelectorAll(sel)
for (let i = 0; i < elements.length; i++)
elements[i].parentNode.removeChild(elements[i])

}, deleteSelector)
})
}
Expand Down
2 changes: 1 addition & 1 deletion docs/content/1.guide/recipes/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ See the [glossary guide](/api/glossary/#columns) for the columns to understand t
```ts
export default {
hooks: {
'resolved-config'(config) {
'resolved-config': function (config) {
// replace FCP column with server response time
config.client.columns.performance[2] = {
cols: 1,
Expand Down
2 changes: 1 addition & 1 deletion docs/content/1.guide/recipes/improving-accuracy.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ performance scores as the extra workload will affect performance metrics.
```ts
export default {
puppeteerClusterOptions: {
// only run 1 worker at a time
// only run 1 worker at a time
maxConcurrency: 1
}
}
Expand Down
1 change: 0 additions & 1 deletion docs/content/2.integrations/0.cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ See the [Configuration](#configuration) section for more details and the guides.
If you want to configure Unlighthouse, you can create a `unlighthouse.config.ts` file in your cwd.

```ts unlighthouse.config.ts

export default {
site: 'example.com',
debug: true,
Expand Down
7 changes: 3 additions & 4 deletions docs/content/2.integrations/1.ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ export default {
site: 'https://example.com',
ci: {
budget: {
performance: 50,
accessibility: 100,
'performance': 50,
'accessibility': 100,
'best-practices': 90,
seo: 90,
'seo': 90,
}
}
}
Expand Down Expand Up @@ -130,7 +130,6 @@ Configuring the CLI can be done either through the CI arguments or through a con
If you want to configure Unlighthouse, you can create a `unlighthouse.config.ts` file in your cwd.

```ts unlighthouse.config.ts

export default {
site: 'example.com',
debug: true,
Expand Down
4 changes: 2 additions & 2 deletions docs/content/2.integrations/4.vite.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ export default defineConfig({
onRoutesGenerated(routes) {
// tell Unlighthouse about the routes
const unlighthouse = useUnlighthouse()
if (unlighthouse?.hooks) {
if (unlighthouse?.hooks)
hooks.callHook('route-definitions-provided', routes)
}

}
}),
]
Expand Down
6 changes: 3 additions & 3 deletions docs/content/3.api/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface Provider {
* The collection of route definitions belonging to the provider. These can be inferred but aren't 100% correct,
* frameworks that can provide these should do so.
*/
routeDefinitions?: RouteDefinition[]|(() => RouteDefinition[]|Promise<RouteDefinition[]>)
routeDefinitions?: RouteDefinition[] | (() => RouteDefinition[] | Promise<RouteDefinition[]>)
}
```

Expand Down Expand Up @@ -201,12 +201,12 @@ See [cluster.task(fn)](https://github.com/thomasdondorf/puppeteer-cluster) for m
/**
* Tasks that Unlighthouse will run, used to track their status.
*/
export type UnlighthouseTask = 'inspectHtmlTask'|'runLighthouseTask'
export type UnlighthouseTask = 'inspectHtmlTask' | 'runLighthouseTask'

/**
* Each task ran by unlighthouse (extractHtmlPayload, runLighthouseTask) has a specific status which we can expose.
*/
export type UnlighthouseTaskStatus = 'waiting'|'in-progress'|'completed'|'failed'
export type UnlighthouseTaskStatus = 'waiting' | 'in-progress' | 'completed' | 'failed'
```
## Client
Expand Down
16 changes: 10 additions & 6 deletions docs/content/3.api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ Functions exposed from the `@unlighthouse/core` package.
// config
{ configFile: 'mysite.config.ts' },
// provider
{
name: 'custom',
// some custom implementation to find the route definitions
routeDefinitions: () => generateRouteDefinitions(),
{
name: 'custom',
// some custom implementation to find the route definitions
routeDefinitions: () => generateRouteDefinitions(),
}
)
```
Expand Down Expand Up @@ -53,6 +53,7 @@ Functions exposed from the `@unlighthouse/core` package.

```ts
import { generateClient } from '@unlighthouse/core'
// ...
logger.info('Generating static client.')
await generateClient({ static: true })
Expand All @@ -68,6 +69,7 @@ Functions exposed from the `@unlighthouse/core` package.

```ts
import { useUnlighthouse } from '@unlighthouse/core'
// access the lighthouse context, pick out the worker
const { worker } = useUnlighthouse()
// force whichever route matches home.md to be re-scanned
Expand All @@ -83,6 +85,7 @@ Functions exposed from the `@unlighthouse/core` package.

```ts
import { useLogger } from '@unlighthouse/core'
// you need to instantiate the logger to get the instance
const logger = useLogger()
// force whichever route matches home.md to be re-scanned
Expand All @@ -105,6 +108,7 @@ running Unlighthouse with the `cli` provider will use this package.

```ts
import { createServer } from '@unlighthouse/server'
// ...
const { server, app } = await createServer()
// server is an instance of listhen, app is an instance of h3
Expand Down Expand Up @@ -147,7 +151,7 @@ Unlighthouse provides hooks using [hookable](https://github.com/unjs/hookable) w
Hooks can be accessed on the `hooks` property of the context and will always return a `Promise<void>|void`.
```ts
export type HookResult = Promise<void>|void
export type HookResult = Promise<void> | void
```

```ts
Expand All @@ -156,7 +160,7 @@ import { useUnlighthouse } from '@unlighthouse/core'
const { hooks } = useUnlighthouse()

hooks.hook('task-complete', (path, response) => {
console.log('task is finished at path', path)
console.log('task is finished at path', path)
})
```
Expand Down

0 comments on commit f60a5a2

Please sign in to comment.