Improve type checking for formal syntax #9349
Closed
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.
There are type validators in
dataType.js
referencing CSS Types, but splitting the basic data types(<length> and <percentage> ) is not a good solution for further maintenance and development. We can just keep them as minimal validators for the css data type.In my opinion,
familyName
andposition
is something like value definition syntax. And we should take them out as validators for formal syntax for better type checking, anddataType.js
is only for basic css data types.This PR created
validateFormalSyntax.js
andsize
type (or formal syntax) for better background-size checking based on background-size MDN web docs.tailwindcss/src/util/validateFormalSyntax.js
Line 22 in b37a44a
and I think it's also a better solution for #7997, which can also fix #9352
Also, as MDN web doc says, the
calc() min() max() clamp()
function can all be used anywhere a <length>, <frequency>, <angle>, <time>, <percentage>, <number>, or <integer> is allowed. So we can basically just check the value is wrapped by css functions innumber
,length
, andpercentage
tailwindcss/src/util/dataTypes.js
Line 9 in b37a44a
So we can now create some crazy stuff like
discussions: #9351