Skip to content

Commit eb54c75

Browse files
committed
chore: prettier
1 parent d4231e5 commit eb54c75

File tree

17 files changed

+117
-107
lines changed

17 files changed

+117
-107
lines changed

.eslintrc.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ module.exports = {
6868
'max-nested-callbacks': 0,
6969
'@typescript-eslint/no-empty-function': 0,
7070
'max-lines-per-function': 0,
71+
'unicorn/no-empty-file': 0,
7172
// esling-plugin-jest specific rules
7273
'jest/consistent-test-it': ['error', { fn: 'it', withinDescribe: 'it' }],
73-
}
74-
}
74+
},
75+
},
7576
],
7677
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":1,"files":["../../webpack-api-runtime.js","../../../package.json"]}
1+
{ "version": 1, "files": ["../../webpack-api-runtime.js", "../../../package.json"] }

test/fixtures/not-static.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,4 @@
8282
"build:ci:frontend": "npm ci && npm run build && yarn workspace frontend build"
8383
}
8484
}
85-
8685
]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
// noop
1+
// noop
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
// noop
1+
// noop
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
target: 'serverless'
2+
target: 'serverless',
33
}

test/helpers/analysis.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ describe('static source analysis', () => {
4040
})
4141
})
4242
it('should throw if schedule is provided when type is background', async () => {
43-
await expect(extractConfigFromFile(resolve(__dirname, '../fixtures/analysis/background-schedule.ts'))).rejects.toThrow(
44-
'Unsupported config value in test/fixtures/analysis/background-schedule.ts',
45-
)
43+
await expect(
44+
extractConfigFromFile(resolve(__dirname, '../fixtures/analysis/background-schedule.ts')),
45+
).rejects.toThrow('Unsupported config value in test/fixtures/analysis/background-schedule.ts')
4646
expect(console.error).toHaveBeenCalledWith(
4747
`Invalid config value in test/fixtures/analysis/background-schedule.ts: schedule is not allowed unless type is "experimental-scheduled"`,
4848
)

test/helpers/config.spec.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import {
2-
generateCustomHeaders,
3-
NextConfig
4-
} from "../../packages/runtime/src/helpers/config"
1+
import { generateCustomHeaders, NextConfig } from '../../packages/runtime/src/helpers/config'
52
import type { NetlifyPluginOptions } from '@netlify/build'
63

7-
const netlifyConfig = { build: { command: 'npm run build' }, functions: {}, redirects: [], headers: [] } as NetlifyPluginOptions["netlifyConfig"]
4+
const netlifyConfig = {
5+
build: { command: 'npm run build' },
6+
functions: {},
7+
redirects: [],
8+
headers: [],
9+
} as NetlifyPluginOptions['netlifyConfig']
810

911
describe('generateCustomHeaders', () => {
1012
// The routesManifest is the contents of the routes-manifest.json file which will already contain the generated
@@ -426,4 +428,4 @@ describe('generateCustomHeaders', () => {
426428
},
427429
])
428430
})
429-
})
431+
})

test/helpers/edge.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ describe('generateRscDataEdgeManifest', () => {
4141
expect(edgeManifest).toEqual([
4242
{
4343
function: 'rsc-data',
44-
generator: "@netlify/next-runtime@1.0.0",
44+
generator: '@netlify/next-runtime@1.0.0',
4545
name: 'RSC data routing',
4646
path: '/',
4747
},
4848
{
4949
function: 'rsc-data',
50-
generator: "@netlify/next-runtime@1.0.0",
50+
generator: '@netlify/next-runtime@1.0.0',
5151
name: 'RSC data routing',
5252
path: '/index.rsc',
5353
},
@@ -94,13 +94,13 @@ describe('generateRscDataEdgeManifest', () => {
9494
expect(edgeManifest).toEqual([
9595
{
9696
function: 'rsc-data',
97-
generator: "@netlify/next-runtime@1.0.0",
97+
generator: '@netlify/next-runtime@1.0.0',
9898
name: 'RSC data routing',
9999
pattern: '^/blog/([^/]+?)(?:/)?$',
100100
},
101101
{
102102
function: 'rsc-data',
103-
generator: "@netlify/next-runtime@1.0.0",
103+
generator: '@netlify/next-runtime@1.0.0',
104104
name: 'RSC data routing',
105105
pattern: '^/blog/([^/]+?)\\.rsc$',
106106
},

test/helpers/files.spec.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,14 @@ import {
77
unpatchNextFiles,
88
getDependenciesOfFile,
99
getSourceFileForPage,
10-
} from "../../packages/runtime/src/helpers/files"
11-
import {
12-
readFileSync,
13-
copy,
14-
ensureDir,
15-
} from "fs-extra"
16-
import path from "path"
17-
import { dirname } from "path"
10+
} from '../../packages/runtime/src/helpers/files'
11+
import { readFileSync, copy, ensureDir } from 'fs-extra'
12+
import path from 'path'
13+
import { dirname } from 'path'
1814
import { resolve } from 'pathe'
19-
import { join } from "pathe"
20-
import { Rewrites } from "../../packages/runtime/src/helpers/types"
21-
import { describeCwdTmpDir, moveNextDist } from "../test-utils"
15+
import { join } from 'pathe'
16+
import { Rewrites } from '../../packages/runtime/src/helpers/types'
17+
import { describeCwdTmpDir, moveNextDist } from '../test-utils'
2218

2319
const TEST_DIR = resolve(__dirname, '..')
2420

@@ -241,4 +237,4 @@ describe('getSourceFileForPage', () => {
241237

242238
expect(filePath.replace(TEST_DIR, '')).toBe('/fixtures/page-extensions/custom/pages/api/custom.api.js')
243239
})
244-
})
240+
})

test/helpers/functions.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { getExtendedApiRouteConfigs } from "../../packages/runtime/src/helpers/functions"
2-
import { describeCwdTmpDir, moveNextDist } from "../test-utils"
1+
import { getExtendedApiRouteConfigs } from '../../packages/runtime/src/helpers/functions'
2+
import { describeCwdTmpDir, moveNextDist } from '../test-utils'
33

44
describeCwdTmpDir('api route file analysis', () => {
55
it('extracts correct route configs from source files', async () => {
@@ -21,4 +21,4 @@ describeCwdTmpDir('api route file analysis', () => {
2121
]),
2222
)
2323
})
24-
})
24+
})

