Skip to content

Commit

Permalink
fix(schema): add help id to blockeditor schema warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoerge authored and skogsmaskin committed Dec 20, 2022
1 parent c323b12 commit 8d74ace
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Expand Up @@ -27,6 +27,7 @@ export const HELP_IDS = {
SLUG_SLUGIFY_FN_RENAMED: 'slug-slugifyfn-renamed',
ASSET_METADATA_FIELD_INVALID: 'asset-metadata-field-invalid',
CROSS_DATASET_REFERENCE_INVALID: 'cross-dataset-reference-invalid',
DEPRECATED_BLOCKEDITOR_KEY: 'schema-deprecated-blockeditor-key',
}

function createValidationResult(
Expand Down
11 changes: 7 additions & 4 deletions packages/@sanity/schema/src/sanity/validation/types/block.ts
@@ -1,6 +1,6 @@
import {omit, isPlainObject} from 'lodash'
import humanizeList from 'humanize-list'
import {error, warning} from '../createValidationResult'
import {error, HELP_IDS, warning} from '../createValidationResult'
import {isJSONTypeOf} from '../utils/isJSONTypeOf'

const getTypeOf = (thing) => (Array.isArray(thing) ? 'array' : typeof thing)
Expand Down Expand Up @@ -197,7 +197,8 @@ function validateStyles(styles, visitorContext, problems) {
if (typeof style.blockEditor !== 'undefined') {
problems.push(
warning(
`Style has deprecated key "blockEditor", please refer to the documentation on how to configure the block type for version 3.`
`Style has deprecated key "blockEditor", please refer to the documentation on how to configure the block type for version 3.`,
HELP_IDS.DEPRECATED_BLOCKEDITOR_KEY
)
)
// TODO remove this backward compatibility at some point.
Expand Down Expand Up @@ -245,7 +246,8 @@ function validateDecorators(decorators, visitorContext, problems) {
if (typeof decorator.blockEditor !== 'undefined') {
problems.push(
warning(
`Decorator "${name}" has deprecated key "blockEditor", please refer to the documentation on how to configure the block type for version 3.`
`Decorator "${name}" has deprecated key "blockEditor", please refer to the documentation on how to configure the block type for version 3.`,
HELP_IDS.DEPRECATED_BLOCKEDITOR_KEY
)
)
// TODO remove this backward compatibility at some point.
Expand Down Expand Up @@ -278,7 +280,8 @@ function validateAnnotations(annotations, visitorContext, problems) {
if (typeof annotation.blockEditor !== 'undefined') {
problems.push(
warning(
`Annotation has deprecated key "blockEditor", please refer to the documentation on how to configure the block type for version 3.`
`Annotation has deprecated key "blockEditor", please refer to the documentation on how to configure the block type for version 3.`,
HELP_IDS.DEPRECATED_BLOCKEDITOR_KEY
)
)
// TODO remove this backward compatibility at some point.
Expand Down

1 comment on commit 8d74ace

@vercel
Copy link

@vercel vercel bot commented on 8d74ace Dec 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

test-studio – ./

test-studio.sanity.build
test-studio-git-next.sanity.build

Please sign in to comment.