Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Moffat authored and Mark Moffat committed Feb 21, 2020
1 parent 2b36876 commit c42a247
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 574 deletions.
10 changes: 9 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@
"keyword-spacing": [
"error", {
"before": false, "after": false, "overrides": {
"const": { "after": true }
"const": {
"after": true
},
"return": {
"after": true
},
"case": {
"after": true
}
}
}],
"space-before-function-paren": 0,
Expand Down
135 changes: 70 additions & 65 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,34 +39,34 @@ if(baseConfig === false){

// Validate the payment gateway config
switch(config.paymentGateway){
case'paypal':
case 'paypal':
if(ajv.validate(require('./config/paypalSchema'), require('./config/paypal.json')) === false){
console.log(colors.red(`PayPal config is incorrect: ${ajv.errorsText()}`));
process.exit(2);
}
break;

case'stripe':
case 'stripe':
if(ajv.validate(require('./config/stripeSchema'), require('./config/stripe.json')) === false){
console.log(colors.red(`Stripe config is incorrect: ${ajv.errorsText()}`));
process.exit(2);
}
break;

case'authorizenet':
case 'authorizenet':
if(ajv.validate(require('./config/authorizenetSchema'), require('./config/authorizenet.json')) === false){
console.log(colors.red(`Authorizenet config is incorrect: ${ajv.errorsText()}`));
process.exit(2);
}
break;

case'adyen':
case 'adyen':
if(ajv.validate(require('./config/adyenSchema'), require('./config/adyen.json')) === false){
console.log(colors.red(`adyen config is incorrect: ${ajv.errorsText()}`));
process.exit(2);
}
break;
case'instore':
case 'instore':
if(ajv.validate(require('./config/instoreSchema'), require('./config/instore.json')) === false){
console.log(colors.red(`instore config is incorrect: ${ajv.errorsText()}`));
process.exit(2);
Expand Down Expand Up @@ -128,37 +128,37 @@ handlebars = handlebars.create({
},
perRowClass: (numProducts) => {
if(parseInt(numProducts) === 1){
return'col-6 col-md-12 product-item';
return 'col-6 col-md-12 product-item';
}
if(parseInt(numProducts) === 2){
return'col-6 col-md-6 product-item';
return 'col-6 col-md-6 product-item';
}
if(parseInt(numProducts) === 3){
return'col-6 col-md-4 product-item';
return 'col-6 col-md-4 product-item';
}
if(parseInt(numProducts) === 4){
return'col-6 col-md-3 product-item';
return 'col-6 col-md-3 product-item';
}

return'col-md-6 product-item';
return 'col-md-6 product-item';
},
menuMatch: (title, search) => {
if(!title || !search){
return'';
return '';
}
if(title.toLowerCase().startsWith(search.toLowerCase())){
return'class="navActive"';
return 'class="navActive"';
}
return'';
return '';
},
getTheme: (view) => {
return`themes/${config.theme}/${view}`;
return `themes/${config.theme}/${view}`;
},
formatAmount: (amt) => {
if(amt){
return numeral(amt).format('0.00');
}
return'0.00';
return '0.00';
},
amountNoDecimal: (amt) => {
if(amt){
Expand All @@ -168,33 +168,33 @@ handlebars = handlebars.create({
},
getStatusColor: (status) => {
switch(status){
case'Paid':
return'success';
case'Approved':
return'success';
case'Approved - Processing':
return'success';
case'Failed':
return'danger';
case'Completed':
return'success';
case'Shipped':
return'success';
case'Pending':
return'warning';
case 'Paid':
return 'success';
case 'Approved':
return 'success';
case 'Approved - Processing':
return 'success';
case 'Failed':
return 'danger';
case 'Completed':
return 'success';
case 'Shipped':
return 'success';
case 'Pending':
return 'warning';
default:
return'danger';
return 'danger';
}
},
checkProductOptions: (opts) => {
if(opts){
return'true';
return 'true';
}
return'false';
return 'false';
},
currencySymbol: (value) => {
if(typeof value === 'undefined' || value === ''){
return'$';
return '$';
}
return value;
},
Expand All @@ -208,19 +208,19 @@ handlebars = handlebars.create({
if(obj){
return JSON.stringify(obj);
}
return'';
return '';
},
checkedState: (state) => {
if(state === 'true' || state === true){
return'checked';
return 'checked';
}
return'';
return '';
},
selectState: (state, value) => {
if(state === value){
return'selected';
return 'selected';
}
return'';
return '';
},
isNull: (value, options) => {
if(typeof value === 'undefined' || value === ''){
Expand All @@ -242,24 +242,24 @@ handlebars = handlebars.create({
},
ifCond: (v1, operator, v2, options) => {
switch(operator){
case'==':
return(v1 === v2) ? options.fn(this) : options.inverse(this);
case'!=':
return(v1 !== v2) ? options.fn(this) : options.inverse(this);
case'===':
return(v1 === v2) ? options.fn(this) : options.inverse(this);
case'<':
return(v1 < v2) ? options.fn(this) : options.inverse(this);
case'<=':
return(v1 <= v2) ? options.fn(this) : options.inverse(this);
case'>':
return(v1 > v2) ? options.fn(this) : options.inverse(this);
case'>=':
return(v1 >= v2) ? options.fn(this) : options.inverse(this);
case'&&':
return(v1 && v2) ? options.fn(this) : options.inverse(this);
case'||':
return(v1 || v2) ? options.fn(this) : options.inverse(this);
case '==':
return (v1 === v2) ? options.fn(this) : options.inverse(this);
case '!=':
return (v1 !== v2) ? options.fn(this) : options.inverse(this);
case '===':
return (v1 === v2) ? options.fn(this) : options.inverse(this);
case '<':
return (v1 < v2) ? options.fn(this) : options.inverse(this);
case '<=':
return (v1 <= v2) ? options.fn(this) : options.inverse(this);
case '>':
return (v1 > v2) ? options.fn(this) : options.inverse(this);
case '>=':
return (v1 >= v2) ? options.fn(this) : options.inverse(this);
case '&&':
return (v1 && v2) ? options.fn(this) : options.inverse(this);
case '||':
return (v1 || v2) ? options.fn(this) : options.inverse(this);
default:
return options.inverse(this);
}
Expand All @@ -272,22 +272,22 @@ handlebars = handlebars.create({
},
paymentMessage: (status) => {
if(status === 'Paid'){
return'<h2 class="text-success">Your payment has been successfully processed</h2>';
return '<h2 class="text-success">Your payment has been successfully processed</h2>';
}
if(status === 'Pending'){
const paymentConfig = common.getPaymentConfig();
if(config.paymentGateway === 'instore'){
return`<h2 class="text-warning">${paymentConfig.resultMessage}</h2>`;
return `<h2 class="text-warning">${paymentConfig.resultMessage}</h2>`;
}
return'<h2 class="text-warning">The payment for this order is pending. We will be in contact shortly.</h2>';
return '<h2 class="text-warning">The payment for this order is pending. We will be in contact shortly.</h2>';
}
return'<h2 class="text-success">Your payment has failed. Please try again or contact us.</h2>';
return '<h2 class="text-success">Your payment has failed. Please try again or contact us.</h2>';
},
paymentOutcome: (status) => {
if(status === 'Paid' || status === 'Pending'){
return'<h5 class="text-warning">Please retain the details above as a reference of payment</h5>';
return '<h5 class="text-warning">Please retain the details above as a reference of payment</h5>';
}
return'';
return '';
},
upperFirst: (value) => {
if(value){
Expand All @@ -301,7 +301,7 @@ handlebars = handlebars.create({
lvalue = parseFloat(lvalue);
rvalue = parseFloat(rvalue);

return{
return {
'+': lvalue + rvalue,
'-': lvalue - rvalue,
'*': lvalue * rvalue,
Expand All @@ -311,16 +311,21 @@ handlebars = handlebars.create({
},
showCartButtons: (cart) => {
if(!cart){
return'd-none';
return 'd-none';
}
return'';
return '';
},
snip: (text) => {
if(text && text.length > 155){
return text.substring(0, 155) + '...';
}
return text;
},
fixTags: (html) => {
html = html.replace(/&gt;/g, '>');
html = html.replace(/&lt;/g, '<');
return html;
},
feather: (icon) => {
// eslint-disable-next-line keyword-spacing
return `<svg
Expand Down
Loading

0 comments on commit c42a247

Please sign in to comment.