From d7f4fcdc94d149e317018cbccad2ccb0ad813529 Mon Sep 17 00:00:00 2001 From: Kylie Stewart Date: Thu, 7 May 2020 23:55:05 -0600 Subject: [PATCH 01/20] Update contributing guidelines --- CONTRIBUTING.md | 22 +++++++++++++++++----- package.json | 9 +++++---- test/typescript/index.ts | 1 + 3 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 test/typescript/index.ts diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7f5e88b..2637c8c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -84,10 +84,16 @@ $ yarn run test-browser-ie ### Types -We validate our TypeScript `index.d.ts` with: +We validate our TypeScript `index.d.ts` with two steps: ```sh +# Runs the TypeScript compiler over our types +$ yarn run test-tsc + +# Runs our types through a sample TypeScript file $ yarn run test-ts +# Compiled output is put into a co-located index.js +# Treat the output like a snapshot, commit any changes ``` ### Style @@ -135,7 +141,13 @@ please flag to your reviewers and have a discussion about whether or not the siz _Only for project administrators_ -1. Run `npm version patch` (or `minor|major|VERSION`) to run tests and lint, - build published directories, then update `package.json` + add a git tag. -2. Run `npm publish` and publish to NPM if all is well. -3. Run `git push && git push --tags` +```sh +# (1) Run tests, lint, build published dir, update package.json +$ npm version [patch|minor|major|] + +# (2) If all is well, publish the new version to the npm registry +$ npm publish + +# (3) Then, update github with the associated tag +$ git push --tags +``` diff --git a/package.json b/package.json index 89131e7..db46959 100644 --- a/package.json +++ b/package.json @@ -10,10 +10,11 @@ "test-browser": "karma start test/browser/karma.conf.js", "test-browser-ie": "karma start test/browser/karma.conf.ie.js", "test-node": "mocha \"test/node/*.spec.js\"", - "test-node-cov": "nyc mocha \"test/node/*.spec.js\"", - "test-ts": "tsc --target ES5 --noImplicitAny index.d.ts", - "test": "builder concurrent --buffer eslint test-ts test-node-cov test-browser", - "test-ie": "builder concurrent --buffer eslint test-ts test-node-cov test-browser-ie", + "test-node-cov": "nyc yarn test-node", + "test-ts": "", + "test-tsc": "tsc --target ES5 --noImplicitAny index.d.ts", + "test": "builder concurrent --buffer eslint test-tsc test-ts test-node-cov test-browser", + "test-ie": "builder concurrent --buffer eslint test-tsc -test-ts test-node-cov test-browser-ie", "compress": "terser --compress --mangle=\"toplevel:true\" -- index.js", "size-min-gz": "yarn -s compress | gzip -9 | wc -c" }, diff --git a/test/typescript/index.ts b/test/typescript/index.ts new file mode 100644 index 0000000..939b3bd --- /dev/null +++ b/test/typescript/index.ts @@ -0,0 +1 @@ +// Test file for types in typescript! \ No newline at end of file From 4ec7948b715b85d3c97772fd5949da03bf40462b Mon Sep 17 00:00:00 2001 From: Kylie Stewart Date: Fri, 8 May 2020 16:29:48 -0600 Subject: [PATCH 02/20] WIP - Add various use cases to test w/ types --- package.json | 2 +- test/typescript/index.js | 13 ++++++++++++ test/typescript/index.ts | 44 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 test/typescript/index.js diff --git a/package.json b/package.json index db46959..8aaa96d 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "test-browser-ie": "karma start test/browser/karma.conf.ie.js", "test-node": "mocha \"test/node/*.spec.js\"", "test-node-cov": "nyc yarn test-node", - "test-ts": "", + "test-ts": "tsc --p test/typescript/index.ts", "test-tsc": "tsc --target ES5 --noImplicitAny index.d.ts", "test": "builder concurrent --buffer eslint test-tsc test-ts test-node-cov test-browser", "test-ie": "builder concurrent --buffer eslint test-tsc -test-ts test-node-cov test-browser-ie", diff --git a/test/typescript/index.js b/test/typescript/index.js new file mode 100644 index 0000000..23edb6a --- /dev/null +++ b/test/typescript/index.js @@ -0,0 +1,13 @@ +// Test file for types in typescript! +// ============= +// An example of `equal` usage that currently breaks: +// https://github.com/FormidableLabs/react-fast-compare/issues/61 +// @types/react-redux/index.d.ts +// export function useSelector( +// selector: (state: TState) => TSelected, +// equalityFn?: (left: TSelected, right: TSelected) => boolean +// ): TSelected; +// ============= +// `a.default is not a function` +// // https://github.com/FormidableLabs/react-fast-compare/pulls/62 +// Test usage of this module elsewhere? Or push a release and hope the upstream is fixed? diff --git a/test/typescript/index.ts b/test/typescript/index.ts index 939b3bd..ed4321c 100644 --- a/test/typescript/index.ts +++ b/test/typescript/index.ts @@ -1 +1,43 @@ -// Test file for types in typescript! \ No newline at end of file +import React from "react"; + +const equal = require("../.."); + +type DeepObject = { + any: any; +}; + +type State = { + any: { + any: any; + }; +}; + +// State +const selector = (state: State) => { + a: { + b: [1, 2, 3]; + } +}; + +class TestComponent extends React.Component { + constructor() { + super(); + this.useSelector = this.useSelector; + } + + shouldComponentUpdate(nextProps) { + return !equal(this.props, nextProps); + } + + useSelector( + selector: (state: TState) => TSelected, + equalityFn?: (left: TSelected, right: TSelected) => boolean + ): TSelected; + + this.useSelector(selector); // typed correctly as DeepObject + this.useSelector(selector, equal); // typed as any + + render() { + // ... + } +}; From 44fce55c80c133c176c8428b94baf5d1654f160f Mon Sep 17 00:00:00 2001 From: Kylie Stewart Date: Mon, 11 May 2020 13:45:38 -0600 Subject: [PATCH 03/20] Use generics, closes #61 --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 1482868..822810a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,3 +1,3 @@ -declare function isEqual(a: any, b: any): boolean; +declare function isEqual(a: A, b: B): boolean; declare namespace isEqual {} export = isEqual; From b755024724c3ec641dfd1c75c96c4d6389e78172 Mon Sep 17 00:00:00 2001 From: Kylie Stewart Date: Tue, 12 May 2020 13:02:59 -0600 Subject: [PATCH 04/20] PR feedback --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2637c8c..b451064 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -149,5 +149,5 @@ $ npm version [patch|minor|major|] $ npm publish # (3) Then, update github with the associated tag -$ git push --tags +$ git push && git push --tags ``` From 9326fcf3e421434b164e13c21b3c195a59b43d7e Mon Sep 17 00:00:00 2001 From: Kylie Stewart Date: Thu, 14 May 2020 11:32:15 -0600 Subject: [PATCH 05/20] PR feedback --- package.json | 13 ++++++---- test/typescript/index.ts | 54 +++++++++++++++++++++------------------- yarn.lock | 45 +++++++++++++++++++++++++++++++-- 3 files changed, 79 insertions(+), 33 deletions(-) diff --git a/package.json b/package.json index 8aaa96d..09066be 100644 --- a/package.json +++ b/package.json @@ -6,15 +6,15 @@ "scripts": { "preversion": "yarn test", "benchmark": "node benchmark", - "eslint": "eslint \"*.js\" benchmark test", + "eslint": "eslint \"*.js\" \"*.ts\" benchmark test", "test-browser": "karma start test/browser/karma.conf.js", "test-browser-ie": "karma start test/browser/karma.conf.ie.js", "test-node": "mocha \"test/node/*.spec.js\"", "test-node-cov": "nyc yarn test-node", - "test-ts": "tsc --p test/typescript/index.ts", - "test-tsc": "tsc --target ES5 --noImplicitAny index.d.ts", - "test": "builder concurrent --buffer eslint test-tsc test-ts test-node-cov test-browser", - "test-ie": "builder concurrent --buffer eslint test-tsc -test-ts test-node-cov test-browser-ie", + "test-ts-types": "tsc --p test/typescript/index.ts", + "test-ts-usage": "tsc --target ES5 --noImplicitAny index.d.ts", + "test": "builder concurrent --buffer eslint test-ts-usage test-ts-types test-node-cov test-browser", + "test-ie": "builder concurrent --buffer eslint test-ts-usage test-ts-types test-node-cov test-browser-ie", "compress": "terser --compress --mangle=\"toplevel:true\" -- index.js", "size-min-gz": "yarn -s compress | gzip -9 | wc -c" }, @@ -41,6 +41,8 @@ "@babel/preset-env": "^7.7.6", "@testing-library/dom": "^7.5.1", "@testing-library/preact": "^1.0.2", + "@types/node": "^14.0.1", + "@types/react": "^16.9.35", "babel-loader": "^8.0.6", "benchmark": "^2.1.4", "builder": "^5.0.0", @@ -65,6 +67,7 @@ "nyc": "^14.1.1", "preact": "^10.4.1", "react": "^16.3.1", + "react-redux": "^7.2.0", "react-test-renderer": "^16.13.1", "shallow-equal-fuzzy": "0.0.2", "sinon": "^7.5.0", diff --git a/test/typescript/index.ts b/test/typescript/index.ts index ed4321c..6d539bd 100644 --- a/test/typescript/index.ts +++ b/test/typescript/index.ts @@ -1,43 +1,45 @@ import React from "react"; +import { useSelector } from "react-redux"; const equal = require("../.."); -type DeepObject = { - any: any; +const testArr = [ + { text: "green", id: "23"}, + { text: "sunshine", id: "1"}, + { text: "mountain", id: "11"}, + { text: "air", id: "8"}, + { text: "plants", id: "9"} +] as ITodo[]; + +type ITodo = { + text: string; + id: string; }; -type State = { - any: { - any: any; - }; +type IProps = { + todo: ITodo; }; -// State -const selector = (state: State) => { - a: { - b: [1, 2, 3]; - } -}; - -class TestComponent extends React.Component { - constructor() { - super(); - this.useSelector = this.useSelector; +class TestChild extends React.Component { + constructor(props) { + super(...props); } shouldComponentUpdate(nextProps) { return !equal(this.props, nextProps); } - useSelector( - selector: (state: TState) => TSelected, - equalityFn?: (left: TSelected, right: TSelected) => boolean - ): TSelected; - - this.useSelector(selector); // typed correctly as DeepObject - this.useSelector(selector, equal); // typed as any + todo = useSelector((state) => state.todos[props.id]); render() { - // ... + return
{todo}
; } -}; +} + +class TestContainer extends React.Component<> { + render() { + return ( + {testArr.map(item => )} + ); + } +} diff --git a/yarn.lock b/yarn.lock index f7c8513..716a4f9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -875,6 +875,24 @@ "@types/istanbul-lib-coverage" "*" "@types/istanbul-lib-report" "*" +"@types/node@^14.0.1": + version "14.0.1" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.1.tgz#5d93e0a099cd0acd5ef3d5bde3c086e1f49ff68c" + integrity sha512-FAYBGwC+W6F9+huFIDtn43cpy7+SzG+atzRiTfdp3inUKL2hXnd4rG8hylJLIh4+hqrQy1P17kvJByE/z825hA== + +"@types/prop-types@*": + version "15.7.3" + resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7" + integrity sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw== + +"@types/react@^16.9.35": + version "16.9.35" + resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.35.tgz#a0830d172e8aadd9bd41709ba2281a3124bbd368" + integrity sha512-q0n0SsWcGc8nDqH2GJfWQWUOmZSJhXV64CjVN5SvcNti3TdEaA3AH0D8DwNmMdzjMAC/78tB8nAZIlV8yTz+zQ== + dependencies: + "@types/prop-types" "*" + csstype "^2.2.0" + "@types/testing-library__dom@^6.12.1": version "6.14.0" resolved "https://registry.yarnpkg.com/@types/testing-library__dom/-/testing-library__dom-6.14.0.tgz#1aede831cb4ed4a398448df5a2c54b54a365644e" @@ -2128,6 +2146,11 @@ cssstyle@^2.2.0: dependencies: cssom "~0.3.6" +csstype@^2.2.0: + version "2.6.10" + resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.6.10.tgz#e63af50e66d7c266edb6b32909cfd0aabe03928b" + integrity sha512-D34BqZU4cIlMCY93rZHbrq9pjTAQJ3U8S8rfBqjwHxkGPThWFjzZDQpgMJY0QViLxth6ZKYiwFBo14RdN44U/w== + custom-event@~1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" @@ -3126,6 +3149,13 @@ hmac-drbg@^1.0.0: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.1" +hoist-non-react-statics@^3.3.0: + version "3.3.2" + resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" + integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw== + dependencies: + react-is "^16.7.0" + hosted-git-info@^2.1.4: version "2.8.8" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488" @@ -4780,7 +4810,7 @@ promise-inflight@^1.0.1: resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3" integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM= -prop-types@^15.6.2: +prop-types@^15.6.2, prop-types@^15.7.2: version "15.7.2" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5" integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ== @@ -4911,11 +4941,22 @@ raw-body@2.4.0: iconv-lite "0.4.24" unpipe "1.0.0" -react-is@^16.12.0, react-is@^16.8.1, react-is@^16.8.4, react-is@^16.8.6: +react-is@^16.12.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.4, react-is@^16.8.6, react-is@^16.9.0: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== +react-redux@^7.2.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-7.2.0.tgz#f970f62192b3981642fec46fd0db18a074fe879d" + integrity sha512-EvCAZYGfOLqwV7gh849xy9/pt55rJXPwmYvI4lilPM5rUT/1NxuuN59ipdBksRVSvz0KInbPnp4IfoXJXCqiDA== + dependencies: + "@babel/runtime" "^7.5.5" + hoist-non-react-statics "^3.3.0" + loose-envify "^1.4.0" + prop-types "^15.7.2" + react-is "^16.9.0" + react-test-renderer@^16.13.1: version "16.13.1" resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.13.1.tgz#de25ea358d9012606de51e012d9742e7f0deabc1" From a300340794db27028e17c847596676b73f26b35b Mon Sep 17 00:00:00 2001 From: Kylie Stewart Date: Fri, 15 May 2020 10:54:15 -0600 Subject: [PATCH 06/20] Use tsc's project reference to isolate tests --- package.json | 10 +++--- test/typescript/index.js | 46 ++++++++++++++++++------- test/typescript/{index.ts => index.tsx} | 13 +++---- test/typescript/tsconfig.json | 5 +++ tsconfig.json | 3 ++ yarn.lock | 33 +++++++++++++++++- 6 files changed, 83 insertions(+), 27 deletions(-) rename test/typescript/{index.ts => index.tsx} (69%) create mode 100644 test/typescript/tsconfig.json create mode 100644 tsconfig.json diff --git a/package.json b/package.json index 09066be..30adbe5 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,10 @@ "test-browser-ie": "karma start test/browser/karma.conf.ie.js", "test-node": "mocha \"test/node/*.spec.js\"", "test-node-cov": "nyc yarn test-node", - "test-ts-types": "tsc --p test/typescript/index.ts", - "test-ts-usage": "tsc --target ES5 --noImplicitAny index.d.ts", - "test": "builder concurrent --buffer eslint test-ts-usage test-ts-types test-node-cov test-browser", - "test-ie": "builder concurrent --buffer eslint test-ts-usage test-ts-types test-node-cov test-browser-ie", + "test-ts-usage": "tsc --jsx react --target ES6 --noImplicitAny --esModuleInterop typescript/index.tsx", + "test-ts-defs": "tsc --target ES5 --noImplicitAny index.d.ts", + "test": "builder concurrent --buffer eslint test-ts-usage test-ts-defs test-node-cov test-browser", + "test-ie": "builder concurrent --buffer eslint test-ts-usage test-ts-defs test-node-cov test-browser-ie", "compress": "terser --compress --mangle=\"toplevel:true\" -- index.js", "size-min-gz": "yarn -s compress | gzip -9 | wc -c" }, @@ -43,6 +43,7 @@ "@testing-library/preact": "^1.0.2", "@types/node": "^14.0.1", "@types/react": "^16.9.35", + "@types/react-redux": "^7.1.8", "babel-loader": "^8.0.6", "benchmark": "^2.1.4", "builder": "^5.0.0", @@ -69,6 +70,7 @@ "react": "^16.3.1", "react-redux": "^7.2.0", "react-test-renderer": "^16.13.1", + "redux": "^4.0.5", "shallow-equal-fuzzy": "0.0.2", "sinon": "^7.5.0", "terser": "^4.4.3", diff --git a/test/typescript/index.js b/test/typescript/index.js index 23edb6a..86c9beb 100644 --- a/test/typescript/index.js +++ b/test/typescript/index.js @@ -1,13 +1,33 @@ -// Test file for types in typescript! -// ============= -// An example of `equal` usage that currently breaks: -// https://github.com/FormidableLabs/react-fast-compare/issues/61 -// @types/react-redux/index.d.ts -// export function useSelector( -// selector: (state: TState) => TSelected, -// equalityFn?: (left: TSelected, right: TSelected) => boolean -// ): TSelected; -// ============= -// `a.default is not a function` -// // https://github.com/FormidableLabs/react-fast-compare/pulls/62 -// Test usage of this module elsewhere? Or push a release and hope the upstream is fixed? +import React from "react"; +import { useSelector } from "react-redux"; +const equal = require("../.."); +// const equal = (a: any, b: any) => { return true; } +/** + * - [ ] Component to wrap the to-dos (Container) + * Maps over an array of random strings to pass into the Child component + * - [ ] Component to render each to-do individually (Child) + */ +const testArr = [ + { text: "green", id: "23" }, + { text: "sunshine", id: "1" }, + { text: "mountain", id: "11" }, + { text: "air", id: "8" }, + { text: "plants", id: "9" } +]; +class TestChild extends React.Component { + // is this doing anything for us? + // should the container be improved to ensure that this update is happening? + // should the container be within a container? 🤔 + shouldComponentUpdate(nextProps) { + return !equal(this.props, nextProps); + } + render() { + const todo = useSelector((state) => state.todos[props.id]); + return React.createElement("div", null, todo); + } +} +class TestContainer extends React.Component { + render() { + return (testArr.map(item => React.createElement(TestChild, { todo: item }))); + } +} diff --git a/test/typescript/index.ts b/test/typescript/index.tsx similarity index 69% rename from test/typescript/index.ts rename to test/typescript/index.tsx index 6d539bd..d5fee81 100644 --- a/test/typescript/index.ts +++ b/test/typescript/index.tsx @@ -21,25 +21,20 @@ type IProps = { }; class TestChild extends React.Component { - constructor(props) { - super(...props); - } - - shouldComponentUpdate(nextProps) { + shouldComponentUpdate(nextProps: IProps) { return !equal(this.props, nextProps); } - todo = useSelector((state) => state.todos[props.id]); - render() { + const todo = useSelector((state) => state.todos[props.id]); return
{todo}
; } } -class TestContainer extends React.Component<> { +class TestContainer extends React.Component { render() { return ( - {testArr.map(item => )} + testArr.map(item => ) ); } } diff --git a/test/typescript/tsconfig.json b/test/typescript/tsconfig.json new file mode 100644 index 0000000..fe52093 --- /dev/null +++ b/test/typescript/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "composite": true + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..29951fc --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,3 @@ +{ + "references": [{ "path": "test/typescript" }] +} diff --git a/yarn.lock b/yarn.lock index 716a4f9..4937743 100644 --- a/yarn.lock +++ b/yarn.lock @@ -855,6 +855,14 @@ resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ== +"@types/hoist-non-react-statics@^3.3.0": + version "3.3.1" + resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz#1124aafe5118cb591977aeb1ceaaed1070eb039f" + integrity sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA== + dependencies: + "@types/react" "*" + hoist-non-react-statics "^3.3.0" + "@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0": version "2.0.1" resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz#42995b446db9a48a11a07ec083499a860e9138ff" @@ -885,7 +893,17 @@ resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7" integrity sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw== -"@types/react@^16.9.35": +"@types/react-redux@^7.1.8": + version "7.1.8" + resolved "https://registry.yarnpkg.com/@types/react-redux/-/react-redux-7.1.8.tgz#3631feb559f7858d6ad9eea1d6ef41fa64fe7205" + integrity sha512-kpplH7Wg2SYU00sZVT98WBN0ou6QKrYcShRaW+5Vpe5l7bluKWJbWmAL+ieiso07OQzpcP5i1PeY3690640ZWg== + dependencies: + "@types/hoist-non-react-statics" "^3.3.0" + "@types/react" "*" + hoist-non-react-statics "^3.3.0" + redux "^4.0.0" + +"@types/react@*", "@types/react@^16.9.35": version "16.9.35" resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.35.tgz#a0830d172e8aadd9bd41709ba2281a3124bbd368" integrity sha512-q0n0SsWcGc8nDqH2GJfWQWUOmZSJhXV64CjVN5SvcNti3TdEaA3AH0D8DwNmMdzjMAC/78tB8nAZIlV8yTz+zQ== @@ -5031,6 +5049,14 @@ readdirp@~3.4.0: dependencies: picomatch "^2.2.1" +redux@^4.0.0, redux@^4.0.5: + version "4.0.5" + resolved "https://registry.yarnpkg.com/redux/-/redux-4.0.5.tgz#4db5de5816e17891de8a80c424232d06f051d93f" + integrity sha512-VSz1uMAH24DM6MF72vcojpYPtrTUu3ByVWfPL1nPfVRb5mZVTve5GnNCUV53QM/BZ66xfWrm0CTWoM+Xlz8V1w== + dependencies: + loose-envify "^1.4.0" + symbol-observable "^1.2.0" + regenerate-unicode-properties@^8.2.0: version "8.2.0" resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-8.2.0.tgz#e5de7111d655e7ba60c057dbe9ff37c87e65cdec" @@ -5809,6 +5835,11 @@ supports-color@^7.1.0: dependencies: has-flag "^4.0.0" +symbol-observable@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804" + integrity sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ== + symbol-tree@^3.2.4: version "3.2.4" resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" From d87b34a54a7f56de4a641e6bbd612a5c16a9cd9a Mon Sep 17 00:00:00 2001 From: Kylie Stewart Date: Fri, 15 May 2020 11:00:03 -0600 Subject: [PATCH 07/20] tsconfig cleanup --- package.json | 4 +-- test/typescript/index.js | 66 ++++++++++++++++++++++------------- test/typescript/tsconfig.json | 5 ++- tsconfig.json | 3 ++ 4 files changed, 50 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index 30adbe5..2486f1c 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "test-browser-ie": "karma start test/browser/karma.conf.ie.js", "test-node": "mocha \"test/node/*.spec.js\"", "test-node-cov": "nyc yarn test-node", - "test-ts-usage": "tsc --jsx react --target ES6 --noImplicitAny --esModuleInterop typescript/index.tsx", - "test-ts-defs": "tsc --target ES5 --noImplicitAny index.d.ts", + "test-ts-usage": "tsc test/typescript/index.tsx", + "test-ts-defs": "tsc --target ES5 index.d.ts", "test": "builder concurrent --buffer eslint test-ts-usage test-ts-defs test-node-cov test-browser", "test-ie": "builder concurrent --buffer eslint test-ts-usage test-ts-defs test-node-cov test-browser-ie", "compress": "terser --compress --mangle=\"toplevel:true\" -- index.js", diff --git a/test/typescript/index.js b/test/typescript/index.js index 86c9beb..eb483aa 100644 --- a/test/typescript/index.js +++ b/test/typescript/index.js @@ -1,33 +1,49 @@ -import React from "react"; -import { useSelector } from "react-redux"; -const equal = require("../.."); -// const equal = (a: any, b: any) => { return true; } -/** - * - [ ] Component to wrap the to-dos (Container) - * Maps over an array of random strings to pass into the Child component - * - [ ] Component to render each to-do individually (Child) - */ -const testArr = [ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +var react_1 = require("react"); +var react_redux_1 = require("react-redux"); +var equal = require("../.."); +var testArr = [ { text: "green", id: "23" }, { text: "sunshine", id: "1" }, { text: "mountain", id: "11" }, { text: "air", id: "8" }, { text: "plants", id: "9" } ]; -class TestChild extends React.Component { - // is this doing anything for us? - // should the container be improved to ensure that this update is happening? - // should the container be within a container? 🤔 - shouldComponentUpdate(nextProps) { - return !equal(this.props, nextProps); - } - render() { - const todo = useSelector((state) => state.todos[props.id]); - return React.createElement("div", null, todo); +var TestChild = /** @class */ (function (_super) { + __extends(TestChild, _super); + function TestChild() { + return _super !== null && _super.apply(this, arguments) || this; } -} -class TestContainer extends React.Component { - render() { - return (testArr.map(item => React.createElement(TestChild, { todo: item }))); + TestChild.prototype.shouldComponentUpdate = function (nextProps) { + return !equal(this.props, nextProps); + }; + TestChild.prototype.render = function () { + var todo = react_redux_1.useSelector(function (state) { return state.todos[props.id]; }); + return
{todo}
; + }; + return TestChild; +}(react_1["default"].Component)); +var TestContainer = /** @class */ (function (_super) { + __extends(TestContainer, _super); + function TestContainer() { + return _super !== null && _super.apply(this, arguments) || this; } -} + TestContainer.prototype.render = function () { + return (testArr.map(function (item) { return ; })); + }; + return TestContainer; +}(react_1["default"].Component)); diff --git a/test/typescript/tsconfig.json b/test/typescript/tsconfig.json index fe52093..c78be17 100644 --- a/test/typescript/tsconfig.json +++ b/test/typescript/tsconfig.json @@ -1,5 +1,8 @@ { "compilerOptions": { - "composite": true + "composite": true, + "jsx": "react", + "target": "ES6", + "esModuleInterop": true } } diff --git a/tsconfig.json b/tsconfig.json index 29951fc..30a7601 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,3 +1,6 @@ { + "compilerOptions": { + "noImplicitAny": true + }, "references": [{ "path": "test/typescript" }] } From 71d165b79e6c0340cb95e2a5b2772abf45739b63 Mon Sep 17 00:00:00 2001 From: Kylie Stewart Date: Fri, 15 May 2020 11:57:17 -0600 Subject: [PATCH 08/20] keep breaking things --- index.d.ts | 2 +- package.json | 5 +++-- test/typescript/index.js | 30 +++++++++++++----------------- test/typescript/index.tsx | 28 ++++++++++++---------------- test/typescript/tsconfig.json | 5 ++++- tsconfig.json | 10 +++++++++- 6 files changed, 42 insertions(+), 38 deletions(-) diff --git a/index.d.ts b/index.d.ts index 822810a..1482868 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,3 +1,3 @@ -declare function isEqual
(a: A, b: B): boolean; +declare function isEqual(a: any, b: any): boolean; declare namespace isEqual {} export = isEqual; diff --git a/package.json b/package.json index 2486f1c..e8c4682 100644 --- a/package.json +++ b/package.json @@ -6,12 +6,13 @@ "scripts": { "preversion": "yarn test", "benchmark": "node benchmark", - "eslint": "eslint \"*.js\" \"*.ts\" benchmark test", + "eslint": "eslint \"*.js\" benchmark test", + "tslint": "eslint test/typescript/index.tsx", "test-browser": "karma start test/browser/karma.conf.js", "test-browser-ie": "karma start test/browser/karma.conf.ie.js", "test-node": "mocha \"test/node/*.spec.js\"", "test-node-cov": "nyc yarn test-node", - "test-ts-usage": "tsc test/typescript/index.tsx", + "test-ts-usage": "tsc --esModuleInterop --jsx react test/typescript/index.tsx", "test-ts-defs": "tsc --target ES5 index.d.ts", "test": "builder concurrent --buffer eslint test-ts-usage test-ts-defs test-node-cov test-browser", "test-ie": "builder concurrent --buffer eslint test-ts-usage test-ts-defs test-node-cov test-browser-ie", diff --git a/test/typescript/index.js b/test/typescript/index.js index eb483aa..d29b36a 100644 --- a/test/typescript/index.js +++ b/test/typescript/index.js @@ -12,8 +12,11 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; exports.__esModule = true; -var react_1 = require("react"); +var react_1 = __importDefault(require("react")); var react_redux_1 = require("react-redux"); var equal = require("../.."); var testArr = [ @@ -21,29 +24,22 @@ var testArr = [ { text: "sunshine", id: "1" }, { text: "mountain", id: "11" }, { text: "air", id: "8" }, - { text: "plants", id: "9" } + { text: "plants", id: "9" }, ]; -var TestChild = /** @class */ (function (_super) { - __extends(TestChild, _super); - function TestChild() { - return _super !== null && _super.apply(this, arguments) || this; - } - TestChild.prototype.shouldComponentUpdate = function (nextProps) { - return !equal(this.props, nextProps); - }; - TestChild.prototype.render = function () { - var todo = react_redux_1.useSelector(function (state) { return state.todos[props.id]; }); - return
{todo}
; - }; - return TestChild; -}(react_1["default"].Component)); +var TestChild = function (props) { + // shouldComponentUpdate(nextProps: IProps) { + // return !equal(this.props, nextProps); + // } + var todo = react_redux_1.useSelector(function (state) { return state.todos[props.id]; }); + return react_1["default"].createElement("div", null, todo); +}; var TestContainer = /** @class */ (function (_super) { __extends(TestContainer, _super); function TestContainer() { return _super !== null && _super.apply(this, arguments) || this; } TestContainer.prototype.render = function () { - return (testArr.map(function (item) { return ; })); + return testArr.map(function (item) { return react_1["default"].createElement(TestChild, { key: item.id, todo: item }); }); }; return TestContainer; }(react_1["default"].Component)); diff --git a/test/typescript/index.tsx b/test/typescript/index.tsx index d5fee81..034451f 100644 --- a/test/typescript/index.tsx +++ b/test/typescript/index.tsx @@ -4,11 +4,11 @@ import { useSelector } from "react-redux"; const equal = require("../.."); const testArr = [ - { text: "green", id: "23"}, - { text: "sunshine", id: "1"}, - { text: "mountain", id: "11"}, - { text: "air", id: "8"}, - { text: "plants", id: "9"} + { text: "green", id: "23" }, + { text: "sunshine", id: "1" }, + { text: "mountain", id: "11" }, + { text: "air", id: "8" }, + { text: "plants", id: "9" }, ] as ITodo[]; type ITodo = { @@ -20,21 +20,17 @@ type IProps = { todo: ITodo; }; -class TestChild extends React.Component { - shouldComponentUpdate(nextProps: IProps) { - return !equal(this.props, nextProps); - } +const TestChild = (props: IProps) => { + // shouldComponentUpdate(nextProps: IProps) { + // return !equal(this.props, nextProps); + // } - render() { - const todo = useSelector((state) => state.todos[props.id]); - return
{todo}
; - } + const todo = useSelector((state) => state.todos[props.id]); + return
{todo}
; } class TestContainer extends React.Component { render() { - return ( - testArr.map(item => ) - ); + return testArr.map((item) => ); } } diff --git a/test/typescript/tsconfig.json b/test/typescript/tsconfig.json index c78be17..346da0f 100644 --- a/test/typescript/tsconfig.json +++ b/test/typescript/tsconfig.json @@ -3,6 +3,9 @@ "composite": true, "jsx": "react", "target": "ES6", - "esModuleInterop": true + "allowSyntheticDefaultImports": true + }, + "parserOptions": { + "sourceType": "module" } } diff --git a/tsconfig.json b/tsconfig.json index 30a7601..526deaa 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,5 +2,13 @@ "compilerOptions": { "noImplicitAny": true }, - "references": [{ "path": "test/typescript" }] + "env": { + "browser": true, + "node": true, + "es6": true + }, + "references": [{ "path": "test/typescript" }], + "parserOptions": { + "sourceType": "module" + } } From 1b4103a85255ebfff5a3ffd23f3395d153755288 Mon Sep 17 00:00:00 2001 From: Kylie Stewart Date: Tue, 19 May 2020 14:35:07 -0600 Subject: [PATCH 09/20] continue to break things? --- test/typescript/index.js | 23 +++++++++++++++-------- test/typescript/index.tsx | 16 +++++++++------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/test/typescript/index.js b/test/typescript/index.js index d29b36a..080b3ba 100644 --- a/test/typescript/index.js +++ b/test/typescript/index.js @@ -17,7 +17,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; exports.__esModule = true; var react_1 = __importDefault(require("react")); -var react_redux_1 = require("react-redux"); var equal = require("../.."); var testArr = [ { text: "green", id: "23" }, @@ -26,13 +25,21 @@ var testArr = [ { text: "air", id: "8" }, { text: "plants", id: "9" }, ]; -var TestChild = function (props) { - // shouldComponentUpdate(nextProps: IProps) { - // return !equal(this.props, nextProps); - // } - var todo = react_redux_1.useSelector(function (state) { return state.todos[props.id]; }); - return react_1["default"].createElement("div", null, todo); -}; +var TestChild = /** @class */ (function (_super) { + __extends(TestChild, _super); + function TestChild() { + return _super !== null && _super.apply(this, arguments) || this; + } + TestChild.prototype.shouldComponentUpdate = function (nextProps) { + return !equal(this.props, nextProps); + }; + TestChild.prototype.render = function () { + var todo = this.props.todo; + return react_1["default"].createElement("div", null, todo.text); + }; + return TestChild; +}(react_1["default"].Component)); +; var TestContainer = /** @class */ (function (_super) { __extends(TestContainer, _super); function TestContainer() { diff --git a/test/typescript/index.tsx b/test/typescript/index.tsx index 034451f..c1d6e2a 100644 --- a/test/typescript/index.tsx +++ b/test/typescript/index.tsx @@ -20,14 +20,16 @@ type IProps = { todo: ITodo; }; -const TestChild = (props: IProps) => { - // shouldComponentUpdate(nextProps: IProps) { - // return !equal(this.props, nextProps); - // } +class TestChild extends React.Component { + shouldComponentUpdate(nextProps: IProps) { + return !equal(this.props, nextProps); + } - const todo = useSelector((state) => state.todos[props.id]); - return
{todo}
; -} + render() { + const todo = this.props.todo; + return
{todo.text}
; + } +}; class TestContainer extends React.Component { render() { From 550e8820e41e36e8e4b8304a21d553d02dce1add Mon Sep 17 00:00:00 2001 From: Kylie Stewart Date: Tue, 19 May 2020 14:37:06 -0600 Subject: [PATCH 10/20] compiled js will never pass lint --- .eslintignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..c8401be --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +test/typescript/index.js From 7a35bd029a670d72e277fb593be9deb1dc0871b7 Mon Sep 17 00:00:00 2001 From: Kylie Stewart Date: Tue, 19 May 2020 14:46:39 -0600 Subject: [PATCH 11/20] Update tslint script --- .eslintrc.yml | 3 ++ package.json | 1 + test/typescript/index.tsx | 18 ++++----- test/typescript/tsconfig.json | 3 -- yarn.lock | 69 ++++++++++++++++++++++++++++++++++- 5 files changed, 81 insertions(+), 13 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 6a81ed8..9d348fd 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -1,6 +1,9 @@ env: node: true extends: 'eslint:recommended' +parser: '@typescript-eslint/parser' +parserOptions: + sourceType: module rules: indent: [ 2, 2, { SwitchCase: 1 } ] no-trailing-spaces: 2 diff --git a/package.json b/package.json index e8c4682..05bc8ca 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "@types/node": "^14.0.1", "@types/react": "^16.9.35", "@types/react-redux": "^7.1.8", + "@typescript-eslint/parser": "^2.34.0", "babel-loader": "^8.0.6", "benchmark": "^2.1.4", "builder": "^5.0.0", diff --git a/test/typescript/index.tsx b/test/typescript/index.tsx index c1d6e2a..7600194 100644 --- a/test/typescript/index.tsx +++ b/test/typescript/index.tsx @@ -1,14 +1,14 @@ -import React from "react"; -import { useSelector } from "react-redux"; +import React from 'react'; +// import { useSelector } from 'react-redux'; -const equal = require("../.."); +const equal = require('../..'); const testArr = [ - { text: "green", id: "23" }, - { text: "sunshine", id: "1" }, - { text: "mountain", id: "11" }, - { text: "air", id: "8" }, - { text: "plants", id: "9" }, + { text: 'green', id: '23' }, + { text: 'sunshine', id: '1' }, + { text: 'mountain', id: '11' }, + { text: 'air', id: '8' }, + { text: 'plants', id: '9' }, ] as ITodo[]; type ITodo = { @@ -29,7 +29,7 @@ class TestChild extends React.Component { const todo = this.props.todo; return
{todo.text}
; } -}; +} class TestContainer extends React.Component { render() { diff --git a/test/typescript/tsconfig.json b/test/typescript/tsconfig.json index 346da0f..b49e850 100644 --- a/test/typescript/tsconfig.json +++ b/test/typescript/tsconfig.json @@ -4,8 +4,5 @@ "jsx": "react", "target": "ES6", "allowSyntheticDefaultImports": true - }, - "parserOptions": { - "sourceType": "module" } } diff --git a/yarn.lock b/yarn.lock index 4937743..304b5d4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -855,6 +855,11 @@ resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ== +"@types/eslint-visitor-keys@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d" + integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag== + "@types/hoist-non-react-statics@^3.3.0": version "3.3.1" resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz#1124aafe5118cb591977aeb1ceaaed1070eb039f" @@ -883,6 +888,11 @@ "@types/istanbul-lib-coverage" "*" "@types/istanbul-lib-report" "*" +"@types/json-schema@^7.0.3": + version "7.0.4" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.4.tgz#38fd73ddfd9b55abb1e1b2ed578cb55bd7b7d339" + integrity sha512-8+KAKzEvSUdeo+kmqnKrqgeE+LcA0tjYWFY7RPProVYwnqDjukzO+3b6dLD56rYX5TdWejnEOLJYOIeh4CXKuA== + "@types/node@^14.0.1": version "14.0.1" resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.1.tgz#5d93e0a099cd0acd5ef3d5bde3c086e1f49ff68c" @@ -937,6 +947,39 @@ dependencies: "@types/yargs-parser" "*" +"@typescript-eslint/experimental-utils@2.34.0": + version "2.34.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.34.0.tgz#d3524b644cdb40eebceca67f8cf3e4cc9c8f980f" + integrity sha512-eS6FTkq+wuMJ+sgtuNTtcqavWXqsflWcfBnlYhg/nS4aZ1leewkXGbvBhaapn1q6qf4M71bsR1tez5JTRMuqwA== + dependencies: + "@types/json-schema" "^7.0.3" + "@typescript-eslint/typescript-estree" "2.34.0" + eslint-scope "^5.0.0" + eslint-utils "^2.0.0" + +"@typescript-eslint/parser@^2.34.0": + version "2.34.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.34.0.tgz#50252630ca319685420e9a39ca05fe185a256bc8" + integrity sha512-03ilO0ucSD0EPTw2X4PntSIRFtDPWjrVq7C3/Z3VQHRC7+13YB55rcJI3Jt+YgeHbjUdJPcPa7b23rXCBokuyA== + dependencies: + "@types/eslint-visitor-keys" "^1.0.0" + "@typescript-eslint/experimental-utils" "2.34.0" + "@typescript-eslint/typescript-estree" "2.34.0" + eslint-visitor-keys "^1.1.0" + +"@typescript-eslint/typescript-estree@2.34.0": + version "2.34.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.34.0.tgz#14aeb6353b39ef0732cc7f1b8285294937cf37d5" + integrity sha512-OMAr+nJWKdlVM9LOqCqh3pQQPwxHAN7Du8DR6dmwCrAmxtiXQnhHJ6tBNtf+cggqfo51SG/FCwnKhXCIM7hnVg== + dependencies: + debug "^4.1.1" + eslint-visitor-keys "^1.1.0" + glob "^7.1.6" + is-glob "^4.0.1" + lodash "^4.17.15" + semver "^7.3.2" + tsutils "^3.17.1" + "@webassemblyjs/ast@1.9.0": version "1.9.0" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.9.0.tgz#bd850604b4042459a5a41cd7d338cbed695ed964" @@ -2572,6 +2615,13 @@ eslint-utils@^1.4.3: dependencies: eslint-visitor-keys "^1.1.0" +eslint-utils@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.0.0.tgz#7be1cc70f27a72a76cd14aa698bcabed6890e1cd" + integrity sha512-0HCPuJv+7Wv1bACm8y5/ECVfYdfsAm9xmVb7saeFlxjPYALefjhbYoCkBjPdPzGH8wWyTpAez82Fh3VKYEZ8OA== + dependencies: + eslint-visitor-keys "^1.1.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" @@ -3017,7 +3067,7 @@ glob@7.1.3: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^7.1.1, glob@^7.1.3, glob@^7.1.4: +glob@^7.1.1, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6: version "7.1.6" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== @@ -5343,6 +5393,11 @@ semver@^6.0.0, semver@^6.1.2: resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== +semver@^7.3.2: + version "7.3.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938" + integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ== + serialize-javascript@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-2.1.2.tgz#ecec53b0e0317bdc95ef76ab7074b7384785fa61" @@ -6018,11 +6073,23 @@ tree-kill@^1.2.1: resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc" integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A== +tslib@^1.8.1: + version "1.13.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043" + integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q== + tslib@^1.9.0: version "1.11.2" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.2.tgz#9c79d83272c9a7aaf166f73915c9667ecdde3cc9" integrity sha512-tTSkux6IGPnUGUd1XAZHcpu85MOkIl5zX49pO+jfsie3eP0B6pyhOlLXm3cAC6T7s+euSDDUUV+Acop5WmtkVg== +tsutils@^3.17.1: + version "3.17.1" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.17.1.tgz#ed719917f11ca0dee586272b2ac49e015a2dd759" + integrity sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g== + dependencies: + tslib "^1.8.1" + tty-browserify@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" From 3dfb3cc2115de89e01f9440da8fff5eab845d5e2 Mon Sep 17 00:00:00 2001 From: Kylie Stewart Date: Wed, 20 May 2020 13:06:31 -0600 Subject: [PATCH 12/20] Update our timeout call --- test/node/advanced.spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/node/advanced.spec.js b/test/node/advanced.spec.js index 58007a8..82e3e85 100644 --- a/test/node/advanced.spec.js +++ b/test/node/advanced.spec.js @@ -13,7 +13,10 @@ const PreactTestRenderer = require('@testing-library/preact'); const equal = require('../..'); const tests = require('./tests'); -const TIMEOUT = '5000'; +// `jsdom-global` does a lazy require under the hood to `jsdom` which is +// super expensive. We deliberately call + cleanup to take the require hit +// early and seed the require cache so subsequent calls are fast. +jsdom()(); class ReactChild extends React.Component { shouldComponentUpdate(nextProps) { @@ -61,9 +64,6 @@ describe('advanced', () => { let sandbox; let warnStub; - // eslint-disable-next-line no-invalid-this - beforeEach(function () { this.timeout(TIMEOUT); }); - beforeEach(() => { sandbox = sinon.createSandbox(); warnStub = sandbox.stub(console, 'warn'); From b228badf93cc3b89febdc93df3d7e5caf8b27a65 Mon Sep 17 00:00:00 2001 From: Kylie Stewart Date: Wed, 20 May 2020 14:01:07 -0600 Subject: [PATCH 13/20] PR feedback --- .gitignore | 3 +++ package.json | 6 +++--- test/typescript/{index.tsx => sample-usage.tsx} | 15 +++++++-------- 3 files changed, 13 insertions(+), 11 deletions(-) rename test/typescript/{index.tsx => sample-usage.tsx} (89%) diff --git a/.gitignore b/.gitignore index 61d02da..bf17c09 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,9 @@ jspm_packages/ # Typescript v1 declaration files typings/ +# Compiled output from Typescript usage test +test/typescript/*.js + # Optional npm cache directory .npm diff --git a/package.json b/package.json index 05bc8ca..37da048 100644 --- a/package.json +++ b/package.json @@ -7,12 +7,12 @@ "preversion": "yarn test", "benchmark": "node benchmark", "eslint": "eslint \"*.js\" benchmark test", - "tslint": "eslint test/typescript/index.tsx", + "tslint": "eslint test/typescript/sample-usage.tsx", "test-browser": "karma start test/browser/karma.conf.js", "test-browser-ie": "karma start test/browser/karma.conf.ie.js", "test-node": "mocha \"test/node/*.spec.js\"", - "test-node-cov": "nyc yarn test-node", - "test-ts-usage": "tsc --esModuleInterop --jsx react test/typescript/index.tsx", + "test-node-cov": "nyc mocha \"test/node/*.spec.js\"", + "test-ts-usage": "tsc --esModuleInterop --jsx react test/typescript/sample-usage.tsx", "test-ts-defs": "tsc --target ES5 index.d.ts", "test": "builder concurrent --buffer eslint test-ts-usage test-ts-defs test-node-cov test-browser", "test-ie": "builder concurrent --buffer eslint test-ts-usage test-ts-defs test-node-cov test-browser-ie", diff --git a/test/typescript/index.tsx b/test/typescript/sample-usage.tsx similarity index 89% rename from test/typescript/index.tsx rename to test/typescript/sample-usage.tsx index 7600194..863def0 100644 --- a/test/typescript/index.tsx +++ b/test/typescript/sample-usage.tsx @@ -1,20 +1,19 @@ import React from 'react'; -// import { useSelector } from 'react-redux'; const equal = require('../..'); -const testArr = [ +type ITodo = { + text: string; + id: string; +}; + +const testArr: ITodo[] = [ { text: 'green', id: '23' }, { text: 'sunshine', id: '1' }, { text: 'mountain', id: '11' }, { text: 'air', id: '8' }, { text: 'plants', id: '9' }, -] as ITodo[]; - -type ITodo = { - text: string; - id: string; -}; +]; type IProps = { todo: ITodo; From 6e4dc3824e5906142272e9600a78dd7410e961c4 Mon Sep 17 00:00:00 2001 From: Kylie Stewart Date: Wed, 20 May 2020 14:04:31 -0600 Subject: [PATCH 14/20] Add a defining comment to the top of our new TS test --- test/typescript/sample-usage.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/typescript/sample-usage.tsx b/test/typescript/sample-usage.tsx index 863def0..bc6c5b0 100644 --- a/test/typescript/sample-usage.tsx +++ b/test/typescript/sample-usage.tsx @@ -1,3 +1,5 @@ +// This file exists to test our types against sample user code +// This is compiled using `tsc` in our `test-ts-usage` script import React from 'react'; const equal = require('../..'); From fcc4530bd57fcdd5dc2d32e163e800a7db5ec2af Mon Sep 17 00:00:00 2001 From: Kylie Stewart Date: Wed, 20 May 2020 14:06:09 -0600 Subject: [PATCH 15/20] Update docs surrounding new scripts --- .github/pull_request_template.md | 1 + CONTRIBUTING.md | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index c15a61a..06a3827 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -12,6 +12,7 @@ Please include a summary of the change and which issue is fixed. Please also inc ## Checklist: - [ ] All tests are passing +- [ ] Type definitions, if updated, pass both `test-ts-defs` and `test-ts-usage` - [ ] Benchmark performance has not significantly decreased - [ ] Bundle size has not been significantly impacted - [ ] The bundle size badge has been updated to reflect the new size diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b451064..633c5ea 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -88,12 +88,10 @@ We validate our TypeScript `index.d.ts` with two steps: ```sh # Runs the TypeScript compiler over our types -$ yarn run test-tsc +$ yarn run test-ts-defs # Runs our types through a sample TypeScript file -$ yarn run test-ts -# Compiled output is put into a co-located index.js -# Treat the output like a snapshot, commit any changes +$ yarn run test-ts-usage ``` ### Style From df743015a609bd66e74826399d638d704a49aaeb Mon Sep 17 00:00:00 2001 From: Kylie Stewart Date: Wed, 20 May 2020 14:09:03 -0600 Subject: [PATCH 16/20] Remove compiled JS, do not generate on test --- package.json | 2 +- test/typescript/index.js | 52 ---------------------------------------- 2 files changed, 1 insertion(+), 53 deletions(-) delete mode 100644 test/typescript/index.js diff --git a/package.json b/package.json index 37da048..743f900 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "test-browser-ie": "karma start test/browser/karma.conf.ie.js", "test-node": "mocha \"test/node/*.spec.js\"", "test-node-cov": "nyc mocha \"test/node/*.spec.js\"", - "test-ts-usage": "tsc --esModuleInterop --jsx react test/typescript/sample-usage.tsx", + "test-ts-usage": "tsc --esModuleInterop --jsx react --noEmit test/typescript/sample-usage.tsx", "test-ts-defs": "tsc --target ES5 index.d.ts", "test": "builder concurrent --buffer eslint test-ts-usage test-ts-defs test-node-cov test-browser", "test-ie": "builder concurrent --buffer eslint test-ts-usage test-ts-defs test-node-cov test-browser-ie", diff --git a/test/typescript/index.js b/test/typescript/index.js deleted file mode 100644 index 080b3ba..0000000 --- a/test/typescript/index.js +++ /dev/null @@ -1,52 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -exports.__esModule = true; -var react_1 = __importDefault(require("react")); -var equal = require("../.."); -var testArr = [ - { text: "green", id: "23" }, - { text: "sunshine", id: "1" }, - { text: "mountain", id: "11" }, - { text: "air", id: "8" }, - { text: "plants", id: "9" }, -]; -var TestChild = /** @class */ (function (_super) { - __extends(TestChild, _super); - function TestChild() { - return _super !== null && _super.apply(this, arguments) || this; - } - TestChild.prototype.shouldComponentUpdate = function (nextProps) { - return !equal(this.props, nextProps); - }; - TestChild.prototype.render = function () { - var todo = this.props.todo; - return react_1["default"].createElement("div", null, todo.text); - }; - return TestChild; -}(react_1["default"].Component)); -; -var TestContainer = /** @class */ (function (_super) { - __extends(TestContainer, _super); - function TestContainer() { - return _super !== null && _super.apply(this, arguments) || this; - } - TestContainer.prototype.render = function () { - return testArr.map(function (item) { return react_1["default"].createElement(TestChild, { key: item.id, todo: item }); }); - }; - return TestContainer; -}(react_1["default"].Component)); From d8b6fc99261bf25ca3fe3045281974f1afcb34c4 Mon Sep 17 00:00:00 2001 From: Kylie Stewart Date: Wed, 20 May 2020 14:32:29 -0600 Subject: [PATCH 17/20] moar PR feedback --- package.json | 8 ++--- test/typescript/sample-usage.tsx | 3 +- yarn.lock | 55 ++------------------------------ 3 files changed, 7 insertions(+), 59 deletions(-) diff --git a/package.json b/package.json index 743f900..4ca3092 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "3.1.1", "description": "Fastest deep equal comparison for React. Great for React.memo & shouldComponentUpdate. Also really fast general-purpose deep comparison.", "main": "index.js", + "typings": "index.d.ts", "scripts": { "preversion": "yarn test", "benchmark": "node benchmark", @@ -12,9 +13,9 @@ "test-browser-ie": "karma start test/browser/karma.conf.ie.js", "test-node": "mocha \"test/node/*.spec.js\"", "test-node-cov": "nyc mocha \"test/node/*.spec.js\"", - "test-ts-usage": "tsc --esModuleInterop --jsx react --noEmit test/typescript/sample-usage.tsx", + "test-ts-usage": "tsc --esModuleInterop --jsx react --noEmit test/typescript/sample-usage.tsx", "test-ts-defs": "tsc --target ES5 index.d.ts", - "test": "builder concurrent --buffer eslint test-ts-usage test-ts-defs test-node-cov test-browser", + "test": "builder concurrent --buffer eslint test-ts-usage test-ts-defs test-node-cov test-browser test-ie", "test-ie": "builder concurrent --buffer eslint test-ts-usage test-ts-defs test-node-cov test-browser-ie", "compress": "terser --compress --mangle=\"toplevel:true\" -- index.js", "size-min-gz": "yarn -s compress | gzip -9 | wc -c" @@ -44,7 +45,6 @@ "@testing-library/preact": "^1.0.2", "@types/node": "^14.0.1", "@types/react": "^16.9.35", - "@types/react-redux": "^7.1.8", "@typescript-eslint/parser": "^2.34.0", "babel-loader": "^8.0.6", "benchmark": "^2.1.4", @@ -70,9 +70,7 @@ "nyc": "^14.1.1", "preact": "^10.4.1", "react": "^16.3.1", - "react-redux": "^7.2.0", "react-test-renderer": "^16.13.1", - "redux": "^4.0.5", "shallow-equal-fuzzy": "0.0.2", "sinon": "^7.5.0", "terser": "^4.4.3", diff --git a/test/typescript/sample-usage.tsx b/test/typescript/sample-usage.tsx index bc6c5b0..acb92ab 100644 --- a/test/typescript/sample-usage.tsx +++ b/test/typescript/sample-usage.tsx @@ -1,8 +1,7 @@ // This file exists to test our types against sample user code // This is compiled using `tsc` in our `test-ts-usage` script import React from 'react'; - -const equal = require('../..'); +import equal from '../../index.js'; type ITodo = { text: string; diff --git a/yarn.lock b/yarn.lock index 304b5d4..248e6bb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -860,14 +860,6 @@ resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d" integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag== -"@types/hoist-non-react-statics@^3.3.0": - version "3.3.1" - resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz#1124aafe5118cb591977aeb1ceaaed1070eb039f" - integrity sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA== - dependencies: - "@types/react" "*" - hoist-non-react-statics "^3.3.0" - "@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0": version "2.0.1" resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz#42995b446db9a48a11a07ec083499a860e9138ff" @@ -903,17 +895,7 @@ resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7" integrity sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw== -"@types/react-redux@^7.1.8": - version "7.1.8" - resolved "https://registry.yarnpkg.com/@types/react-redux/-/react-redux-7.1.8.tgz#3631feb559f7858d6ad9eea1d6ef41fa64fe7205" - integrity sha512-kpplH7Wg2SYU00sZVT98WBN0ou6QKrYcShRaW+5Vpe5l7bluKWJbWmAL+ieiso07OQzpcP5i1PeY3690640ZWg== - dependencies: - "@types/hoist-non-react-statics" "^3.3.0" - "@types/react" "*" - hoist-non-react-statics "^3.3.0" - redux "^4.0.0" - -"@types/react@*", "@types/react@^16.9.35": +"@types/react@^16.9.35": version "16.9.35" resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.35.tgz#a0830d172e8aadd9bd41709ba2281a3124bbd368" integrity sha512-q0n0SsWcGc8nDqH2GJfWQWUOmZSJhXV64CjVN5SvcNti3TdEaA3AH0D8DwNmMdzjMAC/78tB8nAZIlV8yTz+zQ== @@ -3217,13 +3199,6 @@ hmac-drbg@^1.0.0: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.1" -hoist-non-react-statics@^3.3.0: - version "3.3.2" - resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" - integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw== - dependencies: - react-is "^16.7.0" - hosted-git-info@^2.1.4: version "2.8.8" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488" @@ -4878,7 +4853,7 @@ promise-inflight@^1.0.1: resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3" integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM= -prop-types@^15.6.2, prop-types@^15.7.2: +prop-types@^15.6.2: version "15.7.2" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5" integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ== @@ -5009,22 +4984,11 @@ raw-body@2.4.0: iconv-lite "0.4.24" unpipe "1.0.0" -react-is@^16.12.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.4, react-is@^16.8.6, react-is@^16.9.0: +react-is@^16.12.0, react-is@^16.8.1, react-is@^16.8.4, react-is@^16.8.6: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== -react-redux@^7.2.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-7.2.0.tgz#f970f62192b3981642fec46fd0db18a074fe879d" - integrity sha512-EvCAZYGfOLqwV7gh849xy9/pt55rJXPwmYvI4lilPM5rUT/1NxuuN59ipdBksRVSvz0KInbPnp4IfoXJXCqiDA== - dependencies: - "@babel/runtime" "^7.5.5" - hoist-non-react-statics "^3.3.0" - loose-envify "^1.4.0" - prop-types "^15.7.2" - react-is "^16.9.0" - react-test-renderer@^16.13.1: version "16.13.1" resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.13.1.tgz#de25ea358d9012606de51e012d9742e7f0deabc1" @@ -5099,14 +5063,6 @@ readdirp@~3.4.0: dependencies: picomatch "^2.2.1" -redux@^4.0.0, redux@^4.0.5: - version "4.0.5" - resolved "https://registry.yarnpkg.com/redux/-/redux-4.0.5.tgz#4db5de5816e17891de8a80c424232d06f051d93f" - integrity sha512-VSz1uMAH24DM6MF72vcojpYPtrTUu3ByVWfPL1nPfVRb5mZVTve5GnNCUV53QM/BZ66xfWrm0CTWoM+Xlz8V1w== - dependencies: - loose-envify "^1.4.0" - symbol-observable "^1.2.0" - regenerate-unicode-properties@^8.2.0: version "8.2.0" resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-8.2.0.tgz#e5de7111d655e7ba60c057dbe9ff37c87e65cdec" @@ -5890,11 +5846,6 @@ supports-color@^7.1.0: dependencies: has-flag "^4.0.0" -symbol-observable@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804" - integrity sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ== - symbol-tree@^3.2.4: version "3.2.4" resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" From 80e5d3012ae630dadedea69820d25b0b6168d2fd Mon Sep 17 00:00:00 2001 From: Kylie Stewart Date: Wed, 20 May 2020 19:29:06 -0600 Subject: [PATCH 18/20] Remove test-ie from travis --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4ca3092..5121918 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ "test-node-cov": "nyc mocha \"test/node/*.spec.js\"", "test-ts-usage": "tsc --esModuleInterop --jsx react --noEmit test/typescript/sample-usage.tsx", "test-ts-defs": "tsc --target ES5 index.d.ts", - "test": "builder concurrent --buffer eslint test-ts-usage test-ts-defs test-node-cov test-browser test-ie", - "test-ie": "builder concurrent --buffer eslint test-ts-usage test-ts-defs test-node-cov test-browser-ie", + "test": "builder concurrent --buffer eslint test-ts-usage test-ts-defs test-node-cov test-browser", + "test-ie": "builder concurrent --buffer eslint tslint test-ts-usage test-ts-defs test-node-cov test-browser-ie", "compress": "terser --compress --mangle=\"toplevel:true\" -- index.js", "size-min-gz": "yarn -s compress | gzip -9 | wc -c" }, From 5cc0bda80e47a31393e1276aaf21a44f41572054 Mon Sep 17 00:00:00 2001 From: Kylie Stewart Date: Thu, 21 May 2020 08:47:01 -0600 Subject: [PATCH 19/20] Add eslint-plugin-react --- .eslintrc.yml | 5 +- package.json | 1 + test/typescript/sample-usage.tsx | 2 + yarn.lock | 127 ++++++++++++++++++++++++++++++- 4 files changed, 130 insertions(+), 5 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 9d348fd..3f0a35a 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -1,9 +1,12 @@ env: node: true -extends: 'eslint:recommended' +extends: [ 'eslint:recommended', 'plugin:react/recommended' ] parser: '@typescript-eslint/parser' parserOptions: sourceType: module +settings: + react: + version: detect rules: indent: [ 2, 2, { SwitchCase: 1 } ] no-trailing-spaces: 2 diff --git a/package.json b/package.json index 5121918..e18116f 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "codecov": "^3.6.5", "core-js": "^3.5.0", "eslint": "^6.7.2", + "eslint-plugin-react": "^7.20.0", "fast-deep-equal": "3.1.1", "fast-deep-equal-git": "epoberezkin/fast-deep-equal#v3.1.1", "jsdom": "^16.2.2", diff --git a/test/typescript/sample-usage.tsx b/test/typescript/sample-usage.tsx index acb92ab..d9c7b91 100644 --- a/test/typescript/sample-usage.tsx +++ b/test/typescript/sample-usage.tsx @@ -36,3 +36,5 @@ class TestContainer extends React.Component { return testArr.map((item) => ); } } + +export default TestContainer; diff --git a/yarn.lock b/yarn.lock index 248e6bb..df1018b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -703,7 +703,7 @@ "@babel/types" "^7.4.4" esutils "^2.0.2" -"@babel/runtime-corejs3@^7.7.4": +"@babel/runtime-corejs3@^7.7.4", "@babel/runtime-corejs3@^7.8.3": version "7.9.6" resolved "https://registry.yarnpkg.com/@babel/runtime-corejs3/-/runtime-corejs3-7.9.6.tgz#67aded13fffbbc2cb93247388cf84d77a4be9a71" integrity sha512-6toWAfaALQjt3KMZQc6fABqZwUDDuWzz+cAfPhqyEnzxvdWOAkjwPNxgF8xlmo7OWLsSjaKjsskpKHRLaMArOA== @@ -1320,6 +1320,15 @@ array-from@^2.1.1: resolved "https://registry.yarnpkg.com/array-from/-/array-from-2.1.1.tgz#cfe9d8c26628b9dc5aecc62a9f5d8f1f352c1195" integrity sha1-z+nYwmYoudxa7MYqn12PHzUsEZU= +array-includes@^3.0.3, array-includes@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.1.1.tgz#cdd67e6852bdf9c1215460786732255ed2459348" + integrity sha512-c2VXaCHl7zPsvpkFsw4nxvFie4fh1ur9bpcgsVkIjqn0H/Xwdg+7fv3n2r/isyS8EBj5b06M9kHyZuIr4El6WQ== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.0" + is-string "^1.0.5" + array-unique@^0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" @@ -2346,6 +2355,13 @@ diffie-hellman@^5.0.0: miller-rabin "^4.0.0" randombytes "^2.0.0" +doctrine@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d" + integrity sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw== + dependencies: + esutils "^2.0.2" + doctrine@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" @@ -2521,7 +2537,7 @@ error-ex@^1.3.1: dependencies: is-arrayish "^0.2.1" -es-abstract@^1.17.0-next.1, es-abstract@^1.17.5: +es-abstract@^1.17.0, es-abstract@^1.17.0-next.1, es-abstract@^1.17.5: version "1.17.5" resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.5.tgz#d8c9d1d66c8981fb9200e2251d799eee92774ae9" integrity sha512-BR9auzDbySxOcfog0tLECW8l28eRGpDpU3Dm3Hp4q/N+VtLTmyj4EUN088XZWQDW/hzj6sYRDXeOFsaAODKvpg== @@ -2574,6 +2590,23 @@ escodegen@^1.14.1: optionalDependencies: source-map "~0.6.1" +eslint-plugin-react@^7.20.0: + version "7.20.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.20.0.tgz#f98712f0a5e57dfd3e5542ef0604b8739cd47be3" + integrity sha512-rqe1abd0vxMjmbPngo4NaYxTcR3Y4Hrmc/jg4T+sYz63yqlmJRknpEQfmWY+eDWPuMmix6iUIK+mv0zExjeLgA== + dependencies: + array-includes "^3.1.1" + doctrine "^2.1.0" + has "^1.0.3" + jsx-ast-utils "^2.2.3" + object.entries "^1.1.1" + object.fromentries "^2.0.2" + object.values "^1.1.1" + prop-types "^15.7.2" + resolve "^1.15.1" + string.prototype.matchall "^4.0.2" + xregexp "^4.3.0" + eslint-scope@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848" @@ -3361,6 +3394,15 @@ inquirer@^7.0.0: strip-ansi "^6.0.0" through "^2.3.6" +internal-slot@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.0.2.tgz#9c2e9fb3cd8e5e4256c6f45fe310067fcfa378a3" + integrity sha512-2cQNfwhAfJIkU4KZPkDI+Gj5yNNnbqi40W9Gge6dfnk4TocEVm00B3bdiL+JINrbGJil2TeHvM4rETGzk/f/0g== + dependencies: + es-abstract "^1.17.0-next.1" + has "^1.0.3" + side-channel "^1.0.2" + invariant@^2.2.2, invariant@^2.2.4: version "2.2.4" resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" @@ -3540,6 +3582,11 @@ is-stream@^1.0.1: resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= +is-string@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.5.tgz#40493ed198ef3ff477b8c7f92f644ec82a5cd3a6" + integrity sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ== + is-symbol@^1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.3.tgz#38e1014b9e6329be0de9d24a414fd7441ec61937" @@ -3786,6 +3833,14 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" +jsx-ast-utils@^2.2.3: + version "2.2.3" + resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-2.2.3.tgz#8a9364e402448a3ce7f14d357738310d9248054f" + integrity sha512-EdIHFMm+1BPynpKOpdPqiOsvnIrInRGJD7bzPZdPkjitQEqpdpUuFpq4T0npZFKTiB3RhWFdGN+oqOJIdhDhQA== + dependencies: + array-includes "^3.0.3" + object.assign "^4.1.0" + just-extend@^4.0.2: version "4.1.0" resolved "https://registry.yarnpkg.com/just-extend/-/just-extend-4.1.0.tgz#7278a4027d889601640ee0ce0e5a00b992467da4" @@ -4492,6 +4547,25 @@ object.assign@4.1.0, object.assign@^4.1.0: has-symbols "^1.0.0" object-keys "^1.0.11" +object.entries@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/object.entries/-/object.entries-1.1.2.tgz#bc73f00acb6b6bb16c203434b10f9a7e797d3add" + integrity sha512-BQdB9qKmb/HyNdMNWVr7O3+z5MUIx3aiegEIJqjMBbBf0YT9RRxTJSim4mzFqtyr7PDAHigq0N9dO0m0tRakQA== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.5" + has "^1.0.3" + +object.fromentries@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/object.fromentries/-/object.fromentries-2.0.2.tgz#4a09c9b9bb3843dd0f89acdb517a794d4f355ac9" + integrity sha512-r3ZiBH7MQppDJVLx6fhD618GKNG40CZYH9wgwdhKxBDDbQgjeWGGd4AtkZad84d291YxvWe7bJGuE65Anh0dxQ== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.0-next.1" + function-bind "^1.1.1" + has "^1.0.3" + object.getownpropertydescriptors@^2.0.3: version "2.1.0" resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.0.tgz#369bf1f9592d8ab89d712dced5cb81c7c5352649" @@ -4507,6 +4581,16 @@ object.pick@^1.3.0: dependencies: isobject "^3.0.1" +object.values@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.1.1.tgz#68a99ecde356b7e9295a3c5e0ce31dc8c953de5e" + integrity sha512-WTa54g2K8iu0kmS/us18jEmdv1a4Wi//BZ/DTVYEcH0XhLM5NYdpDHja3gt57VrZLcNAO2WGA+KpWsDBaHt6eA== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.0-next.1" + function-bind "^1.1.1" + has "^1.0.3" + on-finished@~2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" @@ -4853,7 +4937,7 @@ promise-inflight@^1.0.1: resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3" integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM= -prop-types@^15.6.2: +prop-types@^15.6.2, prop-types@^15.7.2: version "15.7.2" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5" integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ== @@ -5096,6 +5180,14 @@ regex-not@^1.0.0, regex-not@^1.0.2: extend-shallow "^3.0.2" safe-regex "^1.1.0" +regexp.prototype.flags@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.3.0.tgz#7aba89b3c13a64509dabcf3ca8d9fbb9bdf5cb75" + integrity sha512-2+Q0C5g951OlYlJz6yu5/M33IcsESLlLfsyIaLJaG4FA2r4yP8MvVMJUUP/fVBkSpbbbZlS5gynbEWLipiiXiQ== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.0-next.1" + regexpp@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" @@ -5214,7 +5306,7 @@ resolve-url@^0.2.1: resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= -resolve@^1.10.0, resolve@^1.3.2: +resolve@^1.10.0, resolve@^1.15.1, resolve@^1.3.2: version "1.17.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== @@ -5416,6 +5508,14 @@ shebang-regex@^1.0.0: resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= +side-channel@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.2.tgz#df5d1abadb4e4bf4af1cd8852bf132d2f7876947" + integrity sha512-7rL9YlPHg7Ancea1S96Pa8/QWb4BtXL/TZvS6B8XFetGBeuhAsfmUspK6DokBeZ64+Kj9TCNRD/30pVz1BvQNA== + dependencies: + es-abstract "^1.17.0-next.1" + object-inspect "^1.7.0" + signal-exit@^3.0.0, signal-exit@^3.0.2: version "3.0.3" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" @@ -5729,6 +5829,18 @@ string-width@^4.1.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.0" +string.prototype.matchall@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/string.prototype.matchall/-/string.prototype.matchall-4.0.2.tgz#48bb510326fb9fdeb6a33ceaa81a6ea04ef7648e" + integrity sha512-N/jp6O5fMf9os0JU3E72Qhf590RSRZU/ungsL/qJUYVTNv7hTG0P/dbPjxINVN9jpscu3nzYwKESU3P3RY5tOg== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.0" + has-symbols "^1.0.1" + internal-slot "^1.0.2" + regexp.prototype.flags "^1.3.0" + side-channel "^1.0.2" + string.prototype.trimend@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz#85812a6b847ac002270f5808146064c995fb6913" @@ -6482,6 +6594,13 @@ xmlhttprequest-ssl@~1.5.4: resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz#c2876b06168aadc40e57d97e81191ac8f4398b3e" integrity sha1-wodrBhaKrcQOV9l+gRkayPQ5iz4= +xregexp@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-4.3.0.tgz#7e92e73d9174a99a59743f67a4ce879a04b5ae50" + integrity sha512-7jXDIFXh5yJ/orPn4SXjuVrWWoi4Cr8jfV1eHv9CixKSbU+jY4mxfrBwAuDvupPNKpMUY+FeIqsVw/JLT9+B8g== + dependencies: + "@babel/runtime-corejs3" "^7.8.3" + xtend@^4.0.0, xtend@~4.0.1: version "4.0.2" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" From 60a211c00f4d6462e52427eb9c89fad353f9f50d Mon Sep 17 00:00:00 2001 From: Kylie Stewart Date: Thu, 21 May 2020 08:51:35 -0600 Subject: [PATCH 20/20] Run tslint in CI --- package.json | 2 +- test/node/advanced.spec.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e18116f..3906bef 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "test-node-cov": "nyc mocha \"test/node/*.spec.js\"", "test-ts-usage": "tsc --esModuleInterop --jsx react --noEmit test/typescript/sample-usage.tsx", "test-ts-defs": "tsc --target ES5 index.d.ts", - "test": "builder concurrent --buffer eslint test-ts-usage test-ts-defs test-node-cov test-browser", + "test": "builder concurrent --buffer eslint tslint test-ts-usage test-ts-defs test-node-cov test-browser", "test-ie": "builder concurrent --buffer eslint tslint test-ts-usage test-ts-defs test-node-cov test-browser-ie", "compress": "terser --compress --mangle=\"toplevel:true\" -- index.js", "size-min-gz": "yarn -s compress | gzip -9 | wc -c" diff --git a/test/node/advanced.spec.js b/test/node/advanced.spec.js index 82e3e85..c0fa172 100644 --- a/test/node/advanced.spec.js +++ b/test/node/advanced.spec.js @@ -1,5 +1,8 @@ 'use strict'; +/* eslint-disable react/prop-types */ +/* eslint-disable react/no-children-prop */ + const assert = require('assert'); const jsdom = require('jsdom-global'); const sinon = require('sinon');