Add example, stop modifying files array, rename "styles".

This commit is contained in:
David Anson 2015-03-13 18:20:56 -07:00
parent d3e9f83e7c
commit 9917d7f2fb
7 changed files with 44 additions and 2 deletions

3
example/bad.md Normal file
View file

@ -0,0 +1,3 @@
#bad.md
#This file fails some rules.

3
example/good.md Normal file
View file

@ -0,0 +1,3 @@
# good.md
This file passes all rules.

21
example/standalone.js Normal file
View file

@ -0,0 +1,21 @@
"use strict";
var markdownlint = require("../lib/markdownlint");
var options = {
"files": [ "good.md", "bad.md" ]
};
// Uses result.toString for pretty formatting
markdownlint(options, function callback(err, result) {
if (!err) {
console.log(result.toString());
}
});
// Examines the result object directly
markdownlint(options, function callback(err, result) {
if (!err) {
console.dir(result, { "colors": true });
}
});

View file

@ -77,7 +77,7 @@ function lintFile(file, config, callback) {
module.exports = function markdownlint(options, callback) {
options = options || {};
callback = callback || function noop() {};
var files = options.files || [];
var files = (options.files || []).slice();
var config = options.config || { "default": true };
var results = new Results();
function lintFiles() {

View file

@ -17,7 +17,8 @@
"test": "nodeunit",
"test-cover": "istanbul cover node_modules/nodeunit/bin/nodeunit",
"debug": "node debug node_modules/nodeunit/bin/nodeunit",
"lint": "eslint lib test"
"lint": "eslint lib test & eslint --rule \"no-console: 0\" example",
"example": "cd example & node standalone.js"
},
"dependencies": {
"markdown-it": "^3.0.7"

View file

@ -118,6 +118,20 @@ module.exports.resultFormatting = function resultFormatting(test) {
});
};
module.exports.filesNotModified = function filesNotModified(test) {
test.expect(2);
var files = [
"./test/atx_header_spacing.md",
"./test/first_header_bad_atx.md"
];
var expectedFiles = files.slice();
markdownlint({ "files": files }, function callback(err) {
test.ifError(err);
test.deepEqual(files, expectedFiles, "Files modified.");
test.done();
});
};
module.exports.missingOptions = function missingOptions(test) {
test.expect(2);
markdownlint(null, function callback(err, result) {