From 28c7a7c125f7ee49678b89a5fb722cfe6ba6a177 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@keylocation.sg>
Date: Wed, 11 Jan 2017 09:47:29 +0100
Subject: [PATCH] Use airbnb line length definition

---
 .eslintrc.js               |  1 -
 src/helpers/packageJson.js | 16 ++++++++++++----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/.eslintrc.js b/.eslintrc.js
index b89a5f6346..1366318825 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -10,7 +10,6 @@ module.exports = {
         'promise',
     ],
     'rules': {
-      'max-len': [1, 120],
       'no-console': 0,
       'no-use-before-define': 0,
       'promise/always-return': 'error',
diff --git a/src/helpers/packageJson.js b/src/helpers/packageJson.js
index 4c3b44faf1..aa20aba0d3 100644
--- a/src/helpers/packageJson.js
+++ b/src/helpers/packageJson.js
@@ -17,11 +17,9 @@ module.exports = {
     // Iterate through the rest of the file
     for (; searchIndex < currentFileContent.length; searchIndex += 1) {
       // First check if we have a hit for the old version
-      if (currentFileContent.substring(searchIndex, searchIndex + searchString.length) === searchString) {
+      if (matchAt(currentFileContent, searchIndex, searchString)) {
         // Now test if the result matches
-        const testContent = currentFileContent.substr(0, searchIndex) +
-          newString +
-          currentFileContent.substr(searchIndex + searchString.length);
+        const testContent = replaceAt(currentFileContent, searchIndex, searchString, newString);
         // Compare the parsed JSON structure of old and new
         if (_.isEqual(parsedContents, JSON.parse(testContent))) {
           newFileContent = testContent;
@@ -35,3 +33,13 @@ module.exports = {
     return newFileContent;
   },
 };
+
+// Return true if the match string is found at index in content
+function matchAt(content, index, match) {
+  return content.substring(index, index + match.length) === match;
+}
+
+// Replace oldString with newString at location index of content
+function replaceAt(content, index, oldString, newString) {
+  return content.substr(0, index) + newString + content.substr(index, oldString.length);
+}
-- 
GitLab