aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-06-28 20:58:49 +0100
committerMichael Williamson <mike@zwobble.org>2016-06-28 20:58:49 +0100
commitd046c4297a04b6eecadf01093382b72bb1b71032 (patch)
treed90fc8dde051f2dba93c41f77506f472269124ba
parentf557dc7de5fd0dff3a08808e7c4d9736970e6349 (diff)
Replace jshint with eslint
-rw-r--r--.jshintrc7
-rw-r--r--lib/document-to-html.js2
-rw-r--r--lib/docx/docx-reader.js2
-rw-r--r--lib/main.js2
-rw-r--r--lib/style-reader.js2
-rw-r--r--lib/writers/markdown-writer.js2
-rw-r--r--package.json24
-rw-r--r--tests/.eslintrc.json7
-rw-r--r--tests/document-to-html.tests.js6
-rw-r--r--tests/docx/body-reader.tests.js4
-rw-r--r--tests/docx/styles-reader.tests.js2
-rw-r--r--tests/main.tests.js2
-rw-r--r--tests/writers/markdown-writer.tests.js8
13 files changed, 45 insertions, 25 deletions
diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index 083f4a0..0000000
--- a/.jshintrc
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "eqnull": true,
- "undef": true,
- "unused": "vars",
-
- "predef": ["require", "exports", "__dirname", "module", "Buffer", "describe", "it", "setTimeout", "process", "console"]
-}
diff --git a/lib/document-to-html.js b/lib/document-to-html.js
index 740fc30..f2d5229 100644
--- a/lib/document-to-html.js
+++ b/lib/document-to-html.js
@@ -277,7 +277,7 @@ function DocumentConversion(options) {
var children = convertElements(element.body, messages);
var backLink = Html.elementWithTag(htmlPaths.element("p", {}, {fresh: false}), [
Html.text(" "),
- Html.freshElement("a", {href: "#" + noteRefHtmlId(element)}, [Html.text("↑")]),
+ Html.freshElement("a", {href: "#" + noteRefHtmlId(element)}, [Html.text("↑")])
]);
var body = children.concat([backLink]);
diff --git a/lib/docx/docx-reader.js b/lib/docx/docx-reader.js
index 8627022..8ef4960 100644
--- a/lib/docx/docx-reader.js
+++ b/lib/docx/docx-reader.js
@@ -55,7 +55,7 @@ function read(docxFile, input) {
return result.notes.flatMap(function(notes) {
var reader = new DocumentXmlReader({
bodyReader: bodyReader,
- notes: notes,
+ notes: notes
});
return reader.convertXmlToDocument(xml);
});
diff --git a/lib/main.js b/lib/main.js
index f59064f..f6e149f 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -1,3 +1,5 @@
+/* global process */
+
var fs = require("fs");
var path = require("path");
diff --git a/lib/style-reader.js b/lib/style-reader.js
index af6206c..9969bbe 100644
--- a/lib/style-reader.js
+++ b/lib/style-reader.js
@@ -151,7 +151,7 @@ function htmlPathRule() {
return option.map(function() {
return true;
}).valueOrElse(false);
- }
+ }
);
var tagNamesRule = lop.rules.oneOrMoreWithSeparator(
diff --git a/lib/writers/markdown-writer.js b/lib/writers/markdown-writer.js
index 872db13..079d924 100644
--- a/lib/writers/markdown-writer.js
+++ b/lib/writers/markdown-writer.js
@@ -76,7 +76,7 @@ var htmlToMarkdown = {
"strong": symmetricMarkdownElement("__"),
"em": symmetricMarkdownElement("*"),
"a": markdownLink,
- "img": markdownImage,
+ "img": markdownImage
};
(function() {
diff --git a/package.json b/package.json
index 80f62f0..492757c 100644
--- a/package.json
+++ b/package.json
@@ -33,7 +33,8 @@
"duck": "~0.1.11",
"uglify-js": "~2.4.8",
"temp": "~0.7.0",
- "jshint": "^2.5.2"
+ "eslint": "2.13.1",
+ "eslint-config-airbnb-base": "3.0.1"
},
"browser": {
"./lib/unzip.js": "./browser/unzip.js",
@@ -43,9 +44,26 @@
"mammoth": "bin/mammoth"
},
"scripts": {
- "pretest": "jshint lib tests",
+ "pretest": "eslint lib tests",
"test": "mocha tests --recursive",
"prepublish": "make mammoth.browser.min.js"
},
- "license": "BSD-2-Clause"
+ "license": "BSD-2-Clause",
+ "eslintConfig": {
+ "extends": "eslint:recommended",
+
+ "rules": {
+ "indent": ["error", 4],
+ "no-unused-vars": ["error", {"args": "none"}],
+ "object-curly-spacing": ["error", "never"]
+ },
+
+ "globals": {
+ "Buffer": false,
+ "console": true,
+ "exports": true,
+ "module": true,
+ "require": false
+ }
+ }
}
diff --git a/tests/.eslintrc.json b/tests/.eslintrc.json
new file mode 100644
index 0000000..4869f03
--- /dev/null
+++ b/tests/.eslintrc.json
@@ -0,0 +1,7 @@
+{
+ "globals": {
+ "__dirname": false,
+ "describe": false,
+ "it": false
+ }
+}
diff --git a/tests/document-to-html.tests.js b/tests/document-to-html.tests.js
index ea0056f..10ea265 100644
--- a/tests/document-to-html.tests.js
+++ b/tests/document-to-html.tests.js
@@ -63,7 +63,7 @@ describe('DocumentConverter', function() {
test('uses style mappings to pick HTML element for docx paragraph', function() {
var document = new documents.Document([
- paragraphOfText("Hello.", "Heading1", "Heading 1"),
+ paragraphOfText("Hello.", "Heading1", "Heading 1")
]);
var converter = new DocumentConverter({
styleMap: [
@@ -80,7 +80,7 @@ describe('DocumentConverter', function() {
test('mappings for style names are case insensitive', function() {
var document = new documents.Document([
- paragraphOfText("Hello.", "Heading1", "heading 1"),
+ paragraphOfText("Hello.", "Heading1", "heading 1")
]);
var converter = new DocumentConverter({
styleMap: [
@@ -114,7 +114,7 @@ describe('DocumentConverter', function() {
test('warning is emitted if paragraph style is unrecognised', function() {
var document = new documents.Document([
- paragraphOfText("Hello.", "Heading1", "Heading 1"),
+ paragraphOfText("Hello.", "Heading1", "Heading 1")
]);
var converter = new DocumentConverter();
return converter.convertToHtml(document).then(function(result) {
diff --git a/tests/docx/body-reader.tests.js b/tests/docx/body-reader.tests.js
index 4a54aeb..0a808b0 100644
--- a/tests/docx/body-reader.tests.js
+++ b/tests/docx/body-reader.tests.js
@@ -303,7 +303,7 @@ describe("readXmlElement: ", function() {
test("w:vMerge without val is treated as continue", function() {
var tableXml = new XmlElement("w:tbl", {}, [
row(emptyCell(vMerge("restart"))),
- row(emptyCell(vMerge())),
+ row(emptyCell(vMerge()))
]);
var result = readXmlElement(tableXml);
assert.deepEqual(result.value, new documents.Table([
@@ -336,7 +336,7 @@ describe("readXmlElement: ", function() {
var result = readXmlElement(tableXml);
assert.deepEqual(result.value, new documents.Table([
docRow([docEmptyCell({colSpan: 2})]),
- docRow([docEmptyCell(), docEmptyCell()]),
+ docRow([docEmptyCell(), docEmptyCell()])
]));
});
diff --git a/tests/docx/styles-reader.tests.js b/tests/docx/styles-reader.tests.js
index 2bdda33..4ff19c7 100644
--- a/tests/docx/styles-reader.tests.js
+++ b/tests/docx/styles-reader.tests.js
@@ -45,7 +45,7 @@ describe('readStylesXml', function() {
test('character and table styles are distinct', function() {
var styles = readStylesXml({
root: new XmlElement("w:styles", {}, [
- styleElement("table", "Heading1", "Heading 1"),
+ styleElement("table", "Heading1", "Heading 1")
])
});
assert.equal(styles.findCharacterStyleById("Heading1"), null);
diff --git a/tests/main.tests.js b/tests/main.tests.js
index 8041fbd..5b54441 100644
--- a/tests/main.tests.js
+++ b/tests/main.tests.js
@@ -78,7 +78,7 @@ function runMammoth() {
// TODO: proper escaping of args
var command = processArgs.join(" ");
child_process.exec(command, function(error, stdout, stderr) {
- console.log(stderr);
+ console.log(stderr); // eslint-disable-line no-console
assert.equal(error, null);
deferred.resolve({output: stdout, stderrOutput: stderr});
});
diff --git a/tests/writers/markdown-writer.tests.js b/tests/writers/markdown-writer.tests.js
index 8d05ff6..38d2afe 100644
--- a/tests/writers/markdown-writer.tests.js
+++ b/tests/writers/markdown-writer.tests.js
@@ -69,7 +69,7 @@ describe('markdown-writer', function() {
test('anchor tags are written as hyperlinks', function() {
var writer = mdWriter.writer();
- writer.open("a", { "href": "http://example.com" });
+ writer.open("a", {"href": "http://example.com"});
writer.text("Hello");
writer.close("a");
return assert.equal(writer.asString(), "[Hello](http://example.com)");
@@ -101,19 +101,19 @@ describe('markdown-writer', function() {
test('can generate images', function() {
var writer = mdWriter.writer();
- writer.selfClosing("img", { "src": "http://example.com/image.jpg", "alt": "Alt Text" });
+ writer.selfClosing("img", {"src": "http://example.com/image.jpg", "alt": "Alt Text"});
return assert.equal(writer.asString(), "![Alt Text](http://example.com/image.jpg)");
});
test('can generate images with missing alt attribute', function() {
var writer = mdWriter.writer();
- writer.selfClosing("img", { "src": "http://example.com/image.jpg" });
+ writer.selfClosing("img", {"src": "http://example.com/image.jpg"});
return assert.equal(writer.asString(), "![](http://example.com/image.jpg)");
});
test('can generate images with missing src attribute', function() {
var writer = mdWriter.writer();
- writer.selfClosing("img", { "alt": "Alt Text" });
+ writer.selfClosing("img", {"alt": "Alt Text"});
return assert.equal(writer.asString(), "![Alt Text]()");
});