diff options
| author | Michael Williamson <mike@zwobble.org> | 2014-07-08 10:25:57 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2014-07-08 10:25:57 +0100 |
| commit | 472cd053aab1432d19f9deebb6141567bbe91ff6 (patch) | |
| tree | 2d328353ebd0947e8007267592e45bdd0d879730 | |
| parent | 40fc65d1f2874eb707a4fb4e93c4a66ccd59f850 (diff) | |
Use jshint and fix errors
| -rw-r--r-- | lib/documents.js | 4 | ||||
| -rw-r--r-- | package.json | 4 | ||||
| -rw-r--r-- | tests/docx/document-xml-reader.tests.js | 4 | ||||
| -rw-r--r-- | tests/html-generator.tests.js | 6 | ||||
| -rw-r--r-- | tests/html-writer.tests.js | 2 | ||||
| -rw-r--r-- | tests/main.tests.js | 20 | ||||
| -rw-r--r-- | tests/mammoth.tests.js | 8 | ||||
| -rw-r--r-- | tests/style-reader.tests.js | 6 | ||||
| -rw-r--r-- | tests/testing.js | 2 | ||||
| -rw-r--r-- | tests/xmlreader.tests.js | 22 |
10 files changed, 40 insertions, 38 deletions
diff --git a/lib/documents.js b/lib/documents.js index a781bbd..c1ac4a3 100644 --- a/lib/documents.js +++ b/lib/documents.js @@ -80,7 +80,7 @@ function Footnotes(footnotes) { Footnotes.prototype.findFootnoteById = function(id) { return this._footnotes[id] || null; -} +}; function Footnote(options) { return { @@ -88,7 +88,7 @@ function Footnote(options) { body: options.body, id: options.id }; -}; +} function ElementWithChildren(type) { return function(children, properties) { diff --git a/package.json b/package.json index 5585196..71cf5db 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,8 @@ "license-sniffer": "~0.1.0", "duck": "~0.1.11", "uglify-js": "~2.4.8", - "temp": "~0.7.0" + "temp": "~0.7.0", + "jshint": "^2.5.2" }, "browser": { "./lib/unzip.js": "./browser/unzip.js" @@ -38,6 +39,7 @@ "mammoth": "bin/mammoth" }, "scripts": { + "pretest": "jshint lib tests", "test": "mocha tests --recursive" }, "licenses": [ diff --git a/tests/docx/document-xml-reader.tests.js b/tests/docx/document-xml-reader.tests.js index 0897336..2c0f8ea 100644 --- a/tests/docx/document-xml-reader.tests.js +++ b/tests/docx/document-xml-reader.tests.js @@ -11,7 +11,7 @@ var test = testing.test; var createFakeDocxFile = testing.createFakeDocxFile; function readXmlElement(element, options) { - options = options || {} + options = options || {}; return new DocumentXmlReader(options).readXmlElement(element); } @@ -253,7 +253,7 @@ describe("readXmlElement: ", function() { assert.equal(element.altText, "It's a hat"); return element.read() .then(function(readValue) { - assert.equal(readValue, imageBuffer) + assert.equal(readValue, imageBuffer); }); }); diff --git a/tests/html-generator.tests.js b/tests/html-generator.tests.js index 220a0bf..f361633 100644 --- a/tests/html-generator.tests.js +++ b/tests/html-generator.tests.js @@ -35,7 +35,7 @@ describe('HtmlGenerator', function() { test('generates empty string if text is empty string', function() { var generator = new HtmlGenerator(); generator.satisfyPath(htmlPaths.elements(["p", "span"])); - generator.text("") + generator.text(""); generator.closeAll(); return assert.equal(generator.asString(), ""); }); @@ -45,7 +45,7 @@ describe('HtmlGenerator', function() { var listPath = htmlPaths.elements([ htmlPaths.element("ul", {}, {fresh: false}), htmlPaths.element("li", {}, {fresh: true}) - ]) + ]); generator.satisfyPath(listPath); generator.text("Apple"); generator.satisfyPath(listPath); @@ -69,4 +69,4 @@ describe('HtmlGenerator', function() { generator.selfClosing({tagName: "br", attributes: {"data-blah": "<"}}); return assert.equal(generator.asString(), '<br data-blah="<" />'); }); -}) +}); diff --git a/tests/html-writer.tests.js b/tests/html-writer.tests.js index c317544..64c9ea0 100644 --- a/tests/html-writer.tests.js +++ b/tests/html-writer.tests.js @@ -103,4 +103,4 @@ describe('html-writer', function() { writer.close("p"); return assert.equal(writer.asString(), "<p>\n One\n Two\n</p>"); }); -}) +}); diff --git a/tests/main.tests.js b/tests/main.tests.js index 01004a8..633f0bd 100644 --- a/tests/main.tests.js +++ b/tests/main.tests.js @@ -12,8 +12,8 @@ var testPath = require("./testing").testPath; describe("CLI", function() { test("HTML is printed to stdout if output file is not set", function() { return runMammoth(testPath("single-paragraph.docx")).then(function(result) { - assert.equal(result.stderrOutput, "") - assert.equal(result.output, "<p>Walking on imported air</p>") + assert.equal(result.stderrOutput, ""); + assert.equal(result.output, "<p>Walking on imported air</p>"); }); }); @@ -21,8 +21,8 @@ describe("CLI", function() { return createTempDir().then(function(tempDir) { var outputPath = path.join(tempDir, "output.html"); return runMammoth(testPath("single-paragraph.docx"), outputPath).then(function(result) { - assert.equal(result.stderrOutput, "") - assert.equal(result.output, "") + assert.equal(result.stderrOutput, ""); + assert.equal(result.output, ""); assert.equal(fs.readFileSync(outputPath, "utf8"), "<p>Walking on imported air</p>"); }); }); @@ -32,8 +32,8 @@ describe("CLI", function() { test("inline images are included in output if writing to single file", function() { return runMammoth(testPath("tiny-picture.docx")).then(function(result) { - assert.equal(result.stderrOutput, "") - assert.equal(result.output, '<p><img src="data:image/png;base64,' + imageBase64 + '" /></p>') + assert.equal(result.stderrOutput, ""); + assert.equal(result.output, '<p><img src="data:image/png;base64,' + imageBase64 + '" /></p>'); }); }); @@ -42,8 +42,8 @@ describe("CLI", function() { var outputPath = path.join(tempDir, "tiny-picture.html"); var imagePath = path.join(tempDir, "1.png"); return runMammoth(testPath("tiny-picture.docx"), "--output-dir", tempDir).then(function(result) { - assert.equal(result.stderrOutput, "") - assert.equal(result.output, "") + assert.equal(result.stderrOutput, ""); + assert.equal(result.output, ""); assert.equal(fs.readFileSync(outputPath, "utf8"), '<p><img src="1.png" /></p>'); assert.equal(fs.readFileSync(imagePath, "base64"), imageBase64); }); @@ -55,8 +55,8 @@ describe("CLI", function() { var styleMapPath = path.join(tempDir, "style-map"); fs.writeFileSync(styleMapPath, "p => span:fresh"); return runMammoth(testPath("single-paragraph.docx"), "--style-map", styleMapPath).then(function(result) { - assert.equal(result.stderrOutput, "") - assert.equal(result.output, "<span>Walking on imported air</span>") + assert.equal(result.stderrOutput, ""); + assert.equal(result.output, "<span>Walking on imported air</span>"); }); }); }); diff --git a/tests/mammoth.tests.js b/tests/mammoth.tests.js index 11f4fc6..6d7125d 100644 --- a/tests/mammoth.tests.js +++ b/tests/mammoth.tests.js @@ -4,7 +4,7 @@ var fs = require("fs"); var promises = require("../lib/promises"); -var mammoth = require("../") +var mammoth = require("../"); var htmlPaths = require("../lib/html-paths"); var documentMatchers = require("../lib/document-matchers"); @@ -113,7 +113,7 @@ describe('mammoth', function() { '<sup><a href="#footnote-42-1" id="footnote-ref-42-1">[1]</a></sup>.' + '<sup><a href="#footnote-42-2" id="footnote-ref-42-2">[2]</a></sup></p>' + '<ol><li id="footnote-42-1"><p> A tachyon walks into a bar. <a href="#footnote-ref-42-1">↑</a></p></li>' + - '<li id="footnote-42-2"><p> Fin. <a href="#footnote-ref-42-2">↑</a></p></li></ol>' + '<li id="footnote-42-2"><p> Fin. <a href="#footnote-ref-42-2">↑</a></p></li></ol>'; assert.equal(result.value, expectedOutput); // TODO: get rid of warnings //~ assert.deepEqual(result.messages, []); @@ -130,7 +130,7 @@ describe('mammoth', function() { test('using styleMapping throws error', function() { try { - mammoth.styleMapping() + mammoth.styleMapping(); } catch (error) { assert.equal( error.message, @@ -145,4 +145,4 @@ describe('mammoth', function() { assert.equal(result.value, 'Apple\n\nBanana\n\n'); }); }); -}) +}); diff --git a/tests/style-reader.tests.js b/tests/style-reader.tests.js index d9efe01..28df434 100644 --- a/tests/style-reader.tests.js +++ b/tests/style-reader.tests.js @@ -31,21 +31,21 @@ describe('styleReader.readHtmlPath', function() { test('reads class on element', function() { var expected = htmlPaths.elements([ htmlPaths.element("p", {"class": "tip"}) - ]) + ]); assert.deepEqual(readHtmlPath("p.tip"), expected); }); test('reads multiple classes on element', function() { var expected = htmlPaths.elements([ htmlPaths.element("p", {"class": "tip help"}) - ]) + ]); assert.deepEqual(readHtmlPath("p.tip.help"), expected); }); test('reads when element must be fresh', function() { var expected = htmlPaths.elements([ htmlPaths.element("p", {}, {"fresh": true}) - ]) + ]); assert.deepEqual(readHtmlPath("p:fresh"), expected); }); }); diff --git a/tests/testing.js b/tests/testing.js index 9e64ca6..b8757c9 100644 --- a/tests/testing.js +++ b/tests/testing.js @@ -13,7 +13,7 @@ function test(name, func) { it(name, function(done) { var result = func(); promises.when(result).then(function() { - done() + done(); }).done(); }); } diff --git a/tests/xmlreader.tests.js b/tests/xmlreader.tests.js index aec0229..842e300 100644 --- a/tests/xmlreader.tests.js +++ b/tests/xmlreader.tests.js @@ -9,25 +9,25 @@ describe('xmlreader.read', function() { return xmlreader.read("<body/>").then(function(result) { assert.deepEqual({type: "element", name: "body", attributes: {}, children: []}, result.root); }); - }) + }); test('should read empty element with separate closing tag', function() { return xmlreader.read("<body></body>").then(function(result) { assert.deepEqual({type: "element", name: "body", attributes: {}, children: []}, result.root); }); - }) + }); test('should read attributes of tags', function() { return xmlreader.read('<body name="bob"/>').then(function(result) { assert.deepEqual({name: "bob"}, result.root.attributes); }); - }) + }); test('can read text element', function() { return xmlreader.read('<body>Hello!</body>').then(function(result) { assert.deepEqual({type: "text", value: "Hello!"}, result.root.children[0]); }); - }) + }); test('should read element with children', function() { return xmlreader.read("<body><a/><b/></body>").then(function(result) { @@ -36,13 +36,13 @@ describe('xmlreader.read', function() { assert.equal("a", root.children[0].name); assert.equal("b", root.children[1].name); }); - }) + }); test('unmapped namespaces URIs are included in braces as prefix', function() { return xmlreader.read('<w:body xmlns:w="word"/>').then(function(result) { assert.deepEqual(result.root.name, "{word}:body"); }); - }) + }); test('mapped namespaces URIs are translated using map', function() { var namespaceMap = { @@ -52,7 +52,7 @@ describe('xmlreader.read', function() { return xmlreader.read('<w:body xmlns:w="word"/>', namespaceMap).then(function(result) { assert.deepEqual(result.root.name, "x:body"); }); - }) + }); test('namespace of attributes is mapped to prefix', function() { var namespaceMap = { @@ -62,20 +62,20 @@ describe('xmlreader.read', function() { return xmlreader.read(xmlString, namespaceMap).then(function(result) { assert.deepEqual(result.root.attributes["x:val"], "Hello!"); }); - }) + }); test('can find first element with name', function() { return xmlreader.read('<body><a/><b index="1"/><b index="2"/></body>').then(function(result) { var first = result.root.first("b"); assert.equal("1", first.attributes.index); }); - }) + }); test('whitespace between xml declaration and root tag is ignored', function() { return xmlreader.read('<?xml version="1.0" ?>\n<body/>').then(function(result) { assert.deepEqual("body", result.root.name); }); - }) + }); test('error if XML is badly formed', function() { return xmlreader.read("<bo").then(function(result) { @@ -84,5 +84,5 @@ describe('xmlreader.read', function() { assert.ok(error); return 1; }); - }) + }); }); |
