Files
freeCodeCamp/tools/linter/index.js
Oliver Eyton-Williams 9de68bd4a7 feat: Add rule checking Prism languages
The linter now checks that fences have languages and that those languages are
supported by PrismJS. The linter has been extended over the guide with its own
set of rules that only validate code fences.
2019-07-19 15:30:17 +05:30

26 lines
616 B
JavaScript

const markdownlint = require('markdownlint');
const lintPrism = require('./markdown-prism');
const lintYAML = require('./markdown-yaml');
function linter(rules) {
const lint = (file, next) => {
const options = {
files: [file.path],
config: rules,
customRules: [lintYAML, lintPrism]
};
markdownlint(options, function callback(err, result) {
const resultString = (result || '').toString();
if (resultString) {
process.exitCode = 1;
console.log(resultString);
}
if (next) next(err, file);
});
};
return lint;
}
module.exports = linter;