diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ab8de50..f12ed04 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,6 +43,8 @@ jobs: - run: npm install working-directory: discord-bot + - run: npm run lint + working-directory: discord-bot - run: npm test working-directory: discord-bot test-ecommerce: @@ -82,5 +84,7 @@ jobs: - run: npm install working-directory: netlify-functions-ecommerce + - run: npm run lint + working-directory: netlify-functions-ecommerce - run: npm test working-directory: netlify-functions-ecommerce \ No newline at end of file diff --git a/netlify-functions-ecommerce/.eslintignore b/netlify-functions-ecommerce/.eslintignore new file mode 100644 index 0000000..d70ebaa --- /dev/null +++ b/netlify-functions-ecommerce/.eslintignore @@ -0,0 +1 @@ +public \ No newline at end of file diff --git a/netlify-functions-ecommerce/.eslintrc.js b/netlify-functions-ecommerce/.eslintrc.js new file mode 100644 index 0000000..b5d1028 --- /dev/null +++ b/netlify-functions-ecommerce/.eslintrc.js @@ -0,0 +1,14 @@ +'use strict'; + +module.exports = { + extends: [ + '@masteringjs' + ], + parserOptions: { + ecmaVersion: 2020 + }, + env: { + node: true, + es6: true + } +}; \ No newline at end of file diff --git a/netlify-functions-ecommerce/connect.js b/netlify-functions-ecommerce/connect.js index db7ca79..a8b8588 100644 --- a/netlify-functions-ecommerce/connect.js +++ b/netlify-functions-ecommerce/connect.js @@ -5,7 +5,7 @@ require('dotenv').config(); const mongoose = require('./mongoose'); require('./models'); -const {createAstraUri} = require("stargate-mongoose"); +const { createAstraUri } = require('stargate-mongoose'); let conn = null; diff --git a/netlify-functions-ecommerce/frontend/.eslintrc.js b/netlify-functions-ecommerce/frontend/.eslintrc.js new file mode 100644 index 0000000..c386687 --- /dev/null +++ b/netlify-functions-ecommerce/frontend/.eslintrc.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = { + env: { + browser: true + }, + globals: { + Vue: true, + VueRouter: true + } +}; \ No newline at end of file diff --git a/netlify-functions-ecommerce/frontend/src/BaseComponent.js b/netlify-functions-ecommerce/frontend/src/BaseComponent.js index 5c9270e..63a44a5 100644 --- a/netlify-functions-ecommerce/frontend/src/BaseComponent.js +++ b/netlify-functions-ecommerce/frontend/src/BaseComponent.js @@ -1,3 +1,5 @@ +'use strict'; + module.exports = (html, css) => { appendCSS(css); return { diff --git a/netlify-functions-ecommerce/frontend/src/cart/cart.js b/netlify-functions-ecommerce/frontend/src/cart/cart.js index 05fb51e..2366fdd 100644 --- a/netlify-functions-ecommerce/frontend/src/cart/cart.js +++ b/netlify-functions-ecommerce/frontend/src/cart/cart.js @@ -10,7 +10,7 @@ module.exports = app => app.component('cart', { computed: { cartTotal() { return '$' + this.state.cart.items.reduce((sum, item) => { - return sum + (+(item.quantity * this.product(item).price).toFixed(2)) + return sum + (+(item.quantity * this.product(item).price).toFixed(2)); }, 0).toFixed(2); } }, diff --git a/netlify-functions-ecommerce/netlify/functions/checkout.js b/netlify-functions-ecommerce/netlify/functions/checkout.js index a23e41f..4868105 100644 --- a/netlify-functions-ecommerce/netlify/functions/checkout.js +++ b/netlify-functions-ecommerce/netlify/functions/checkout.js @@ -39,7 +39,7 @@ const handler = async(event) => { return { statusCode: 200, body: JSON.stringify({ cart: cart, url: '/order-confirmation' }) - } + }; } const session = await stripe.checkout.sessions.create({ diff --git a/netlify-functions-ecommerce/package.json b/netlify-functions-ecommerce/package.json index bab77b6..805376f 100644 --- a/netlify-functions-ecommerce/package.json +++ b/netlify-functions-ecommerce/package.json @@ -12,7 +12,9 @@ "webpack": "5.x" }, "devDependencies": { + "@masteringjs/eslint-config": "0.0.1", "axios": "1.6.2", + "eslint": "8.54.0", "mocha": "10.2.0", "netlify-cli": "17.5.1" }, @@ -21,6 +23,7 @@ }, "scripts": { "build": "node ./frontend/build", + "lint": "eslint .", "seed": "node ./seed", "start": "netlify dev --dir public --functions netlify/functions", "test": "mocha ./test/*.test.js", diff --git a/netlify-functions-ecommerce/public/app.js b/netlify-functions-ecommerce/public/app.js index a95704d..921946f 100644 --- a/netlify-functions-ecommerce/public/app.js +++ b/netlify-functions-ecommerce/public/app.js @@ -1,4 +1,5 @@ /******/ (() => { // webpackBootstrap +/******/ "use strict"; /******/ var __webpack_modules__ = ({ /***/ "./frontend/src/BaseComponent.js": @@ -7,6 +8,8 @@ \***************************************/ /***/ ((module) => { + + module.exports = (html, css) => { appendCSS(css); return { @@ -42,7 +45,6 @@ function appendCSS(css) { \***********************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { -"use strict"; const BaseComponent = __webpack_require__(/*! ../BaseComponent */ "./frontend/src/BaseComponent.js"); @@ -55,7 +57,7 @@ module.exports = app => app.component('cart', { computed: { cartTotal() { return '$' + this.state.cart.items.reduce((sum, item) => { - return sum + (+(item.quantity * this.product(item).price).toFixed(2)) + return sum + (+(item.quantity * this.product(item).price).toFixed(2)); }, 0).toFixed(2); } }, @@ -100,7 +102,6 @@ module.exports = app => app.component('cart', { \***********************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { -"use strict"; const BaseComponent = __webpack_require__(/*! ../BaseComponent */ "./frontend/src/BaseComponent.js"); @@ -148,7 +149,6 @@ module.exports = app => app.component('home', { \***************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { -"use strict"; const BaseComponent = __webpack_require__(/*! ../BaseComponent */ "./frontend/src/BaseComponent.js"); @@ -166,7 +166,6 @@ module.exports = app => app.component('navbar', { \***************************************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { -"use strict"; const BaseComponent = __webpack_require__(/*! ../BaseComponent */ "./frontend/src/BaseComponent.js"); @@ -207,7 +206,6 @@ module.exports = app => app.component('order-confirmation', { \*****************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { -"use strict"; const BaseComponent = __webpack_require__(/*! ../BaseComponent */ "./frontend/src/BaseComponent.js"); @@ -261,7 +259,6 @@ module.exports = app => app.component('product', { \*******************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { -"use strict"; const BaseComponent = __webpack_require__(/*! ../BaseComponent */ "./frontend/src/BaseComponent.js"); @@ -309,7 +306,6 @@ module.exports = app => app.component('products', { \********************************/ /***/ ((module) => { -"use strict"; module.exports = [ @@ -343,7 +339,6 @@ module.exports = [ \************************************/ /***/ ((module) => { -"use strict"; module.exports = ".cart .cart-item {\n display: flex;\n gap: 10px;\n width: 100%;\n margin-bottom: 1em;\n}\n\n.cart .cart-item .product-image {\n width: 80px;\n border: 1px solid #ddd;\n border-radius: 8px;\n padding: 5px;\n}\n\n.cart .cart-item .product-image img {\n width: 100%;\n height: auto;\n vertical-align: middle;\n}\n\n.cart .cart-item .item-description {\n flex-grow: 1;\n}\n\n.cart .cart-item .item-description .name {\n margin-bottom: 0.5em;\n font-weight: bold;\n}\n\n.cart .cart-item .subtotal {\n width: 120px;\n font-weight: bold;\n text-align: right;\n}\n\n.cart .total {\n width: 100%;\n font-weight: bold;\n border-top: 1px solid #ddd;\n padding-top: 1em;\n display: flex;\n}\n\n.cart .total .total-text {\n width: 50%;\n}\n\n.cart .total .total-price {\n text-align: right;\n width: 50%;\n}\n\n.cart .checkout {\n text-align: center;\n}\n\n.cart .checkout button {\n margin-top: 1em;\n font-size: 2em;\n background-color: white;\n border: 2px solid #43783E;\n color: #43783E;\n padding: 0.5em 1em;\n border-radius: 16px;\n}\n\n.cart .checkout button:hover {\n color: white;\n background-color: #43783E;\n}"; /***/ }), @@ -354,7 +349,6 @@ module.exports = ".cart .cart-item {\n display: flex;\n gap: 10px;\n width: 1 \*************************************/ /***/ ((module) => { -"use strict"; module.exports = "