Skip to content

Commit

Permalink
improve prettier config
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Aug 23, 2022
1 parent 9947e6a commit 91633fb
Show file tree
Hide file tree
Showing 264 changed files with 1,125 additions and 1,133 deletions.
2 changes: 1 addition & 1 deletion .libframe-submodule/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exec('git submodule status libframe', { cwd: `${__dirname}/..` }, (err, stdout,
'',
'❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗',
'❗❗❗ SETUP MISSING: run `pnpm run setup` before running `pnpm install`. ❗❗❗',
'❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗',
'❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗❗'
].join('\n')
console.log(errMsg)
process.exit(1)
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ semi: false
tabWidth: 2
singleQuote: true
printWidth: 120
trailingComma: all
trailingComma: none
34 changes: 17 additions & 17 deletions boilerplates/.testRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
expectBrowserError,
editFile,
editFileRevert,
sleep,
sleep
} from '../libframe/test/setup'
import assert from 'assert'

Expand All @@ -21,14 +21,14 @@ function testRun(
noDefaultPageInUserCode,
isPrerendered,
uiFramewok,
lang,
lang
}: {
skipCssTest?: boolean
noDefaultPageInUserCode?: true
isPrerendered?: true
uiFramewok: 'react' | 'vue' | 'preact'
lang?: 'ts'
},
}
) {
run(cmd)

Expand Down Expand Up @@ -59,54 +59,54 @@ function testRun(
const hashRegexp = /[a-z0-9]+/
expect(html).toMatch(partRegex`<link rel="icon" href="/assets/logo.${hashRegexp}.svg" />`)
expect(html).toMatch(
partRegex`<link rel="preload" href="/assets/logo.${hashRegexp}.svg" as="image" type="image/svg+xml">`,
partRegex`<link rel="preload" href="/assets/logo.${hashRegexp}.svg" as="image" type="image/svg+xml">`
)

try {
expect(html).toMatch(
partRegex`<script type="module" src="/assets/entry-client-routing.${hashRegexp}.js" async>`,
partRegex`<script type="module" src="/assets/entry-client-routing.${hashRegexp}.js" async>`
)
expect(html).toMatch(
partRegex`<link rel="modulepreload" as="script" type="text/javascript" href="/assets/entry-client-routing.${hashRegexp}.js">`,
partRegex`<link rel="modulepreload" as="script" type="text/javascript" href="/assets/entry-client-routing.${hashRegexp}.js">`
)
} catch (err) {
expect(html).toMatch(
partRegex`<script type="module" src="/assets/entry-server-routing.${hashRegexp}.js" async>`,
partRegex`<script type="module" src="/assets/entry-server-routing.${hashRegexp}.js" async>`
)
expect(html).toMatch(
partRegex`<link rel="modulepreload" as="script" type="text/javascript" href="/assets/entry-server-routing.${hashRegexp}.js">`,
partRegex`<link rel="modulepreload" as="script" type="text/javascript" href="/assets/entry-server-routing.${hashRegexp}.js">`
)
}

expect(html).toMatch(
partRegex`<link rel="modulepreload" as="script" type="text/javascript" href="/assets/chunk-${hashRegexp}.js">`,
partRegex`<link rel="modulepreload" as="script" type="text/javascript" href="/assets/chunk-${hashRegexp}.js">`
)
expect(html).toMatch(
partRegex`<link rel="modulepreload" as="script" type="text/javascript" href="/assets/pages/index/index.page.${hashRegexp}.js">`,
partRegex`<link rel="modulepreload" as="script" type="text/javascript" href="/assets/pages/index/index.page.${hashRegexp}.js">`
)
expect(html).not.toMatch(
partRegex`<link rel="modulepreload" as="script" type="text/javascript" href="/assets/pages/about/index.page.${hashRegexp}.js">`,
partRegex`<link rel="modulepreload" as="script" type="text/javascript" href="/assets/pages/about/index.page.${hashRegexp}.js">`
)
if (!noDefaultPageInUserCode) {
try {
expect(html).toMatch(
partRegex`<link rel="stylesheet" type="text/css" href="/assets/PageShell.${hashRegexp}.css">`,
partRegex`<link rel="stylesheet" type="text/css" href="/assets/PageShell.${hashRegexp}.css">`
)
} catch {
try {
// Vite 2
expect(html).toMatch(
partRegex`<link rel="stylesheet" type="text/css" href="/assets/renderer/_default.page.client.${hashRegexp}.css">`,
partRegex`<link rel="stylesheet" type="text/css" href="/assets/renderer/_default.page.client.${hashRegexp}.css">`
)
} catch {
// Vite 3 (not sure why it differs from Vite 2)
expect(html).toMatch(
partRegex`<link rel="stylesheet" type="text/css" href="/assets/_default.page.client.${hashRegexp}.css">`,
partRegex`<link rel="stylesheet" type="text/css" href="/assets/_default.page.client.${hashRegexp}.css">`
)
}
}
expect(html).toMatch(
partRegex`<link rel="modulepreload" as="script" type="text/javascript" href="/assets/renderer/_default.page.client.${hashRegexp}.js">`,
partRegex`<link rel="modulepreload" as="script" type="text/javascript" href="/assets/renderer/_default.page.client.${hashRegexp}.js">`
)
}
}
Expand Down Expand Up @@ -170,7 +170,7 @@ function testRun(
// Not sure why `autoRetry()` is needed here; isn't the CSS loading already awaited for in the previous `test()` call?
await autoRetry(async () => {
expect(await page.$eval('a[href="/about"]', (e) => getComputedStyle(e).backgroundColor)).toBe(
'rgb(238, 238, 238)',
'rgb(238, 238, 238)'
)
expect(await page.$eval('a[href="/"]', (e) => getComputedStyle(e).backgroundColor)).toBe('rgba(0, 0, 0, 0)')
})
Expand All @@ -184,7 +184,7 @@ function testRun(
expectBrowserError(
(browserLog) =>
partRegex`http://${/[^\/]+/}:3000/does-not-exist`.test(browserLog.logText) &&
browserLog.logText.includes('Failed to load resource: the server responded with a status of 404 (Not Found)'),
browserLog.logText.includes('Failed to load resource: the server responded with a status of 404 (Not Found)')
)
})
}
Expand Down
8 changes: 4 additions & 4 deletions boilerplates/boilerplate-react-ts/renderer/PageShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function Layout({ children }: { children: React.ReactNode }) {
style={{
display: 'flex',
maxWidth: 900,
margin: 'auto',
margin: 'auto'
}}
>
{children}
Expand All @@ -51,7 +51,7 @@ function Sidebar({ children }: { children: React.ReactNode }) {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
lineHeight: '1.8em',
lineHeight: '1.8em'
}}
>
{children}
Expand All @@ -66,7 +66,7 @@ function Content({ children }: { children: React.ReactNode }) {
padding: 20,
paddingBottom: 50,
borderLeft: '2px solid #eee',
minHeight: '100vh',
minHeight: '100vh'
}}
>
{children}
Expand All @@ -79,7 +79,7 @@ function Logo() {
<div
style={{
marginTop: 20,
marginBottom: 10,
marginBottom: 10
}}
>
<a href="/">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async function render(pageContext: PageContextBuiltInClient & PageContext) {
document.getElementById('page-view')!,
<PageShell pageContext={pageContext}>
<Page {...pageProps} />
</PageShell>,
</PageShell>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function render(pageContext: PageContextBuiltIn & PageContext) {
const pageHtml = ReactDOMServer.renderToString(
<PageShell pageContext={pageContext}>
<Page {...pageProps} />
</PageShell>,
</PageShell>
)

// See https://vite-plugin-ssr.com/head
Expand All @@ -41,6 +41,6 @@ async function render(pageContext: PageContextBuiltIn & PageContext) {
documentHtml,
pageContext: {
// We can add some `pageContext` here, which is useful if we want to do page redirection https://vite-plugin-ssr.com/page-redirection
},
}
}
}
4 changes: 2 additions & 2 deletions boilerplates/boilerplate-react-ts/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ async function startServer() {
const viteDevMiddleware = (
await vite.createServer({
root,
server: { middlewareMode: 'ssr' },
server: { middlewareMode: 'ssr' }
})
).middlewares
app.use(viteDevMiddleware)
}

app.get('*', async (req, res, next) => {
const pageContextInit = {
urlOriginal: req.originalUrl,
urlOriginal: req.originalUrl
}
const pageContext = await renderPage(pageContextInit)
const { httpResponse } = pageContext
Expand Down
2 changes: 1 addition & 1 deletion boilerplates/boilerplate-react-ts/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ssr from 'vite-plugin-ssr/plugin'
import { UserConfig } from 'vite'

const config: UserConfig = {
plugins: [react(), ssr()],
plugins: [react(), ssr()]
}

export default config
8 changes: 4 additions & 4 deletions boilerplates/boilerplate-react/renderer/PageShell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function Layout({ children }) {
style={{
display: 'flex',
maxWidth: 900,
margin: 'auto',
margin: 'auto'
}}
>
{children}
Expand All @@ -50,7 +50,7 @@ function Sidebar({ children }) {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
lineHeight: '1.8em',
lineHeight: '1.8em'
}}
>
{children}
Expand All @@ -65,7 +65,7 @@ function Content({ children }) {
padding: 20,
paddingBottom: 50,
borderLeft: '2px solid #eee',
minHeight: '100vh',
minHeight: '100vh'
}}
>
{children}
Expand All @@ -78,7 +78,7 @@ function Logo() {
<div
style={{
marginTop: 20,
marginBottom: 10,
marginBottom: 10
}}
>
<a href="/">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async function render(pageContext) {
document.getElementById('page-view'),
<PageShell pageContext={pageContext}>
<Page {...pageProps} />
</PageShell>,
</PageShell>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async function render(pageContext) {
const pageHtml = ReactDOMServer.renderToString(
<PageShell pageContext={pageContext}>
<Page {...pageProps} />
</PageShell>,
</PageShell>
)

// See https://vite-plugin-ssr.com/head
Expand All @@ -39,6 +39,6 @@ async function render(pageContext) {
documentHtml,
pageContext: {
// We can add some `pageContext` here, which is useful if we want to do page redirection https://vite-plugin-ssr.com/page-redirection
},
}
}
}
4 changes: 2 additions & 2 deletions boilerplates/boilerplate-react/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ async function startServer() {
const viteDevMiddleware = (
await vite.createServer({
root,
server: { middlewareMode: 'ssr' },
server: { middlewareMode: 'ssr' }
})
).middlewares
app.use(viteDevMiddleware)
}

app.get('*', async (req, res, next) => {
const pageContextInit = {
urlOriginal: req.originalUrl,
urlOriginal: req.originalUrl
}
const pageContext = await renderPage(pageContextInit)
const { httpResponse } = pageContext
Expand Down
2 changes: 1 addition & 1 deletion boilerplates/boilerplate-react/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import react from '@vitejs/plugin-react'
import ssr from 'vite-plugin-ssr/plugin'

export default {
plugins: [react(), ssr()],
plugins: [react(), ssr()]
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ async function render(pageContext: PageContextBuiltIn & PageContext) {
documentHtml,
pageContext: {
// We can add some `pageContext` here, which is useful if we want to do page redirection https://vite-plugin-ssr.com/page-redirection
},
}
}
}
6 changes: 3 additions & 3 deletions boilerplates/boilerplate-vue-ts/renderer/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ function createApp(pageContext: PageContext) {
{
default() {
return h(Page, pageProps || {})
},
},
}
}
)
},
}
})

