Repository navigation
Report unknown field properties in block.json and field.json - #192
Merged
dnnsjsk merged 2 commits intoOct 28, 2026
Merged
Conversation
The block and extension schemas did not list radio display and allowNull, checkbox toggle, code asset, wysiwyg mode, and repeater default, although the editor and the renderer read them and the docs describe asset and repeater defaults. The default and fallback of color and gradient sat inside their options property instead of on the field. A tooling test checks every field in the test theme against the schema for its type. It also caught the help test block, which used set and subSet instead of sets and subSets.
The shape rules checked a field's type, id, options, and nesting, but not its properties, so a misspelled property such as "translat" passed and silently did nothing. Both rules now report every property the field type does not accept, with the closest known property as a suggestion. FieldProperties lists the properties per built-in type. A unit test keeps it equal to the field branches of schemas/block.json and skips outside the monorepo. custom/* references and registered field types are not checked.
Contributor
|
Merged and released in Blockstudio PHPStan 0.1.12, alongside Blockstudio 7.7.10. This resolves #190. Update the standalone extension with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #190. Builds on #191 and contains its commit until that is merged.
BlockJsonShapeRuleandFieldJsonShapeRulenow report every property a field's type does not accept, with the closest known property as a suggestion:How the questions from #190 are answered here (happy to change any of them):
schemas/at runtime, soSchema\FieldPropertieskeeps a static list per built-in type, likeSettingsGetReturnTypedoes for settings paths.FieldPropertiesTestcompares it with every field branch inschemas/block.json(top level,definitions/Attribute, group children) and skips when the schemas are not there, the same wayHookInventoryTestskips withoutincludes/. A property added to the schema without the list, or the other way round, fails that test.blockstudio.blockJson.propertyandblockstudio.fieldJson.property, so a project with its own keys can ignore just these.custom/*references and types registered withbs_register_field_type()are not checked; only the 27 built-in types are.The schema had to be complete first, otherwise valid properties such as radio
displayor codeassetwould have been reported. That is #191. With it, the fields intests/themeproduce no finding (the tooling test from #191 checks exactly that), and a real theme with 28 blocks and 263 fields produced none either.Extension files are not covered:
ExtensionJsonShapeRuledoes not validate fields today, andextend.jsonhas its own common propertyset.Tests: fixtures for a block with four unknown properties (text, a repeater, a field in a repeater, an icon field inside tabs with
setinstead ofsets), a block that uses only valid properties including the ones from #191, and afield.json. The two new rule tests fail without the rule change.phpunitfor the package passes (306 tests), as does its PHPStan run;lint,format:check,typecheck,audit:tooling,docs:check, andtest:toolingpass. Docs: the PHPStan page and the package README.