Skip to content

Commit

Permalink
ci: format with prettier (#329)
Browse files Browse the repository at this point in the history
* ci: format with prettier

* chore: disable "only changed" just for this PR

* Format with prettier

* chore: re-enable only_changed for future PRs

* chore: move prettier into existing lint workflow

* chore: format with prettier

* chore: don't clean node_modules

* chore: format with prettier

---------

Co-authored-by: ascorbic <[email protected]>
  • Loading branch information
ascorbic and ascorbic authored Mar 4, 2024
1 parent b0cc3cd commit fcf0afe
Show file tree
Hide file tree
Showing 84 changed files with 4,855 additions and 2,217 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,24 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18.x'
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- run: npm ci
- name: Prettify code
uses: creyD/[email protected]
with:
prettier_options: --write .
only_changed: true
commit_message: 'chore: format with prettier'
clean_node_folder: false

- name: Lint
# github adds inline annotation for compact or stylish format
# which is different than our default for local usage
Expand Down
12 changes: 11 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
dist/
demo/
.next
playwright-report/
.netlify
CHANGELOG.md
package-lock.json
package.json
edge-runtime/vendor/
deno.lock
tests/fixtures/simple-next-app-dist-dir/cool/output
.nx
custom-dist-dir
35 changes: 22 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
🎉 Thanks for considering contributing to this project! 🎉

When contributing to this repository, please first discuss the change you wish to make via an
[issue](https://github.com/netlify/next-runtime/issues/new/choose). Please use the issue templates. They are there to
help you and to help the maintainers gather information.
[issue](https://github.com/netlify/next-runtime/issues/new/choose). Please use the issue templates.
They are there to help you and to help the maintainers gather information.

Before working on an issue, ask to be assigned to it. This makes it clear to other potential contributors that someone
is working on the issue.
Before working on an issue, ask to be assigned to it. This makes it clear to other potential
contributors that someone is working on the issue.

When creating a PR, please use the template. The information in the template helps maintainers review your pull request.```
When creating a PR, please use the template. The information in the template helps maintainers
review your pull request.```

This project was made with ❤️. The simplest way to give back is by starring and sharing it online.

Everyone is welcome regardless of personal background. We enforce a [Code of conduct](CODE_OF_CONDUCT.md) in order to
promote a positive and inclusive environment.
Everyone is welcome regardless of personal background. We enforce a
[Code of conduct](CODE_OF_CONDUCT.md) in order to promote a positive and inclusive environment.

## Development process

Expand All @@ -35,7 +36,8 @@ npm test

## How to write commit messages

We use [Conventional Commit messages](https://www.conventionalcommits.org/) to automate version management.
We use [Conventional Commit messages](https://www.conventionalcommits.org/) to automate version
management.

Most common commit message prefixes are:

Expand All @@ -45,15 +47,22 @@ Most common commit message prefixes are:

## Releasing

This repository uses [release-please](https://github.com/googleapis/release-please) to automate its releases.
This repository uses [release-please](https://github.com/googleapis/release-please) to automate its
releases.

## How to make a minimal reproduction

A reproducible test case is a small Next.js site built to demonstrate a problem - often this problem is caused by a bug in Next.js, next-runtime or user code. Your reproducible test case should contain the bare minimum features needed to clearly demonstrate the bug.
A reproducible test case is a small Next.js site built to demonstrate a problem - often this problem
is caused by a bug in Next.js, next-runtime or user code. Your reproducible test case should contain
the bare minimum features needed to clearly demonstrate the bug.

Steps to create a reproducible test case:

- Create a new Next.js site: `npx create-next-app@latest`
- Add any code or functionality related to the issue. For example, if you have problems with middleware functionality you should add all the necessary code of your middleware.
- Verify that you're seeing the expected error(s) when running `netlify serve` and on a deployed version on [Netlify](https://www.netlify.com)
- Publish the code (your GitHub account is a good place to do this) and then link to it when creating an issue. While creating the issue, please give as many details as possible. This could also include screenshots of error messages.
- Add any code or functionality related to the issue. For example, if you have problems with
middleware functionality you should add all the necessary code of your middleware.
- Verify that you're seeing the expected error(s) when running `netlify serve` and on a deployed
version on [Netlify](https://www.netlify.com)
- Publish the code (your GitHub account is a good place to do this) and then link to it when
creating an issue. While creating the issue, please give as many details as possible. This could
also include screenshots of error messages.
38 changes: 30 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"build": "node ./tools/build.js",
"build:watch": "node ./tools/build.js --watch",
"lint": "eslint --cache --format=codeframe --max-warnings=0 --ext .ts,.cts,.js src",
"format:fix": "prettier --write .",
"format:check": "prettier --check .",
"test": "vitest",
"test:ci": "vitest run --reporter=default --retry=3",
"typecheck": "tsc --noEmit",
Expand Down Expand Up @@ -78,6 +80,7 @@
"p-limit": "^4.0.0",
"path-to-regexp": "^6.2.1",
"picomatch": "^3.0.1",
"prettier": "^3.2.5",
"regexp-tree": "^0.1.27",
"typescript": "^5.1.6",
"unionfs": "^4.5.1",
Expand Down
4 changes: 1 addition & 3 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>netlify/renovate-config"
]
"extends": ["local>netlify/renovate-config"]
}
14 changes: 12 additions & 2 deletions report/style.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
* {
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font-family:
system-ui,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
Oxygen,
Ubuntu,
Cantarell,
'Open Sans',
'Helvetica Neue',
sans-serif;
}

.test-results {
Expand Down
4 changes: 1 addition & 3 deletions tests/fixtures/middleware-i18n/pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
export default function App({ Component, pageProps }) {
if (!pageProps || typeof pageProps !== 'object') {
throw new Error(
`Invariant: received invalid pageProps in _app, received ${pageProps}`
)
throw new Error(`Invariant: received invalid pageProps in _app, received ${pageProps}`)
}
return <Component {...pageProps} />
}
14 changes: 3 additions & 11 deletions tests/fixtures/middleware-i18n/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,15 @@ export default function Home() {
<div />
<Link href="/blank-page?foo=bar">Redirect me with URL params intact</Link>
<div />
<Link href="/redirect-to-google">
Redirect me to Google (with no body response)
</Link>
<Link href="/redirect-to-google">Redirect me to Google (with no body response)</Link>
<div />
<Link href="/redirect-to-google">
Redirect me to Google (with no stream response)
</Link>
<Link href="/redirect-to-google">Redirect me to Google (with no stream response)</Link>
<div />
<Link href="/redirect-me-alot">Redirect me alot (chained requests)</Link>
<div />
<Link href="/infinite-loop">Redirect me alot (infinite loop)</Link>
<div />
<Link
href="/to?pathname=/api/ok"
locale="nl"
id="link-to-api-with-locale"
>
<Link href="/to?pathname=/api/ok" locale="nl" id="link-to-api-with-locale">
Redirect me to api with locale
</Link>
<div />
Expand Down
3 changes: 1 addition & 2 deletions tests/fixtures/middleware-pages/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ export async function middleware(request) {
'req-url-pathname': request.nextUrl.pathname,
'req-url-query': request.nextUrl.searchParams.get('foo'),
'req-url-locale': request.nextUrl.locale,
'req-url-params':
url.pathname !== '/static' ? JSON.stringify(params(request.url)) : '{}',
'req-url-params': url.pathname !== '/static' ? JSON.stringify(params(request.url)) : '{}',
},
})
}
Expand Down
4 changes: 1 addition & 3 deletions tests/fixtures/middleware-pages/pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
export default function App({ Component, pageProps }) {
if (!pageProps || typeof pageProps !== 'object') {
throw new Error(
`Invariant: received invalid pageProps in _app, received ${pageProps}`
)
throw new Error(`Invariant: received invalid pageProps in _app, received ${pageProps}`)
}
return <Component {...pageProps} />
}
10 changes: 2 additions & 8 deletions tests/fixtures/middleware-pages/pages/html-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@ export default function Page() {
return (
<ul>
<li>
<Link
id="with-html"
href="/product/shirts_and_tops/mens_ua_playoff_polo_2.0/1327037.html"
>
<Link id="with-html" href="/product/shirts_and_tops/mens_ua_playoff_polo_2.0/1327037.html">
Does not work
</Link>
</li>
<li>
<Link
id="without-html"
href="/product/shirts_and_tops/mens_ua_playoff_polo_2.0/1327037"
>
<Link id="without-html" href="/product/shirts_and_tops/mens_ua_playoff_polo_2.0/1327037">
Works
</Link>
</li>
Expand Down
4 changes: 1 addition & 3 deletions tests/fixtures/middleware-pages/pages/ssg/[slug].js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { useState } from 'react'

export default function Page(props) {
const router = useRouter()
const [asPath, setAsPath] = useState(
router.isReady ? router.asPath : router.href
)
const [asPath, setAsPath] = useState(router.isReady ? router.asPath : router.href)

useEffect(() => {
if (router.isReady) {
Expand Down
16 changes: 3 additions & 13 deletions tests/fixtures/middleware-pages/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"compilerOptions": {
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
Expand All @@ -17,12 +13,6 @@
"isolatedModules": true,
"jsx": "preserve"
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
],
"exclude": [
"node_modules"
]
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
4 changes: 2 additions & 2 deletions tests/fixtures/middleware/app/og.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ export default function og() {
>
Open Graph
</div>
)
),
)
}
}
2 changes: 1 addition & 1 deletion tests/fixtures/middleware/app/opengraph-image.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const alt = 'Open Graph'

export { default } from './og'
export { default } from './og'
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export async function GET(request: Request) {
return new Response('Hello, from API!');
return new Response('Hello, from API!')
}
Loading

0 comments on commit fcf0afe

Please sign in to comment.