const app = createSSRApp(PageWithLayout)
Expand Down
4 changes: 2 additions & 2 deletions boilerplates/boilerplate-vue-ts/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ async function startServer() {
const viteDevMiddleware = (
await vite.createServer({
root,
server: { middlewareMode: 'ssr' },
server: { middlewareMode: 'ssr' }
})
).middlewares
app.use(viteDevMiddleware)
}

app.get('*', async (req, res, next) => {
const pageContextInit = {
urlOriginal: req.originalUrl,
urlOriginal: req.originalUrl
}
const pageContext = await renderPage(pageContextInit)
const { httpResponse } = pageContext
Expand Down
2 changes: 1 addition & 1 deletion boilerplates/boilerplate-vue-ts/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ssr from 'vite-plugin-ssr/plugin'
import { UserConfig } from 'vite'

const config: UserConfig = {
plugins: [vue(), ssr()],
plugins: [vue(), ssr()]
}

export default config
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ async function render(pageContext) {
documentHtml,
pageContext: {
// We can add some `pageContext` here, which is useful if we want to do page redirection https://vite-plugin-ssr.com/page-redirection
},
}
}
}
6 changes: 3 additions & 3 deletions boilerplates/boilerplate-vue/renderer/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ function createApp(pageContext) {
{
default() {
return h(Page, pageProps || {})
},
},
}
}
)
},
}
}

const app = createSSRApp(PageWithLayout)
Expand Down
4 changes: 2 additions & 2 deletions boilerplates/boilerplate-vue/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ async function startServer() {
const viteDevMiddleware = (
await vite.createServer({
root,
server: { middlewareMode: 'ssr' },
server: { middlewareMode: 'ssr' }
})
).middlewares
app.use(viteDevMiddleware)
}

app.get('*', async (req, res, next) => {
const pageContextInit = {
urlOriginal: req.originalUrl,
urlOriginal: req.originalUrl
}
const pageContext = await renderPage(pageContextInit)
const { httpResponse } = pageContext
Expand Down
2 changes: 1 addition & 1 deletion boilerplates/boilerplate-vue/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import vue from '@vitejs/plugin-vue'
import ssr from 'vite-plugin-ssr/plugin'

export default {
plugins: [vue(), ssr()],
plugins: [vue(), ssr()]
}
Loading

0 comments on commit 91633fb

Please sign in to comment.