diff --git a/.eslintrc.json b/.eslintrc.json index 001ff56..060e4ca 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -35,6 +35,9 @@ "@typescript-eslint/no-non-null-assertion": "off", "@typescript-eslint/no-redeclare": "error", "@typescript-eslint/no-shadow": "error", + "@typescript-eslint/no-use-before-define": [ + "error" + ], "@typescript-eslint/semi": "error", "@typescript-eslint/space-before-function-paren": [ "error", @@ -73,6 +76,7 @@ "no-redeclare": "off", "no-shadow": "off", "no-unused-vars": "off", + "no-use-before-define": "off", "object-curly-newline": [ "error", { diff --git a/jest.config.js b/jest.config.js index 58ce3b1..2a4bf67 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,7 +1,7 @@ module.exports = { globals: { 'ts-jest': { - tsConfig: { + tsconfig: { jsx: 'react', target: 'es2019', }, diff --git a/package-lock.json b/package-lock.json index 08d5f14..eaa7cff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1974,13 +1974,13 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.0.1.tgz", - "integrity": "sha512-pQZtXupCn11O4AwpYVUX4PDFfmIJl90ZgrEBg0CEcqlwvPiG0uY81fimr1oMFblZnpKAq6prrT9a59pj1x58rw==", + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.11.1.tgz", + "integrity": "sha512-fABclAX2QIEDmTMk6Yd7Muv1CzFLwWM4505nETzRHpP3br6jfahD9UUJkhnJ/g2m7lwfz8IlswcwGGPGiq9exw==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "4.0.1", - "@typescript-eslint/scope-manager": "4.0.1", + "@typescript-eslint/experimental-utils": "4.11.1", + "@typescript-eslint/scope-manager": "4.11.1", "debug": "^4.1.1", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.0.0", @@ -1988,11 +1988,70 @@ "tsutils": "^3.17.1" }, "dependencies": { - "semver": { - "version": "7.3.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", - "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", + "@typescript-eslint/experimental-utils": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.11.1.tgz", + "integrity": "sha512-mAlWowT4A6h0TC9F+J5pdbEhjNiEMO+kqPKQ4sc3fVieKL71dEqfkKgtcFVSX3cjSBwYwhImaQ/mXQF0oaI38g==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.3", + "@typescript-eslint/scope-manager": "4.11.1", + "@typescript-eslint/types": "4.11.1", + "@typescript-eslint/typescript-estree": "4.11.1", + "eslint-scope": "^5.0.0", + "eslint-utils": "^2.0.0" + } + }, + "@typescript-eslint/scope-manager": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.11.1.tgz", + "integrity": "sha512-Al2P394dx+kXCl61fhrrZ1FTI7qsRDIUiVSuN6rTwss6lUn8uVO2+nnF4AvO0ug8vMsy3ShkbxLu/uWZdTtJMQ==", + "dev": true, + "requires": { + "@typescript-eslint/types": "4.11.1", + "@typescript-eslint/visitor-keys": "4.11.1" + } + }, + "@typescript-eslint/types": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.11.1.tgz", + "integrity": "sha512-5kvd38wZpqGY4yP/6W3qhYX6Hz0NwUbijVsX2rxczpY6OXaMxh0+5E5uLJKVFwaBM7PJe1wnMym85NfKYIh6CA==", "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.11.1.tgz", + "integrity": "sha512-tC7MKZIMRTYxQhrVAFoJq/DlRwv1bnqA4/S2r3+HuHibqvbrPcyf858lNzU7bFmy4mLeIHFYr34ar/1KumwyRw==", + "dev": true, + "requires": { + "@typescript-eslint/types": "4.11.1", + "@typescript-eslint/visitor-keys": "4.11.1", + "debug": "^4.1.1", + "globby": "^11.0.1", + "is-glob": "^4.0.1", + "lodash": "^4.17.15", + "semver": "^7.3.2", + "tsutils": "^3.17.1" + } + }, + "@typescript-eslint/visitor-keys": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.11.1.tgz", + "integrity": "sha512-IrlBhD9bm4bdYcS8xpWarazkKXlE7iYb1HzRuyBP114mIaj5DJPo11Us1HgH60dTt41TCZXMaTCAW+OILIYPOg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "4.11.1", + "eslint-visitor-keys": "^2.0.0" + } + }, + "semver": { + "version": "7.3.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", + "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } } } }, @@ -2011,15 +2070,68 @@ } }, "@typescript-eslint/parser": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.0.1.tgz", - "integrity": "sha512-1+qLmXHNAWSQ7RB6fdSQszAiA7JTwzakj5cNYjBTUmpH2cqilxMZEIV+DRKjVZs8NzP3ALmKexB0w/ExjcK9Iw==", + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.11.1.tgz", + "integrity": "sha512-BJ3jwPQu1jeynJ5BrjLuGfK/UJu6uwHxJ/di7sanqmUmxzmyIcd3vz58PMR7wpi8k3iWq2Q11KMYgZbUpRoIPw==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "4.0.1", - "@typescript-eslint/types": "4.0.1", - "@typescript-eslint/typescript-estree": "4.0.1", + "@typescript-eslint/scope-manager": "4.11.1", + "@typescript-eslint/types": "4.11.1", + "@typescript-eslint/typescript-estree": "4.11.1", "debug": "^4.1.1" + }, + "dependencies": { + "@typescript-eslint/scope-manager": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.11.1.tgz", + "integrity": "sha512-Al2P394dx+kXCl61fhrrZ1FTI7qsRDIUiVSuN6rTwss6lUn8uVO2+nnF4AvO0ug8vMsy3ShkbxLu/uWZdTtJMQ==", + "dev": true, + "requires": { + "@typescript-eslint/types": "4.11.1", + "@typescript-eslint/visitor-keys": "4.11.1" + } + }, + "@typescript-eslint/types": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.11.1.tgz", + "integrity": "sha512-5kvd38wZpqGY4yP/6W3qhYX6Hz0NwUbijVsX2rxczpY6OXaMxh0+5E5uLJKVFwaBM7PJe1wnMym85NfKYIh6CA==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.11.1.tgz", + "integrity": "sha512-tC7MKZIMRTYxQhrVAFoJq/DlRwv1bnqA4/S2r3+HuHibqvbrPcyf858lNzU7bFmy4mLeIHFYr34ar/1KumwyRw==", + "dev": true, + "requires": { + "@typescript-eslint/types": "4.11.1", + "@typescript-eslint/visitor-keys": "4.11.1", + "debug": "^4.1.1", + "globby": "^11.0.1", + "is-glob": "^4.0.1", + "lodash": "^4.17.15", + "semver": "^7.3.2", + "tsutils": "^3.17.1" + } + }, + "@typescript-eslint/visitor-keys": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.11.1.tgz", + "integrity": "sha512-IrlBhD9bm4bdYcS8xpWarazkKXlE7iYb1HzRuyBP114mIaj5DJPo11Us1HgH60dTt41TCZXMaTCAW+OILIYPOg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "4.11.1", + "eslint-visitor-keys": "^2.0.0" + } + }, + "semver": { + "version": "7.3.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", + "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + } } }, "@typescript-eslint/scope-manager": { diff --git a/package.json b/package.json index 714e4db..22cf875 100644 --- a/package.json +++ b/package.json @@ -32,8 +32,8 @@ "@types/react": "^16.14.2", "@types/react-dom": "^16.9.10", "@types/react-test-renderer": "^16.9.4", - "@typescript-eslint/eslint-plugin": "4.0.1", - "@typescript-eslint/parser": "4.0.1", + "@typescript-eslint/eslint-plugin": "4.11.1", + "@typescript-eslint/parser": "4.11.1", "@wessberg/rollup-plugin-ts": "^1.3.8", "concurrently": "^5.3.0", "eslint": "^7.16.0", diff --git a/src/__fixtures__/withIdContext.tsx b/src/__fixtures__/withIdContext.tsx index 76a2281..286ffa1 100644 --- a/src/__fixtures__/withIdContext.tsx +++ b/src/__fixtures__/withIdContext.tsx @@ -4,10 +4,18 @@ import IdContext, { useIdContext } from '../IdContext'; const withIdContext: ( context: IdContext -) => ComponentType<{ id?: Id }> = (context) => ({ id = null }) => ( -
- {useIdContext(context, id)} -
-); +) => ComponentType<{ id?: Id }> = (context) => { + const Component = ({ id }: { id?: Id }) => ( +
+ {useIdContext(context, id)} +
+ ); + + Component.defaultProps = { + id: null, + }; + + return Component; +}; export default withIdContext; diff --git a/src/__fixtures__/withService.tsx b/src/__fixtures__/withService.tsx index 083a8a0..982d28e 100644 --- a/src/__fixtures__/withService.tsx +++ b/src/__fixtures__/withService.tsx @@ -4,10 +4,18 @@ import Service, { useService } from '../Service'; const withService: ( service: Service -) => ComponentType<{ id?: Id }> = (service) => ({ id = null }) => ( -
- {useService(service, id)} -
-); +) => ComponentType<{ id?: Id }> = (service) => { + const Component = ({ id }: { id?: Id }) => ( +
+ {useService(service, id)} +
+ ); + + Component.defaultProps = { + id: null, + }; + + return Component; +}; export default withService; diff --git a/typedoc.json b/typedoc.json index 8eb1422..35e8580 100644 --- a/typedoc.json +++ b/typedoc.json @@ -1,7 +1,6 @@ { "disableOutputCheck": true, "hideProjectName": true, - "mode": "file", "out": "docs", "sourcefile-url-prefix": "https://github.com/patrickroberts/suspense-service/blob/master/src/" }