-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🔧 Tighten up JSON input #1405
🔧 Tighten up JSON input #1405
Conversation
opts, | ||
); | ||
// Although this is required, we'll set it to an empty article by default | ||
const mdast: GenericParent = value?.mdast ?? { type: 'root', children: [] }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a reasonable thing to do? Declare this mdast
property required
, but add a default? I did this so that we don't need to throw an error in this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although maybe throwing an error (or at least returning undefined
) would be better?
Both of these results are handled gracefully in the loadFile
function where this is called, and then we wouldn't end up persisting and processing this likely erroneous empty page?
@rowanc1 this follows from our meeting, and fixes the frontmatter. |
file: vfile.path, | ||
messages: {}, | ||
errorLogFn: (message: string) => { | ||
fileError(vfile, message, { ruleId: opts?.ruleId ?? RuleId.mystJsonValid }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of the rule ID follows our existing convention.
@fwkoch friendly ping! :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to be slow on this! A few comments, hopefully they make sense. In particular, I think just throwing an error during validation would be fine (and probably better).
opts, | ||
); | ||
// Although this is required, we'll set it to an empty article by default | ||
const mdast: GenericParent = value?.mdast ?? { type: 'root', children: [] }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although maybe throwing an error (or at least returning undefined
) would be better?
Both of these results are handled gracefully in the loadFile
function where this is called, and then we wouldn't end up persisting and processing this likely erroneous empty page?
🦋 Changeset detectedLatest commit: bdad6fc The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Fab! Thanks @fwkoch, will merge this in! |
This PR adds some validation for JSON-file input, and applies our frontmatter transforms.