test/helpers/functionsMetaData.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@ describe('writeFunctionConfiguration', () => {
102102

103103
expect(actual).toEqual(expected)
104104
})
105-
})
105+
})

test/helpers/verification.spec.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
import Chance from 'chance'
2-
import { checkNextSiteHasBuilt, checkZipSize, getProblematicUserRewrites } from '../../packages/runtime/src/helpers/verification'
2+
import {
3+
checkNextSiteHasBuilt,
4+
checkZipSize,
5+
getProblematicUserRewrites,
6+
} from '../../packages/runtime/src/helpers/verification'
37
import { outdent } from 'outdent'
48
import type { NetlifyPluginOptions } from '@netlify/build'
5-
import { describeCwdTmpDir, moveNextDist } from "../test-utils"
9+
import { describeCwdTmpDir, moveNextDist } from '../test-utils'
610

7-
const netlifyConfig = { build: { command: 'npm run build' }, functions: {}, redirects: [], headers: [] } as NetlifyPluginOptions["netlifyConfig"]
11+
const netlifyConfig = {
12+
build: { command: 'npm run build' },
13+
functions: {},
14+
redirects: [],
15+
headers: [],
16+
} as NetlifyPluginOptions['netlifyConfig']
817

918
import type { NetlifyPluginUtils } from '@netlify/build'
1019
type FailBuild = NetlifyPluginUtils['build']['failBuild']
@@ -101,11 +110,13 @@ describe('checkZipSize', () => {
101110
it('emits a warning that DISABLE_BUNDLE_ZIP_SIZE_CHECK was enabled', async () => {
102111
process.env.DISABLE_BUNDLE_ZIP_SIZE_CHECK = 'true'
103112
await checkZipSize(chance.string())
104-
expect(consoleSpy).toHaveBeenCalledWith('Function bundle size check was DISABLED with the DISABLE_BUNDLE_ZIP_SIZE_CHECK environment variable. Your deployment will break if it exceeds the maximum supported size of function zip files in your account.')
113+
expect(consoleSpy).toHaveBeenCalledWith(
114+
'Function bundle size check was DISABLED with the DISABLE_BUNDLE_ZIP_SIZE_CHECK environment variable. Your deployment will break if it exceeds the maximum supported size of function zip files in your account.',
115+
)
105116
})
106117
})
107118

