From 4cc1970d06333f4860b8f44c82d24ac856a1a1ad Mon Sep 17 00:00:00 2001 From: Vladimir Starkov Date: Thu, 31 Jan 2019 13:49:36 +0100 Subject: [PATCH 1/8] warn consumers if themed styles are misused. fix #1005 --- changelog.md | 1 + packages/react-jss/package.json | 3 ++- packages/react-jss/src/withStyles.js | 10 ++++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 13dc05d21..cb48f03cd 100755 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,7 @@ - [jss] Simplify cloneStyle function ([#1003](https://github.com/cssinjs/jss/pull/1003)) - [internal] Improve publish script for creating github release ([#999](https://github.com/cssinjs/jss/pull/999)) +- [react-jss] Warn about themed styles misuse ([#1006](https://github.com/cssinjs/jss/pull/1006)) ### Bug fixes diff --git a/packages/react-jss/package.json b/packages/react-jss/package.json index d8740ff00..052420e58 100644 --- a/packages/react-jss/package.json +++ b/packages/react-jss/package.json @@ -46,7 +46,8 @@ "jss": "10.0.0-alpha.9", "jss-preset-default": "10.0.0-alpha.9", "prop-types": "^15.6.0", - "theming": "^3.0.3" + "theming": "^3.0.3", + "tiny-warning": "^1.0.2" }, "devDependencies": { "@types/react": "^16.7.20" diff --git a/packages/react-jss/src/withStyles.js b/packages/react-jss/src/withStyles.js index 064ea41f8..6159c25fb 100644 --- a/packages/react-jss/src/withStyles.js +++ b/packages/react-jss/src/withStyles.js @@ -3,6 +3,7 @@ import React, {Component, type ComponentType, type Node} from 'react' import hoistNonReactStatics from 'hoist-non-react-statics' import {getDynamicStyles, SheetsManager, type StyleSheet} from 'jss' import {ThemeContext} from 'theming' +import warning from 'tiny-warning' import type {HOCProps, Options, Styles, InnerProps} from './types' import getDisplayName from './getDisplayName' @@ -35,10 +36,15 @@ let managersCounter = 0 const NoRenderer = (props: {children?: Node}) => props.children || null -const getStyles = (styles: Styles, theme: Theme) => { +const getStyles = (styles: Styles, theme: Theme, displayName: string) => { if (typeof styles !== 'function') { return styles } + warning( + styles.length !== 0, + `[JSS] <${displayName} />'s styles function doesn't rely on a theme. We recommend to rewrite it to plain object. Read more: https://github.com/cssinjs/jss/blob/master/docs/react-jss.md#basic` + ) + return styles(theme) } @@ -134,7 +140,7 @@ export default function withStyles>( return staticSheet } - const themedStyles = getStyles(styles, theme) + const themedStyles = getStyles(styles, theme, displayName) const contextSheetOptions = this.props.jssContext.sheetOptions staticSheet = this.jss.createStyleSheet(themedStyles, { ...sheetOptions, From e740e2f46a0fb239e7fe3a8f3f8a1414ac8e7050 Mon Sep 17 00:00:00 2001 From: Vladimir Starkov Date: Thu, 31 Jan 2019 13:52:04 +0100 Subject: [PATCH 2/8] Fix tests on node 10 upgrade karma-browserstack-launcher to at least 1.4.0, because "internalBinding is not defined" due to old "natives" module See more: * karma-runner/karma-browserstack-launcher#140 * popcodeorg/popcode#1626 --- package.json | 2 +- yarn.lock | 188 ++++++++++++++++++++------------------------------- 2 files changed, 73 insertions(+), 117 deletions(-) diff --git a/package.json b/package.json index a3af5f8ee..3663e6d04 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "karma": "^1.3.0", "karma-benchmark": "^0.6.0", "karma-benchmark-reporter": "^0.1.1", - "karma-browserstack-launcher": "^1.1.1", + "karma-browserstack-launcher": "^1.4.0", "karma-chrome-launcher": "^2.0.0", "karma-coverage": "^1.1.1", "karma-mocha": "^1.3.0", diff --git a/yarn.lock b/yarn.lock index 8a5c5d85b..374f79660 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1750,14 +1750,6 @@ after@0.8.2: resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f" integrity sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8= -agent-base@2: - version "2.1.1" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-2.1.1.tgz#d6de10d5af6132d5bd692427d46fc538539094c7" - integrity sha1-1t4Q1a9hMtW9aSQn1G/FOFOQlMc= - dependencies: - extend "~3.0.0" - semver "~5.0.1" - agent-base@4, agent-base@^4.1.0, agent-base@~4.2.0: version "4.2.1" resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.2.1.tgz#d89e5999f797875674c07d87f260fc41e83e8ca9" @@ -2196,6 +2188,11 @@ better-assert@~1.0.0: dependencies: callsite "1.0.0" +big-integer@^1.6.17: + version "1.6.41" + resolved "https://registry.npmjs.org/big-integer/-/big-integer-1.6.41.tgz#6fb0e51bc8661129ef3832d46c939170b81ca794" + integrity sha512-d5AT9lMTYJ/ZE/4gzxb+5ttPcRWljVsvv7lF1w9KzkPhVUhBtHrjDo1J8swfZKepfLsliDhYa31zRYwcD0Yg9w== + big.js@^3.1.3: version "3.2.0" resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.2.0.tgz#a5fc298b81b9e0dca2e458824784b65c52ba588e" @@ -2222,9 +2219,9 @@ binary-extensions@^1.0.0: resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.11.0.tgz#46aa1751fb6a2f93ee5e689bb1087d4b14c6c205" integrity sha1-RqoXUftqL5PuXmibsQh9SxTGwgU= -"binary@>= 0.3.0 < 1": +binary@~0.3.0: version "0.3.0" - resolved "https://registry.yarnpkg.com/binary/-/binary-0.3.0.tgz#9f60553bc5ce8c3386f3b553cff47462adecaa79" + resolved "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz#9f60553bc5ce8c3386f3b553cff47462adecaa79" integrity sha1-n2BVO8XOjDOG87VTz/R0Yq3sqnk= dependencies: buffers "~0.1.1" @@ -2252,6 +2249,11 @@ bluebird@^3.5.0, bluebird@^3.5.1, bluebird@^3.5.3: resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.3.tgz#7d01c6f9616c9a51ab0f8c549a79dfe6ec33efa7" integrity sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw== +bluebird@~3.4.1: + version "3.4.7" + resolved "https://registry.npmjs.org/bluebird/-/bluebird-3.4.7.tgz#f72d760be09b7f76d08ed8fae98b289a8d05fab3" + integrity sha1-9y12C+Cbf3bQjtj66Ysomo0F+rM= + bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.4.0: version "4.11.8" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f" @@ -2391,20 +2393,20 @@ browserslist@^4.1.0: electron-to-chromium "^1.3.61" node-releases "^1.0.0-alpha.11" -browserstack@1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/browserstack/-/browserstack-1.5.0.tgz#b565425ad62ed72c1082a1eb979d5313c7d4754f" - integrity sha1-tWVCWtYu1ywQgqHrl51TE8fUdU8= +browserstack@~1.5.1: + version "1.5.2" + resolved "https://registry.npmjs.org/browserstack/-/browserstack-1.5.2.tgz#17d8bb76127a1cc0ea416424df80d218f803673f" + integrity sha512-+6AFt9HzhKykcPF79W6yjEUJcdvZOV0lIXdkORXMJftGrDl0OKWqRF4GHqpDNkxiceDT/uB7Fb/aDwktvXX7dg== dependencies: - https-proxy-agent "1.0.0" + https-proxy-agent "^2.2.1" -browserstacktunnel-wrapper@~2.0.1: - version "2.0.3" - resolved "https://registry.yarnpkg.com/browserstacktunnel-wrapper/-/browserstacktunnel-wrapper-2.0.3.tgz#4e9c1595a08c8e57098a73a56561251d815bb695" - integrity sha512-I3u/EOOPGBt34RN0PBhPDwee4Dsik/Y2URK7iJn/vj5sR8JIoNh5I9gA6bFyxhU9sCo/1ISN4p7URNXK4zD4AA== +browserstacktunnel-wrapper@~2.0.2: + version "2.0.4" + resolved "https://registry.npmjs.org/browserstacktunnel-wrapper/-/browserstacktunnel-wrapper-2.0.4.tgz#0ebffd3d6311b8526c30d8b430fdc651a535eebb" + integrity sha512-GCV599FUUxNOCFl3WgPnfc5dcqq9XTmMXoxWpqkvmk0R9TOIoqmjENNU6LY6DtgIL6WfBVbg/jmWtnM5K6UYSg== dependencies: https-proxy-agent "^2.2.1" - unzip "~0.1.11" + unzipper "^0.9.3" buffer-alloc-unsafe@^1.1.0: version "1.1.0" @@ -2434,6 +2436,11 @@ buffer-from@^1.0.0: resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== +buffer-indexof-polyfill@~1.0.0: + version "1.0.1" + resolved "https://registry.npmjs.org/buffer-indexof-polyfill/-/buffer-indexof-polyfill-1.0.1.tgz#a9fb806ce8145d5428510ce72f278bb363a638bf" + integrity sha1-qfuAbOgUXVQoUQznLyeLs2OmOL8= + buffer-xor@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9" @@ -3336,13 +3343,6 @@ dateformat@^3.0.0: resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae" integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q== -debug@2, debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3, debug@^2.6.8, debug@^2.6.9: - version "2.6.9" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" - integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== - dependencies: - ms "2.0.0" - debug@2.2.0: version "2.2.0" resolved "http://registry.npmjs.org/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" @@ -3364,6 +3364,13 @@ debug@2.6.8: dependencies: ms "2.0.0" +debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3, debug@^2.6.8, debug@^2.6.9: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== + dependencies: + ms "2.0.0" + debug@3.1.0, debug@=3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" @@ -3589,6 +3596,13 @@ dot-prop@^4.2.0: dependencies: is-obj "^1.0.0" +duplexer2@~0.1.4: + version "0.1.4" + resolved "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1" + integrity sha1-ixLauHjA1p4+eJEFFmKjL8a93ME= + dependencies: + readable-stream "^2.0.2" + duplexer@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" @@ -4161,7 +4175,7 @@ extend-shallow@^3.0.0, extend-shallow@^3.0.2: assign-symbols "^1.0.0" is-extendable "^1.0.1" -extend@3, extend@^3.0.0, extend@~3.0.0, extend@~3.0.2: +extend@^3.0.0, extend@~3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== @@ -4491,17 +4505,7 @@ fsevents@^1.0.0, fsevents@^1.2.2: nan "^2.9.2" node-pre-gyp "^0.10.0" -"fstream@>= 0.1.30 < 1": - version "0.1.31" - resolved "https://registry.yarnpkg.com/fstream/-/fstream-0.1.31.tgz#7337f058fbbbbefa8c9f561a28cab0849202c988" - integrity sha1-czfwWPu7vvqMn1YaKMqwhJICyYg= - dependencies: - graceful-fs "~3.0.2" - inherits "~2.0.0" - mkdirp "0.5" - rimraf "2" - -fstream@^1.0.0, fstream@^1.0.2: +fstream@^1.0.0, fstream@^1.0.2, fstream@~1.0.10: version "1.0.11" resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171" integrity sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE= @@ -4763,13 +4767,6 @@ graceful-fs@~1: resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-1.2.3.tgz#15a4806a57547cb2d2dbf27f42e89a8c3451b364" integrity sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q= -graceful-fs@~3.0.2: - version "3.0.11" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-3.0.11.tgz#7613c778a1afea62f25c630a086d7f3acbbdd818" - integrity sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg= - dependencies: - natives "^1.1.0" - "graceful-readlink@>= 1.0.0": version "1.0.1" resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" @@ -4995,15 +4992,6 @@ https-browserify@^1.0.0: resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73" integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM= -https-proxy-agent@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-1.0.0.tgz#35f7da6c48ce4ddbfa264891ac593ee5ff8671e6" - integrity sha1-NffabEjOTdv6JkiRrFk+5f+GceY= - dependencies: - agent-base "2" - debug "2" - extend "3" - https-proxy-agent@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz#51552970fa04d723e04c56d04178c3f92592bbc0" @@ -5765,13 +5753,13 @@ karma-benchmark@^0.6.0: lodash "4.13.1" platform "1.3.1" -karma-browserstack-launcher@^1.1.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/karma-browserstack-launcher/-/karma-browserstack-launcher-1.3.0.tgz#61fe3d36b1cf10681e40f9d874bf37271fb1c674" - integrity sha512-LrPf5sU/GISkEElWyoy06J8x0c8BcOjjOwf61Wqu6M0aWQu0Eoqm9yh3xON64/ByST/CEr0GsWiREQ/EIEMd4Q== +karma-browserstack-launcher@^1.4.0: + version "1.4.0" + resolved "https://registry.npmjs.org/karma-browserstack-launcher/-/karma-browserstack-launcher-1.4.0.tgz#22f92e969d2db6cfc00e578708bda39378d5f2ab" + integrity sha512-bUQK84U+euDfOUfEjcF4IareySMOBNRLrrl9q6cttIe8f011Ir6olLITTYMOJDcGY58wiFIdhPHSPd9Pi6+NfQ== dependencies: - browserstack "1.5.0" - browserstacktunnel-wrapper "~2.0.1" + browserstack "~1.5.1" + browserstacktunnel-wrapper "~2.0.2" q "~1.5.0" karma-chrome-launcher@^2.0.0: @@ -6040,6 +6028,11 @@ lint-staged@^3.2.2: p-map "^1.1.1" staged-git-files "0.0.4" +listenercount@~1.0.1: + version "1.0.1" + resolved "https://registry.npmjs.org/listenercount/-/listenercount-1.0.1.tgz#84c8a72ab59c4725321480c975e6508342e70937" + integrity sha1-hMinKrWcRyUyFIDJdeZQg0LnCTc= + listr-silent-renderer@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/listr-silent-renderer/-/listr-silent-renderer-1.1.1.tgz#924b5a3757153770bf1a8e3fbf74b8bbf3f9242e" @@ -6448,14 +6441,6 @@ markdown-escapes@^1.0.0: resolved "https://registry.yarnpkg.com/markdown-escapes/-/markdown-escapes-1.0.2.tgz#e639cbde7b99c841c0bacc8a07982873b46d2122" integrity sha512-lbRZ2mE3Q9RtLjxZBZ9+IMl68DKIXaVAhwvwn9pmjnPLS0h/6kyBMgNhqi1xFJ/2yv6cSyv0jbiZavZv93JkkA== -"match-stream@>= 0.0.2 < 1": - version "0.0.2" - resolved "https://registry.yarnpkg.com/match-stream/-/match-stream-0.0.2.tgz#99eb050093b34dffade421b9ac0b410a9cfa17cf" - integrity sha1-mesFAJOzTf+t5CG5rAtBCpz6F88= - dependencies: - buffers "~0.1.1" - readable-stream "~1.0.0" - math-random@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/math-random/-/math-random-1.0.1.tgz#8b3aac588b8a66e4975e3cdea67f7bb329601fac" @@ -6722,7 +6707,7 @@ mixin-deep@^1.2.0: for-in "^1.0.2" is-extendable "^1.0.1" -mkdirp@0.5, mkdirp@0.5.1, mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0: +mkdirp@0.5.1, mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM= @@ -6826,11 +6811,6 @@ nanomatch@^1.2.9: snapdragon "^0.8.1" to-regex "^3.0.1" -natives@^1.1.0: - version "1.1.4" - resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.4.tgz#2f0f224fc9a7dd53407c7667c84cf8dbe773de58" - integrity sha512-Q29yeg9aFKwhLVdkTAejM/HvYG0Y1Am1+HUkFQGn5k2j8GS+v60TVmZh6nujpEAj/qql+wGUrlryO8bF+b1jEg== - natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" @@ -7295,11 +7275,6 @@ osenv@0, osenv@^0.1.4, osenv@^0.1.5: os-homedir "^1.0.0" os-tmpdir "^1.0.0" -"over@>= 0.0.5 < 1": - version "0.0.5" - resolved "https://registry.yarnpkg.com/over/-/over-0.0.5.tgz#f29852e70fd7e25f360e013a8ec44c82aedb5708" - integrity sha1-8phS5w/X4l82DgE6jsRMgq7bVwg= - p-defer@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" @@ -7789,16 +7764,6 @@ public-encrypt@^4.0.0: parse-asn1 "^5.0.0" randombytes "^2.0.1" -"pullstream@>= 0.4.1 < 1": - version "0.4.1" - resolved "https://registry.yarnpkg.com/pullstream/-/pullstream-0.4.1.tgz#d6fb3bf5aed697e831150eb1002c25a3f8ae1314" - integrity sha1-1vs79a7Wl+gxFQ6xACwlo/iuExQ= - dependencies: - over ">= 0.0.5 < 1" - readable-stream "~1.0.31" - setimmediate ">= 1.0.2 < 2" - slice-stream ">= 1.0.0 < 2" - pump@^2.0.0, pump@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/pump/-/pump-2.0.1.tgz#12399add6e4cf7526d973cbc8b5ce2e2908b3909" @@ -8061,7 +8026,7 @@ read@1, read@~1.0.1: string_decoder "~1.1.1" util-deprecate "~1.0.1" -readable-stream@~1.0.0, readable-stream@~1.0.2, readable-stream@~1.0.31: +readable-stream@~1.0.2: version "1.0.34" resolved "http://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" integrity sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw= @@ -8573,11 +8538,6 @@ semver@~4.3.3: resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.6.tgz#300bc6e0e86374f7ba61068b5b1ecd57fc6532da" integrity sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto= -semver@~5.0.1: - version "5.0.3" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.0.3.tgz#77466de589cd5d3c95f138aa78bc569a3cb5d27a" - integrity sha1-d0Zt5YnNXTyV8TiqeLxWmjy10no= - semver@~5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" @@ -8618,9 +8578,9 @@ set-value@^2.0.0: is-plain-object "^2.0.3" split-string "^3.0.1" -"setimmediate@>= 1.0.1 < 2", "setimmediate@>= 1.0.2 < 2", setimmediate@^1.0.4, setimmediate@^1.0.5: +setimmediate@^1.0.4, setimmediate@^1.0.5, setimmediate@~1.0.4: version "1.0.5" - resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" + resolved "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU= setprototypeof@1.1.0: @@ -8692,13 +8652,6 @@ slice-ansi@1.0.0: dependencies: is-fullwidth-code-point "^2.0.0" -"slice-stream@>= 1.0.0 < 2": - version "1.0.0" - resolved "https://registry.yarnpkg.com/slice-stream/-/slice-stream-1.0.0.tgz#5b33bd66f013b1a7f86460b03d463dec39ad3ea0" - integrity sha1-WzO9ZvATsaf4ZGCwPUY97DmtPqA= - dependencies: - readable-stream "~1.0.31" - slide@^1.1.6: version "1.1.6" resolved "https://registry.yarnpkg.com/slide/-/slide-1.1.6.tgz#56eb027d65b4d2dce6cb2e2d32c4d4afc9e1d707" @@ -9676,17 +9629,20 @@ unset-value@^1.0.0: has-value "^0.3.1" isobject "^3.0.0" -unzip@~0.1.11: - version "0.1.11" - resolved "https://registry.yarnpkg.com/unzip/-/unzip-0.1.11.tgz#89749c63b058d7d90d619f86b98aa1535d3b97f0" - integrity sha1-iXScY7BY19kNYZ+GuYqhU107l/A= - dependencies: - binary ">= 0.3.0 < 1" - fstream ">= 0.1.30 < 1" - match-stream ">= 0.0.2 < 1" - pullstream ">= 0.4.1 < 1" - readable-stream "~1.0.31" - setimmediate ">= 1.0.1 < 2" +unzipper@^0.9.3: + version "0.9.10" + resolved "https://registry.npmjs.org/unzipper/-/unzipper-0.9.10.tgz#1954ed60f69d102d4416f92825588f2916ba503e" + integrity sha512-dhxTaR67KGyrmxseXTmsyzdlRWkuN0rMPo9j6lxosR/PkzbHNd3smzMobaApx6o/oYvqU1uv+fAPoWr1P4bd8Q== + dependencies: + big-integer "^1.6.17" + binary "~0.3.0" + bluebird "~3.4.1" + buffer-indexof-polyfill "~1.0.0" + duplexer2 "~0.1.4" + fstream "~1.0.10" + listenercount "~1.0.1" + readable-stream "~2.3.6" + setimmediate "~1.0.4" upath@^1.0.5: version "1.1.0" From 6695c885acb85da5266e3dbba189c7b1572c0ed3 Mon Sep 17 00:00:00 2001 From: Vladimir Starkov Date: Thu, 31 Jan 2019 13:58:09 +0100 Subject: [PATCH 3/8] add tests --- packages/react-jss/src/withStyles.test.js | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/packages/react-jss/src/withStyles.test.js b/packages/react-jss/src/withStyles.test.js index be5331aab..5697d5c32 100644 --- a/packages/react-jss/src/withStyles.test.js +++ b/packages/react-jss/src/withStyles.test.js @@ -244,4 +244,40 @@ describe('React-JSS: withStyles', () => { process.env.NODE_ENV = 'development' }) }) + + describe('.withStyles() properly warns about themed styles misuse', () => { + beforeEach(() => { + spy(console, 'warn') + }) + + afterEach(() => { + console.warn.restore() + }) + + it('warn if themed styles dont use theme', () => { + function DisplayNameTest() { + return null + } + const MyComponent = withStyles(() => ({}))(DisplayNameTest) + + TestRenderer.create() + + expect( + console.warn.calledWithExactly( + `Warning: [JSS] 's styles function doesn't rely on a theme. We recommend to rewrite it to plain object. Read more: https://github.com/cssinjs/jss/blob/master/docs/react-jss.md#basic` + ) + ).to.be(true) + }) + + it('doesnt warn if themed styles _do use_ theme', () => { + function DisplayNameTest() { + return null + } + const MyComponent = withStyles(theme => ({}))(DisplayNameTest) // eslint-disable-line no-unused-vars + + TestRenderer.create() + + expect(console.warn.called).to.be(false) + }) + }) }) From bc5a50c2fe4b49c98a6973e0dc7dbab54a856491 Mon Sep 17 00:00:00 2001 From: Vladimir Starkov Date: Thu, 31 Jan 2019 14:00:12 +0100 Subject: [PATCH 4/8] update snapshots --- packages/react-jss/.size-snapshot.json | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/react-jss/.size-snapshot.json b/packages/react-jss/.size-snapshot.json index ed48ab7eb..b16c7e32b 100644 --- a/packages/react-jss/.size-snapshot.json +++ b/packages/react-jss/.size-snapshot.json @@ -1,30 +1,30 @@ { "dist/react-jss.js": { - "bundled": 131866, - "minified": 44695, - "gzipped": 13215 + "bundled": 132124, + "minified": 44900, + "gzipped": 13346 }, "dist/react-jss.min.js": { - "bundled": 100134, - "minified": 34854, - "gzipped": 10467 + "bundled": 100159, + "minified": 34858, + "gzipped": 10468 }, "dist/react-jss.cjs.js": { - "bundled": 14377, - "minified": 6602, - "gzipped": 2191 + "bundled": 14738, + "minified": 6899, + "gzipped": 2351 }, "dist/react-jss.esm.js": { - "bundled": 13737, - "minified": 6056, - "gzipped": 2082, + "bundled": 14078, + "minified": 6338, + "gzipped": 2241, "treeshaked": { "rollup": { - "code": 1925, - "import_statements": 436 + "code": 1946, + "import_statements": 457 }, "webpack": { - "code": 3285 + "code": 3340 } } } From 4b34d6880ca6be61e3f98f8826d096d125c32e1d Mon Sep 17 00:00:00 2001 From: Vladimir Starkov Date: Sat, 2 Feb 2019 21:03:51 +0100 Subject: [PATCH 5/8] add test for themed styles misuse warning not shown in prod --- packages/react-jss/src/withStyles.test.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/react-jss/src/withStyles.test.js b/packages/react-jss/src/withStyles.test.js index 5697d5c32..2a10759e7 100644 --- a/packages/react-jss/src/withStyles.test.js +++ b/packages/react-jss/src/withStyles.test.js @@ -279,5 +279,18 @@ describe('React-JSS: withStyles', () => { expect(console.warn.called).to.be(false) }) + + it('doesnt warn if themed styles dont use theme in _prod_', () => { + process.env.NODE_ENV = 'production' + function DisplayNameTest() { + return null + } + const MyComponent = withStyles(() => ({}))(DisplayNameTest) // eslint-disable-line no-unused-vars + + TestRenderer.create() + + expect(console.warn.called).to.be(false) + process.env.NODE_ENV = 'development' + }) }) }) From 41b9729e309f9d00e9e61a19310172b9c74852bc Mon Sep 17 00:00:00 2001 From: Henri Beck Date: Sat, 2 Feb 2019 23:15:14 +0100 Subject: [PATCH 6/8] Add dev expression babel plugin while testing --- packages/react-jss/src/withStyles.test.js | 2 +- webpack.config.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/react-jss/src/withStyles.test.js b/packages/react-jss/src/withStyles.test.js index 2a10759e7..257bd0df2 100644 --- a/packages/react-jss/src/withStyles.test.js +++ b/packages/react-jss/src/withStyles.test.js @@ -280,7 +280,7 @@ describe('React-JSS: withStyles', () => { expect(console.warn.called).to.be(false) }) - it('doesnt warn if themed styles dont use theme in _prod_', () => { + it('doesnt warn if themed styles dont use theme in production', () => { process.env.NODE_ENV = 'production' function DisplayNameTest() { return null diff --git a/webpack.config.js b/webpack.config.js index 64c11910f..d705241e5 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -30,7 +30,11 @@ module.exports = { exclude: /node_modules/, options: { presets: ['@babel/react', '@babel/flow', '@babel/env'], - plugins: ['@babel/proposal-class-properties', '@babel/proposal-object-rest-spread'] + plugins: [ + '@babel/proposal-class-properties', + '@babel/proposal-object-rest-spread', + 'dev-expression' + ] } } ] From 9eaa13ca666eba72d15ab31987b59a993a0cc6cb Mon Sep 17 00:00:00 2001 From: Henri Beck Date: Sun, 3 Feb 2019 00:28:14 +0100 Subject: [PATCH 7/8] Remove test and babel plugin from test setup --- packages/react-jss/src/withStyles.test.js | 13 ------------- webpack.config.js | 6 +----- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/packages/react-jss/src/withStyles.test.js b/packages/react-jss/src/withStyles.test.js index 257bd0df2..5697d5c32 100644 --- a/packages/react-jss/src/withStyles.test.js +++ b/packages/react-jss/src/withStyles.test.js @@ -279,18 +279,5 @@ describe('React-JSS: withStyles', () => { expect(console.warn.called).to.be(false) }) - - it('doesnt warn if themed styles dont use theme in production', () => { - process.env.NODE_ENV = 'production' - function DisplayNameTest() { - return null - } - const MyComponent = withStyles(() => ({}))(DisplayNameTest) // eslint-disable-line no-unused-vars - - TestRenderer.create() - - expect(console.warn.called).to.be(false) - process.env.NODE_ENV = 'development' - }) }) }) diff --git a/webpack.config.js b/webpack.config.js index d705241e5..64c11910f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -30,11 +30,7 @@ module.exports = { exclude: /node_modules/, options: { presets: ['@babel/react', '@babel/flow', '@babel/env'], - plugins: [ - '@babel/proposal-class-properties', - '@babel/proposal-object-rest-spread', - 'dev-expression' - ] + plugins: ['@babel/proposal-class-properties', '@babel/proposal-object-rest-spread'] } } ] From 56800f9705769911206ce92f1e915ec20221a764 Mon Sep 17 00:00:00 2001 From: Henri Beck Date: Sun, 3 Feb 2019 01:08:19 +0100 Subject: [PATCH 8/8] Update size-snapshot --- packages/react-jss/.size-snapshot.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/react-jss/.size-snapshot.json b/packages/react-jss/.size-snapshot.json index b16c7e32b..b9656b86c 100644 --- a/packages/react-jss/.size-snapshot.json +++ b/packages/react-jss/.size-snapshot.json @@ -1,23 +1,23 @@ { "dist/react-jss.js": { - "bundled": 132124, - "minified": 44900, - "gzipped": 13346 + "bundled": 132277, + "minified": 44968, + "gzipped": 13372 }, "dist/react-jss.min.js": { - "bundled": 100159, - "minified": 34858, - "gzipped": 10468 + "bundled": 100312, + "minified": 34926, + "gzipped": 10494 }, "dist/react-jss.cjs.js": { - "bundled": 14738, - "minified": 6899, - "gzipped": 2351 + "bundled": 14771, + "minified": 6929, + "gzipped": 2359 }, "dist/react-jss.esm.js": { - "bundled": 14078, - "minified": 6338, - "gzipped": 2241, + "bundled": 14090, + "minified": 6349, + "gzipped": 2244, "treeshaked": { "rollup": { "code": 1946,