Skip to content
This repository has been archived by the owner on Dec 9, 2017. It is now read-only.

Commit

Permalink
Merge pull request #5 from azu/fix_4
Browse files Browse the repository at this point in the history
Add "json" formatter
  • Loading branch information
azu committed Oct 17, 2015
2 parents c87ed7f + f7e6946 commit 6920e56
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/formatters/json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// LICENSE : MIT
"use strict";
module.exports = function (results) {
return JSON.stringify(results);
};
47 changes: 47 additions & 0 deletions test/json-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// LICENSE : MIT
"use strict";
var assert = require("power-assert");
describe("json-test", function () {
it("should return json", function () {

it("run all formatter", function () {
var formatter = createFormatter({
formatterName: "json"
});
var results = [
{
filePath: __dirname + "/fixtures/myfile.js",
messages: [
{
ruleId: "semi",
line: 1,
column: 0,
message: "0 pattern."
},
{
ruleId: "semi",
line: 2,
column: 26,
message: "Expected a semicolon."
},
{
ruleId: "semi",
line: 1,
column: 21,
message: "Expected a semicolon."
},
{
ruleId: "semi",
line: 2,
column: 26,
message: "Expected a semicolon."
}
]
}
];
var output = formatter(results);
var reParse = JSON.parse(output);
assert.deepEqual(reParse, results);
});
});
});

0 comments on commit 6920e56

Please sign in to comment.