change linter to standard

This commit is contained in:
Unknown
2018-11-12 10:28:59 +00:00
parent 19f3edf55a
commit 04d80c7c2f
19 changed files with 837 additions and 691 deletions

View File

@@ -1,16 +1,17 @@
import R from "ramda";
import R from 'ramda'
String.prototype.replaceAll = function(search, replacement) {
const target = this;
return target.replace(new RegExp(search, "g"), replacement);
};
/* eslint-disable */
String.prototype.replaceAll = function (search, replacement) {
const target = this
return target.replace(new RegExp(search, 'g'), replacement)
}
/* eslint-enable */
function camelize(str) {
return str.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function(match, index) {
if (+match === 0) return ""; // or if (/\s+/.test(match)) for white spaces
// return index == 0 ? match.toLowerCase() : match.toUpperCase();
return match.toUpperCase();
});
function camelize (str) {
return str.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function (match) {
if (+match === 0) return '' // or if (/\s+/.test(match)) for white spaces
return match.toUpperCase()
})
}
export const fmtObj = R.curry(
@@ -23,71 +24,71 @@ export const fmtObj = R.curry(
camelCaseKeys: false
}
) => {
const obj = {};
const obj = {}
const fmtColName = colName => {
if (options.camelCaseKeys) {
return camelize(colName);
return camelize(colName)
} else if (options.hyphenatedKeys) {
return colName.toLowerCase().replaceAll(" ", "-");
return colName.toLowerCase().replaceAll(' ', '-')
} else if (options.noSpacesInKeys) {
return colName.replaceAll(" ", "");
return colName.replaceAll(' ', '')
} else {
return colName;
return colName
}
};
}
columnNames.forEach((columnName, idx) => {
obj[fmtColName(columnName)] = row[idx];
});
return obj;
obj[fmtColName(columnName)] = row[idx]
})
return obj
}
);
)
/* search for object with key in array. Return index if exists, or -1 if not */
export const idxSearcher = R.curry((attrName, searchValue, myArray) => {
for (var i = 0; i < myArray.length; i++) {
if (myArray[i][attrName] == searchValue) {
return i;
if (myArray[i][attrName] === searchValue) {
return i
}
}
return -1;
});
return -1
})
/* more site specific functions. TODO: maybe move to another folder? */
export function fmtSourceTitle(name) {
return name.replaceAll(" ", "-").toLowerCase();
export function fmtSourceTitle (name) {
return name.replaceAll(' ', '-').toLowerCase()
}
export function fmtBlueprinterTitles(tabs) {
const obj = {};
export function fmtBlueprinterTitles (tabs) {
const obj = {}
Object.keys(tabs).forEach(tab => {
const name = fmtSourceTitle(tab);
obj[name] = tabs[tab];
});
return obj;
const name = fmtSourceTitle(tab)
obj[name] = tabs[tab]
})
return obj
}
export function deriveFilename(source, tab) {
return `${fmtSourceTitle(source)}-${fmtSourceTitle(tab)}.json`;
export function deriveFilename (source, tab) {
return `${fmtSourceTitle(source)}-${fmtSourceTitle(tab)}.json`
}
export function bp(full) {
export function bp (full) {
const blueprint = {
name: R.clone(full.name),
source: R.clone(full.source),
dialects: R.clone(full.dialects),
routes: {}
};
}
Object.keys(full.routes).forEach(route => {
blueprint.routes[route] = {
options: R.clone(full.routes[route].options)
};
});
return blueprint;
}
})
return blueprint
}
export function isFunction(functionToCheck) {
export function isFunction (functionToCheck) {
return (
functionToCheck && {}.toString.call(functionToCheck) === "[object Function]"
);
functionToCheck && {}.toString.call(functionToCheck) === '[object Function]'
)
}