Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jul 7, 2024
1 parent a75516b commit 26e1e07
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ export async function build(ssgOptions: Partial<ViteSSGOptions> = {}, viteConfig

async function detectEntry(root: string) {
// pick the first script tag of type module as the entry
const scriptSrcReg = /<script(?:.*?)src=["'](.+?)["'](?!<)(?:.*)\>(?:[\n\r\s]*?)(?:<\/script>)/img
// eslint-disable-next-line regexp/no-super-linear-backtracking
const scriptSrcReg = /<script.*?src=["'](.+?)["'](?!<).*>\s*<\/script>/gi
const html = await fs.readFile(join(root, 'index.html'), 'utf-8')
const scripts = [...html.matchAll(scriptSrcReg)] || []
const [, entry] = scripts.find((matchResult) => {
Expand Down
2 changes: 1 addition & 1 deletion src/node/cli.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable no-unused-expressions */
import process from 'node:process'
import { bold, gray, red, reset, underline } from 'kolorist'
import yargs from 'yargs'
import { hideBin } from 'yargs/helpers'
import { build } from './build'

// eslint-disable-next-line ts/no-unused-expressions
yargs(hideBin(process.argv))
.scriptName('vite-ssg')
.usage('$0 [args]')
Expand Down
2 changes: 1 addition & 1 deletion src/node/critical.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export async function getCritters(outDir: string, options: Options = {}): Promis
...options,
})
}
catch (e) {
catch {
return undefined
}
}
3 changes: 2 additions & 1 deletion src/node/jsdomGlobal.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ export function jsdomGlobal(html = defaultHtml, options = {}) {
&& global.navigator.userAgent
&& global.navigator.userAgent.includes('Node.js')
&& global.document
&& typeof global.document.destroy === 'function')
&& typeof global.document.destroy === 'function') {
return global.document.destroy
}

// set a default url if we don't get one - otherwise things explode when we copy localstorage keys
if (!('url' in options))
Expand Down
2 changes: 1 addition & 1 deletion src/utils/state.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// https://github.com/yahoo/serialize-javascript
const UNSAFE_CHARS_REGEXP = /[<>\/\u2028\u2029]/g
const UNSAFE_CHARS_REGEXP = /[<>/\u2028\u2029]/g
const ESCAPED_CHARS = {
'<': '\\u003C',
'>': '\\u003E',
Expand Down

0 comments on commit 26e1e07

Please sign in to comment.