Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jun 5, 2022
1 parent 33359ce commit 7bcf6ec
Show file tree
Hide file tree
Showing 62 changed files with 304 additions and 299 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist/
*.svelte
18 changes: 14 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{
"extends": "@antfu/eslint-config",
"rules": {
"@typescript-eslint/no-unused-vars": "off"
}
"extends": "@antfu",
"overrides": [
{
"files": [
"**/*.md/*.*"
],
"rules": {
"@typescript-eslint/no-this-alias": "off",
"n/handle-callback-err": "off",
"no-restricted-syntax": "off",
"no-labels": "off"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export default defineConfig({
plugins: [
VitePWA({
workbox: {
cleanupOutdatedCaches: false
}
cleanupOutdatedCaches: false
}
})
]
]
})
```
6 changes: 3 additions & 3 deletions docs/.vitepress/theme/components/GenerateSWSourceMap.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export default defineConfig({
plugins: [
VitePWA({
workbox: {
sourcemap: true
}
sourcemap: true
}
})
]
]
})
```
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ also the old ones. To delete old assets (from previous versions that are no long
building your own service worker, you will need to add the following code to your custom service worker:

```js
import { precacheAndRoute, cleanupOutdatedCaches } from 'workbox-precaching'
import { cleanupOutdatedCaches, precacheAndRoute } from 'workbox-precaching'

cleanupOutdatedCaches()

Expand Down
5 changes: 2 additions & 3 deletions docs/.vitepress/theme/components/SsrSsg.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ You can register the service worker on `src/pwa.ts` module:
```ts
import { registerSW } from 'virtual:pwa-register'

registerSW({ ... })
registerSW({ /* ... */ })
```

and then import it from your `main.ts`:

```ts
if (typeof window !== 'undefined') {
if (typeof window !== 'undefined')
import('./pwa')
}
```

You can see the [FAQ](/guide/faq.md#navigator-window-is-undefined) entry for more info.
3 changes: 0 additions & 3 deletions docs/.vitepress/theme/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-namespace */

export namespace DefaultTheme {
export interface Config {
logo?: string
Expand Down
15 changes: 7 additions & 8 deletions docs/frameworks/preact.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ You can use the built-in `Vite` virtual module `virtual:pwa-register/preact` for

```ts
declare module 'virtual:pwa-register/preact' {
// @ts-ignore ignore when preact/hooks is not installed
// @ts-expect-error ignore when preact/hooks is not installed
import type { StateUpdater } from 'preact/hooks'

export interface RegisterSWOptions {
Expand All @@ -40,7 +40,6 @@ You can use this `ReloadPrompt.tsx` component:
<summary><strong>ReloadPrompt.tsx</strong> code</summary>

```tsx
// eslint-disable-next-line no-use-before-define
import './ReloadPrompt.css'

import { useRegisterSW } from 'virtual:pwa-register/preact'
Expand All @@ -52,11 +51,11 @@ function ReloadPrompt() {
updateServiceWorker,
} = useRegisterSW({
onRegistered(r) {
// eslint-disable-next-line prefer-template
console.log('SW Registered: ' + r)
// eslint-disable-next-line prefer-template
console.log('SW Registered: ' + r)
},
onRegisterError(error) {
console.log('SW registration error', error)
console.log('SW registration error', error)
},
})

Expand All @@ -71,8 +70,8 @@ function ReloadPrompt() {
&& <div className="ReloadPrompt-toast">
<div className="ReloadPrompt-message">
{ offlineReady
? <span>App ready to work offline</span>
: <span>New content available, click on reload button to update.</span>
? <span>App ready to work offline</span>
: <span>New content available, click on reload button to update.</span>
}
</div>
{ needRefresh && <button className="ReloadPrompt-toast-button" onClick={() => updateServiceWorker(true)}>Reload</button> }
Expand Down Expand Up @@ -131,7 +130,7 @@ As explained in [Periodic Service Worker Updates](/guide/periodic-sw-updates.htm
behavior on your application with the virtual module `virtual:pwa-register/preact`:

```ts
import { useRegisterSW } from 'virtual:pwa-register/preact';
import { useRegisterSW } from 'virtual:pwa-register/preact'

const intervalMS = 60 * 60 * 1000

Expand Down
15 changes: 7 additions & 8 deletions docs/frameworks/react.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ You can use the built-in `Vite` virtual module `virtual:pwa-register/react` for

```ts
declare module 'virtual:pwa-register/react' {
// @ts-ignore ignore when react is not installed
// @ts-expect-error ignore when react is not installed
import type { Dispatch, SetStateAction } from 'react'

export interface RegisterSWOptions {
Expand All @@ -40,7 +40,6 @@ You can use this `ReloadPrompt.tsx` component:
<summary><strong>ReloadPrompt.tsx</strong> code</summary>

```tsx
// eslint-disable-next-line no-use-before-define
import React from 'react'
import './ReloadPrompt.css'

Expand All @@ -53,11 +52,11 @@ function ReloadPrompt() {
updateServiceWorker,
} = useRegisterSW({
onRegistered(r) {
// eslint-disable-next-line prefer-template
console.log('SW Registered: ' + r)
// eslint-disable-next-line prefer-template
console.log('SW Registered: ' + r)
},
onRegisterError(error) {
console.log('SW registration error', error)
console.log('SW registration error', error)
},
})

Expand All @@ -72,8 +71,8 @@ function ReloadPrompt() {
&& <div className="ReloadPrompt-toast">
<div className="ReloadPrompt-message">
{ offlineReady
? <span>App ready to work offline</span>
: <span>New content available, click on reload button to update.</span>
? <span>App ready to work offline</span>
: <span>New content available, click on reload button to update.</span>
}
</div>
{ needRefresh && <button className="ReloadPrompt-toast-button" onClick={() => updateServiceWorker(true)}>Reload</button> }
Expand Down Expand Up @@ -132,7 +131,7 @@ As explained in [Periodic Service Worker Updates](/guide/periodic-sw-updates.htm
behavior on your application with the virtual module `virtual:pwa-register/react`:

```ts
import { useRegisterSW } from 'virtual:pwa-register/react';
import { useRegisterSW } from 'virtual:pwa-register/react'

const intervalMS = 60 * 60 * 1000

Expand Down
29 changes: 14 additions & 15 deletions docs/frameworks/solidjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ You can use the built-in `Vite` virtual module `virtual:pwa-register/solid` for

```ts
declare module 'virtual:pwa-register/solid' {
// @ts-ignore ignore when solid-js is not installed
// @ts-expect-error ignore when solid-js is not installed
import type { Accessor, Setter } from 'solid-js'

export interface RegisterSWOptions {
Expand All @@ -40,24 +40,23 @@ You can use this `ReloadPrompt.tsx` component:
<summary><strong>ReloadPrompt.tsx</strong> code</summary>

```tsx
// eslint-disable-next-line no-use-before-define
import { Component, Show } from "solid-js";
import styles from './ReloadPrompt.module.css'

import type { Component } from 'solid-js'
import { Show } from 'solid-js'
import { useRegisterSW } from 'virtual:pwa-register/solid'
import styles from './ReloadPrompt.module.css'

const ReloadPrompt: Component = () => {
const ReloadPrompt: Component = () => {
const {
offlineReady: [offlineReady, setOfflineReady],
needRefresh: [needRefresh, setNeedRefresh],
updateServiceWorker,
} = useRegisterSW({
onRegistered(r) {
// eslint-disable-next-line prefer-template
console.log('SW Registered: ' + r)
// eslint-disable-next-line prefer-template
console.log('SW Registered: ' + r)
},
onRegisterError(error) {
console.log('SW registration error', error)
console.log('SW registration error', error)
},
})

Expand All @@ -67,10 +66,10 @@ const ReloadPrompt: Component = () => {
}

return (
<div class={styles.Container}>
<div className={styles.Container}>
<Show when={offlineReady() || needRefresh()}>
<div class={styles.Toast}>
<div class={styles.Message}>
<div className={styles.Toast}>
<div className={styles.Message}>
<Show
fallback={<span>New content available, click on reload button to update.</span>}
when={offlineReady()}
Expand All @@ -79,9 +78,9 @@ const ReloadPrompt: Component = () => {
</Show>
</div>
<Show when={needRefresh()}>
<button class={styles.ToastButton} onClick={() => updateServiceWorker(true)}>Reload</button>
<button className={styles.ToastButton} onClick={() => updateServiceWorker(true)}>Reload</button>
</Show>
<button class={styles.ToastButton} onClick={() => close()}>Close</button>
<button className={styles.ToastButton} onClick={() => close()}>Close</button>
</div>
</Show>
</div>
Expand Down Expand Up @@ -136,7 +135,7 @@ As explained in [Periodic Service Worker Updates](/guide/periodic-sw-updates.htm
behavior on your application with the virtual module `virtual:pwa-register/solid`:

```ts
import { useRegisterSW } from 'virtual:pwa-register/solid';
import { useRegisterSW } from 'virtual:pwa-register/solid'

const intervalMS = 60 * 60 * 1000

Expand Down
4 changes: 2 additions & 2 deletions docs/frameworks/svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ You can use the built-in `Vite` virtual module `virtual:pwa-register/svelte` for

```ts
declare module 'virtual:pwa-register/svelte' {
// @ts-ignore ignore when svelte is not installed
// @ts-expect-error ignore when svelte is not installed
import type { Writable } from 'svelte/store'

export interface RegisterSWOptions {
Expand Down Expand Up @@ -121,7 +121,7 @@ As explained in [Periodic Service Worker Updates](/guide/periodic-sw-updates.htm
behavior on your application with the virtual module `virtual:pwa-register/svelte`:

```ts
import { useRegisterSW } from 'virtual:pwa-register/svelte';
import { useRegisterSW } from 'virtual:pwa-register/svelte'

const intervalMS = 60 * 60 * 1000

Expand Down

0 comments on commit 7bcf6ec

Please sign in to comment.