Skip to content

Commit

Permalink
Build: Makefile - Check for rule ids in docs titles (Fixes eslint#969)
Browse files Browse the repository at this point in the history
  • Loading branch information
Delapouite committed Jun 11, 2014
1 parent e9525bc commit 0645c33
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Makefile.js
Expand Up @@ -265,6 +265,7 @@ target.checkRuleFiles = function() {

ruleFiles.forEach(function(filename) {
var basename = path.basename(filename, ".js");
var docFilename = "docs/rules/" + basename + ".md";

var indexLine = new RegExp("\\* \\[" + basename + "\\].*").exec(rulesIndexText);
indexLine = indexLine ? indexLine[0] : "";
Expand Down Expand Up @@ -299,9 +300,14 @@ target.checkRuleFiles = function() {
}
}

function hasIdInTitle(basename) {
var docText = cat(docFilename);
var idInTitleRegExp = new RegExp("^# (.*?) \\(" + basename + "\\)");
return idInTitleRegExp.test(docText);
}

// check for docs
if (!test("-f", "docs/rules/" + basename + ".md")) {
if (!test("-f", docFilename)) {
console.error("Missing documentation for rule %s", basename);
errors++;
} else {
Expand All @@ -311,6 +317,12 @@ target.checkRuleFiles = function() {
console.error("Missing link to documentation for rule %s in index", basename);
errors++;
}

// check for proper doc format
if (!hasIdInTitle(basename)) {
console.error("Missing id in the doc page's title of rule %s", basename);
errors++;
}
}

// check for default configuration
Expand Down Expand Up @@ -354,7 +366,7 @@ target.checkRuleFiles = function() {
errors++;
}

// rule has been overridden in environment but is not in docs
// rule has been overridden in environment but is not in docs
} else {
console.error("Missing '(%s by default in the %s environment)' for rule %s in index", isOnInConfig(env) ? "on" : "off", env, basename);
errors++;
Expand Down

0 comments on commit 0645c33

Please sign in to comment.