From c42a2478ef9bb14285a235fa68306298644198b9 Mon Sep 17 00:00:00 2001 From: Mark Moffat Date: Fri, 21 Feb 2020 12:52:43 +1030 Subject: [PATCH] Linting --- .eslintrc.json | 10 +- app.js | 135 ++++++------- style.css | 508 ------------------------------------------------- 3 files changed, 79 insertions(+), 574 deletions(-) delete mode 100644 style.css diff --git a/.eslintrc.json b/.eslintrc.json index 0ee3260..215026e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -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, diff --git a/app.js b/app.js index 5adfbd8..7e17670 100644 --- a/app.js +++ b/app.js @@ -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); @@ -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){ @@ -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; }, @@ -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 === ''){ @@ -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); } @@ -272,22 +272,22 @@ handlebars = handlebars.create({ }, paymentMessage: (status) => { if(status === 'Paid'){ - return'

Your payment has been successfully processed

'; + return '

Your payment has been successfully processed

'; } if(status === 'Pending'){ const paymentConfig = common.getPaymentConfig(); if(config.paymentGateway === 'instore'){ - return`

${paymentConfig.resultMessage}

`; + return `

${paymentConfig.resultMessage}

`; } - return'

The payment for this order is pending. We will be in contact shortly.

'; + return '

The payment for this order is pending. We will be in contact shortly.

'; } - return'

Your payment has failed. Please try again or contact us.

'; + return '

Your payment has failed. Please try again or contact us.

'; }, paymentOutcome: (status) => { if(status === 'Paid' || status === 'Pending'){ - return'
Please retain the details above as a reference of payment
'; + return '
Please retain the details above as a reference of payment
'; } - return''; + return ''; }, upperFirst: (value) => { if(value){ @@ -301,7 +301,7 @@ handlebars = handlebars.create({ lvalue = parseFloat(lvalue); rvalue = parseFloat(rvalue); - return{ + return { '+': lvalue + rvalue, '-': lvalue - rvalue, '*': lvalue * rvalue, @@ -311,9 +311,9 @@ handlebars = handlebars.create({ }, showCartButtons: (cart) => { if(!cart){ - return'd-none'; + return 'd-none'; } - return''; + return ''; }, snip: (text) => { if(text && text.length > 155){ @@ -321,6 +321,11 @@ handlebars = handlebars.create({ } return text; }, + fixTags: (html) => { + html = html.replace(/>/g, '>'); + html = html.replace(/</g, '<'); + return html; + }, feather: (icon) => { // eslint-disable-next-line keyword-spacing return ` img { - width: auto; - height: 100%; -} -.thumbnail { - min-height: 415px; -} -.vertical-center { - display: flex; - align-items: center; -} -.title-image-container .img-fluid { - display: block; - width: auto; - max-height: 100%; - margin: auto; -} -.title-image-container { - height: 400px; -} -.thumbnail-image-container { - height: 350px; -} -.product-title { - font-size: 24px; - margin-top: 0px; -} -.product-title-home { - display: -webkit-box; - display: -moz-box; - display: -ms-flexbox; - display: -webkit-flex; - display: flex; - align-items: center; - justify-content: center; - text-align: center; -} -.product-price { - padding-bottom: 10px; - font-size: 20px; - color: #AAAAAA; -} -.productOptions { - padding-bottom: 15px; -} -.product-option { - font-size: 18px; -} -.btnAddToCart, -.body_text { - padding-top: 15px; - padding-bottom: 15px; -} -.product-option-text { - font-size: 16px; - color: #AAAAAA; - padding-bottom: 10px; - padding-top: 10px; -} -.seporator { - padding-top: 5px; - border-bottom: 1px solid #EEEEEE; - padding-bottom: 6px; -} -.list-group-input-pad select { - margin-top: -7px; -} -.no-pad-left { - padding-left: 0px; -} -.no-pad-right { - padding-right: 0px; -} -.top-marg-10 { - margin-top: 10px; -} -.top-marg-15 { - margin-top: 15px; -} -.top-marg-20 { - margin-top: 20px; -} -.top-pad-10 { - padding-top: 10px; -} -.top-pad-20 { - padding-top: 20px; -} -.top-pad-50 { - padding-top: 50px; -} -.top-pad-100 { - padding-top: 100px; -} -.bottom-pad-10 { - padding-bottom: 10px; -} -.bottom-pad-15 { - padding-bottom: 15px; -} -.bottom-pad-20 { - padding-bottom: 20px; -} -.bottom-marg-10 { - margin-bottom: 10px; -} -.bottom-marg-15 { - margin-bottom: 15px; -} -.bottom-marg-20 { - margin-bottom: 20px; -} -.left-pad-30 { - padding-left: 30px; -} -.shipping-form input { - margin-bottom: 15px; -} -#header { - height: 50px; -} -.search-bar { - margin-top: 10px; -} -.searchMenuLocation-side { - padding-left: 25px; - padding-right: 25px; -} -.searchMenuLocation-top { - padding-left: 5px; - padding-right: 5px; -} -.breadcrumb { - background-color: #f8f9fa; - margin-top: 10px; -} -.breadcrumbProPerRow-3 { - margin-left: 10px; - margin-right: 10px; -} -.searchProPerRow-3, -.searchProPerRow-4 { - padding-left: 0; - padding-right: 0; -} -.dropup-button { - height: 34px; - padding: 0px; - color: white !important; -} -.dropdown-menu > li > a { - padding-top: 5px !important; -} -.pad-bottom { - padding-bottom: 25px; -} -.keywords { - padding-bottom: 30px; - padding-top: 20px; - font-size: 19px; -} -.file-form { - padding-left: 15px; - padding-right: 15px; -} -.editor_btn_action { - border-top-left-radius: 4px !important; - border-bottom-left-radius: 4px !important; -} -.dropup-list { - padding-bottom: 5px; - margin-right: 10px; - margin-left: 10px; - margin-top: 10px; -} -#notify_message { - position: fixed; - display: none; - z-index: 9999; - padding-top: 10px; - height: 50px; - bottom: 0px; - width: 100%; - text-align: center; - font-size: 22px; -} -.input-group .form-control { - z-index: 1; -} -.btn-file { - position: relative; - overflow: hidden; -} -.btn-file input[type=file] { - position: absolute; - top: 0; - right: 0; - min-width: 100%; - min-height: 100%; - font-size: 100px; - text-align: right; - filter: alpha(opacity=0); - opacity: 0; - outline: none; - background: white; - cursor: inherit; - display: block; -} -.offcanvas-element { - z-index: 100; - background-color: #ffffff; -} -.product-item { - padding-left: 0px; - padding-right: 0px; -} -input:focus { - outline: none; - background: #fbfbe9; -} -input + label { - display: block; - cursor: text; - transition: 0.15s ease-out all; - position: absolute; - top: 0.9em; - left: 1.3em; -} -.floatLabel { - top: 0.1em; - left: 32px; - font-size: 0.7em; - color: #999999; - font-weight: normal; - transition: 0.15s ease-out all; -} -input.form-control.customerDetails { - padding-bottom: 5px; -} -.footer { - position: absolute; - bottom: 0; - width: 100%; - height: 100px; - padding-top: 25px; - background-color: #f5f5f5; -} -.admin { - margin-bottom: 0; -} -.image-next { - position: absolute; - top: 180px; - right: 0px; -} -.image-prev { - position: absolute; - top: 180px; - left: 0px; -} -.image-button { - cursor: pointer; - opacity: 0.7; -} -.image-button-show { - cursor: pointer; - opacity: 0.7 !important; -} -.navbar-default { - background-color: #ffffff; -} -.navbar-default .navbar-nav > li > a { - color: #000000; -} -.navbar-default .navbar-nav > li > a:hover, -.navbar-default .navbar-nav > li > a:focus { - color: #000000; -} -.btn-outline-danger, -.btn-warning, -.btn-outline-primary { - color: #ffffff; - background-color: #000000; - border-color: #000000; -} -.btn-warning:hover, -.btn-outline-danger:hover { - color: #ffffff; - background-color: #000000; - border-color: #000000; - opacity: 0.65; -} -a:hover, -a:focus { - color: #000000; -} -a { - color: #000000; -} -.list-group-item.active, -.list-group-item.active:hover, -.list-group-item.active:focus { - background-color: #000000; - border-color: #000000; -} -.navbar-default .navbar-brand { - color: #000000; - font-size: 40px; - font-weight: 700; -} -.navbar-default .navbar-brand:hover, -.navbar-default .navbar-brand:focus { - color: #000000; -} -.navbar-brand-image { - padding: 0px; - height: 70px; -} -.navbar-default .badge { - background-color: #000000; - color: #fff; -} -.navbar-default .navbar-toggle { - background-color: #000000; - border-color: #000000; -} -.page-item.disabled .page-link { - color: #b7b7b7; -} -.page-link { - color: white; - border: 0; -} -.navbar-default .navbar-toggle:hover, -.navbar-default .navbar-toggle:focus { - background-color: #000000; -} -.thumbnail { - border: none; -} -.help-block { - color: #95a5a6; -} -@media only screen and (min-width: 768px) { - .pushy { - width: 700px; - } - .pushy-right { - -webkit-transform: translate3d(700px, 0, 0); - -ms-transform: translate3d(700px, 0, 0); - transform: translate3d(700px, 0, 0); - } - .pushy-open-right #container, - .pushy-open-right .push { - -webkit-transform: translate3d(-700px, 0, 0); - -ms-transform: translate3d(-700px, 0, 0); - transform: translate3d(-700px, 0, 0); - } -} -@media only screen and (max-width: 768px) { - .pushy { - width: calc(100%); - } - .pushy-right { - -webkit-transform: translate3d(calc(100%), 0, 0); - -ms-transform: translate3d(calc(100%), 0, 0); - transform: translate3d(calc(100%), 0, 0); - } - .pushy-open-right #container, - .pushy-open-right .push { - -webkit-transform: translate3d(-calc(100%), 0, 0); - -ms-transform: translate3d(-calc(100%), 0, 0); - transform: translate3d(-calc(100%), 0, 0); - } - .product-item { - padding-left: 0px; - padding-right: 0px; - } - .showFooter { - margin-bottom: 220px; - } - .title-image-container { - height: auto; - } - .product-title { - font-size: 18px; - padding-top: 18px; - min-height: auto; - } - .search-bar-input { - padding-left: 0; - padding-right: 0; - } - .menu-side { - padding-top: 15px; - } - .product-layout { - padding-top: 0px; - padding-bottom: 30px; - } - #btn_search { - border-top-right-radius: 4px; - border-bottom-right-radius: 4px; - } - .cart-row { - padding-top: 10px; - border-bottom: 1px solid #ecf0f1; - display: block; - } - .cart-body { - padding-top: 0px; - } - .cart-contents-shipping { - padding-top: 10px; - } - #cart { - padding-bottom: 15px; - } - .footer { - height: 100px; - } - body { - margin-bottom: 100px; - } -}