test: check replaced iff translatable comment

All translatable comments should be replaced, but nothing else.
This commit is contained in:
Oliver Eyton-Williams
2020-09-23 16:38:20 +02:00
committed by Mrugesh Mohapatra
parent d2ecd03013
commit 793fa8fb52
15 changed files with 1057 additions and 1304 deletions

View File

@ -0,0 +1,20 @@
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;