From 38c5b0aaad77e90a181a4360c014c97b8e299d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Castiel?= Date: Thu, 9 Nov 2017 21:29:12 -0500 Subject: [PATCH] Some small fixes for ESLint --- babylon-to-espree/convertTemplateType.js | 7 ++++--- test/non-regression.js | 14 ++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/babylon-to-espree/convertTemplateType.js b/babylon-to-espree/convertTemplateType.js index 7ba60fb0..1d742d86 100644 --- a/babylon-to-espree/convertTemplateType.js +++ b/babylon-to-espree/convertTemplateType.js @@ -8,6 +8,7 @@ // beginning of the next oneā€¦ // * and so on till end of the template string, the last token containing // the closing backquote. +// // Examples: (the resulting template tokens are underlined with successive '^') // var a = `Result: ${result}.`; // ^^^^^^^^^^^ ^^^ @@ -43,12 +44,12 @@ module.exports = function(tokens, tt) { if (token.type === tt.dollarBraceL) { // If '${', then we begin a new expression with its own context. This means that // we add a new context to the stack, and define it as the current context. - index = createTemplateTokenAndReturnNewIndex(index, token); + index = createTemplateTokenAndReturnNewIndex(index); contextStack.pushNewNonTemplateContext(); } else if (token.type === tt.backQuote) { // If '`', then we go back to the previous expression (the one before the template // string began). We restore the previous context, with its numOfBraces. - index = createTemplateTokenAndReturnNewIndex(index, token); + index = createTemplateTokenAndReturnNewIndex(index); contextStack.popContext(); } @@ -114,7 +115,7 @@ module.exports = function(tokens, tt) { // Create a template token to aggregate previous tokens, and returns // the new current index. - function createTemplateTokenAndReturnNewIndex(index, token) { + function createTemplateTokenAndReturnNewIndex(index) { const startIndex = contextStack.current().startIndex; replaceWithTemplateType(startIndex, index); return startIndex; diff --git a/test/non-regression.js b/test/non-regression.js index 4161af03..03ab8cbc 100644 --- a/test/non-regression.js +++ b/test/non-regression.js @@ -38,18 +38,16 @@ function verifyAndAssertMessages( if (messages.length !== expectedMessages.length) { throw new Error( - `Expected ${expectedMessages.length} message(s), got ${messages.length}\n${JSON.stringify( - messages, - null, - 2 - )}` + `Expected ${expectedMessages.length} message(s), got ${ + messages.length + }\n${JSON.stringify(messages, null, 2)}` ); } messages.forEach((message, i) => { - var formatedMessage = `${message.line}:${message.column} ${message.message}${message.ruleId - ? ` ${message.ruleId}` - : ""}`; + var formatedMessage = `${message.line}:${message.column} ${ + message.message + }${message.ruleId ? ` ${message.ruleId}` : ""}`; if (formatedMessage !== expectedMessages[i]) { throw new Error( unpad(`