diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..ce2791e --- /dev/null +++ b/.eslintignore @@ -0,0 +1,3 @@ +src/serviceWorker.ts +node_modules +*.test.tsx \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..76c7fff --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,31 @@ +module.exports={ + 'env': { + 'browser': true, + 'es6': true + }, + 'extends': [ + 'eslint:recommended', + 'plugin:react/recommended', + "plugin:@typescript-eslint/recommended", + "plugin:prettier/recommended" + + ], + 'globals': { + 'Atomics': 'readonly', + 'SharedArrayBuffer': 'readonly' + }, + 'parser': '@typescript-eslint/parser', + 'parserOptions': { + 'ecmaFeatures': { + 'jsx': true + }, + 'ecmaVersion': 2018, + 'sourceType': 'module' + }, + 'plugins': [ + 'react', + '@typescript-eslint' + ], + 'rules': { + } +}; \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..233de0e --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,8 @@ +{ + "printWidth": 120, + "singleQuote": true, + "useTabs": true, + "tabWidth": 4, + "semi": true, + "bracketSpacing": true +} diff --git a/package-lock.json b/package-lock.json index 4012a5a..fafeda0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1683,9 +1683,9 @@ "integrity": "sha512-ce5d3q03Ex0sy4R14722Rmt6MT07Ua+k4FwDfdcToYJcMKNtRVQvJ6JCAPdAmAnbRb6CsX6aYb9m96NGod9uTw==" }, "@types/react": { - "version": "16.9.25", - "resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.25.tgz", - "integrity": "sha512-Dlj2V72cfYLPNscIG3/SMUOzhzj7GK3bpSrfefwt2YT9GLynvLCCZjbhyF6VsT0q0+aRACRX03TDJGb7cA0cqg==", + "version": "16.9.31", + "resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.31.tgz", + "integrity": "sha512-NpYJpNMWScFXtx3A2BJMeew2G3+9SEslVWMdxNJ6DLvxIuxWjY1bizK9q5Y1ujhln31vtjmhjOAYDr9Xx3k9FQ==", "requires": { "@types/prop-types": "*", "csstype": "^2.2.0" @@ -1812,42 +1812,42 @@ "integrity": "sha512-FA/BWv8t8ZWJ+gEOnLLd8ygxH/2UFbAvgEonyfN6yWGLKc7zVjbpl2Y4CTjid9h2RfgPP6SEt6uHwEOply00yw==" }, "@typescript-eslint/eslint-plugin": { - "version": "2.25.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.25.0.tgz", - "integrity": "sha512-W2YyMtjmlrOjtXc+FtTelVs9OhuR6OlYc4XKIslJ8PUJOqgYYAPRJhAqkYRQo3G4sjvG8jSodsNycEn4W2gHUw==", + "version": "2.26.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.26.0.tgz", + "integrity": "sha512-4yUnLv40bzfzsXcTAtZyTjbiGUXMrcIJcIMioI22tSOyAxpdXiZ4r7YQUU8Jj6XXrLz9d5aMHPQf5JFR7h27Nw==", "requires": { - "@typescript-eslint/experimental-utils": "2.25.0", + "@typescript-eslint/experimental-utils": "2.26.0", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.0.0", "tsutils": "^3.17.1" } }, "@typescript-eslint/experimental-utils": { - "version": "2.25.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.25.0.tgz", - "integrity": "sha512-0IZ4ZR5QkFYbaJk+8eJ2kYeA+1tzOE1sBjbwwtSV85oNWYUBep+EyhlZ7DLUCyhMUGuJpcCCFL0fDtYAP1zMZw==", + "version": "2.26.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.26.0.tgz", + "integrity": "sha512-RELVoH5EYd+JlGprEyojUv9HeKcZqF7nZUGSblyAw1FwOGNnmQIU8kxJ69fttQvEwCsX5D6ECJT8GTozxrDKVQ==", "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/typescript-estree": "2.25.0", + "@typescript-eslint/typescript-estree": "2.26.0", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" } }, "@typescript-eslint/parser": { - "version": "2.25.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.25.0.tgz", - "integrity": "sha512-mccBLaBSpNVgp191CP5W+8U1crTyXsRziWliCqzj02kpxdjKMvFHGJbK33NroquH3zB/gZ8H511HEsJBa2fNEg==", + "version": "2.26.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.26.0.tgz", + "integrity": "sha512-+Xj5fucDtdKEVGSh9353wcnseMRkPpEAOY96EEenN7kJVrLqy/EVwtIh3mxcUz8lsFXW1mT5nN5vvEam/a5HiQ==", "requires": { "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "2.25.0", - "@typescript-eslint/typescript-estree": "2.25.0", + "@typescript-eslint/experimental-utils": "2.26.0", + "@typescript-eslint/typescript-estree": "2.26.0", "eslint-visitor-keys": "^1.1.0" } }, "@typescript-eslint/typescript-estree": { - "version": "2.25.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.25.0.tgz", - "integrity": "sha512-VUksmx5lDxSi6GfmwSK7SSoIKSw9anukWWNitQPqt58LuYrKalzsgeuignbqnB+rK/xxGlSsCy8lYnwFfB6YJg==", + "version": "2.26.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.26.0.tgz", + "integrity": "sha512-3x4SyZCLB4zsKsjuhxDLeVJN6W29VwBnYpCsZ7vIdPel9ZqLfIZJgJXO47MNUkurGpQuIBALdPQKtsSnWpE1Yg==", "requires": { "debug": "^4.1.1", "eslint-visitor-keys": "^1.1.0", @@ -2834,6 +2834,15 @@ "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz", "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==" }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "optional": true, + "requires": { + "file-uri-to-path": "1.0.0" + } + }, "block-stream": { "version": "0.0.9", "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", @@ -3516,6 +3525,12 @@ "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=" }, + "compare-versions": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.6.0.tgz", + "integrity": "sha512-W6Af2Iw1z4CB7q4uU4hv646dW9GQuBM+YpC0UvUCWSD8w90SJjp+ujJuXaEMtAXBtSqGfMPuFOVn4/+FlaqfBA==", + "dev": true + }, "component-emitter": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", @@ -4043,9 +4058,9 @@ } }, "csstype": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.9.tgz", - "integrity": "sha512-xz39Sb4+OaTsULgUERcCk+TJj8ylkL4aSVDQiX/ksxbELSqwkgt4d4RD7fovIdgJGSuNYqwZEiVjYY5l0ask+Q==" + "version": "2.6.10", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.10.tgz", + "integrity": "sha512-D34BqZU4cIlMCY93rZHbrq9pjTAQJ3U8S8rfBqjwHxkGPThWFjzZDQpgMJY0QViLxth6ZKYiwFBo14RdN44U/w==" }, "currently-unhandled": { "version": "0.4.1", @@ -4780,6 +4795,29 @@ } } }, + "eslint-config-prettier": { + "version": "6.10.1", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.10.1.tgz", + "integrity": "sha512-svTy6zh1ecQojvpbJSgH3aei/Rt7C6i090l5f2WQ4aB05lYHeZIR1qL4wZyyILTbtmnbHP5Yn8MrsOJMGa8RkQ==", + "dev": true, + "requires": { + "get-stdin": "^6.0.0" + }, + "dependencies": { + "get-stdin": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", + "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==", + "dev": true + } + } + }, + "eslint-config-react": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/eslint-config-react/-/eslint-config-react-1.1.7.tgz", + "integrity": "sha1-oJGND8R9DpvRYaRzCAIdqF0lhbM=", + "dev": true + }, "eslint-config-react-app": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/eslint-config-react-app/-/eslint-config-react-app-5.2.1.tgz", @@ -5057,6 +5095,15 @@ } } }, + "eslint-plugin-prettier": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.2.tgz", + "integrity": "sha512-GlolCC9y3XZfv3RQfwGew7NnuFDKsfI4lbvRK+PIIo23SFH+LemGs4cKwzAaRa+Mdb+lQO/STaIayno8T5sJJA==", + "dev": true, + "requires": { + "prettier-linter-helpers": "^1.0.0" + } + }, "eslint-plugin-react": { "version": "7.19.0", "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.19.0.tgz", @@ -5468,6 +5515,12 @@ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz", "integrity": "sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA==" }, + "fast-diff": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", + "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", + "dev": true + }, "fast-glob": { "version": "2.2.7", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-2.2.7.tgz", @@ -5558,6 +5611,12 @@ "schema-utils": "^2.5.0" } }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "optional": true + }, "filesize": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/filesize/-/filesize-6.0.1.tgz", @@ -5631,6 +5690,15 @@ "locate-path": "^3.0.0" } }, + "find-versions": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/find-versions/-/find-versions-3.2.0.tgz", + "integrity": "sha512-P8WRou2S+oe222TOCHitLy8zj+SIsVJh52VP4lvXkaFVnOFFdoWv1H1Jjvel1aI6NCFOAaeAVm8qrI0odiLcww==", + "dev": true, + "requires": { + "semver-regex": "^2.0.0" + } + }, "flat-cache": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", @@ -5642,9 +5710,9 @@ } }, "flatted": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.1.tgz", - "integrity": "sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==" + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz", + "integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==" }, "flatten": { "version": "1.0.3", @@ -6435,6 +6503,172 @@ "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=" }, + "husky": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/husky/-/husky-4.2.3.tgz", + "integrity": "sha512-VxTsSTRwYveKXN4SaH1/FefRJYCtx+wx04sSVcOpD7N2zjoHxa+cEJ07Qg5NmV3HAK+IRKOyNVpi2YBIVccIfQ==", + "dev": true, + "requires": { + "chalk": "^3.0.0", + "ci-info": "^2.0.0", + "compare-versions": "^3.5.1", + "cosmiconfig": "^6.0.0", + "find-versions": "^3.2.0", + "opencollective-postinstall": "^2.0.2", + "pkg-dir": "^4.2.0", + "please-upgrade-node": "^3.2.0", + "slash": "^3.0.0", + "which-pm-runs": "^1.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", + "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "cosmiconfig": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-6.0.0.tgz", + "integrity": "sha512-xb3ZL6+L8b9JLLCx3ZdoZy4+2ECphCMo2PwqgP1tlfVq6M6YReyzBJtvWWtbDSpNr9hn96pkCiZqUcFEc+54Qg==", + "dev": true, + "requires": { + "@types/parse-json": "^4.0.0", + "import-fresh": "^3.1.0", + "parse-json": "^5.0.0", + "path-type": "^4.0.0", + "yaml": "^1.7.2" + } + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "import-fresh": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz", + "integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "parse-json": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.0.0.tgz", + "integrity": "sha512-OOY5b7PAEFV0E2Fir1KOkxchnZNCdowAJgQ5NuxjpBKTRP3pQhwkrkxqQjeoKJ+fO7bCpmIZaogI4eZGDMEGOw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1", + "lines-and-columns": "^1.1.6" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true + }, + "pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "requires": { + "find-up": "^4.0.0" + } + }, + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true + }, + "slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -7247,6 +7481,7 @@ "integrity": "sha512-Ggd/Ktt7E7I8pxZRbGIs7vwqAPscSESMrCSkx2FtWeqmheJgCo2R74fTsZFCifr0VTPwqRpPv17+6b8Zp7th0Q==", "optional": true, "requires": { + "bindings": "^1.5.0", "nan": "^2.12.1", "node-pre-gyp": "*" }, @@ -9495,6 +9730,12 @@ } } }, + "opencollective-postinstall": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/opencollective-postinstall/-/opencollective-postinstall-2.0.2.tgz", + "integrity": "sha512-pVOEP16TrAO2/fjej1IdOyupJY8KDUM1CvsaScRbw6oddvpQoOfGk4ywha0HKKVAD6RkW4x6Q+tNBwhf3Bgpuw==", + "dev": true + }, "opn": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/opn/-/opn-5.5.0.tgz", @@ -9853,6 +10094,15 @@ "find-up": "^3.0.0" } }, + "please-upgrade-node": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz", + "integrity": "sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg==", + "dev": true, + "requires": { + "semver-compare": "^1.0.0" + } + }, "pn": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/pn/-/pn-1.1.0.tgz", @@ -10826,6 +11076,21 @@ "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=" }, + "prettier": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.2.tgz", + "integrity": "sha512-5xJQIPT8BraI7ZnaDwSbu5zLrB6vvi8hVV58yHQ+QK64qrY40dULy0HSRlQ2/2IdzeBpjhDkqdcFBnFeDEMVdg==", + "dev": true + }, + "prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "requires": { + "fast-diff": "^1.1.2" + } + }, "pretty-bytes": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.3.0.tgz", @@ -12193,6 +12458,18 @@ "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" }, + "semver-compare": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", + "integrity": "sha1-De4hahyUGrN+nvsXiPavxf9VN/w=", + "dev": true + }, + "semver-regex": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/semver-regex/-/semver-regex-2.0.0.tgz", + "integrity": "sha512-mUdIBBvdn0PLOeP3TEkMH7HHeUP3GjsXCwKarjv/kGmUFOYg1VqEemKhoQpWMu6X2I8kHeuVdGibLGkVK+/5Qw==", + "dev": true + }, "send": { "version": "0.17.1", "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", @@ -13865,6 +14142,7 @@ "integrity": "sha512-Ggd/Ktt7E7I8pxZRbGIs7vwqAPscSESMrCSkx2FtWeqmheJgCo2R74fTsZFCifr0VTPwqRpPv17+6b8Zp7th0Q==", "optional": true, "requires": { + "bindings": "^1.5.0", "nan": "^2.12.1", "node-pre-gyp": "*" }, @@ -14640,6 +14918,7 @@ "integrity": "sha512-Ggd/Ktt7E7I8pxZRbGIs7vwqAPscSESMrCSkx2FtWeqmheJgCo2R74fTsZFCifr0VTPwqRpPv17+6b8Zp7th0Q==", "optional": true, "requires": { + "bindings": "^1.5.0", "nan": "^2.12.1", "node-pre-gyp": "*" }, @@ -15422,6 +15701,12 @@ "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" }, + "which-pm-runs": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/which-pm-runs/-/which-pm-runs-1.0.0.tgz", + "integrity": "sha1-Zws6+8VS4LVd9rd4DKdGFfI60cs=", + "dev": true + }, "wide-align": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", diff --git a/package.json b/package.json index 2a37896..375d4a8 100644 --- a/package.json +++ b/package.json @@ -1,40 +1,57 @@ { - "name": "react-starter", - "version": "0.1.0", - "private": true, - "dependencies": { - "@testing-library/jest-dom": "^4.2.4", - "@testing-library/react": "^9.5.0", - "@testing-library/user-event": "^7.2.1", - "@types/jest": "^24.9.1", - "@types/node": "^12.12.30", - "@types/react": "^16.9.25", - "@types/react-dom": "^16.9.5", - "node-sass": "^4.13.1", - "react": "^16.13.1", - "react-dom": "^16.13.1", - "react-scripts": "3.4.1", - "typescript": "^3.7.5" - }, - "scripts": { - "start": "react-scripts start", - "build": "react-scripts build", - "test": "react-scripts test", - "eject": "react-scripts eject" - }, - "eslintConfig": { - "extends": "react-app" - }, - "browserslist": { - "production": [ - ">0.2%", - "not dead", - "not op_mini all" - ], - "development": [ - "last 1 chrome version", - "last 1 firefox version", - "last 1 safari version" - ] - } + "name": "react-starter", + "version": "0.1.0", + "private": true, + "dependencies": { + "@testing-library/jest-dom": "^4.2.4", + "@testing-library/react": "^9.5.0", + "@testing-library/user-event": "^7.2.1", + "@types/jest": "^24.9.1", + "@types/node": "^12.12.30", + "@types/react": "^16.9.31", + "@types/react-dom": "^16.9.5", + "node-sass": "^4.13.1", + "react": "^16.13.1", + "react-dom": "^16.13.1", + "react-scripts": "3.4.1", + "typescript": "^3.7.5" + }, + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test", + "eject": "react-scripts eject", + "lint": "eslint './src/**/*.{ts,tsx}'" + }, + "eslintConfig": { + "extends": "react-app" + }, + "husky": { + "hooks": { + "pre-commit": "npm run lint", + "pre-push": "CI=true react-scripts test" + } + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] + }, + "devDependencies": { + "@typescript-eslint/eslint-plugin": "^2.26.0", + "@typescript-eslint/parser": "^2.26.0", + "eslint": "^6.8.0", + "eslint-config-prettier": "^6.10.1", + "eslint-config-react": "^1.1.7", + "eslint-plugin-prettier": "^3.1.2", + "husky": "^4.2.3", + "prettier": "^2.0.2" + } } diff --git a/src/App.scss b/src/App.scss index c846908..ad05320 100644 --- a/src/App.scss +++ b/src/App.scss @@ -1,36 +1,36 @@ body { - background-color: #ededed; + background-color: #ededed; } .page-wrapper { - width: 70%; - margin: 0 auto; - background-color: white; - height: 100vh; + width: 70%; + margin: 0 auto; + background-color: white; + height: 100vh; } .content { - padding-top: 70px; - display: flex; - justify-content: center; + padding-top: 70px; + display: flex; + justify-content: center; } .button { - margin: 2px; - padding: 5px 15px; - border-radius: 3px; - height: 35px; - font-size: 14px; - outline-style: none; - cursor: pointer; - color: white; - background-color: #3b92b3; + margin: 2px; + padding: 5px 15px; + border-radius: 3px; + height: 35px; + font-size: 14px; + outline-style: none; + cursor: pointer; + color: white; + background-color: #3b92b3; } .red-button { - background-color: #ce1400; + background-color: #ce1400; } .green-button { - background-color: #52b230; + background-color: #52b230; } diff --git a/src/App.test.tsx b/src/App.test.tsx index 4db7ebc..1330c44 100644 --- a/src/App.test.tsx +++ b/src/App.test.tsx @@ -1,9 +1,9 @@ +import App from './App'; import React from 'react'; import { render } from '@testing-library/react'; -import App from './App'; test('renders learn react link', () => { - const { getByText } = render(); - const linkElement = getByText(/learn react/i); - expect(linkElement).toBeInTheDocument(); + const { getByText } = render(); + const currentNameLabel = getByText(/Current name/i); + expect(currentNameLabel).toBeInTheDocument(); }); diff --git a/src/App.tsx b/src/App.tsx index 70f2a03..fa7d6b2 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,80 +1,74 @@ -import React from "react"; -import "./App.scss"; -import { useGlobalState } from "./state/useGlobalState"; -import { InProgressList } from "./features/InProgressList/InProgressList"; -import { Header } from "./shared/Header/Header"; -import { DoneList } from "./features/DoneList/DoneList"; -import { UpdateToDoItems } from "./state/toDoItems/ToDoItemsActions"; -import { ListItemType } from "./common.types"; +import './App.scss'; -function App() { - const { state, dispatch } = useGlobalState(); +import React, { ReactElement } from 'react'; - const moveItemFromArrayToAnother = ( - itemId: number, - oldArray: ListItemType[], - newArray: ListItemType[] - ) => { - const item = oldArray.find(item => item.id === itemId); - if (!item) { - return; - } - const newArrayUpdated = [...newArray]; - newArrayUpdated.push(item); - const oldArrayUpdated = oldArray.filter(item => item.id !== itemId); +import { DoneList } from './features/DoneList/DoneList'; +import { Header } from './shared/Header/Header'; +import { InProgressList } from './features/InProgressList/InProgressList'; +import { ListItemType } from './common.types'; +import { UpdateToDoItems } from './state/toDoItems/ToDoItemsActions'; +import { useGlobalState } from './state/useGlobalState'; - return [oldArrayUpdated, newArrayUpdated]; - }; +function App(): ReactElement { + const { state, dispatch } = useGlobalState(); - const deleteInProgressItem = (itemIndex: number) => { - const { inProgress, done } = state.toDoItems; - const newArray = inProgress.filter(item => item.id !== itemIndex); + const moveItemFromArrayToAnother = (itemId: number, oldArray: ListItemType[], newArray: ListItemType[]) => { + const item = oldArray.find((item) => item.id === itemId); + if (!item) { + return; + } + const newArrayUpdated = [...newArray]; + newArrayUpdated.push(item); + const oldArrayUpdated = oldArray.filter((item) => item.id !== itemId); + return [oldArrayUpdated, newArrayUpdated]; + }; - dispatch( - new UpdateToDoItems({ - done: [...done], - inProgress: newArray - }) - ); - }; + const deleteInProgressItem = (itemIndex: number): void => { + const { inProgress, done } = state.toDoItems; + const newArray = inProgress.filter((item) => item.id !== itemIndex); - const moveItemToDone = (itemIndex: number) => { - const { inProgress, done } = state.toDoItems; - const result = moveItemFromArrayToAnother(itemIndex, inProgress, done); - if (result) { - dispatch(new UpdateToDoItems({ done: result[1], inProgress: result[0] })); - } - }; + dispatch( + new UpdateToDoItems({ + done: [...done], + inProgress: newArray, + }) + ); + }; - const removeItemFromDone = (itemIndex: number) => { - const { inProgress, done } = state.toDoItems; - const result = moveItemFromArrayToAnother(itemIndex, done, inProgress); - if (result) { - dispatch(new UpdateToDoItems({ done: result[0], inProgress: result[1] })); - } - }; + const moveItemToDone = (itemIndex: number): void => { + const { inProgress, done } = state.toDoItems; + const result = moveItemFromArrayToAnother(itemIndex, inProgress, done); + if (result) { + dispatch(new UpdateToDoItems({ done: result[1], inProgress: result[0] })); + } + }; - return ( -
- Current name: {state.user.name} -
- Current age: {state.user.age} -
-
-
- - -
-
-
- ); + const removeItemFromDone = (itemIndex: number): void => { + const { inProgress, done } = state.toDoItems; + const result = moveItemFromArrayToAnother(itemIndex, done, inProgress); + if (result) { + dispatch(new UpdateToDoItems({ done: result[0], inProgress: result[1] })); + } + }; + + return ( +
+ Current name: {state.user.name} +
+ Current age: {state.user.age} +
+
+
+ + +
+
+
+ ); } export default App; diff --git a/src/common.types.ts b/src/common.types.ts index a302a31..72c76da 100644 --- a/src/common.types.ts +++ b/src/common.types.ts @@ -1,11 +1,11 @@ export type ListItemType = { - title: string; - buttons?: ListItemButtonType[]; - id: number; + title: string; + buttons?: ListItemButtonType[]; + id: number; }; export type ListItemButtonType = { - label: string; - class: string; - action: Function; + label: string; + class: string; + action: Function; }; diff --git a/src/features/DoneList/DoneList.tsx b/src/features/DoneList/DoneList.tsx index a2e885c..fbf82c4 100644 --- a/src/features/DoneList/DoneList.tsx +++ b/src/features/DoneList/DoneList.tsx @@ -1,17 +1,16 @@ -import React, { FunctionComponent } from "react"; -import { List } from "../../shared/List/List"; -import { ListItemButtonType, ListItemType } from "../../common.types"; +import { ListItemButtonType, ListItemType } from '../../common.types'; +import React, { FunctionComponent } from 'react'; -type Props = { doneItems: ListItemType[]; onRemove: Function }; +import { List } from '../../shared/List/List'; -export const DoneList: FunctionComponent = ({ doneItems, onRemove }) => { - const buttons: ListItemButtonType[] = [ - { label: "Remove", class: "red-button", action: onRemove } - ]; - let DoneItems: ListItemType[] = doneItems.map(item => { - item.buttons = buttons; - return item; - }); +type PropTypes = { doneItems: ListItemType[]; onRemove: Function }; - return ; +export const DoneList: FunctionComponent = ({ doneItems, onRemove }: PropTypes) => { + const buttons: ListItemButtonType[] = [{ label: 'Remove', class: 'red-button', action: onRemove }]; + const DoneItems: ListItemType[] = doneItems.map((item) => { + item.buttons = buttons; + return item; + }); + + return ; }; diff --git a/src/features/InProgressList/InProgressList.tsx b/src/features/InProgressList/InProgressList.tsx index 5e96744..272d931 100644 --- a/src/features/InProgressList/InProgressList.tsx +++ b/src/features/InProgressList/InProgressList.tsx @@ -1,27 +1,25 @@ -import React, { FunctionComponent } from "react"; -import { List } from "../../shared/List/List"; -import "./InProgressList.scss"; -import { ListItemButtonType, ListItemType } from "../../common.types"; +import './InProgressList.scss'; + +import { ListItemButtonType, ListItemType } from '../../common.types'; +import React, { FunctionComponent } from 'react'; + +import { List } from '../../shared/List/List'; type Props = { - onDelete: Function; - onMoveItemToDone: Function; - inProgressItems: ListItemType[]; + onDelete: Function; + onMoveItemToDone: Function; + inProgressItems: ListItemType[]; }; -export const InProgressList: FunctionComponent = ({ - onDelete, - onMoveItemToDone, - inProgressItems -}) => { - const buttons: ListItemButtonType[] = [ - { label: "Done", class: "green-button", action: onMoveItemToDone }, - { label: "Delete", class: "red-button", action: onDelete } - ]; - let items: ListItemType[] = inProgressItems.map(item => { - item.buttons = buttons; - return item; - }); +export const InProgressList: FunctionComponent = ({ onDelete, onMoveItemToDone, inProgressItems }: Props) => { + const buttons: ListItemButtonType[] = [ + { label: 'Done', class: 'green-button', action: onMoveItemToDone }, + { label: 'Delete', class: 'red-button', action: onDelete }, + ]; + const items: ListItemType[] = inProgressItems.map((item) => { + item.buttons = buttons; + return item; + }); - return ; + return ; }; diff --git a/src/index.scss b/src/index.scss index ec2585e..98ede8d 100644 --- a/src/index.scss +++ b/src/index.scss @@ -1,13 +1,11 @@ body { - margin: 0; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', - 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', - sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', + 'Droid Sans', 'Helvetica Neue', sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; } code { - font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', - monospace; + font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; } diff --git a/src/index.tsx b/src/index.tsx index fd37a4e..45a4658 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,19 +1,19 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import "./index.scss"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; -import { Provider } from "./state/Provider"; +import './index.scss'; +import * as serviceWorker from './serviceWorker'; +import App from './App'; +import { Provider } from './state/Provider'; +import React from 'react'; +import ReactDOM from 'react-dom'; ReactDOM.render( - - - - - , - document.getElementById("root") + + + + + , + document.getElementById('root') ); // If you want your app to work offline and load faster, you can change diff --git a/src/shared/Header/Header.tsx b/src/shared/Header/Header.tsx index 2f02421..f8dc67f 100644 --- a/src/shared/Header/Header.tsx +++ b/src/shared/Header/Header.tsx @@ -1,12 +1,11 @@ -import React, { FunctionComponent } from "react"; -import "./Header.scss"; +import './Header.scss'; + +import React, { FunctionComponent } from 'react'; type Props = { label: string }; -export const Header: FunctionComponent = ({ label }) => { - return ( -
- -
- ); -}; +export const Header: FunctionComponent = ({ label }: Props) => ( +
+ +
+); diff --git a/src/shared/List/List.tsx b/src/shared/List/List.tsx index 90daf67..4df146b 100644 --- a/src/shared/List/List.tsx +++ b/src/shared/List/List.tsx @@ -1,20 +1,22 @@ -import React, { FunctionComponent } from "react"; -import { ListItem } from "../ListItem/ListItem"; -import { ListItemType } from "../../common.types"; -import "./List.scss"; +import './List.scss'; + +import React, { FunctionComponent } from 'react'; + +import { ListItem } from '../ListItem/ListItem'; +import { ListItemType } from '../../common.types'; type Props = { - items: ListItemType[]; + items: ListItemType[]; }; -export const List: FunctionComponent = ({ items }) => { - return ( -
- {items.length ? ( - items.map(item => ) - ) : ( - No items in the list - )} -
- ); +export const List: FunctionComponent = ({ items }: Props) => { + return ( +
+ {items.length ? ( + items.map((item) => ) + ) : ( + No items in the list + )} +
+ ); }; diff --git a/src/shared/ListItem/ListItem.tsx b/src/shared/ListItem/ListItem.tsx index c7e2a7e..7869632 100644 --- a/src/shared/ListItem/ListItem.tsx +++ b/src/shared/ListItem/ListItem.tsx @@ -1,35 +1,33 @@ -import React, { FunctionComponent } from "react"; -import { ListItemType } from "../../common.types"; -import "./ListItem.scss"; +import './ListItem.scss'; + +import React, { FunctionComponent, ReactElement } from 'react'; + +import { ListItemType } from '../../common.types'; type Props = { - item: ListItemType; + item: ListItemType; }; -export const ListItem: FunctionComponent = ({ item }) => { - function getButtons() { - if (!item.buttons) { - return; - } - return item.buttons.map(button => { - return ( - - ); - }); - } +export const ListItem: FunctionComponent = ({ item }: Props) => { + function getButtons(): ReactElement[] | undefined { + if (!item.buttons) { + return; + } + return item.buttons.map((button) => { + return ( + + ); + }); + } - return ( -
-
- {item.title} -
-
{getButtons()}
-
- ); + return ( +
+
+ {item.title} +
+
{getButtons()}
+
+ ); }; diff --git a/src/state/Action.ts b/src/state/Action.ts index 51ae1d2..cf7967e 100644 --- a/src/state/Action.ts +++ b/src/state/Action.ts @@ -1,3 +1,3 @@ export interface Action { - readonly type: string; -} \ No newline at end of file + readonly type: string; +} diff --git a/src/state/Context.ts b/src/state/Context.ts index c23748f..2f9db41 100644 --- a/src/state/Context.ts +++ b/src/state/Context.ts @@ -1,12 +1,12 @@ import React, { createContext } from 'react'; import { State, initialState } from './State'; -import { Action } from './Action'; - +import { Action } from './Action'; const initialContext: { state: State; dispatch: React.Dispatch } = { - state: initialState, - dispatch: () => {} + state: initialState, + /* eslint-disable @typescript-eslint/no-empty-function */ + dispatch: () => {}, }; -export const Context = createContext(initialContext); \ No newline at end of file +export const Context = createContext(initialContext); diff --git a/src/state/Provider.tsx b/src/state/Provider.tsx index a388d2c..5439482 100644 --- a/src/state/Provider.tsx +++ b/src/state/Provider.tsx @@ -1,10 +1,10 @@ +import React, { ReactElement, useReducer } from 'react'; -import React, { useReducer } from 'react'; import { Context } from './Context'; import { initialState } from './State'; import { reducer } from './Reducer'; -export function Provider({ children }: any) { - const [state, dispatch] = useReducer(reducer, initialState); - return {children}; - } \ No newline at end of file +export function Provider({ children }: any): ReactElement { + const [state, dispatch] = useReducer(reducer, initialState); + return {children}; +} diff --git a/src/state/Reducer.ts b/src/state/Reducer.ts index e54ff6f..0ea1d27 100644 --- a/src/state/Reducer.ts +++ b/src/state/Reducer.ts @@ -1,21 +1,21 @@ -import { UserReducer } from "./user/UserReducer"; -import { State } from "./State"; -import { ToDoItemsReducer } from "./toDoItems/ToDoItemsReducer"; +import { State } from './State'; +import { ToDoItemsReducer } from './toDoItems/ToDoItemsReducer'; +import { UserReducer } from './user/UserReducer'; export const combineReducers = (reducers: { [P in keyof T]: any }) => { - const reducerEntries = Object.entries(reducers) as [keyof T, any][]; - return (state: T, action: any) => { - const nextState = {} as T; - for (const [key, reducer] of reducerEntries) { - const previousStateForKey = state[key]; - const nextStateForKey = reducer(previousStateForKey, action); - nextState[key] = nextStateForKey; - } - return nextState; - }; + const reducerEntries = Object.entries(reducers) as [keyof T, any][]; + return (state: T, action: any) => { + const nextState = {} as T; + for (const [key, reducer] of reducerEntries) { + const previousStateForKey = state[key]; + const nextStateForKey = reducer(previousStateForKey, action); + nextState[key] = nextStateForKey; + } + return nextState; + }; }; export const reducer = combineReducers({ - user: UserReducer, - toDoItems: ToDoItemsReducer + user: UserReducer, + toDoItems: ToDoItemsReducer, }); diff --git a/src/state/State.ts b/src/state/State.ts index 79bfe26..4a4cc81 100644 --- a/src/state/State.ts +++ b/src/state/State.ts @@ -1,15 +1,12 @@ -import { - initialToDoItemsState, - ToDoItemsState -} from "./toDoItems/ToDoItemsState"; -import { UserState, initialUserState } from "./user/UserState"; +import { ToDoItemsState, initialToDoItemsState } from './toDoItems/ToDoItemsState'; +import { UserState, initialUserState } from './user/UserState'; export interface State { - user: UserState; - toDoItems: ToDoItemsState; + user: UserState; + toDoItems: ToDoItemsState; } export const initialState: State = { - user: initialUserState, - toDoItems: initialToDoItemsState + user: initialUserState, + toDoItems: initialToDoItemsState, }; diff --git a/src/state/toDoItems/ToDoItemsActions.ts b/src/state/toDoItems/ToDoItemsActions.ts index 1820f20..555dc4c 100644 --- a/src/state/toDoItems/ToDoItemsActions.ts +++ b/src/state/toDoItems/ToDoItemsActions.ts @@ -1,13 +1,13 @@ -import { Action } from "../Action"; -import { ToDoItemsState } from "./ToDoItemsState"; +import { Action } from '../Action'; +import { ToDoItemsState } from './ToDoItemsState'; export enum ToDoItemsActionTypes { - UpdateToDoItems = "[ToDoItems] Update items" + UpdateToDoItems = '[ToDoItems] Update items', } export class UpdateToDoItems implements Action { - public readonly type = ToDoItemsActionTypes.UpdateToDoItems; - constructor(public items: ToDoItemsState) {} + public readonly type = ToDoItemsActionTypes.UpdateToDoItems; + constructor(public items: ToDoItemsState) {} } export type ToDoItemsActions = UpdateToDoItems; diff --git a/src/state/toDoItems/ToDoItemsReducer.ts b/src/state/toDoItems/ToDoItemsReducer.ts index 833d70f..88e1774 100644 --- a/src/state/toDoItems/ToDoItemsReducer.ts +++ b/src/state/toDoItems/ToDoItemsReducer.ts @@ -1,17 +1,15 @@ -import { ToDoItemsActionTypes, ToDoItemsActions } from "./ToDoItemsActions"; -import { ToDoItemsState } from "./ToDoItemsState"; +import { ToDoItemsActionTypes, ToDoItemsActions } from './ToDoItemsActions'; -export const ToDoItemsReducer = ( - state: ToDoItemsState, - action: ToDoItemsActions -) => { - switch (action.type) { - case ToDoItemsActionTypes.UpdateToDoItems: - return { - ...action.items - }; +import { ToDoItemsState } from './ToDoItemsState'; - default: - return state; - } +export const ToDoItemsReducer = (state: ToDoItemsState, action: ToDoItemsActions) => { + switch (action.type) { + case ToDoItemsActionTypes.UpdateToDoItems: + return { + ...action.items, + }; + + default: + return state; + } }; diff --git a/src/state/toDoItems/ToDoItemsState.ts b/src/state/toDoItems/ToDoItemsState.ts index ba9c464..10f5bd4 100644 --- a/src/state/toDoItems/ToDoItemsState.ts +++ b/src/state/toDoItems/ToDoItemsState.ts @@ -1,15 +1,18 @@ -import { ListItemType } from "../../common.types"; +import { ListItemType } from '../../common.types'; export type ToDoItemsState = { - done: ListItemType[]; - inProgress: ListItemType[]; + done: ListItemType[]; + inProgress: ListItemType[]; }; export const initialToDoItemsState: ToDoItemsState = { - done: [{ id: 1, title: "Shopping" }, { id: 2, title: "Cooking" }], - inProgress: [ - { id: 3, title: "Groceries" }, - { id: 4, title: "Cleaning" }, - { id: 5, title: "Creating a website" } - ] + done: [ + { id: 1, title: 'Shopping' }, + { id: 2, title: 'Cooking' }, + ], + inProgress: [ + { id: 3, title: 'Groceries' }, + { id: 4, title: 'Cleaning' }, + { id: 5, title: 'Creating a website' }, + ], }; diff --git a/src/state/useGlobalState.ts b/src/state/useGlobalState.ts index cb7a72d..78722cd 100644 --- a/src/state/useGlobalState.ts +++ b/src/state/useGlobalState.ts @@ -1,5 +1,4 @@ -import { useContext } from 'react'; import { Context } from './Context'; +import { useContext } from 'react'; - -export const useGlobalState = () => useContext(Context); \ No newline at end of file +export const useGlobalState = () => useContext(Context); diff --git a/src/state/user/UserActions.ts b/src/state/user/UserActions.ts index 2685e58..bac40c1 100644 --- a/src/state/user/UserActions.ts +++ b/src/state/user/UserActions.ts @@ -1,18 +1,18 @@ -import { Action } from "../Action"; +import { Action } from '../Action'; export enum UserActionTypes { - UpdateUserName = "[User] Update User name", - UpdateUserAge = "[User] Update User age" + UpdateUserName = '[User] Update User name', + UpdateUserAge = '[User] Update User age', } export class UpdateUserAge implements Action { - public readonly type = UserActionTypes.UpdateUserAge; - constructor(public age: number) {} + public readonly type = UserActionTypes.UpdateUserAge; + constructor(public age: number) {} } export class UpdateUserName implements Action { - public readonly type = UserActionTypes.UpdateUserName; - constructor(public name: string) {} + public readonly type = UserActionTypes.UpdateUserName; + constructor(public name: string) {} } export type UserActions = UpdateUserName | UpdateUserAge; diff --git a/src/state/user/UserReducer.ts b/src/state/user/UserReducer.ts index 576c0e1..6ee8f96 100644 --- a/src/state/user/UserReducer.ts +++ b/src/state/user/UserReducer.ts @@ -1,19 +1,20 @@ -import { UserActionTypes, UserActions } from "./UserActions"; -import { UserState } from "./UserState"; +import { UserActionTypes, UserActions } from './UserActions'; + +import { UserState } from './UserState'; export const UserReducer = (state: UserState, action: UserActions) => { - switch (action.type) { - case UserActionTypes.UpdateUserAge: - return { - ...state, - age: action.age - }; - case UserActionTypes.UpdateUserName: - return { - ...state, - name: action.name - }; - default: - return state; - } + switch (action.type) { + case UserActionTypes.UpdateUserAge: + return { + ...state, + age: action.age, + }; + case UserActionTypes.UpdateUserName: + return { + ...state, + name: action.name, + }; + default: + return state; + } }; diff --git a/src/state/user/UserState.ts b/src/state/user/UserState.ts index 4b059c2..9e76e1f 100644 --- a/src/state/user/UserState.ts +++ b/src/state/user/UserState.ts @@ -1,9 +1,9 @@ export type UserState = { - age: number; - name: string; + age: number; + name: string; }; export const initialUserState: UserState = { - age: 12, - name: "Initial name" + age: 12, + name: 'Initial name', }; diff --git a/tsconfig.json b/tsconfig.json index f2850b7..e4ffaee 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,25 +1,20 @@ { - "compilerOptions": { - "target": "es5", - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], - "allowJs": true, - "skipLibCheck": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "strict": true, - "forceConsistentCasingInFileNames": true, - "module": "esnext", - "moduleResolution": "node", - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - "jsx": "react" - }, - "include": [ - "src" - ] + "compilerOptions": { + "target": "es5", + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "module": "esnext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "rootDir": "./src", + "jsx": "react" + }, + "include": ["src"] }