freeCodeCamp/curriculum/test/utils/plugins/get-html-comments.js
Oliver Eyton-Williams 793fa8fb52 test: check replaced iff translatable comment
All translatable comments should be replaced, but nothing else.
2020-10-22 03:18:13 +05:30

21 lines
429 B
JavaScript

const { isEmpty } = require('lodash');
const visit = require('unist-util-visit');
const { commentToData } = require('../comment-to-data');
function plugin() {
return transformer;
function transformer(tree, file) {
if (isEmpty(file.data)) {
file.data = {};
}
visit(tree, 'comment', visitor);
function visitor(node) {
commentToData(file, node.value.trim());
}
}
}
module.exports = plugin;