Skip to content

Commit

Permalink
Merge pull request #53 from unexpectedjs/depfu/update/npm/prettier-2.0.2
Browse files Browse the repository at this point in the history
Upgrade prettier to version 2.0.2
  • Loading branch information
papandreou committed Apr 4, 2020
2 parents 2561e08 + b3c74fd commit 3181f82
Show file tree
Hide file tree
Showing 16 changed files with 178 additions and 179 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ node_js:
matrix:
include:
- name: Lint
node_js: '8'
node_js: '12'
env:
- TARGET=lint
- name: Coverage
Expand Down
6 changes: 3 additions & 3 deletions lib/Snippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Snippets {
evaluatedExampleIndex = index;
tests.push({
code: snippet.code,
flags: flags
flags: flags,
});
}
break;
Expand All @@ -45,7 +45,7 @@ class Snippets {
}

module.exports = {
fromMarkdown: function(markdown) {
fromMarkdown: function (markdown) {
return new Snippets(extractSnippets(markdown));
}
},
};
10 changes: 5 additions & 5 deletions lib/UnexpectedMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var maps = {};
// Make the md-to-mocha transpiler avaliable as a side effect of requiring unexpected-markdown
// so that mocha --compilers md:unexpected-markdown will work:
// eslint-disable-next-line node/no-deprecated-api
require.extensions['.md'] = function(module, fileName) {
require.extensions['.md'] = function (module, fileName) {
var sourceMapWithCode = convertMarkdownToMocha(
fs.readFileSync(fileName, 'utf-8'),
fileName
Expand Down Expand Up @@ -40,9 +40,9 @@ try {
if (sourceMapSupport) {
sourceMapSupport.install({
handleUncaughtExceptions: false,
retrieveSourceMap: function(source) {
retrieveSourceMap: function (source) {
return maps[source] ? { url: null, map: maps[source] } : null;
}
},
});
}

Expand All @@ -64,7 +64,7 @@ class UnexpectedMarkdown {

var index = 0;
var renderer = new marked.Renderer();
renderer.code = function(code) {
renderer.code = function (code) {
var snippet = snippets.get(index);
var previousSnippet = snippets.get(index - 1);
index += 1;
Expand Down Expand Up @@ -108,7 +108,7 @@ class UnexpectedMarkdown {
const snippets = await this.getSnippets(options);

var index = 0;
var updatedContent = this.content.replace(snippetRegexp, function(
var updatedContent = this.content.replace(snippetRegexp, function (
$0,
htmlComments,
lang
Expand Down
53 changes: 27 additions & 26 deletions lib/convertMarkdownToMocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ try {
var babelResult = babelCore.transform(code, {
...babelOptions,
sourceMaps: false,
compact: false
compact: false,
});

return babelResult.code.replace(/'use strict';/, '');
Expand Down Expand Up @@ -49,17 +49,17 @@ function instrumentReturns(astNode, exampleNumber) {
operator: '=',
left: {
type: 'Identifier',
name: `__returnValue${exampleNumber}`
name: `__returnValue${exampleNumber}`,
},
right: statement.argument
}
right: statement.argument,
},
},
{
type: 'BreakStatement',
label: {
type: 'Identifier',
name: `example${exampleNumber}`
}
name: `example${exampleNumber}`,
},
}
);
} else if (statement.type === 'IfStatement') {
Expand All @@ -85,7 +85,7 @@ function makeTryCatchConstruct(exampleNumber, topLevelStatements) {
return endOfExampleX(err);
}
if (isPromise(__returnValueX)) {
return __returnValueX.then(function() {
return __returnValueX.then(function () {
return endOfExampleX();
}, endOfExampleX);
} else {
Expand Down Expand Up @@ -114,7 +114,7 @@ function makeTryCatchConstruct(exampleNumber, topLevelStatements) {

function countLinesUntilIndex(text, untilIndex) {
var count = 0;
text.replace(/\r\n?|\n\r?/g, function($0, index) {
text.replace(/\r\n?|\n\r?/g, function ($0, index) {
if (index < untilIndex) {
count += 1;
}
Expand Down Expand Up @@ -155,7 +155,7 @@ function compileCodeBlocksToAst(codeBlocks, fileName) {

for (const [
statementIndex,
topLevelStatement
topLevelStatement,
] of topLevelStatements.entries()) {
switch (topLevelStatement.type) {
case 'VariableDeclaration':
Expand All @@ -170,10 +170,10 @@ function compileCodeBlocksToAst(codeBlocks, fileName) {
loc: topLevelStatement.loc,
type: 'VariableDeclarator',
id: topLevelStatement.id,
init: topLevelStatement
}
init: topLevelStatement,
},
],
kind: 'var'
kind: 'var',
};
topLevelStatements[statementIndex] = newStatement;
break;
Expand Down Expand Up @@ -226,22 +226,22 @@ function compileCodeBlocksToAst(codeBlocks, fileName) {
operator: '=',
left: {
type: 'Identifier',
name: 'message'
name: 'message',
},
right: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'cleanStackTrace'
name: 'cleanStackTrace',
},
arguments: [
{
type: 'Identifier',
name: 'message'
}
]
}
}
name: 'message',
},
],
},
},
});
check.unshift(esprima.parse(cleanStackTrace.toString()).body[0]);
}
Expand All @@ -261,7 +261,7 @@ function compileCodeBlocksToAst(codeBlocks, fileName) {
return top;
}

module.exports = function(mdSrc, fileName) {
module.exports = function (mdSrc, fileName) {
if (fileName) {
fileName = pathModule.relative(process.cwd(), fileName);
} else {
Expand All @@ -283,9 +283,9 @@ module.exports = function(mdSrc, fileName) {
unexpected = require('unexpected');
unexpected.output.preferredWidth = 80;
}
describe('', function() {});
describe('', function () {});
}
)
),
};
/* eslint-enable */

Expand All @@ -302,7 +302,7 @@ module.exports = function(mdSrc, fileName) {
var transpiledCode = transpile(
preambleSeparator +
codeBlocks
.map(function(codeBlock) {
.map(function (codeBlock) {
return codeBlock.flags.async
? `(function unexpectedMarkdownScope() {${codeBlock.code}})("unexpectedMarkdownScope");`
: codeBlock.code;
Expand Down Expand Up @@ -335,14 +335,15 @@ module.exports = function(mdSrc, fileName) {
var itExpressionStatement = parseFunctionBody(
/* istanbul ignore next */
function f() {
it('', function() {
it('', function () {
var expect = unexpected.clone();
});
}
)[0];
/* eslint-enable */
itExpressionStatement.expression.arguments[0].value = `example #${exampleNumber} (${fileName}:${codeBlock.lineNumber +
1}:1) should ${
itExpressionStatement.expression.arguments[0].value = `example #${exampleNumber} (${fileName}:${
codeBlock.lineNumber + 1
}:1) should ${
typeof codeBlock.output === 'string'
? 'fail with the correct error message'
: 'succeed'
Expand Down
2 changes: 1 addition & 1 deletion lib/createExpect.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global unexpected */
module.exports = function(options) {
module.exports = function (options) {
options = { ...options };
var expect;
if (options.unexpected) {
Expand Down
8 changes: 4 additions & 4 deletions lib/evaluateSnippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ try {
var babelResult = babelCore.transform(code, {
...babelOptions,
sourceMaps: false,
compact: false
compact: false,
});

return babelResult.code.replace(/'use strict';/, '');
Expand Down Expand Up @@ -52,7 +52,7 @@ function getErrorMessage(expect, format, error) {
}
}

module.exports = async function(snippets, options) {
module.exports = async function (snippets, options) {
var oldGlobal = Object.assign({}, global);
var expect = createExpect(options);
global.expect = expect.clone();
Expand All @@ -63,15 +63,15 @@ module.exports = async function(snippets, options) {
'\n//---------------------preamble----------------------\n';
var separator = '\n//---------------------separator---------------------\n';

var exampleSnippets = snippets.filter(function(snippet) {
var exampleSnippets = snippets.filter(function (snippet) {
return snippet.lang === 'javascript' && snippet.flags.evaluate;
});

if (exampleSnippets.length) {
var codeForTranspilation =
preambleSeparator +
exampleSnippets
.map(function(snippet) {
.map(function (snippet) {
return snippet.flags.async
? `(function () {${snippet.code}})();`
: snippet.code;
Expand Down
4 changes: 2 additions & 2 deletions lib/extractSnippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ function parseSnippetInfo(lang) {

return {
lang: lang,
flags: flags
flags: flags,
};
}

module.exports = function(markdown) {
module.exports = function (markdown) {
var snippets = [];
var m;
while ((m = snippetRegexp.exec(markdown))) {
Expand Down
6 changes: 3 additions & 3 deletions lib/magicpenDarkSyntaxTheme.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
name: 'dark-syntax-theme',
installInto: function(pen) {
installInto: function (pen) {
pen.installTheme('html', {
jsComment: '#888',
jsFunctionName: 'jsKeyword',
Expand Down Expand Up @@ -28,7 +28,7 @@ module.exports = {
prismKeyword: '#F92672',
prismRegex: '#AE81FF',

prismFunction: []
prismFunction: [],
});
}
},
};
6 changes: 3 additions & 3 deletions lib/magicpenGithubSyntaxTheme.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
name: 'github-syntax-theme',
installInto: function(pen) {
installInto: function (pen) {
pen.installTheme('html', {
// Mimic github theme
prismComment: 'jsComment',
Expand Down Expand Up @@ -28,7 +28,7 @@ module.exports = {

prismFunction: '#000000',

prismImportant: ['#0086b3', 'bold']
prismImportant: ['#0086b3', 'bold'],
});
}
},
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"eslint-plugin-standard": "^4.0.0",
"mocha": "^7.0.0",
"nyc": "^15.0.0",
"prettier": "~1.19.1",
"prettier": "~2.0.2",
"unexpected": "^11.12.1"
},
"author": "Sune Simonsen",
Expand Down
6 changes: 3 additions & 3 deletions test/Snippets.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Snippets', () => {
'foo',
' at bar (/path/to/file.js:x:y)',
' at quux (/path/to/file.js:x:y)',
'```'
'```',
].join('\n')
);

Expand All @@ -28,8 +28,8 @@ describe('Snippets', () => {
'throw new Error("foo\\n at bar (/somewhere.js:1:2)\\n at quux (/blah.js:3:4)\\n at baz (/yadda.js:5:6)")',
flags: { evaluate: true },
output:
'foo\n at bar (/path/to/file.js:x:y)\n at quux (/path/to/file.js:x:y)'
}
'foo\n at bar (/path/to/file.js:x:y)\n at quux (/path/to/file.js:x:y)',
},
]);
});
});
Expand Down
Loading

0 comments on commit 3181f82

Please sign in to comment.