fix(lint): re-arrange scripts (#36511)

This commit is contained in:
mrugesh
2019-07-26 00:45:31 +05:30
committed by GitHub
parent d73b94133a
commit 603c842c97
15 changed files with 4 additions and 101 deletions

View File

@ -0,0 +1,24 @@
const yaml = require('js-yaml');
module.exports = {
names: ['yaml-linter'],
description: 'YAML code blocks should be valid',
tags: ['yaml'],
function: function rule(params, onError) {
params.tokens
.filter(param => param.type === 'fence')
.filter(param => param.info === 'yml' || param.info === 'yaml')
// TODO since the parser only looks for yml, should we reject yaml blocks?
.forEach(codeBlock => {
try {
yaml.safeLoad(codeBlock.content);
} catch (e) {
onError({
lineNumber: codeBlock.lineNumber,
detail: e.message,
context: codeBlock.line
});
}
});
}
};