Skip to content

Commit 2d9f18f

Browse files
authored
build: fix prettier configuration, reformat files, and run prettier in CI (#227)
* build: fix prettier configuration * style: reformat files with fixed prettier * ci: run prettier in CI * ci: rename format job * style: reformat again after rebasing
1 parent 2ce5919 commit 2d9f18f

File tree

18 files changed

+82
-52
lines changed

18 files changed

+82
-52
lines changed

.github/workflows/format.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Check formatting
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
types: [opened, synchronize, reopened]
7+
merge_group:
8+
jobs:
9+
format:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
- name: Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: lts/*
19+
cache: 'npm'
20+
- name: Install dependencies
21+
run: npm ci
22+
- name: Check formatting
23+
run: npm run format:ci

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ jobs:
4747
- name: Build
4848
run: npm run build --workspaces=true
4949
- name: Tests
50-
run: npm run test --workspaces=true
50+
run: npm run test --workspaces=true

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.circleci
2+
dist
23
coverage
4+
CHANGELOG.md

packages/cache/src/cache-status/cache-status.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,17 @@ export const parseCacheStatusValue = (value: string) => {
4242
const parts = value.split(';').map((part) => part.trim())
4343
const [namePart, ...attributeParts] = parts
4444
const name = (namePart ?? '').replace(/"/g, '').toLowerCase()
45-
const attributes = attributeParts.reduce((acc, part) => {
46-
const [key, value = ''] = part.split('=')
45+
const attributes = attributeParts.reduce(
46+
(acc, part) => {
47+
const [key, value = ''] = part.split('=')
4748

48-
return {
49-
...acc,
50-
[key]: value,
51-
}
52-
}, {} as Record<string, string>)
49+
return {
50+
...acc,
51+
[key]: value,
52+
}
53+
},
54+
{} as Record<string, string>,
55+
)
5356

5457
return {
5558
attributes,

packages/dev-utils/src/lib/base64.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import { shouldBase64Encode } from './base64.js'
44

55
describe('`shouldBase64Encode` helper', () => {
66
test('Returns `false` for `text/` content types', async () => {
7-
expect(shouldBase64Encode("text/html")).toBeFalsy()
7+
expect(shouldBase64Encode('text/html')).toBeFalsy()
88
})
9-
})
9+
})

packages/dev/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# @netlify/dev
22

3-
> [!WARNING]
4-
> This module is under active development and does **not** yet support all Netlify platform features.
3+
> [!WARNING] This module is under active development and does **not** yet support all Netlify platform features.
54
65
`@netlify/dev` is a local emulator for the Netlify production environment. While it can be used directly by advanced
76
users, it is primarily designed as a foundational library for higher-level tools like the

packages/dev/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export class NetlifyDev {
144144
publishDir: this.#config?.config.build.publish ?? undefined,
145145
logger: this.#logger,
146146
})
147-
: {handle: async (_request: Request, response: Response) => response}
147+
: { handle: async (_request: Request, response: Response) => response }
148148

149149
// Redirects
150150
const redirects = this.#features.redirects

packages/functions/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ To use Scheduled Functions, wrap your function handler with the `schedule` funct
6868
```ts
6969
import { schedule } from '@netlify/functions'
7070

71-
export const handler = schedule("5 4 * * *", async () => {
71+
export const handler = schedule('5 4 * * *', async () => {
7272
console.log("It's 04:05 AM!")
7373
})
7474
```

packages/functions/test/helpers/main.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@ export const invokeLambda = (handler, { method = 'GET', ...options } = {}) => {
1616
resolve(handler(event, {}, callback))
1717
})
1818
}
19-

packages/functions/test/helpers/mock_fetch.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import assert from "node:assert"
1+
import assert from 'node:assert'
22

33
export class MockFetch {
44
constructor() {

packages/otel/src/bootstrap/main.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { GET_TRACER, SHUTDOWN_TRACERS } from '../constants.js'
22

33
export const createTracerProvider = async (options: {
4-
headers: Headers,
5-
serviceName: string,
6-
serviceVersion: string,
7-
deploymentEnvironment: string,
8-
siteUrl: string,
9-
siteId: string,
10-
siteName: string,
4+
headers: Headers
5+
serviceName: string
6+
serviceVersion: string
7+
deploymentEnvironment: string
8+
siteUrl: string
9+
siteId: string
10+
siteName: string
1111
}) => {
1212
if (!options.headers.has('x-nf-enable-tracing')) {
1313
return
@@ -52,7 +52,7 @@ export const createTracerProvider = async (options: {
5252

5353
const { default: pkg } = await import('../../package.json', { with: { type: 'json' } })
5454
return new SugaredTracer(trace.getTracer(pkg.name, pkg.version))
55-
}
55+
},
5656
})
5757

5858
Object.defineProperty(globalThis, SHUTDOWN_TRACERS, {
@@ -61,7 +61,6 @@ export const createTracerProvider = async (options: {
6161
writable: false,
6262
value: async () => {
6363
return await nodeTracerProvider.shutdown()
64-
}
64+
},
6565
})
6666
}
67-

packages/otel/src/main.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { type SugaredTracer } from '@opentelemetry/api/experimental';
2-
import { GET_TRACER, SHUTDOWN_TRACERS } from './constants.js';
1+
import { type SugaredTracer } from '@opentelemetry/api/experimental'
2+
import { GET_TRACER, SHUTDOWN_TRACERS } from './constants.js'
33

44
type GlobalThisExtended = typeof globalThis & {
5-
[GET_TRACER]?: (name?: string, version?: string) => SugaredTracer | undefined;
6-
[SHUTDOWN_TRACERS]?: () => void;
5+
[GET_TRACER]?: (name?: string, version?: string) => SugaredTracer | undefined
6+
[SHUTDOWN_TRACERS]?: () => void
77
}
88

99
export const getTracer = async (name?: string, version?: string): Promise<SugaredTracer | undefined> => {
10-
return (globalThis as GlobalThisExtended)[GET_TRACER]?.(name, version);
10+
return (globalThis as GlobalThisExtended)[GET_TRACER]?.(name, version)
1111
}
1212

1313
export const shutdownTracers = async (): Promise<void> => {
14-
return (globalThis as GlobalThisExtended)[SHUTDOWN_TRACERS]?.();
15-
}
14+
return (globalThis as GlobalThisExtended)[SHUTDOWN_TRACERS]?.()
15+
}
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
21
// eslint-disable-next-line n/prefer-global/buffer
3-
export const base64Decode = globalThis.Buffer ? (input: string) => Buffer.from(input, 'base64').toString() : (input: string) => atob(input)
2+
export const base64Decode = globalThis.Buffer
3+
? (input: string) => Buffer.from(input, 'base64').toString()
4+
: (input: string) => atob(input)
45

56
// eslint-disable-next-line n/prefer-global/buffer
6-
export const base64Encode = globalThis.Buffer ? (input: string) => Buffer.from(input).toString('base64') : (input: string) => btoa(input)
7+
export const base64Encode = globalThis.Buffer
8+
? (input: string) => Buffer.from(input).toString('base64')
9+
: (input: string) => btoa(input)

packages/static/src/lib/fs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ export const fileExists = async (path: string) => {
1717

1818
export const getReadableStreamFromFile = (path: string) => {
1919
const stream = createReadStream(path)
20-
20+
2121
return Readable.toWeb(stream) as ReadableStream
2222
}

packages/static/src/lib/paths.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import path from "node:path"
1+
import path from 'node:path'
22

33
// Used as an optimization to avoid dual lookups for missing assets
44
const assetExtensionRegExp = /\.(html?|png|jpg|js|css|svg|gif|ico|woff|woff2)$/
55

6-
export const getFilePathsForURL = (pathname: string, baseDirectory = "") => {
6+
export const getFilePathsForURL = (pathname: string, baseDirectory = '') => {
77
const urlVariations = getURLVariations(pathname)
8-
const possiblePaths = urlVariations.map(urlVariation => {
9-
const parts = urlVariation.split("/").filter(Boolean) as string[]
8+
const possiblePaths = urlVariations.map((urlVariation) => {
9+
const parts = urlVariation.split('/').filter(Boolean) as string[]
1010

1111
return path.resolve.apply(null, [baseDirectory, ...parts])
1212
})
@@ -16,7 +16,7 @@ export const getFilePathsForURL = (pathname: string, baseDirectory = "") => {
1616

1717
export const getURLVariations = (pathname: string) => {
1818
const paths: string[] = []
19-
19+
2020
if (pathname[pathname.length - 1] === '/') {
2121
const end = pathname.length - 1
2222

@@ -29,9 +29,9 @@ export const getURLVariations = (pathname: string) => {
2929
paths.push(`${pathname}.html`, `${pathname}.htm`, `${pathname}/index.html`, `${pathname}/index.htm`)
3030
}
3131

32-
if (!(paths.includes(pathname))) {
32+
if (!paths.includes(pathname)) {
3333
return [pathname, ...paths]
3434
}
3535

3636
return paths
37-
}
37+
}

packages/types/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ npm install @netlify/types
1616

1717
## Usage
1818

19-
This package provides TypeScript type definitions for various Netlify platform primitives. Import the types you need in your TypeScript code:
19+
This package provides TypeScript type definitions for various Netlify platform primitives. Import the types you need in
20+
your TypeScript code:
2021

2122
```typescript
2223
import type { Context } from '@netlify/types'
@@ -32,4 +33,5 @@ The package includes TypeScript definitions for:
3233

3334
## Contributing
3435

35-
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request.
36+
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or
37+
submit a pull request.

packages/vite-plugin/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# @netlify/vite-plugin
22

3-
> [!WARNING] This is an experimental Vite plugin for Netlify. It is under active development and does **not** yet support all Netlify platform features.
3+
> [!WARNING] This is an experimental Vite plugin for Netlify. It is under active development and does **not** yet
4+
> support all Netlify platform features.
45
56
A Vite plugin that integrates with Netlify's platform features.
67

@@ -14,7 +15,8 @@ npm install @netlify/vite-plugin
1415

1516
The plugin accepts the following options:
1617

17-
- `middleware` (boolean, default: `true`): Attach a Vite middleware that intercepts requests and handles them in the same way as the Netlify production environment
18+
- `middleware` (boolean, default: `true`): Attach a Vite middleware that intercepts requests and handles them in the
19+
same way as the Netlify production environment
1820
- `blobs`: Configure blob storage functionality
1921
- `functions`: Configure serverless functions
2022
- `headers`: Configure response headers
@@ -30,6 +32,6 @@ import { defineConfig } from 'vite'
3032
import netlify from '@netlify/vite-plugin'
3133

3234
export default defineConfig({
33-
plugins: [netlify()]
35+
plugins: [netlify()],
3436
})
3537
```

renovate.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
22
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3-
"extends": [
4-
"local>netlify/renovate-config"
5-
]
3+
"extends": ["local>netlify/renovate-config"]
64
}

0 commit comments

Comments
 (0)