Skip to content

Commit

Permalink
feat: validate illformed YAML comments (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickm68 committed Apr 24, 2021
1 parent ca72175 commit 2a24eac
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions remark-lint-nodejs-yaml-comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ function validateMeta(node, file, meta) {

function validateYAMLComments(tree, file) {
visit(tree, "html", function visitor(node) {
if (node.value.startsWith("<!--YAML\n"))
file.message(
"Expected `<!-- YAML`, found `<!--YAML`. Please add a space",
node
);
if (!node.value.startsWith("<!-- YAML\n")) return;
try {
const meta = yaml.load("#" + node.value.slice(0, -"-->".length));
Expand Down

0 comments on commit 2a24eac

Please sign in to comment.