108-
describeCwdTmpDir("getProblematicUserRewrites", () => {
119+
describeCwdTmpDir('getProblematicUserRewrites', () => {
109120
it('finds problematic user rewrites', async () => {
110121
await moveNextDist()
111122
const rewrites = getProblematicUserRewrites({

test/index.spec.ts

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,42 +16,29 @@ jest.mock('../packages/runtime/src/helpers/functionsMetaData', () => {
1616
}
1717
})
1818

19-
import Chance from "chance"
20-
import {
21-
writeJSON,
22-
unlink,
23-
existsSync,
24-
readFileSync,
25-
ensureDir,
26-
readJson,
27-
pathExists,
28-
writeFile,
29-
move,
30-
} from "fs-extra"
31-
import path from "path"
32-
import process from "process"
33-
import os from "os"
34-
import { dir as getTmpDir } from "tmp-promise"
19+
import Chance from 'chance'
20+
import { writeJSON, unlink, existsSync, readFileSync, ensureDir, readJson, pathExists, writeFile, move } from 'fs-extra'
21+
import path from 'path'
22+
import process from 'process'
23+
import os from 'os'
24+
import { dir as getTmpDir } from 'tmp-promise'
3525
// @ts-expect-error - TODO: Convert runtime export to ES6
36-
import nextRuntimeFactory from "../packages/runtime/src"
26+
import nextRuntimeFactory from '../packages/runtime/src'
3727
const nextRuntime = nextRuntimeFactory({})
38-
import { watchForMiddlewareChanges } from "../packages/runtime/src/helpers/compiler"
39-
import { HANDLER_FUNCTION_NAME, ODB_FUNCTION_NAME, IMAGE_FUNCTION_NAME } from "../packages/runtime/src/constants"
40-
import { join } from "pathe"
41-
import {
42-
getRequiredServerFiles,
43-
updateRequiredServerFiles,
44-
} from "../packages/runtime/src/helpers/config"
45-
import { resolve } from "path"
28+
import { watchForMiddlewareChanges } from '../packages/runtime/src/helpers/compiler'
29+
import { HANDLER_FUNCTION_NAME, ODB_FUNCTION_NAME, IMAGE_FUNCTION_NAME } from '../packages/runtime/src/constants'
30+
import { join } from 'pathe'
31+
import { getRequiredServerFiles, updateRequiredServerFiles } from '../packages/runtime/src/helpers/config'
32+
import { resolve } from 'path'
4633
import type { NetlifyPluginOptions } from '@netlify/build'
47-
import { changeCwd, useFixture, moveNextDist } from "./test-utils"
34+
import { changeCwd, useFixture, moveNextDist } from './test-utils'
4835

4936
const chance = new Chance()
5037
const constants = {
5138
INTERNAL_FUNCTIONS_SRC: '.netlify/functions-internal',
5239
PUBLISH_DIR: '.next',
5340
FUNCTIONS_DIST: '.netlify/functions',
54-
} as unknown as NetlifyPluginOptions["constants"]
41+
} as unknown as NetlifyPluginOptions['constants']
5542
const utils = {
5643
build: {
5744
failBuild(message) {
@@ -63,14 +50,19 @@ const utils = {
6350
save: jest.fn(),
6451
restore: jest.fn(),
6552
},
66-
} as unknown as NetlifyPluginOptions["utils"]
53+
} as unknown as NetlifyPluginOptions['utils']
6754

6855
const normalizeChunkNames = (source) => source.replaceAll(/\/chunks\/\d+\.js/g, '/chunks/CHUNK_ID.js')
6956

7057
const onBuildHasRun = (netlifyConfig) =>
7158
Boolean(netlifyConfig.functions[HANDLER_FUNCTION_NAME]?.included_files?.some((file) => file.includes('BUILD_ID')))
7259

73-
const netlifyConfig = { build: { command: 'npm run build' }, functions: {}, redirects: [], headers: [] } as NetlifyPluginOptions["netlifyConfig"]
60+
const netlifyConfig = {
61+
build: { command: 'npm run build' },
62+
functions: {},
63+
redirects: [],
64+
headers: [],
65+
} as NetlifyPluginOptions['netlifyConfig']
7466
const defaultArgs = {
7567
netlifyConfig,
7668
utils,
@@ -637,30 +629,29 @@ describe('onBuild()', () => {
637629
await nextRuntime.onBuild(defaultArgs)
638630
const manifestPath = await readJson(path.resolve('.netlify/edge-functions/manifest.json'))
639631
const manifest = manifestPath.functions
640-
632+
641633
expect(manifest).toEqual(
642634
expect.arrayContaining([
643635
expect.objectContaining({
644-
generator: '@netlify/next-runtime@1.0.0'
645-
})
646-
])
636+
generator: '@netlify/next-runtime@1.0.0',
637+
}),
638+
]),
647639
)
648640
})
649641

650-
651642
test('generates generator field within the edge-functions manifest includes IPX', async () => {
652643
process.env.NEXT_FORCE_EDGE_IMAGES = '1'
653644
await moveNextDist()
654645
await nextRuntime.onBuild(defaultArgs)
655646
const manifestPath = await readJson(path.resolve('.netlify/edge-functions/manifest.json'))
656647
const manifest = manifestPath.functions
657-
648+
658649
expect(manifest).toEqual(
659650
expect.arrayContaining([
660651
expect.objectContaining({
661-
generator: '@netlify/next-runtime@1.0.0'
662-
})
663-
])
652+
generator: '@netlify/next-runtime@1.0.0',
653+
}),
654+
]),
664655
)
665656
})
666657

test/templates/handlerUtils.spec.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,10 @@ import {
55
localizeDataRoute,
66
downloadFile,
77
} from '../../packages/runtime/src/templates/handlerUtils'
8-
import { join } from "pathe"
9-
import os from "os"
10-
import path from "path"
11-
import {
12-
unlink,
13-
existsSync,
14-
readFileSync,
15-
ensureDir,
16-
} from "fs-extra"
8+
import { join } from 'pathe'
9+
import os from 'os'
10+
import path from 'path'
11+
import { unlink, existsSync, readFileSync, ensureDir } from 'fs-extra'
1712

1813
describe('normalizeRoute', () => {
1914
it('removes a trailing slash from a route', () => {

0 commit comments

Comments
 (0)