From 2d66bb243d83c00e3e8b716f95dd3880ad8ea1bf Mon Sep 17 00:00:00 2001 From: MattAgn Date: Mon, 23 Dec 2019 12:16:09 +0100 Subject: [PATCH 1/4] Add some configuration for eslint and jest --- .eslintrc.js | 3 + jest.config.js | 1 + package.json | 11 +- tsconfig.json | 1 + yarn.lock | 310 ++++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 320 insertions(+), 6 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 3a4b89a..405c8d6 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -19,6 +19,9 @@ module.exports = { modules: true, }, }, + env: { + jest: true, + }, rules: { '@typescript-eslint/no-parameter-properties': 'off', '@typescript-eslint/explicit-function-return-type': 'off', diff --git a/jest.config.js b/jest.config.js index 4734449..c1ab5b8 100644 --- a/jest.config.js +++ b/jest.config.js @@ -21,4 +21,5 @@ module.exports = { watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'], testEnvironment: 'jsdom', resetMocks: true, + projects: ['src/utils/tests/jest.lint.js'], }; diff --git a/package.json b/package.json index 486fee4..7ab6f27 100644 --- a/package.json +++ b/package.json @@ -5,11 +5,18 @@ "scripts": { "start": "react-native start", "test": "jest", - "lint": "eslint src --ext .js,.ts,.tsx --no-ignore --max-warnings=0 && yarn ts:check", + "check-types": "tsc --project tsconfig.json", + "lint": "eslint src --ext .js,.ts,.tsx --no-ignore --max-warnings=0", "format": "prettier --write --ignore-path .gitignore \"**/*.+(js|ts|tsx|json)\"", + "validate": "npm-run-all check-types lint test", "lint-committed": "lint-committed", "commit-formatting": "git commit -m \"Format files\" || echo \"No files to format\"" }, + "jest-runner-eslint": { + "clipOptions": { + "ignorePath": "./.gitignore" + } + }, "dependencies": { "@bam.tech/react-native-component-text-input": "^1.0.3", "@martin_hotell/rex-tils": "^2.1.1", @@ -58,11 +65,13 @@ "fetch-mock": "^7.3.3", "husky": "3.1.0", "jest": "^24.9.0", + "jest-runner-eslint": "0.7.5", "jest-styled-components": "^6.3.3", "jest-watch-typeahead": "0.4.2", "jetifier": "^1.6.4", "lint-committed": "0.0.0-development", "metro-react-native-babel-preset": "^0.56.0", + "npm-run-all": "4.1.5", "patch-package": "^6.1.2", "prettier": "^1.16.4", "react-dom": "^16.8.6", diff --git a/tsconfig.json b/tsconfig.json index 575b8c7..37434ca 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,7 @@ "allowSyntheticDefaultImports": true, "esModuleInterop": true, "isolatedModules": true, + "skipLibCheck": true, // does not check lib typings because there is an issues with jest typings "jsx": "react", "lib": ["es6"], "types": ["jest"], diff --git a/yarn.lock b/yarn.lock index 48386ac..b746baf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1329,6 +1329,11 @@ acorn-jsx@^5.0.2: resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.0.2.tgz#84b68ea44b373c4f8686023a551f61a21b7c4a4f" integrity sha512-tiNTrP1MP0QrChmD2DdupCr6HWSFeKVw5d/dHTu4Y7rkAkRhU/Dt7dphAfIUyxtHpl/eBVip5uTNSpQJHylpAw== +acorn-jsx@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.1.0.tgz#294adb71b57398b0680015f0a38c563ee1db5384" + integrity sha512-tMUqwBWfLFbJbizRmEcWSLw6HnFzfdJs2sOJEOwwtVPMoH/0Ay+E703oZz78VSXZiiDcZrQ5XKjPIUQixhmgVw== + acorn-walk@^6.0.1: version "6.2.0" resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-6.2.0.tgz#123cb8f3b84c2171f1f7fb252615b1c78a6b1a8c" @@ -1349,6 +1354,11 @@ acorn@^7.0.0: resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.0.0.tgz#26b8d1cd9a9b700350b71c0905546f64d1284e7a" integrity sha512-PaF/MduxijYYt7unVGRuds1vBC9bFxbNf+VWqhOClfdgy7RlVkQqt610ig1/yxTgsDIfW1cWDel5EBbOy3jdtQ== +acorn@^7.1.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.1.0.tgz#949d36f2c292535da602283586c2477c57eb2d6c" + integrity sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ== + ajv@^6.10.0, ajv@^6.10.2, ajv@^6.5.5: version "6.10.2" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.2.tgz#d3cea04d6b017b2894ad69040fec8b623eb4bd52" @@ -1435,6 +1445,11 @@ ansi-regex@^4.0.0, ansi-regex@^4.1.0: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== +ansi-regex@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75" + integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg== + ansi-styles@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" @@ -2026,6 +2041,13 @@ cli-cursor@^2.1.0: dependencies: restore-cursor "^2.0.0" +cli-cursor@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-3.1.0.tgz#264305a7ae490d1d03bf0c9ba7c925d1753af307" + integrity sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw== + dependencies: + restore-cursor "^3.1.0" + cli-spinners@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-0.1.2.tgz#bb764d88e185fb9e1e6a2a1f19772318f605e31c" @@ -2271,7 +2293,7 @@ cosmiconfig@^1.1.0: pinkie-promise "^2.0.0" require-from-string "^1.1.0" -cosmiconfig@^5.0.5, cosmiconfig@^5.1.0, cosmiconfig@^5.2.1: +cosmiconfig@^5.0.0, cosmiconfig@^5.0.5, cosmiconfig@^5.1.0, cosmiconfig@^5.2.1: version "5.2.1" resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-5.2.1.tgz#040f726809c591e77a17c0a3626ca45b4f168b1a" integrity sha512-H65gsXo1SKjf8zmrJ67eJk8aIRKV5ff2D4uKZIBZShbhGSpEmsQOPW/SKMKYhSTrqR7ufy6RP69rPogdaPh/kA== @@ -2288,6 +2310,15 @@ create-error-class@^3.0.0: dependencies: capture-stack-trace "^1.0.0" +create-jest-runner@^0.5.3: + version "0.5.3" + resolved "https://registry.yarnpkg.com/create-jest-runner/-/create-jest-runner-0.5.3.tgz#1387e2ce70b08e4c989ae55f677005b64f9ba97b" + integrity sha512-a9VY2doMBmzRollJB3Ft3/Y5fBceSWJ4gdyVsg4/d7nP1S4715VG939s2VnITDj79YBmRgKhjGjNRv1c+Kre1g== + dependencies: + chalk "^2.4.2" + jest-worker "^24.0.0" + throat "^4.1.0" + create-react-class@^15.6.0, create-react-class@^15.6.3: version "15.6.3" resolved "https://registry.yarnpkg.com/create-react-class/-/create-react-class-15.6.3.tgz#2d73237fb3f970ae6ebe011a9e66f46dbca80036" @@ -2593,6 +2624,11 @@ emoji-regex@^7.0.1: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + encodeurl@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" @@ -2648,6 +2684,23 @@ es-abstract@^1.11.0, es-abstract@^1.12.0, es-abstract@^1.5.1, es-abstract@^1.7.0 string.prototype.trimleft "^2.0.0" string.prototype.trimright "^2.0.0" +es-abstract@^1.17.0-next.1: + version "1.17.0" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.0.tgz#f42a517d0036a5591dbb2c463591dc8bb50309b1" + integrity sha512-yYkE07YF+6SIBmg1MsJ9dlub5L48Ek7X0qz+c/CPCHS9EBXfESorzng4cJQjJW5/pB6vDF41u7F8vUhLVDqIug== + dependencies: + es-to-primitive "^1.2.1" + function-bind "^1.1.1" + has "^1.0.3" + has-symbols "^1.0.1" + is-callable "^1.1.5" + is-regex "^1.0.5" + object-inspect "^1.7.0" + object-keys "^1.1.1" + object.assign "^4.1.0" + string.prototype.trimleft "^2.1.1" + string.prototype.trimright "^2.1.1" + es-to-primitive@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.0.tgz#edf72478033456e8dda8ef09e00ad9650707f377" @@ -2657,6 +2710,15 @@ es-to-primitive@^1.2.0: is-date-object "^1.0.1" is-symbol "^1.0.2" +es-to-primitive@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" + integrity sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA== + dependencies: + is-callable "^1.1.4" + is-date-object "^1.0.1" + is-symbol "^1.0.2" + escape-html@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" @@ -2830,11 +2892,61 @@ eslint-utils@^1.3.1, eslint-utils@^1.4.2: dependencies: eslint-visitor-keys "^1.0.0" +eslint-utils@^1.4.3: + version "1.4.3" + resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.4.3.tgz#74fec7c54d0776b6f67e0251040b5806564e981f" + integrity sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q== + dependencies: + eslint-visitor-keys "^1.1.0" + eslint-visitor-keys@^1.0.0, eslint-visitor-keys@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2" integrity sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A== +"eslint@^4.0.0 || ^5.0.0 || ^6.0.0": + version "6.8.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-6.8.0.tgz#62262d6729739f9275723824302fb227c8c93ffb" + integrity sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig== + dependencies: + "@babel/code-frame" "^7.0.0" + ajv "^6.10.0" + chalk "^2.1.0" + cross-spawn "^6.0.5" + debug "^4.0.1" + doctrine "^3.0.0" + eslint-scope "^5.0.0" + eslint-utils "^1.4.3" + eslint-visitor-keys "^1.1.0" + espree "^6.1.2" + esquery "^1.0.1" + esutils "^2.0.2" + file-entry-cache "^5.0.1" + functional-red-black-tree "^1.0.1" + glob-parent "^5.0.0" + globals "^12.1.0" + ignore "^4.0.6" + import-fresh "^3.0.0" + imurmurhash "^0.1.4" + inquirer "^7.0.0" + is-glob "^4.0.0" + js-yaml "^3.13.1" + json-stable-stringify-without-jsonify "^1.0.1" + levn "^0.3.0" + lodash "^4.17.14" + minimatch "^3.0.4" + mkdirp "^0.5.1" + natural-compare "^1.4.0" + optionator "^0.8.3" + progress "^2.0.0" + regexpp "^2.0.1" + semver "^6.1.2" + strip-ansi "^5.2.0" + strip-json-comments "^3.0.1" + table "^5.2.3" + text-table "^0.2.0" + v8-compile-cache "^2.0.3" + eslint@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/eslint/-/eslint-6.3.0.tgz#1f1a902f67bfd4c354e7288b81e40654d927eb6a" @@ -2887,6 +2999,15 @@ espree@^6.1.1: acorn-jsx "^5.0.2" eslint-visitor-keys "^1.1.0" +espree@^6.1.2: + version "6.1.2" + resolved "https://registry.yarnpkg.com/espree/-/espree-6.1.2.tgz#6c272650932b4f91c3714e5e7b5f5e2ecf47262d" + integrity sha512-2iUPuuPP+yW1PZaMSDM9eyVf8D5P0Hi8h83YtZ5bPc/zHYjII5khoixIUTMO794NOY8F/ThF1Bo8ncZILarUTA== + dependencies: + acorn "^7.1.0" + acorn-jsx "^5.1.0" + eslint-visitor-keys "^1.1.0" + esprima@^3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633" @@ -3109,7 +3230,7 @@ fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0: resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" integrity sha1-1RQsDK7msRifh9OnYREGT4bIu/I= -fast-levenshtein@~2.0.4: +fast-levenshtein@~2.0.4, fast-levenshtein@~2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= @@ -3195,6 +3316,13 @@ figures@^2.0.0: dependencies: escape-string-regexp "^1.0.5" +figures@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/figures/-/figures-3.1.0.tgz#4b198dd07d8d71530642864af2d45dd9e459c4ec" + integrity sha512-ravh8VRXqHuMvZt/d8GblBeqDMkdJMBdv/2KntFH+ra5MXkO7nxNKpzQ3n6QD/2da1kH0aWmNISdvhM7gl2gVg== + dependencies: + escape-string-regexp "^1.0.5" + file-entry-cache@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-5.0.1.tgz#ca0f6efa6dd3d561333fb14515065c2fafdf439c" @@ -3497,6 +3625,13 @@ globals@^11.1.0, globals@^11.7.0: resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== +globals@^12.1.0: + version "12.3.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-12.3.0.tgz#1e564ee5c4dded2ab098b0f88f24702a3c56be13" + integrity sha512-wAfjdLgFsPZsklLJvOBUBmzYE8/CwhEqSBEMRXA3qxIiNtyqvjYurAtIfDh6chlEPUfmTY3MnZh5Hfh4q0UlIw== + dependencies: + type-fest "^0.8.1" + got@^6.7.1: version "6.7.1" resolved "https://registry.yarnpkg.com/got/-/got-6.7.1.tgz#240cd05785a9a18e561dc1b44b41c763ef1e8db0" @@ -3575,6 +3710,11 @@ has-symbols@^1.0.0: resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.0.tgz#ba1a8f1af2a0fc39650f5c850367704122063b44" integrity sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q= +has-symbols@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.1.tgz#9f5214758a44196c406d9bd76cebf81ec2dd31e8" + integrity sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg== + has-unicode@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" @@ -3816,6 +3956,25 @@ inquirer@^6.4.1: strip-ansi "^5.1.0" through "^2.3.6" +inquirer@^7.0.0: + version "7.0.1" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.0.1.tgz#13f7980eedc73c689feff3994b109c4e799c6ebb" + integrity sha512-V1FFQ3TIO15det8PijPLFR9M9baSlnRs9nL7zWu1MNVA2T9YVl9ZbrHJhYs7e9X8jeMZ3lr2JH/rdHFgNCBdYw== + dependencies: + ansi-escapes "^4.2.1" + chalk "^2.4.2" + cli-cursor "^3.1.0" + cli-width "^2.0.0" + external-editor "^3.0.3" + figures "^3.0.0" + lodash "^4.17.15" + mute-stream "0.0.8" + run-async "^2.2.0" + rxjs "^6.5.3" + string-width "^4.1.0" + strip-ansi "^5.1.0" + through "^2.3.6" + invariant@^2.2.4: version "2.2.4" resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" @@ -3862,6 +4021,11 @@ is-callable@^1.1.4: resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75" integrity sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA== +is-callable@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.5.tgz#f7e46b596890456db74e7f6e976cb3273d06faab" + integrity sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q== + is-ci@^1.0.10: version "1.2.1" resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-1.2.1.tgz#e3779c8ee17fccf428488f6e281187f2e632841c" @@ -3954,6 +4118,11 @@ is-fullwidth-code-point@^2.0.0: resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + is-generator-fn@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-2.1.0.tgz#7d140adc389aaf3011a8f2a2a4cfa6faadffb118" @@ -4022,6 +4191,13 @@ is-regex@^1.0.4: dependencies: has "^1.0.1" +is-regex@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.5.tgz#39d589a358bf18967f726967120b8fc1aed74eae" + integrity sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ== + dependencies: + has "^1.0.3" + is-regexp@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-regexp/-/is-regexp-1.0.0.tgz#fd2d883545c46bac5a633e7b9a09e87fa2cb5069" @@ -4379,6 +4555,16 @@ jest-resolve@^24.9.0: jest-pnp-resolver "^1.2.1" realpath-native "^1.1.0" +jest-runner-eslint@0.7.5: + version "0.7.5" + resolved "https://registry.yarnpkg.com/jest-runner-eslint/-/jest-runner-eslint-0.7.5.tgz#ab413f531490b6ea42ce82186b25fcfe4ba3c2e5" + integrity sha512-R4EqQnX0gtUv2SA1vwerI6rd5hLm0tVBTq2j3j4BZBHEfh7oKGF/hlkkNVDRfd73TAOcCaM3uhgzny7R4mnWVQ== + dependencies: + chalk "^2.4.1" + cosmiconfig "^5.0.0" + create-jest-runner "^0.5.3" + eslint "^4.0.0 || ^5.0.0 || ^6.0.0" + jest-runner@^24.9.0: version "24.9.0" resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-24.9.0.tgz#574fafdbd54455c2b34b4bdf4365a23857fcdf42" @@ -4530,7 +4716,7 @@ jest-watcher@^24.3.0, jest-watcher@^24.9.0: jest-util "^24.9.0" string-length "^2.0.0" -jest-worker@^24.6.0, jest-worker@^24.9.0: +jest-worker@^24.0.0, jest-worker@^24.6.0, jest-worker@^24.9.0: version "24.9.0" resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-24.9.0.tgz#5dbfdb5b2d322e98567898238a9697bcce67b3e5" integrity sha512-51PE4haMSXcHohnSMdM42anbvZANYTqMrr52tVKPqqsPJMzoP6FYYDVqahX/HrAoKEKz3uUPzSvKs9A3qR4iVw== @@ -4923,7 +5109,7 @@ lodash.unescape@4.0.1: resolved "https://registry.yarnpkg.com/lodash.unescape/-/lodash.unescape-4.0.1.tgz#bf2249886ce514cda112fae9218cdc065211fc9c" integrity sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw= -lodash@^4.0.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0: +lodash@^4.0.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0: version "4.17.15" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== @@ -5046,6 +5232,11 @@ memoize-one@^5.0.0: resolved "https://registry.yarnpkg.com/memoize-one/-/memoize-one-5.1.1.tgz#047b6e3199b508eaec03504de71229b8eb1d75c0" integrity sha512-HKeeBpWvqiVJD57ZUAsJNm71eHTykffzcLZVYWiVfQeI1rJtuEaS7hQiEpWfVVk18donPwJEcFKIkCmPJNOhHA== +memorystream@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2" + integrity sha1-htcJCzDORV1j+64S3aUaR93K+bI= + merge-anything@^2.2.4: version "2.4.1" resolved "https://registry.yarnpkg.com/merge-anything/-/merge-anything-2.4.1.tgz#e9bccaec1e49ec6cb5f77ca78c5770d1a35315e6" @@ -5346,7 +5537,7 @@ mimic-fn@^1.0.0: resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" integrity sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ== -mimic-fn@^2.0.0: +mimic-fn@^2.0.0, mimic-fn@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== @@ -5434,6 +5625,11 @@ mute-stream@0.0.7: resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" integrity sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s= +mute-stream@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" + integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA== + nan@^2.12.1: version "2.14.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c" @@ -5580,6 +5776,21 @@ npm-path@^2.0.2: dependencies: which "^1.2.10" +npm-run-all@4.1.5: + version "4.1.5" + resolved "https://registry.yarnpkg.com/npm-run-all/-/npm-run-all-4.1.5.tgz#04476202a15ee0e2e214080861bff12a51d98fba" + integrity sha512-Oo82gJDAVcaMdi3nuoKFavkIHBRVqQ1qvMb+9LHk/cF4P6B2m8aP04hGf7oL6wZ9BuGwX1onlLhpuoofSyoQDQ== + dependencies: + ansi-styles "^3.2.1" + chalk "^2.4.1" + cross-spawn "^6.0.5" + memorystream "^0.3.1" + minimatch "^3.0.4" + pidtree "^0.3.0" + read-pkg "^3.0.0" + shell-quote "^1.6.1" + string.prototype.padend "^3.0.0" + npm-run-path@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" @@ -5650,6 +5861,11 @@ object-inspect@^1.6.0: resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.6.0.tgz#c70b6cbf72f274aab4c34c0c82f5167bf82cf15b" integrity sha512-GJzfBZ6DgDAmnuaM3104jR4s1Myxr3Y3zfIyN4z3UdqN69oSRacNK8UhnobDdC+7J2AHCjGwxQubNJfE70SXXQ== +object-inspect@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.7.0.tgz#f4f6bd181ad77f006b5ece60bd0b6f398ff74a67" + integrity sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw== + object-keys@^1.0.11, object-keys@^1.0.12, object-keys@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" @@ -5748,6 +5964,13 @@ onetime@^2.0.0: dependencies: mimic-fn "^1.0.0" +onetime@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.0.tgz#fff0f3c91617fe62bb50189636e99ac8a6df7be5" + integrity sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q== + dependencies: + mimic-fn "^2.1.0" + open@^6.2.0: version "6.4.0" resolved "https://registry.yarnpkg.com/open/-/open-6.4.0.tgz#5c13e96d0dc894686164f18965ecfe889ecfc8a9" @@ -5780,6 +6003,18 @@ optionator@^0.8.1, optionator@^0.8.2: type-check "~0.3.2" wordwrap "~1.0.0" +optionator@^0.8.3: + version "0.8.3" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495" + integrity sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA== + dependencies: + deep-is "~0.1.3" + fast-levenshtein "~2.0.6" + levn "~0.3.0" + prelude-ls "~1.1.2" + type-check "~0.3.2" + word-wrap "~1.2.3" + options@>=0.0.5: version "0.0.6" resolved "https://registry.yarnpkg.com/options/-/options-0.0.6.tgz#ec22d312806bb53e731773e7cdaefcf1c643128f" @@ -6062,6 +6297,11 @@ performance-now@^2.1.0: resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= +pidtree@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/pidtree/-/pidtree-0.3.0.tgz#f6fada10fccc9f99bf50e90d0b23d72c9ebc2e6b" + integrity sha512-9CT4NFlDcosssyg8KVFltgokyKZIFjoBxw8CTGy+5F38Y1eQWrt8tRayiUOXE+zVKQnYu5BR8JjCtvK3BcnBhg== + pify@^2.0.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" @@ -6862,6 +7102,14 @@ restore-cursor@^2.0.0: onetime "^2.0.0" signal-exit "^3.0.2" +restore-cursor@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-3.1.0.tgz#39f67c54b3a7a58cea5236d95cf0034239631f7e" + integrity sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA== + dependencies: + onetime "^5.1.0" + signal-exit "^3.0.2" + ret@~0.1.10: version "0.1.15" resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" @@ -6929,6 +7177,13 @@ rxjs@^6.3.3, rxjs@^6.4.0: dependencies: tslib "^1.9.0" +rxjs@^6.5.3: + version "6.5.3" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.3.tgz#510e26317f4db91a7eb1de77d9dd9ba0a4899a3a" + integrity sha512-wuYsAYYFdWTAnAaPoKGNhfpWwKZbJW+HgAJ+mImp+Epl7BG8oNWBCTyRM8gba9k4lk8BgWdoYm21Mo/RYhhbgA== + dependencies: + tslib "^1.9.0" + safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.2" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" @@ -7367,6 +7622,23 @@ string-width@^3.0.0, string-width@^3.1.0: is-fullwidth-code-point "^2.0.0" strip-ansi "^5.1.0" +string-width@^4.1.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.0.tgz#952182c46cc7b2c313d1596e623992bd163b72b5" + integrity sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.0" + +string.prototype.padend@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/string.prototype.padend/-/string.prototype.padend-3.1.0.tgz#dc08f57a8010dc5c153550318f67e13adbb72ac3" + integrity sha512-3aIv8Ffdp8EZj8iLwREGpQaUZiPyrWrpzMBHvkiSW/bK/EGve9np07Vwy7IJ5waydpGXzQZu/F8Oze2/IWkBaA== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.0-next.1" + string.prototype.trimleft@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/string.prototype.trimleft/-/string.prototype.trimleft-2.0.0.tgz#68b6aa8e162c6a80e76e3a8a0c2e747186e271ff" @@ -7375,6 +7647,14 @@ string.prototype.trimleft@^2.0.0: define-properties "^1.1.2" function-bind "^1.0.2" +string.prototype.trimleft@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz#9bdb8ac6abd6d602b17a4ed321870d2f8dcefc74" + integrity sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag== + dependencies: + define-properties "^1.1.3" + function-bind "^1.1.1" + string.prototype.trimright@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/string.prototype.trimright/-/string.prototype.trimright-2.0.0.tgz#ab4a56d802a01fbe7293e11e84f24dc8164661dd" @@ -7383,6 +7663,14 @@ string.prototype.trimright@^2.0.0: define-properties "^1.1.2" function-bind "^1.0.2" +string.prototype.trimright@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz#440314b15996c866ce8a0341894d45186200c5d9" + integrity sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g== + dependencies: + define-properties "^1.1.3" + function-bind "^1.1.1" + string_decoder@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" @@ -7420,6 +7708,13 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: dependencies: ansi-regex "^4.1.0" +strip-ansi@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532" + integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w== + dependencies: + ansi-regex "^5.0.0" + strip-bom@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" @@ -8045,6 +8340,11 @@ widest-line@^2.0.0: dependencies: string-width "^2.1.1" +word-wrap@~1.2.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" + integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== + wordwrap@^1.0.0, wordwrap@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" From c477589f9fa84aca336df70e628e7ddeccc261d2 Mon Sep 17 00:00:00 2001 From: MattAgn Date: Mon, 23 Dec 2019 12:16:16 +0100 Subject: [PATCH 2/4] Fix lint issues --- src/api/signup/index.ts | 4 +-- src/components/ButtonLink.tsx | 5 ++-- src/components/Toaster.tsx | 1 - src/modules/loading/reducer.ts | 4 +-- src/modules/loading/sagas.ts | 4 +-- src/modules/loading/selectors.ts | 4 +-- src/modules/loading/types.ts | 4 +-- src/modules/movies/reducer.ts | 6 ++--- src/modules/movies/sagas.ts | 11 ++++---- src/modules/movies/selectors.ts | 4 +-- src/modules/movies/types.ts | 2 +- src/modules/reducer.ts | 10 +++++-- src/modules/signup/reducer.ts | 3 +-- src/modules/signup/sagas.ts | 1 + src/modules/signup/types.ts | 2 -- src/modules/storeManager.ts | 6 ++--- src/modules/toaster/reducer.ts | 4 +-- src/modules/toaster/selectors.ts | 4 +-- src/modules/toaster/types.ts | 2 +- src/modules/todos/reducer.ts | 6 ++--- src/modules/todos/selectors.ts | 4 +-- src/modules/todos/types.ts | 2 +- src/modules/types.ts | 19 ++++++------- src/pages/About/About.tsx | 2 +- src/pages/About/__tests__/About.test.tsx | 2 +- src/pages/Home/Home.tsx | 5 +--- src/pages/Movies/Movies.tsx | 2 +- src/pages/Subscription/Subscription.tsx | 2 +- .../TodoList/__tests__/TodoList.test.tsx | 2 +- src/utils/tests/helpers.tsx | 27 ++++++++++--------- src/utils/tests/jest.lint.js | 9 +++++++ src/utils/tests/mockStore.ts | 4 +-- 32 files changed, 89 insertions(+), 78 deletions(-) create mode 100644 src/utils/tests/jest.lint.js diff --git a/src/api/signup/index.ts b/src/api/signup/index.ts index 520ff18..4c32623 100644 --- a/src/api/signup/index.ts +++ b/src/api/signup/index.ts @@ -2,12 +2,12 @@ import wretch from 'wretch'; import { EMAIL_API_ENDPOINT } from '../config'; -interface IValidateEmailParams { +interface ValidateEmailParams { email: string; } export class SignUpApi { - public static subscribeNewsletter(subscribeNewsletterParams: IValidateEmailParams) { + public static subscribeNewsletter(subscribeNewsletterParams: ValidateEmailParams) { return wretch() .url(EMAIL_API_ENDPOINT) .post(subscribeNewsletterParams) diff --git a/src/components/ButtonLink.tsx b/src/components/ButtonLink.tsx index 5ddf33c..d6a7dd9 100644 --- a/src/components/ButtonLink.tsx +++ b/src/components/ButtonLink.tsx @@ -4,12 +4,13 @@ import { Button } from './Button'; import styled from 'styled-components/native'; import { NavigationScreenProps } from 'react-navigation'; -interface IProps extends NavigationScreenProps { +interface Props extends NavigationScreenProps { + // eslint-disable-next-line @typescript-eslint/no-explicit-any navigationParams?: Record; route: string; } -export const ButtonLink: FunctionComponent = ({ route, navigation, navigationParams }) => ( +export const ButtonLink: FunctionComponent = ({ route, navigation, navigationParams }) => ( navigation.navigate(route, navigationParams)} /> ); diff --git a/src/components/Toaster.tsx b/src/components/Toaster.tsx index 1c82765..b016faa 100644 --- a/src/components/Toaster.tsx +++ b/src/components/Toaster.tsx @@ -1,5 +1,4 @@ import React, { FunctionComponent } from 'react'; -//@ts-ignore import ToasterMessage from 'react-native-toaster'; import { useSelector } from 'react-redux'; diff --git a/src/modules/loading/reducer.ts b/src/modules/loading/reducer.ts index ce1226e..d85152b 100644 --- a/src/modules/loading/reducer.ts +++ b/src/modules/loading/reducer.ts @@ -1,9 +1,9 @@ import { Reducer } from 'redux'; -import { TLoadingState, LoadingActionTypes } from './types'; +import { LoadingState, LoadingActionTypes } from './types'; import { TLoadingActionObjectTypes } from './actions'; -export const loadingReducer: Reducer = ( +export const loadingReducer: Reducer = ( state = {}, action ) => { diff --git a/src/modules/loading/sagas.ts b/src/modules/loading/sagas.ts index 440d9ae..f3f8de8 100644 --- a/src/modules/loading/sagas.ts +++ b/src/modules/loading/sagas.ts @@ -3,15 +3,15 @@ import { call, put } from 'redux-saga/effects'; import { LoadingActions } from './actions'; import { LoaderName } from './types'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any export const addLoader = (saga: (...args: any[]) => any, loaderName: LoaderName) => + // eslint-disable-next-line @typescript-eslint/no-explicit-any function*(...args: any[]): any { try { yield put(LoadingActions.showLoader(loaderName)); const result = yield call(saga, ...args); return result; - } catch (error) { - throw error; } finally { yield put(LoadingActions.hideLoader(loaderName)); } diff --git a/src/modules/loading/selectors.ts b/src/modules/loading/selectors.ts index 3c3388d..10f1334 100644 --- a/src/modules/loading/selectors.ts +++ b/src/modules/loading/selectors.ts @@ -1,6 +1,6 @@ -import { IAppState } from '../types'; +import { AppState } from '../types'; import { LoaderName } from './types'; -export const isLoadingSelector = (loaderName: LoaderName) => (state: IAppState) => +export const isLoadingSelector = (loaderName: LoaderName) => (state: AppState) => state.loading[loaderName]; diff --git a/src/modules/loading/types.ts b/src/modules/loading/types.ts index 2f2e7ad..38a94eb 100644 --- a/src/modules/loading/types.ts +++ b/src/modules/loading/types.ts @@ -7,8 +7,8 @@ export enum LoaderName { Movies = 'Movies', } -export type TLoadingState = { [name in LoaderName]?: boolean }; +export type LoadingState = { [name in LoaderName]?: boolean }; -export interface ILoadingProps { +export interface LoadingProps { isLoading?: boolean; } diff --git a/src/modules/movies/reducer.ts b/src/modules/movies/reducer.ts index e671e4e..9a13d52 100644 --- a/src/modules/movies/reducer.ts +++ b/src/modules/movies/reducer.ts @@ -1,13 +1,13 @@ import { Reducer } from 'redux'; import { TMoviesActionObjectTypes } from './actions'; -import { IMoviesState, MoviesActionTypes } from './types'; +import { MoviesState, MoviesActionTypes } from './types'; -const initialMoviesState: IMoviesState = { +const initialMoviesState: MoviesState = { movieList: undefined, }; -export const moviesReducer: Reducer = ( +export const moviesReducer: Reducer = ( state = initialMoviesState, action ) => { diff --git a/src/modules/movies/sagas.ts b/src/modules/movies/sagas.ts index f33c283..d4aa6f0 100644 --- a/src/modules/movies/sagas.ts +++ b/src/modules/movies/sagas.ts @@ -1,19 +1,18 @@ import { put, takeEvery, delay, call, all } from 'redux-saga/effects'; -import { ActionsOfType } from '@martin_hotell/rex-tils'; import { MoviesActionTypes } from './types'; -import { TMoviesActionObjectTypes, MoviesActions } from './actions'; +import { MoviesActions } from './actions'; import { addLoader } from '../loading/sagas'; import { LoaderName } from '../loading/types'; import { MoviesApi } from '../../api/movies'; -function* getMoviesSaga( - action: ActionsOfType -) { +function* getMoviesSaga() { try { + // eslint-disable-next-line @typescript-eslint/unbound-method const [movies] = yield all([call(MoviesApi.getMovies), delay(2000)]); // delay is used here for testing purposes to demonstrate how to use jest timers - const movieTitles = movies.results.map(movie => movie.title); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const movieTitles = movies.results.map((movie: any) => movie.title); yield put(MoviesActions.getMoviesSuccess(movieTitles)); } catch (err) { console.log(err); diff --git a/src/modules/movies/selectors.ts b/src/modules/movies/selectors.ts index c091f0b..2d1b62a 100644 --- a/src/modules/movies/selectors.ts +++ b/src/modules/movies/selectors.ts @@ -1,3 +1,3 @@ -import { IAppState } from '../types'; +import { AppState } from '../types'; -export const movieListSelector = (state: IAppState) => state.movies.movieList; +export const movieListSelector = (state: AppState) => state.movies.movieList; diff --git a/src/modules/movies/types.ts b/src/modules/movies/types.ts index eddfb96..d6a46c1 100644 --- a/src/modules/movies/types.ts +++ b/src/modules/movies/types.ts @@ -3,6 +3,6 @@ export enum MoviesActionTypes { GET_MOVIES_SUCCESS = 'GET_MOVIES_SUCCESS', } -export interface IMoviesState { +export interface MoviesState { movieList?: string[]; } diff --git a/src/modules/reducer.ts b/src/modules/reducer.ts index cffb154..317ec55 100644 --- a/src/modules/reducer.ts +++ b/src/modules/reducer.ts @@ -1,23 +1,29 @@ import { ReducersMapObject, combineReducers } from 'redux'; -import { IAppState } from './types'; +import { AppState } from './types'; import { signupReducer } from './signup/reducer'; import { toasterReducer } from './toaster/reducer'; import { todoReducer } from './todos/reducer'; import { moviesReducer } from './movies/reducer'; import { loadingReducer } from './loading/reducer'; +// TODO: fix typing const reducers: ReducersMapObject = { + // eslint-disable-next-line @typescript-eslint/ban-ts-ignore //@ts-ignore signup: signupReducer, + // eslint-disable-next-line @typescript-eslint/ban-ts-ignore //@ts-ignore toaster: toasterReducer, + // eslint-disable-next-line @typescript-eslint/ban-ts-ignore //@ts-ignore todos: todoReducer, + // eslint-disable-next-line @typescript-eslint/ban-ts-ignore //@ts-ignore movies: moviesReducer, + // eslint-disable-next-line @typescript-eslint/ban-ts-ignore //@ts-ignore loading: loadingReducer, }; -export const rootReducer = combineReducers(reducers); +export const rootReducer = combineReducers(reducers); diff --git a/src/modules/signup/reducer.ts b/src/modules/signup/reducer.ts index fa915d7..3b4a072 100644 --- a/src/modules/signup/reducer.ts +++ b/src/modules/signup/reducer.ts @@ -1,6 +1,5 @@ import { Reducer } from 'redux'; import { TSignUpActionObjectTypes } from './actions'; -import { ISignupState } from './types'; -export const signupReducer: Reducer = (state = {}) => state; +export const signupReducer: Reducer<{}, TSignUpActionObjectTypes> = (state = {}) => state; diff --git a/src/modules/signup/sagas.ts b/src/modules/signup/sagas.ts index 3c1887f..b1f3e90 100644 --- a/src/modules/signup/sagas.ts +++ b/src/modules/signup/sagas.ts @@ -13,6 +13,7 @@ function* subscribeNewsletterSaga( ) { try { const { email } = action.payload; + // eslint-disable-next-line @typescript-eslint/unbound-method yield call(SignUpApi.subscribeNewsletter, { email }); yield put(ToasterActions.showSuccessMessage(wording.subscriptionSuccessful)); } catch (err) { diff --git a/src/modules/signup/types.ts b/src/modules/signup/types.ts index cf869e8..2e51d85 100644 --- a/src/modules/signup/types.ts +++ b/src/modules/signup/types.ts @@ -1,5 +1,3 @@ export enum SignUpActionTypes { SUBSCRIBE_NEWSLETTER = 'SUBSCRIBE_NEWSLETTER', } - -export interface ISignupState {} diff --git a/src/modules/storeManager.ts b/src/modules/storeManager.ts index 0468e90..8bf7e18 100644 --- a/src/modules/storeManager.ts +++ b/src/modules/storeManager.ts @@ -1,9 +1,9 @@ import { Store as ReduxStore } from 'redux'; -import { IAppState } from '../modules/types'; +import { AppState } from '../modules/types'; class StoreManager { - private _store?: ReduxStore = undefined; + private _store?: ReduxStore = undefined; private static _instance: StoreManager; public static getInstance = () => { @@ -14,7 +14,7 @@ class StoreManager { return StoreManager._instance; }; - public set store(store: ReduxStore) { + public set store(store: ReduxStore) { this._store = store; } public get store() { diff --git a/src/modules/toaster/reducer.ts b/src/modules/toaster/reducer.ts index 10f6f3f..acb199a 100644 --- a/src/modules/toaster/reducer.ts +++ b/src/modules/toaster/reducer.ts @@ -1,10 +1,10 @@ import { Reducer } from 'redux'; -import { IToasterState, ToasterActionTypes } from './types'; +import { ToasterState, ToasterActionTypes } from './types'; import { TToasterActionObjectTypes } from './actions'; const initialState = null; -export const toasterReducer: Reducer = ( +export const toasterReducer: Reducer = ( state = initialState, action ) => { diff --git a/src/modules/toaster/selectors.ts b/src/modules/toaster/selectors.ts index 3644548..f88f81c 100644 --- a/src/modules/toaster/selectors.ts +++ b/src/modules/toaster/selectors.ts @@ -1,3 +1,3 @@ -import { IAppState } from '../types'; +import { AppState } from '../types'; -export const toasterMessageSelector = (state: IAppState) => state.toaster; +export const toasterMessageSelector = (state: AppState) => state.toaster; diff --git a/src/modules/toaster/types.ts b/src/modules/toaster/types.ts index e89bf62..187fc5f 100644 --- a/src/modules/toaster/types.ts +++ b/src/modules/toaster/types.ts @@ -4,7 +4,7 @@ export enum ToasterActionTypes { ADD_TOAST = 'ADD_TOAST', } -export interface IToasterState { +export interface ToasterState { text?: string; duration?: number; styles?: { diff --git a/src/modules/todos/reducer.ts b/src/modules/todos/reducer.ts index 10b9dba..d44a4c4 100644 --- a/src/modules/todos/reducer.ts +++ b/src/modules/todos/reducer.ts @@ -1,13 +1,13 @@ import { Reducer } from 'redux'; import { TTodoActionObjectTypes } from './actions'; -import { ITodoState, TodoActionTypes } from './types'; +import { TodoState, TodoActionTypes } from './types'; -const initialTodoState: ITodoState = { +const initialTodoState: TodoState = { todoList: [], }; -export const todoReducer: Reducer = ( +export const todoReducer: Reducer = ( state = initialTodoState, action ) => { diff --git a/src/modules/todos/selectors.ts b/src/modules/todos/selectors.ts index 6d479ef..8bcd7be 100644 --- a/src/modules/todos/selectors.ts +++ b/src/modules/todos/selectors.ts @@ -1,3 +1,3 @@ -import { IAppState } from '../types'; +import { AppState } from '../types'; -export const todoListSelector = (state: IAppState) => state.todos.todoList; +export const todoListSelector = (state: AppState) => state.todos.todoList; diff --git a/src/modules/todos/types.ts b/src/modules/todos/types.ts index 06cc375..37acf25 100644 --- a/src/modules/todos/types.ts +++ b/src/modules/todos/types.ts @@ -2,6 +2,6 @@ export enum TodoActionTypes { ADD_TODO = 'ADD_TODO', } -export interface ITodoState { +export interface TodoState { todoList: string[]; } diff --git a/src/modules/types.ts b/src/modules/types.ts index 6566f43..451b8e1 100644 --- a/src/modules/types.ts +++ b/src/modules/types.ts @@ -1,11 +1,12 @@ -import { ISignupState } from './signup/types'; -import { IToasterState } from './toaster/types'; -import { ITodoState } from './todos/types'; -import { IMoviesState } from './movies/types'; +import { ToasterState } from './toaster/types'; +import { TodoState } from './todos/types'; +import { MoviesState } from './movies/types'; +import { LoadingState } from './loading/types'; -export interface IAppState { - signup: ISignupState; - toaster: IToasterState; - todos: ITodoState; - movies: IMoviesState; +export interface AppState { + signup: {}; + toaster: ToasterState; + todos: TodoState; + movies: MoviesState; + loading: LoadingState; } diff --git a/src/pages/About/About.tsx b/src/pages/About/About.tsx index 846a907..6294f36 100644 --- a/src/pages/About/About.tsx +++ b/src/pages/About/About.tsx @@ -1,7 +1,7 @@ import React, { FunctionComponent } from 'react'; import { Button } from '../../components/Button'; import { wording } from '../../utils/wording'; -import { Container, Card, Title, Input } from '../../components/StyledComponents'; +import { Container, Card, Title } from '../../components/StyledComponents'; import { NavigationScreenProps } from 'react-navigation'; import { Routes } from '../../navigation/routes'; import { Text } from 'react-native'; diff --git a/src/pages/About/__tests__/About.test.tsx b/src/pages/About/__tests__/About.test.tsx index ebac9e1..ab91d66 100644 --- a/src/pages/About/__tests__/About.test.tsx +++ b/src/pages/About/__tests__/About.test.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { fireEvent, debug } from 'react-native-testing-library'; +import { fireEvent } from 'react-native-testing-library'; import 'jest-styled-components'; import { renderPage, getPropsWithNavigation } from '../../../utils/tests/helpers'; diff --git a/src/pages/Home/Home.tsx b/src/pages/Home/Home.tsx index 2720e42..d173d57 100644 --- a/src/pages/Home/Home.tsx +++ b/src/pages/Home/Home.tsx @@ -1,9 +1,6 @@ import React, { FunctionComponent } from 'react'; -import { useDispatch } from 'react-redux'; -import { SignUpActions } from '../../modules/signup/actions'; -import { wording } from '../../utils/wording'; -import { Card, Container, Title } from '../../components/StyledComponents'; +import { Card, Container } from '../../components/StyledComponents'; import { NavigationScreenProps } from 'react-navigation'; import { Routes } from '../../navigation/routes'; import { ButtonLink } from '../../components/ButtonLink'; diff --git a/src/pages/Movies/Movies.tsx b/src/pages/Movies/Movies.tsx index c45b861..5f97582 100644 --- a/src/pages/Movies/Movies.tsx +++ b/src/pages/Movies/Movies.tsx @@ -1,5 +1,5 @@ import React, { useEffect } from 'react'; -import { View, Text, ActivityIndicator } from 'react-native'; +import { Text, ActivityIndicator } from 'react-native'; import { Container, Card } from '../../components/StyledComponents'; import { useSelector, useDispatch } from 'react-redux'; import { movieListSelector } from '../../modules/movies/selectors'; diff --git a/src/pages/Subscription/Subscription.tsx b/src/pages/Subscription/Subscription.tsx index 4087513..bf533c2 100644 --- a/src/pages/Subscription/Subscription.tsx +++ b/src/pages/Subscription/Subscription.tsx @@ -1,7 +1,7 @@ import React, { FunctionComponent } from 'react'; import { Button } from '../../components/Button'; -import { useDispatch, useSelector } from 'react-redux'; +import { useDispatch } from 'react-redux'; import { SignUpActions } from '../../modules/signup/actions'; import { Formik } from 'formik'; import { FormikInput } from '../../components/Input'; diff --git a/src/pages/TodoList/__tests__/TodoList.test.tsx b/src/pages/TodoList/__tests__/TodoList.test.tsx index d4190c2..9808664 100644 --- a/src/pages/TodoList/__tests__/TodoList.test.tsx +++ b/src/pages/TodoList/__tests__/TodoList.test.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { renderPage, getPropsWithNavigation } from '../../../utils/tests/helpers'; +import { renderPage } from '../../../utils/tests/helpers'; import { TodoList } from '../TodoList'; import { wording } from '../../../utils/wording'; import { fireEvent, waitForElement } from 'react-native-testing-library'; diff --git a/src/utils/tests/helpers.tsx b/src/utils/tests/helpers.tsx index 1a38657..1dc0bdd 100644 --- a/src/utils/tests/helpers.tsx +++ b/src/utils/tests/helpers.tsx @@ -7,7 +7,7 @@ import { Toaster } from '../../components/Toaster'; import watchAll from '../../modules/saga'; import { ThemeProvider } from 'styled-components'; import { theme } from '../theme'; -import { IAppState } from '../../modules/types'; +import { AppState } from '../../modules/types'; import { createInitialiasedStore, sagaMiddlewareTest } from './mockStore'; import { storeManager } from '../../modules/storeManager'; import { createAppContainerWithInitialRoute } from '../../navigation/stack'; @@ -16,7 +16,7 @@ import { createAppContainerWithInitialRoute } from '../../navigation/stack'; * If you need to have a wrapper around your page, use it in pageContainerComponent (like the Redux Provider) * If you need a component rendered outside your page (like a Toaster), do the same */ -export const renderPage = (page: ReactElement, initialState?: Partial) => { +export const renderPage = (page: ReactElement, initialState?: Partial) => { storeManager.store = createInitialiasedStore(initialState); sagaMiddlewareTest.run(watchAll); @@ -35,24 +35,25 @@ export const renderPage = (page: ReactElement, initialState?: Partial }; export const getPropsWithNavigation = ( - props?: any, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + props?: Record, navigationPropExtension?: Partial> -) => - ({ - ...props, - navigation: { - navigate: jest.fn(), - goBack: jest.fn(), - ...navigationPropExtension, - }, - } as any); +) => ({ + ...props, + navigation: { + navigate: jest.fn(), + goBack: jest.fn(), + ...navigationPropExtension, + }, +}); +// eslint-disable-next-line @typescript-eslint/no-explicit-any export const getMockApiResponse = (status: number, data: any = {}) => ({ status, body: { data }, }); -export const renderWithNavigation = (pageRoute: string, initialState?: IAppState) => { +export const renderWithNavigation = (pageRoute: string, initialState?: AppState) => { const App = createAppContainerWithInitialRoute(pageRoute); storeManager.store = createInitialiasedStore(initialState); sagaMiddlewareTest.run(watchAll); diff --git a/src/utils/tests/jest.lint.js b/src/utils/tests/jest.lint.js new file mode 100644 index 0000000..ad8eb50 --- /dev/null +++ b/src/utils/tests/jest.lint.js @@ -0,0 +1,9 @@ +import path from 'path'; + +module.exports = { + rootDir: path.join(__dirname, '..'), + displayName: 'lint', + runner: 'jest-runner-eslint', + testMatch: ['src/**/*.(js|ts|tsx)'], + maxWarnings: 0, +}; diff --git a/src/utils/tests/mockStore.ts b/src/utils/tests/mockStore.ts index 964ec97..ca3d193 100644 --- a/src/utils/tests/mockStore.ts +++ b/src/utils/tests/mockStore.ts @@ -2,8 +2,8 @@ import { applyMiddleware, createStore } from 'redux'; import createSagaMiddleware from 'redux-saga'; import { rootReducer } from '../../modules/reducer'; -import { IAppState } from '../../modules/types'; +import { AppState } from '../../modules/types'; export const sagaMiddlewareTest = createSagaMiddleware(); -export const createInitialiasedStore = (initialState?: Partial) => +export const createInitialiasedStore = (initialState?: Partial) => createStore(rootReducer, initialState, applyMiddleware(sagaMiddlewareTest)); From 47b3cdd945d7bce8a5d8e2db9aaa7e7935be01ae Mon Sep 17 00:00:00 2001 From: MattAgn Date: Mon, 23 Dec 2019 17:23:49 +0100 Subject: [PATCH 3/4] Fix type issues --- .../DisabledButton/__tests__/DisabledButton.test.tsx | 10 ++++------ src/utils/tests/helpers.tsx | 6 +++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/pages/DisabledButton/__tests__/DisabledButton.test.tsx b/src/pages/DisabledButton/__tests__/DisabledButton.test.tsx index f8b5629..b320229 100644 --- a/src/pages/DisabledButton/__tests__/DisabledButton.test.tsx +++ b/src/pages/DisabledButton/__tests__/DisabledButton.test.tsx @@ -1,25 +1,23 @@ import React from 'react'; -import { renderPage, getPropsWithNavigation } from '../../../utils/tests/helpers'; +import { renderPage } from '../../../utils/tests/helpers'; import { DisabledButton } from '../DisabledButton'; import { fireEvent } from 'react-native-testing-library'; describe('[Page] DisabledButton', () => { - const props = getPropsWithNavigation(); - it('renders correctly', () => { - const page = renderPage(); + const page = renderPage(); expect(page).toMatchSnapshot(); }); it('shows disabled confirm button while password is blank', () => { - const page = renderPage(); + const page = renderPage(); const ConfirmButton = page.getByText('Confirm'); expect(ConfirmButton).toBeDisabled(); }); it('shows success message when password confirmed', () => { // Given - const page = renderPage(); + const page = renderPage(); const PasswordInput = page.getByPlaceholder('password'); const ConfirmButton = page.getByText('Confirm'); // When diff --git a/src/utils/tests/helpers.tsx b/src/utils/tests/helpers.tsx index 1dc0bdd..588e8e4 100644 --- a/src/utils/tests/helpers.tsx +++ b/src/utils/tests/helpers.tsx @@ -1,7 +1,7 @@ import React, { ReactElement } from 'react'; import { render } from 'react-native-testing-library'; import { Provider } from 'react-redux'; -import { NavigationScreenProp } from 'react-navigation'; +import { NavigationScreenProp, NavigationRoute, NavigationParams } from 'react-navigation'; import { Toaster } from '../../components/Toaster'; import watchAll from '../../modules/saga'; @@ -40,11 +40,11 @@ export const getPropsWithNavigation = ( navigationPropExtension?: Partial> ) => ({ ...props, - navigation: { + navigation: ({ navigate: jest.fn(), goBack: jest.fn(), ...navigationPropExtension, - }, + } as unknown) as NavigationScreenProp, NavigationParams>, }); // eslint-disable-next-line @typescript-eslint/no-explicit-any From a5ce3c9e3d046afcaa21cea6b1d63da38cf3065d Mon Sep 17 00:00:00 2001 From: MattAgn Date: Sat, 18 Jan 2020 19:31:07 +0100 Subject: [PATCH 4/4] :rotating_light: (test) remove eslint warning --- src/pages/About/__tests__/About.test.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/About/__tests__/About.test.tsx b/src/pages/About/__tests__/About.test.tsx index ab91d66..d3b9f5b 100644 --- a/src/pages/About/__tests__/About.test.tsx +++ b/src/pages/About/__tests__/About.test.tsx @@ -18,6 +18,7 @@ describe('[Page] About', () => { // WHEN fireEvent.press(NavigateSubscribeButton); // THEN + // eslint-disable-next-line @typescript-eslint/unbound-method expect(props.navigation.navigate).toHaveBeenCalledWith(Routes.Home); }); });