From 67bdd4ba5b10756b10a98525eaa3f33f7750979d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=A4dler?= Date: Wed, 6 Aug 2014 15:14:59 +0200 Subject: [PATCH 1/2] jslint: remove whitespaces using simple regex Replacing obsolete for loop with a simple regex to remove whitespaces, if a line contains only whitespace. --- src/extensions/default/JSLint/main.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/extensions/default/JSLint/main.js b/src/extensions/default/JSLint/main.js index c3ec9705dcc..55d656959fb 100644 --- a/src/extensions/default/JSLint/main.js +++ b/src/extensions/default/JSLint/main.js @@ -72,15 +72,7 @@ define(function (require, exports, module) { */ function lintOneFile(text, fullPath) { // If a line contains only whitespace, remove the whitespace - // This should be doable with a regexp: text.replace(/\r[\x20|\t]+\r/g, "\r\r");, - // but that doesn't work. - var i, arr = text.split("\n"); - for (i = 0; i < arr.length; i++) { - if (!arr[i].match(/\S/)) { - arr[i] = ""; - } - } - text = arr.join("\n"); + text = text.replace(/^[\x20\t\f]+$/gm, ""); var options = prefs.get("options"); From 986eda77c431056dfe4828f8d4a361d932999044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=A4dler?= Date: Thu, 7 Aug 2014 09:12:28 +0200 Subject: [PATCH 2/2] updated regex to catch spaces and tabs only seems to be cleaner, also other "weird whitespace characters" in an isolated line will be flagged as an error by jslint --- src/extensions/default/JSLint/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/extensions/default/JSLint/main.js b/src/extensions/default/JSLint/main.js index 55d656959fb..c0116314a47 100644 --- a/src/extensions/default/JSLint/main.js +++ b/src/extensions/default/JSLint/main.js @@ -71,8 +71,8 @@ define(function (require, exports, module) { * a gold star when no errors are found. */ function lintOneFile(text, fullPath) { - // If a line contains only whitespace, remove the whitespace - text = text.replace(/^[\x20\t\f]+$/gm, ""); + // If a line contains only whitespace (here spaces or tabs), remove the whitespace + text = text.replace(/^[ \t]+$/gm, ""); var options = prefs.get("options");