From 0ee0914179487103100c89dfdb43a82067c391da Mon Sep 17 00:00:00 2001 From: vsiakka Date: Fri, 8 Nov 2019 14:11:14 +0200 Subject: [PATCH 1/2] Fix stylish formatter for node 6 --- babel.config.js | 23 +++++++++++++++++++++++ package.json | 7 ++++--- src/formatters/stylish.js | 7 ++++--- 3 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 babel.config.js diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 00000000..53016690 --- /dev/null +++ b/babel.config.js @@ -0,0 +1,23 @@ +module.exports = function (api) { + api.cache(true); + + const presets = [ + [ + '@babel/preset-env', + { + targets: { + node: 4 + }, + useBuiltIns: 'entry', + corejs: { version: 3 } + } + ] + ]; + const plugins = []; + + return { + presets, + plugins + }; +} + diff --git a/package.json b/package.json index 01bef4f6..0edef5c6 100644 --- a/package.json +++ b/package.json @@ -76,14 +76,15 @@ ], "dependencies": { "commander": "2.18.0", + "core-js": "3.4.0", "gherkin": "5.1.0", "glob": "7.1.3", "lodash": "4.17.14" }, "devDependencies": { - "@babel/cli": "7.4.4", - "@babel/core": "7.4.4", - "@babel/preset-env": "7.4.4", + "@babel/cli": "7.7.0", + "@babel/core": "7.7.2", + "@babel/preset-env": "7.7.1", "chai": "4.1.2", "coveralls": "3.0.3", "eslint": "5.14.1", diff --git a/src/formatters/stylish.js b/src/formatters/stylish.js index ae05b983..b4745ed7 100644 --- a/src/formatters/stylish.js +++ b/src/formatters/stylish.js @@ -1,4 +1,5 @@ /*eslint no-console: "off"*/ +import 'core-js/stable/string'; var style = { gray: function(text) { @@ -20,7 +21,7 @@ function stylizeError(error, maxLineLength, maxMessageLength, addColors) { var padding = ' '; //padding of 4 spaces, will be used between line numbers, error msgs and rule names, for readability var errorLinePadded = error.line.toString().padEnd(maxLineLength); var errorLineStylized = addColors ? style.gray(errorLinePadded) : errorLinePadded; - + var errorRuleStylized = addColors ? style.gray(error.rule) : error.rule; return indent + errorLineStylized + padding + error.message.padEnd(maxMessageLength) + padding + errorRuleStylized; } @@ -40,7 +41,7 @@ function getMaxMessageLength(result, maxLineLength, consoleWidth) { var length = 0; result.errors.forEach(function(error) { var errorStr = error.message.toString(); - + // Get the length of the formatted error message when no extra padding is applied // If the formatted message is longer than the console width, we will ignore its length var expandedErrorStrLength = stylizeError(error, maxLineLength, 0, false).length; @@ -54,7 +55,7 @@ function getMaxMessageLength(result, maxLineLength, consoleWidth) { } function printResults(results) { - // If the console is tty, get its width and use it to ensure we don't try to write messages longer + // If the console is tty, get its width and use it to ensure we don't try to write messages longer // than the console width when possible var consoleWidth = Infinity; if (process.stdout.isTTY) { From 633e1db7699964bfc30e073aeefbaa1d659cc65f Mon Sep 17 00:00:00 2001 From: vsiakka Date: Fri, 8 Nov 2019 14:12:43 +0200 Subject: [PATCH 2/2] Remove duplicate babel config file --- .babelrc | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 .babelrc diff --git a/.babelrc b/.babelrc deleted file mode 100644 index db015e55..00000000 --- a/.babelrc +++ /dev/null @@ -1,12 +0,0 @@ -{ - "presets": [ - [ - "@babel/preset-env", - { - "targets": { - "node": "4" - } - } - ] - ] -}