From 1515ff4a8f749aa6d075bffdcda543ca94c559a9 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 25 May 2020 13:46:44 -0700 Subject: [PATCH] [eslint] remove useless regex escapes --- .eslintrc | 1 + lib/results.js | 2 +- lib/test.js | 4 ++-- test/common.js | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.eslintrc b/.eslintrc index 40369d2a..5cc84b03 100644 --- a/.eslintrc +++ b/.eslintrc @@ -11,5 +11,6 @@ "anonymous": "always", "named": "never", }], + "no-useless-escape": "error", }, } diff --git a/lib/results.js b/lib/results.js index 89da4b0a..d4bf0ab2 100644 --- a/lib/results.js +++ b/lib/results.js @@ -7,7 +7,7 @@ var inspect = require('object-inspect'); var bind = require('function-bind'); var has = require('has'); var regexpTest = bind.call(Function.call, RegExp.prototype.test); -var yamlIndicators = /\:|\-|\?/; +var yamlIndicators = /:|-|\?/; var nextTick = typeof setImmediate !== 'undefined' ? setImmediate : process.nextTick diff --git a/lib/test.js b/lib/test.js index 3e75ee2f..ff22871c 100644 --- a/lib/test.js +++ b/lib/test.js @@ -269,8 +269,8 @@ Test.prototype._assert = function assert(ok, opts) { /((?:\/|[a-zA-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)\)?/ */ - var re = /^(?:[^\s]*\s*\bat\s+)(?:(.*)\s+\()?((?:\/|[a-zA-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)\)?$/; - var lineWithTokens = err[i].replace(process.cwd(), '/\$CWD').replace(__dirname, '/\$TEST'); + var re = /^(?:[^\s]*\s*\bat\s+)(?:(.*)\s+\()?((?:\/|[a-zA-Z]:\\)[^:)]+:(\d+)(?::(\d+))?)\)?$/; + var lineWithTokens = err[i].replace(process.cwd(), '/$CWD').replace(__dirname, '/$TEST'); var m = re.exec(lineWithTokens); if (!m) { diff --git a/test/common.js b/test/common.js index e7df7d1c..856c9250 100644 --- a/test/common.js +++ b/test/common.js @@ -37,7 +37,7 @@ var stripChangingData = function (line) { var withoutPackageDir = withoutTestDir.replace(path.dirname(__dirname), '$TAPE'); var withoutPathSep = withoutPackageDir.replace(new RegExp('\\' + path.sep, 'g'), '/'); var withoutLineNumbers = withoutPathSep.replace(/:\d+:\d+/g, ':$LINE:$COL'); - var withoutNestedLineNumbers = withoutLineNumbers.replace(/, \:\$LINE:\$COL\)$/, ')'); + var withoutNestedLineNumbers = withoutLineNumbers.replace(/, :\$LINE:\$COL\)$/, ')'); return withoutNestedLineNumbers; };