frontend-plugin-api: always warn on deprecated config.schema with call site
Instead of a one-time warning, emit a deprecation warning every time an extension is created using the deprecated `config.schema` option, including the call site location to help track down each usage. Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com> Made-with: Cursor
This commit is contained in:
@@ -323,17 +323,13 @@ function formatStandardIssue(
|
||||
return `${message} at '${path}'`;
|
||||
}
|
||||
|
||||
let hasWarnedConfigSchemaProp = false;
|
||||
|
||||
/** @internal */
|
||||
export function warnConfigSchemaPropDeprecation() {
|
||||
if (!hasWarnedConfigSchemaProp) {
|
||||
hasWarnedConfigSchemaProp = true;
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
'DEPRECATION WARNING: The `config.schema` option for extension config is deprecated. ' +
|
||||
'Use the `configSchema` option instead with Standard Schema values, for example ' +
|
||||
'`configSchema: { title: z.string() }` using zod v3.25+ or v4.',
|
||||
);
|
||||
}
|
||||
export function warnConfigSchemaPropDeprecation(callSite: string) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
`DEPRECATION WARNING: The \`config.schema\` option for extension config is deprecated. ` +
|
||||
`Use the \`configSchema\` option instead with Standard Schema values, for example ` +
|
||||
`\`configSchema: { title: z.string() }\` using zod v3.25+ or v4. ` +
|
||||
`Declared at ${callSite}`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
createConfigSchema,
|
||||
warnConfigSchemaPropDeprecation,
|
||||
} from '../schema/createPortableSchema';
|
||||
import { describeParentCallSite } from '../routing/describeParentCallSite';
|
||||
import { type StandardSchemaV1 } from '@standard-schema/spec';
|
||||
import { OpaqueExtensionDefinition } from '@internal/frontend';
|
||||
import { ExtensionDataContainer } from './types';
|
||||
@@ -646,7 +647,7 @@ export function createExtension(
|
||||
const schemaDeclaration =
|
||||
options.configSchema ?? (options.config?.schema as any);
|
||||
if (options.config?.schema) {
|
||||
warnConfigSchemaPropDeprecation();
|
||||
warnConfigSchemaPropDeprecation(describeParentCallSite());
|
||||
}
|
||||
const resolvedConfigSchema =
|
||||
schemaDeclaration && createConfigSchema(schemaDeclaration);
|
||||
|
||||
Reference in New Issue
Block a user