From 94108a5a169d5d698ba6ea99030b4b60d145c7b6 Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Fri, 21 Dec 2018 13:21:10 +0000 Subject: [PATCH 1/4] Highlight line endings etc. in linter diff --- test/test-style.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/test/test-style.js b/test/test-style.js index 4074d23874929b..86812a242d71c1 100644 --- a/test/test-style.js +++ b/test/test-style.js @@ -2,6 +2,17 @@ const fs = require('fs'); const path = require('path'); +function escapeInvisibles(str) { + const invisibles = [['\b', '\\b'], ['\f', '\\f'], ['\n', '\\n'], ['\r', '\\r'], ['\v', '\\v'], ['\0', '\\']]; + let finalString = str; + + invisibles.forEach(([invisible, replacement]) => { + finalString = finalString.replace(invisible, replacement); + }); + + return finalString; +} + function jsonDiff(actual, expected) { var actualLines = actual.split(/\n/); var expectedLines = expected.split(/\n/); @@ -10,8 +21,8 @@ function jsonDiff(actual, expected) { if (actualLines[i] !== expectedLines[i]) { return [ '#' + (i + 1) + '\x1b[0m', - ' Actual: ' + actualLines[i], - ' Expected: ' + expectedLines[i] + ' Actual: ' + escapeInvisibles(actualLines[i]), + ' Expected: ' + escapeInvisibles(expectedLines[i]), ].join('\n'); } } From 3a6bd56896198939fed083452888350a9b6a1d7a Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Mon, 24 Dec 2018 12:24:34 +0000 Subject: [PATCH 2/4] Fix typo --- test/test-style.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-style.js b/test/test-style.js index 86812a242d71c1..14a528416818a1 100644 --- a/test/test-style.js +++ b/test/test-style.js @@ -3,7 +3,7 @@ const fs = require('fs'); const path = require('path'); function escapeInvisibles(str) { - const invisibles = [['\b', '\\b'], ['\f', '\\f'], ['\n', '\\n'], ['\r', '\\r'], ['\v', '\\v'], ['\0', '\\']]; + const invisibles = [['\b', '\\b'], ['\f', '\\f'], ['\n', '\\n'], ['\r', '\\r'], ['\v', '\\v'], ['\0', '\\0']]; let finalString = str; invisibles.forEach(([invisible, replacement]) => { From ed279d5b1055a6b7dbfef63d8686e8b52013c4fa Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Mon, 24 Dec 2018 12:25:18 +0000 Subject: [PATCH 3/4] Force JSON files to use Unixy line endings --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000000000..4ee01478dc02fb --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.json text eol=lf From 8dd211955fa21321d9e8ea73c43bf2b2f5ee7ac3 Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Wed, 2 Jan 2019 13:04:45 +0000 Subject: [PATCH 4/4] Reformat invisibles array Co-Authored-By: ddbeck --- test/test-style.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/test-style.js b/test/test-style.js index 14a528416818a1..27f1770e327895 100644 --- a/test/test-style.js +++ b/test/test-style.js @@ -3,7 +3,15 @@ const fs = require('fs'); const path = require('path'); function escapeInvisibles(str) { - const invisibles = [['\b', '\\b'], ['\f', '\\f'], ['\n', '\\n'], ['\r', '\\r'], ['\v', '\\v'], ['\0', '\\0']]; + const invisibles = [ + ['\b', '\\b'], + ['\f', '\\f'], + ['\n', '\\n'], + ['\r', '\\r'], + ['\v', '\\v'], + ['\t', '\\t'], + ['\0', '\\0'], + ]; let finalString = str; invisibles.forEach(([invisible, replacement]) => {