Satisfy eslint rule no-useless-escape

This commit is contained in:
witzig 2017-06-15 21:44:54 +02:00
parent 80aca59af7
commit 830ca4f17f
2 changed files with 9 additions and 9 deletions

View file

@ -311,7 +311,7 @@ function addCustomField(listId, name, defaultValue, type, group, groupTemplate,
}
if (module.exports.grouped.indexOf(type) < 0) {
column = ('custom_' + slugify(name, '_') + '_' + shortid.generate()).toLowerCase().replace(/[^a-z0-9\_]/g, '');
column = ('custom_' + slugify(name, '_') + '_' + shortid.generate()).toLowerCase().replace(/[^a-z0-9_]/g, '');
}
let query = 'INSERT INTO custom_fields (`list`, `name`, `key`,`default_value`, `type`, `group`, `group_template`, `column`, `visible`) VALUES(?,?,?,?,?,?,?,?,?)';
@ -414,7 +414,7 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
visible: !!field.visible,
mergeTag: field.key,
mergeValue: (valueList[field.column] || '').toString().trim() || field.defaultValue,
['type' + (field.type || '').toString().trim().replace(/(?:^|\-)([a-z])/g, (m, c) => c.toUpperCase())]: true
['type' + (field.type || '').toString().trim().replace(/(?:^|-)([a-z])/g, (m, c) => c.toUpperCase())]: true
};
row.push(item);
break;
@ -444,7 +444,7 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
visible: !!field.visible,
mergeTag: field.key,
mergeValue: value || field.defaultValue,
['type' + (field.type || '').toString().trim().replace(/(?:^|\-)([a-z])/g, (m, c) => c.toUpperCase())]: true
['type' + (field.type || '').toString().trim().replace(/(?:^|-)([a-z])/g, (m, c) => c.toUpperCase())]: true
};
row.push(item);
break;
@ -460,7 +460,7 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
visible: !!field.visible,
mergeTag: field.key,
mergeValue: (Number(valueList[field.column]) || Number(field.defaultValue) || 0).toString(),
['type' + (field.type || '').toString().trim().replace(/(?:^|\-)([a-z])/g, (m, c) => c.toUpperCase())]: true
['type' + (field.type || '').toString().trim().replace(/(?:^|-)([a-z])/g, (m, c) => c.toUpperCase())]: true
};
row.push(item);
break;
@ -477,7 +477,7 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
key: 'group-g' + field.id,
mergeTag: field.key,
mergeValue: field.defaultValue,
['type' + (field.type || '').toString().trim().replace(/(?:^|\-)([a-z])/g, (m, c) => c.toUpperCase())]: true,
['type' + (field.type || '').toString().trim().replace(/(?:^|-)([a-z])/g, (m, c) => c.toUpperCase())]: true,
groupTemplate: field.groupTemplate,
options: (field.options || []).map(subField => {
if (onlyExisting && subField.column && !valueList.hasOwnProperty(subField.column)) {
@ -508,7 +508,7 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
case 'date-us':
case 'birthday-us':
{
let isUs = /\-us$/.test(field.type);
let isUs = /-us$/.test(field.type);
let isYear = field.type.indexOf('date-') === 0;
let value = valueList[field.column];
let day, month, year;
@ -569,7 +569,7 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
visible: !!field.visible,
mergeTag: field.key,
mergeValue: (useDate ? value : formatted) || field.defaultValue,
['type' + (field.type || '').toString().trim().replace(/(?:^|\-)([a-z])/g, (m, c) => c.toUpperCase())]: true
['type' + (field.type || '').toString().trim().replace(/(?:^|-)([a-z])/g, (m, c) => c.toUpperCase())]: true
};
row.push(item);
break;

View file

@ -36,7 +36,7 @@ module.exports = {
function toDbKey(key) {
return key.
replace(/[^a-z0-9\-_]/gi, '').
replace(/\-+/g, '_').
replace(/-+/g, '_').
replace(/[A-Z]/g, c => '_' + c.toLowerCase()).
replace(/^_+|_+$/g, '').
replace(/_+/g, '_').
@ -50,7 +50,7 @@ function fromDbKey(key) {
prefix = '_';
}
return prefix + key.replace(/[_\-]([a-z])/g, (m, c) => c.toUpperCase());
return prefix + key.replace(/[_-]([a-z])/g, (m, c) => c.toUpperCase());
}
function convertKeys(obj, options) {