Skip to content
Snippets Groups Projects
Commit 28c7a7c1 authored by Rhys Arkins's avatar Rhys Arkins
Browse files

Use airbnb line length definition

parent 19a4dc1b
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,6 @@ module.exports = { ...@@ -10,7 +10,6 @@ module.exports = {
'promise', 'promise',
], ],
'rules': { 'rules': {
'max-len': [1, 120],
'no-console': 0, 'no-console': 0,
'no-use-before-define': 0, 'no-use-before-define': 0,
'promise/always-return': 'error', 'promise/always-return': 'error',
......
...@@ -17,11 +17,9 @@ module.exports = { ...@@ -17,11 +17,9 @@ module.exports = {
// Iterate through the rest of the file // Iterate through the rest of the file
for (; searchIndex < currentFileContent.length; searchIndex += 1) { for (; searchIndex < currentFileContent.length; searchIndex += 1) {
// First check if we have a hit for the old version // 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 // Now test if the result matches
const testContent = currentFileContent.substr(0, searchIndex) + const testContent = replaceAt(currentFileContent, searchIndex, searchString, newString);
newString +
currentFileContent.substr(searchIndex + searchString.length);
// Compare the parsed JSON structure of old and new // Compare the parsed JSON structure of old and new
if (_.isEqual(parsedContents, JSON.parse(testContent))) { if (_.isEqual(parsedContents, JSON.parse(testContent))) {
newFileContent = testContent; newFileContent = testContent;
...@@ -35,3 +33,13 @@ module.exports = { ...@@ -35,3 +33,13 @@ module.exports = {
return newFileContent; 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);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment