Skip to content

Commit

Permalink
Docs: Adding rule summary to README.
Browse files Browse the repository at this point in the history
More details, such as a quick summary of what the rule does, can be added later if needed.
  • Loading branch information
platinumazure committed Apr 5, 2016
1 parent fd0ba50 commit 8cbb8b9
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Expand Up @@ -5,3 +5,22 @@
[![devDependency Status](https://david-dm.org/platinumazure/eslint-plugin-qunit/dev-status.svg)](https://david-dm.org/platinumazure/eslint-plugin-qunit#info=devDependencies)

ESLint plugin containing rules useful for QUnit tests.

## Available Rules

Below is the list of rules available in this plugin.

* [assert-args](./docs/rules/assert-args.md)
* [literal-compare-order](./docs/rules/literal-compare-order.md)
* [no-arrow-tests](./docs/rules/no-arrow-tests.md)
* [no-assert-equal](./docs/rules/no-assert-equal.md)
* [no-async-in-loops](./docs/rules/no-async-in-loops.md)
* [no-async-test](./docs/rules/no-async-test.md)
* [no-commented-tests](./docs/rules/no-commented-tests.md)
* [no-global-assertions](./docs/rules/no-global-assertions.md)
* [no-global-expect](./docs/rules/no-global-expect.md)
* [no-global-module-test](./docs/rules/no-global-module-test.md)
* [no-ok-equality](./docs/rules/no-ok-equality.md)
* [no-only](./docs/rules/no-only.md)
* [require-expect](./docs/rules/require-expect.md)
* [resolve-async](./docs/rules/resolve-async.md)
58 changes: 58 additions & 0 deletions tests/readme.js
@@ -0,0 +1,58 @@
/**
* @fileoverview Unit tests for the README.
* @author Kevin Partington
*/
"use strict";

//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------

var assert = require("chai").assert,
fs = require("fs"),
path = require("path");

//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------

describe("README", function () {
var ruleGroupRegex = /## Available Rules[\s\S]*(?:\n(?=##)|$)/,
ruleRegex = /^\* \[([a-z-]+)\]\(\.\/docs\/rules\/\1\.md\)$/gm,
fileContents,
availableRules;

before(function (done) {
fs.readFile("./README.md", "utf8", function (err, contents) {
if (err) throw err;

fileContents = contents;

fs.readdir("./lib/rules", function (err, files) {
if (err) throw err;

availableRules = files.map(function (file) {
return path.basename(file, ".js");
});

done();
});
});
});

it("should find the rules", function () {
var match = ruleGroupRegex.exec(fileContents),
foundRules = [],
ruleSection;

assert.ok(match, "Rule section should be present");

ruleSection = match[0];

while ((match = ruleRegex.exec(ruleSection)) !== null) {
foundRules.push(match[1]);
}

assert.deepEqual(foundRules, availableRules, "Rules in README should match available rules");
});
});

0 comments on commit 8cbb8b9

Please sign in to comment.