diff --git a/.eslintrc.js b/.eslintrc.js index 9d952ec..346d8b7 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -4,6 +4,5 @@ module.exports = { ], env: { es6: false - }, - parserOptions: null + } }; diff --git a/.travis.yml b/.travis.yml index 054c653..2d20f42 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,5 @@ language: node_js node_js: - - "0.10" - - "0.12" - - "4" - "6" - "8" - "10" diff --git a/lib/UnexpectedMarkdown.js b/lib/UnexpectedMarkdown.js index 8f1ec24..e442c30 100644 --- a/lib/UnexpectedMarkdown.js +++ b/lib/UnexpectedMarkdown.js @@ -59,7 +59,7 @@ UnexpectedMarkdown.prototype.toHtml = function (options, cb) { this.getSnippets(options, passError(cb, function (snippets) { var index = 0; var renderer = new marked.Renderer(); - renderer.code = function (code, blockInfoString, escaped) { + renderer.code = function (code) { var snippet = snippets.get(index); var previousSnippet = snippets.get(index - 1); index += 1; @@ -94,6 +94,7 @@ UnexpectedMarkdown.prototype.getSnippets = function (options, cb) { if (this.snippets) { cb(null, this.snippets); } else { + // eslint-disable-next-line handle-callback-err Snippets.fromMarkdown(this.content, options, function (err, snippets) { that.snippets = snippets; cb(null, snippets); @@ -105,7 +106,7 @@ UnexpectedMarkdown.prototype.withUpdatedExamples = function (options, cb) { var content = this.content; this.getSnippets(options, passError(cb, function (snippets) { var index = 0; - var updateContent = content.replace(snippetRegexp, function ($0, lang, code) { + var updateContent = content.replace(snippetRegexp, function ($0, lang) { var currentIndex = index; index += 1; var snippet = snippets.get(currentIndex); diff --git a/lib/convertMarkdownToMocha.js b/lib/convertMarkdownToMocha.js index bc37517..8e60723 100644 --- a/lib/convertMarkdownToMocha.js +++ b/lib/convertMarkdownToMocha.js @@ -267,10 +267,10 @@ module.exports = function (mdSrc, fileName) { var separator = '\n//---------------------um-separator---------------------\n'; var transpiledCode = transpile(preambleSeparator + codeBlocks.map(function (codeBlock) { return codeBlock.flags.async - ? '(function unexpectedMarkdownScope() {' + + ? '(function unexpectedMarkdownScope() {' + codeBlock.code + '})("unexpectedMarkdownScope");' - : codeBlock.code; + : codeBlock.code; }).join(separator)); var transpiledBlocks = transpiledCode diff --git a/lib/evaluateSnippets.js b/lib/evaluateSnippets.js index fae9c4b..f1e6362 100644 --- a/lib/evaluateSnippets.js +++ b/lib/evaluateSnippets.js @@ -66,8 +66,8 @@ module.exports = function (snippets, options, cb) { if (exampleSnippets.length) { var codeForTranspilation = preambleSeparator + exampleSnippets.map(function (snippet) { return snippet.flags.async - ? '(function () {' + snippet.code + '})();' - : snippet.code; + ? '(function () {' + snippet.code + '})();' + : snippet.code; }).join(separator); var transpiledCode = transpile(codeForTranspilation); @@ -92,8 +92,8 @@ module.exports = function (snippets, options, cb) { if (snippet.flags.async) { var promise = vm.runInThisContext( hasBabel - ? snippet.code - : '(function () {' + snippet.code + '})();' + ? snippet.code + : '(function () {' + snippet.code + '})();' ); if (!isPromise(promise)) { throw new Error('Async code block did not return a promise or throw\n' + snippet.code); diff --git a/package.json b/package.json index 0926379..822fdb1 100644 --- a/package.json +++ b/package.json @@ -31,9 +31,9 @@ "source-map-support": "^0.5.9" }, "devDependencies": { - "eslint": "^2.13.1", - "eslint-config-onelint": "^1.2.0", - "mocha": "^2.2.5", + "eslint": "^5.11.1", + "eslint-config-onelint": "^4.0.0", + "mocha": "^5.2.0", "unexpected": "^10.40.0" }, "author": "Sune Simonsen", diff --git a/test/UnexpectedMarkdown.spec.js b/test/UnexpectedMarkdown.spec.js index 0231dec..d29ffc9 100644 --- a/test/UnexpectedMarkdown.spec.js +++ b/test/UnexpectedMarkdown.spec.js @@ -5,26 +5,26 @@ describe('UnexpectedMarkdown', function () { var markdown; beforeEach(function () { markdown = new UnexpectedMarkdown([ - "Asserts deep equality.", - "", - "```javascript", + 'Asserts deep equality.', + '', + '```javascript', "expect({ a: 'b' }, 'to equal', { a: 'b' });", - "var now = new Date();", + 'var now = new Date();', "expect(now, 'to equal', now);", "expect(now, 'to equal', new Date(now.getTime()));", "expect({ now: now }, 'to equal', { now: now });", - "```", - "", - "For a lot of types a failing equality test results in a nice", - "diff. Below you can see an object diff.", - "", - "```javascript", + '```', + '', + 'For a lot of types a failing equality test results in a nice', + 'diff. Below you can see an object diff.', + '', + '```javascript', "expect({ text: 'foo!' }, 'to equal', { text: 'f00!' });", - "```", - "", - "```output", - "Missing output", - "```" + '```', + '', + '```output', + 'Missing output', + '```' ].join('\n')); }); @@ -44,12 +44,12 @@ describe('UnexpectedMarkdown', function () { it('syntax highlight examples', function () { return expect(htmlPromise, 'when fulfilled', - 'to contain', 'expect'); + 'to contain', 'expect'); }); it('outputs evaluated examples', function () { return expect(htmlPromise, 'when fulfilled', - 'to contain', 'f00'); + 'to contain', 'f00'); }); }); @@ -69,16 +69,16 @@ describe('UnexpectedMarkdown', function () { it('produces a markdown where the examples has been updated', function () { return expect(updatedMarkdownPromise, 'when fulfilled', 'to contain', [ - "```output", + '```output', "expected { text: 'foo!' } to equal { text: 'f00!' }", - "", - "{", + '', + '{', " text: 'foo!' // should equal 'f00!'", - " //", - " // -foo!", - " // +f00!", - "}", - "```" + ' //', + ' // -foo!', + ' // +f00!', + '}', + '```' ].join('\n')); }); }); diff --git a/test/convertMarkdownToMocha.js b/test/convertMarkdownToMocha.js index 34a394a..1cd574f 100644 --- a/test/convertMarkdownToMocha.js +++ b/test/convertMarkdownToMocha.js @@ -27,12 +27,12 @@ var synchronousSuccessfulSnippet = var returningSuccessfulSnippet = "var blah = 'abc';\n" + "if (blah === 'abc') {\n" + - " return expect.promise(function (resolve, reject) {\n" + - " setImmediate(resolve);\n" + - " });\n" + - "} else {\n" + - " return 456;\n" + - "}\n"; + ' return expect.promise(function (resolve, reject) {\n' + + ' setImmediate(resolve);\n' + + ' });\n' + + '} else {\n' + + ' return 456;\n' + + '}\n'; var synchronousThrowingSnippet = "var bar = 'abc';\n" + @@ -211,6 +211,7 @@ describe('convertMarkdownToMocha', function () { } else { return endOfExample1(); } + // eslint-disable-next-line handle-callback-err function endOfExample1(err) { var __returnValue2; example2: try { @@ -373,6 +374,7 @@ describe('convertMarkdownToMocha', function () { } else { return endOfExample1(); } + // eslint-disable-next-line handle-callback-err function endOfExample1(err) { var __returnValue2; example2: try { @@ -449,6 +451,7 @@ describe('convertMarkdownToMocha', function () { } else { return endOfExample1(); } + // eslint-disable-next-line handle-callback-err function endOfExample1(err) { var __returnValue2; example2: try { @@ -525,6 +528,7 @@ describe('convertMarkdownToMocha', function () { } else { return endOfExample1(); } + // eslint-disable-next-line handle-callback-err function endOfExample1(err) { expect = unexpected.clone(); var __returnValue2;