From e0b732f107eeeff787e2e4c0dc84ed8734d674b9 Mon Sep 17 00:00:00 2001 From: Janka Uryga Date: Mon, 29 Jul 2024 16:22:19 +0200 Subject: [PATCH] change "next/form" to "
" in error messages to match Link --- packages/next/src/client/form.tsx | 22 +++++++++---------- .../next-form/default/next-form.test.ts | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/next/src/client/form.tsx b/packages/next/src/client/form.tsx index 50cea038def3b..3b06a64fb25b9 100644 --- a/packages/next/src/client/form.tsx +++ b/packages/next/src/client/form.tsx @@ -48,7 +48,7 @@ export default function Form({ if (key in props) { if (process.env.NODE_ENV === 'development') { console.error( - `next/form does not support changing \`${key}\`. ` + + ` does not support changing \`${key}\`. ` + (typeof actionProp === 'string' ? `If you'd like to use it to perform a mutation, consider making \`action\` a function instead.\n` + `Learn more: https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations` @@ -99,7 +99,7 @@ export default function Form({ if (process.env.NODE_ENV === 'development') { if (replace || scroll) { console.error( - 'Passing `replace` or `scroll` to a next/form whose `action` is a function has no effect.\n' + + 'Passing `replace` or `scroll` to a whose `action` is a function has no effect.\n' + 'See the relevant docs to learn how to control this behavior for navigations triggered from actions:\n' + ' `redirect()` - https://nextjs.org/docs/app/api-reference/functions/redirect#parameters\n' + ' `router.replace()` - https://nextjs.org/docs/app/api-reference/functions/use-router#userouter\n' @@ -219,7 +219,7 @@ function onFormSubmit( // the native browser behavior is to use the filename as the value instead. if (process.env.NODE_ENV === 'development') { console.warn( - `next/form only supports file inputs if \`action\` is a function. File inputs cannot be used if \`action\` is a string, ` + + ` only supports file inputs if \`action\` is a function. File inputs cannot be used if \`action\` is a string, ` + `because files cannot be encoded as search params.` ) } @@ -244,7 +244,7 @@ function checkActionUrl(action: string, source: 'action' | 'formAction') { testUrl = new URL(action, 'http://n') } catch (err) { console.error( - `next/form received ${aPropName} that cannot be parsed as a URL: "${action}".` + ` received ${aPropName} that cannot be parsed as a URL: "${action}".` ) return } @@ -252,7 +252,7 @@ function checkActionUrl(action: string, source: 'action' | 'formAction') { // url-encoded HTML forms ignore any queryparams in the `action` url. We need to match that. if (testUrl.searchParams.size) { console.warn( - `next/form received ${aPropName} that contains search params: "${action}". This is not supported, and they will be ignored. ` + + ` received ${aPropName} that contains search params: "${action}". This is not supported, and they will be ignored. ` + `If you need to pass in additional search params, use an \`\` instead.` ) } @@ -269,8 +269,8 @@ function hasUnsupportedSubmitterAttributes(submitter: HTMLElement): boolean { if (formEncType !== null && !isSupportedEncType(formEncType)) { if (process.env.NODE_ENV === 'development') { console.error( - `next/form's \`encType\` was set to an unsupported value via \`formEncType="${formEncType}"\`. ` + - `This will disable next/form's navigation functionality. If you need this, use a native element instead.` + `'s \`encType\` was set to an unsupported value via \`formEncType="${formEncType}"\`. ` + + `This will disable 's navigation functionality. If you need this, use a native element instead.` ) } return true @@ -281,8 +281,8 @@ function hasUnsupportedSubmitterAttributes(submitter: HTMLElement): boolean { if (formMethod !== null && !isSupportedMethod(formMethod)) { if (process.env.NODE_ENV === 'development') { console.error( - `next/form's \`method\` was set to an unsupported value via \`formMethod="${formMethod}"\`. ` + - `This will disable next/form's navigation functionality. If you need this, use a native element instead.` + `'s \`method\` was set to an unsupported value via \`formMethod="${formMethod}"\`. ` + + `This will disable 's navigation functionality. If you need this, use a native element instead.` ) } return true @@ -293,8 +293,8 @@ function hasUnsupportedSubmitterAttributes(submitter: HTMLElement): boolean { if (formTarget !== null && !isSupportedTarget(formTarget)) { if (process.env.NODE_ENV === 'development') { console.error( - `next/form's \`target\` was set to an unsupported value via \`formTarget="${formTarget}"\`. ` + - `This will disable next/form's navigation functionality. If you need this, use a native element instead.` + `'s \`target\` was set to an unsupported value via \`formTarget="${formTarget}"\`. ` + + `This will disable 's navigation functionality. If you need this, use a native element instead.` ) } return true diff --git a/test/e2e/app-dir/next-form/default/next-form.test.ts b/test/e2e/app-dir/next-form/default/next-form.test.ts index 70b7b97a036b6..020ceffac0f64 100644 --- a/test/e2e/app-dir/next-form/default/next-form.test.ts +++ b/test/e2e/app-dir/next-form/default/next-form.test.ts @@ -128,7 +128,7 @@ describe('app dir - form', () => { expect(logs).not.toContainEqual( expect.stringMatching( - /next\/form's `.+?` was set to an unsupported value/ + /'s `.+?` was set to an unsupported value/ ) ) } @@ -158,7 +158,7 @@ describe('app dir - form', () => { expect.objectContaining({ source: 'error', message: expect.stringContaining( - `next/form's \`${attributeBaseName}\` was set to an unsupported value` + `'s \`${attributeBaseName}\` was set to an unsupported value` ), }) )