Skip to content

Commit 3f39303

Browse files
huozhieps1lon
andauthored
codemod: unify comments prefix for dynamic api (#70970)
Co-authored-by: Sebastian "Sebbie" Silbermann <[email protected]>
1 parent f6906fc commit 3f39303

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

packages/next-codemod/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-15.output.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { cookies } from "next/headers";
22

33
async function MyComponent() {
44
function asyncFunction() {
5-
callSomething(/* TODO: please manually await this call, if it's a server component, you can turn it to async function */
5+
callSomething(/* Next.js Dynamic Async API Codemod: Manually await this call, if it's a Server Component */
66
cookies());
77
}
88
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { cookies } from "next/headers";
22

33
function MyComponent() {
4-
callSomething(/* TODO: please manually await this call, if it's a server component, you can turn it to async function */
4+
callSomething(/* Next.js Dynamic Async API Codemod: Manually await this call, if it's a Server Component */
55
cookies());
66
}

packages/next-codemod/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-21.input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ function myFunc() {
44
nextHeaders.cookies()
55
}
66

7-
const nextHeaders2 = /* The APIs under 'next/headers' are async now, need to be manually awaited. */ import('next/headers')
7+
const nextHeaders2 = /* Next.js Dynamic Async API Codemod: The APIs under 'next/headers' are async now, need to be manually awaited. */ import('next/headers')
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
const nextHeaders = /* The APIs under 'next/headers' are async now, need to be manually awaited. */
1+
const nextHeaders = /* Next.js Dynamic Async API Codemod: The APIs under 'next/headers' are async now, need to be manually awaited. */
22
import('next/headers')
33

44
function myFunc() {
55
nextHeaders.cookies()
66
}
77

8-
const nextHeaders2 = /* The APIs under 'next/headers' are async now, need to be manually awaited. */ import('next/headers')
8+
const nextHeaders2 = /* Next.js Dynamic Async API Codemod: The APIs under 'next/headers' are async now, need to be manually awaited. */ import('next/headers')

packages/next-codemod/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-type-cast-02.output.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from 'next/headers'
77

88
export function MyDraftComponent() {
9-
if (/* TODO: please manually await this call, if it's a server component, you can turn it to async function */
9+
if (/* Next.js Dynamic Async API Codemod: Manually await this call, if it's a Server Component */
1010
draftMode().isEnabled) {
1111
return null
1212
}
@@ -15,13 +15,13 @@ draftMode().isEnabled) {
1515
}
1616

1717
export function MyCookiesComponent() {
18-
const c = /* TODO: please manually await this call, if it's a server component, you can turn it to async function */
18+
const c = /* Next.js Dynamic Async API Codemod: Manually await this call, if it's a Server Component */
1919
cookies()
2020
return c.get('name')
2121
}
2222

2323
export function MyHeadersComponent() {
24-
const h = /* TODO: please manually await this call, if it's a server component, you can turn it to async function */
24+
const h = /* Next.js Dynamic Async API Codemod: Manually await this call, if it's a Server Component */
2525
headers()
2626
return (
2727
<p>{h.get('x-foo')}</p>
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
export default function Page(props: any) {
2-
callback(/* 'props' is passed as an argument. Any asynchronous properties of 'props' must be awaited when accessed. */
2+
callback(/* Next.js Dynamic Async API Codemod: 'props' is passed as an argument. Any asynchronous properties of 'props' must be awaited when accessed. */
33
props, 1)
44
}
55

66
export function generateMetadata(props) {
7-
callback2(/* 'props' is passed as an argument. Any asynchronous properties of 'props' must be awaited when accessed. */
7+
callback2(/* Next.js Dynamic Async API Codemod: 'props' is passed as an argument. Any asynchronous properties of 'props' must be awaited when accessed. */
88
props)
99
}
1010

packages/next-codemod/transforms/lib/async-request-api/next-async-dynamic-api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
insertCommentOnce,
1212
} from './utils'
1313

14-
const DYNAMIC_IMPORT_WARN_COMMENT = ` The APIs under 'next/headers' are async now, need to be manually awaited. `
14+
const DYNAMIC_IMPORT_WARN_COMMENT = ` Next.js Dynamic Async API Codemod: The APIs under 'next/headers' are async now, need to be manually awaited. `
1515

1616
function findDynamicImportsAndComment(root: Collection<any>, j: API['j']) {
1717
let modified = false
@@ -187,7 +187,7 @@ export function transformDynamicAPI(
187187
root,
188188
filePath,
189189
insertedTypes,
190-
` TODO: please manually await this call, if it's a server component, you can turn it to async function `
190+
` Next.js Dynamic Async API Codemod: Manually await this call, if it's a Server Component `
191191
)
192192
}
193193
} else {
@@ -198,7 +198,7 @@ export function transformDynamicAPI(
198198
root,
199199
filePath,
200200
insertedTypes,
201-
' TODO: please manually await this call, codemod cannot transform due to undetermined async scope '
201+
' Next.js Dynamic Async API Codemod: please manually await this call, codemod cannot transform due to undetermined async scope '
202202
)
203203
}
204204
modified = true

packages/next-codemod/transforms/lib/async-request-api/next-async-dynamic-prop.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ export function transformDynamicProps(
406406
const propPassedAsArg = args.find(
407407
(arg) => j.Identifier.check(arg) && arg.name === argName
408408
)
409-
const comment = ` '${argName}' is passed as an argument. Any asynchronous properties of 'props' must be awaited when accessed. `
409+
const comment = ` Next.js Dynamic Async API Codemod: '${argName}' is passed as an argument. Any asynchronous properties of 'props' must be awaited when accessed. `
410410
insertCommentOnce(propPassedAsArg, j, comment)
411411

412412
modified = true

0 commit comments

Comments
 (0)