From 2607cb25ab81d4149b9842d730eaa2f9814e7fc8 Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Sun, 9 Jul 2017 18:42:42 -0700 Subject: [PATCH] Clean up benchmark exports and PropTypes import --- benchmarks/createRenderBenchmark.js | 8 +++-- benchmarks/src/components/AppText/index.js | 3 +- .../src/components/AspectRatio/index.js | 3 +- benchmarks/src/components/Box/aphrodite.js | 2 +- benchmarks/src/components/Box/css-modules.js | 2 +- benchmarks/src/components/Box/glamor.js | 2 +- benchmarks/src/components/Box/jss.js | 2 +- .../components/Box/react-native-stylesheet.js | 2 +- benchmarks/src/components/Box/react-native.js | 2 +- benchmarks/src/components/Box/reactxp.js | 2 +- .../Box/styled-components-primitives.js | 2 +- .../src/components/Box/styled-components.js | 2 +- benchmarks/src/components/Box/styletron.js | 2 +- benchmarks/src/components/GridView/index.js | 3 +- benchmarks/src/components/NestedTree/index.js | 5 +-- benchmarks/src/components/Tweet/index.js | 3 +- .../src/components/TweetAction/index.js | 5 +-- .../src/components/TweetActionsBar/index.js | 3 +- benchmarks/src/components/TweetText/index.js | 9 +++--- .../src/components/TweetTextPart/index.js | 3 +- benchmarks/src/components/UserAvatar/index.js | 3 +- benchmarks/src/components/UserNames/index.js | 3 +- benchmarks/src/components/View/aphrodite.js | 2 +- benchmarks/src/components/View/css-modules.js | 2 +- benchmarks/src/components/View/glamor.js | 2 +- benchmarks/src/components/View/jss.js | 2 +- .../View/react-native-stylesheet.js | 2 +- .../src/components/View/styled-components.js | 2 +- benchmarks/src/components/theme.js | 4 ++- benchmarks/src/css-modules.js | 4 ++- benchmarks/src/jss.js | 4 ++- benchmarks/src/react-native-stylesheet.js | 4 ++- benchmarks/tests/renderTweet.js | 2 +- package.json | 2 +- yarn.lock | 32 +++---------------- 35 files changed, 68 insertions(+), 67 deletions(-) diff --git a/benchmarks/createRenderBenchmark.js b/benchmarks/createRenderBenchmark.js index 79384a10..49205dad 100644 --- a/benchmarks/createRenderBenchmark.js +++ b/benchmarks/createRenderBenchmark.js @@ -5,7 +5,9 @@ const node = document.querySelector('.root'); const createRenderBenchmark = ({ description, getElement, name, runs }) => () => { const setup = () => {}; - const teardown = () => ReactDOM.unmountComponentAtNode(node); + const teardown = () => { + ReactDOM.unmountComponentAtNode(node); + }; return benchmark({ name, @@ -13,7 +15,9 @@ const createRenderBenchmark = ({ description, getElement, name, runs }) => () => runs, setup, teardown, - task: () => ReactDOM.render(getElement(), node) + task: () => { + ReactDOM.render(getElement(), node); + } }); }; diff --git a/benchmarks/src/components/AppText/index.js b/benchmarks/src/components/AppText/index.js index 34d0de7e..5d5e3c23 100644 --- a/benchmarks/src/components/AppText/index.js +++ b/benchmarks/src/components/AppText/index.js @@ -1,5 +1,6 @@ +import PropTypes from 'prop-types'; import theme from '../theme'; -import React, { PropTypes, PureComponent } from 'react'; +import React, { PureComponent } from 'react'; import { StyleSheet, Text } from 'react-native'; class AppText extends PureComponent { diff --git a/benchmarks/src/components/AspectRatio/index.js b/benchmarks/src/components/AspectRatio/index.js index 5d92768b..b5a91341 100644 --- a/benchmarks/src/components/AspectRatio/index.js +++ b/benchmarks/src/components/AspectRatio/index.js @@ -1,4 +1,5 @@ -import React, { PureComponent, PropTypes } from 'react'; +import PropTypes from 'prop-types'; +import React, { PureComponent } from 'react'; import { StyleSheet, View } from 'react-native'; class AspectRatio extends PureComponent { diff --git a/benchmarks/src/components/Box/aphrodite.js b/benchmarks/src/components/Box/aphrodite.js index f7471b7e..c20db270 100644 --- a/benchmarks/src/components/Box/aphrodite.js +++ b/benchmarks/src/components/Box/aphrodite.js @@ -45,4 +45,4 @@ const styles = StyleSheet.create({ } }); -module.exports = Box; +export default Box; diff --git a/benchmarks/src/components/Box/css-modules.js b/benchmarks/src/components/Box/css-modules.js index 6c81bd0a..2c90bb24 100644 --- a/benchmarks/src/components/Box/css-modules.js +++ b/benchmarks/src/components/Box/css-modules.js @@ -14,4 +14,4 @@ const Box = ({ color, fixed = false, layout = 'column', outer = false, ...other })} />; -module.exports = Box; +export default Box; diff --git a/benchmarks/src/components/Box/glamor.js b/benchmarks/src/components/Box/glamor.js index a4fbf12e..e75c9542 100644 --- a/benchmarks/src/components/Box/glamor.js +++ b/benchmarks/src/components/Box/glamor.js @@ -44,4 +44,4 @@ const styles = { } }; -module.exports = Box; +export default Box; diff --git a/benchmarks/src/components/Box/jss.js b/benchmarks/src/components/Box/jss.js index 221e6a80..1814fe4d 100644 --- a/benchmarks/src/components/Box/jss.js +++ b/benchmarks/src/components/Box/jss.js @@ -46,4 +46,4 @@ const styles = { } }; -module.exports = injectSheet(styles)(Box); +export default injectSheet(styles)(Box); diff --git a/benchmarks/src/components/Box/react-native-stylesheet.js b/benchmarks/src/components/Box/react-native-stylesheet.js index 3a938c28..623df2a6 100644 --- a/benchmarks/src/components/Box/react-native-stylesheet.js +++ b/benchmarks/src/components/Box/react-native-stylesheet.js @@ -45,4 +45,4 @@ const styles = StyleSheet.create({ } }); -module.exports = Box; +export default Box; diff --git a/benchmarks/src/components/Box/react-native.js b/benchmarks/src/components/Box/react-native.js index 7abaac74..7f6b184d 100644 --- a/benchmarks/src/components/Box/react-native.js +++ b/benchmarks/src/components/Box/react-native.js @@ -44,4 +44,4 @@ const styles = StyleSheet.create({ } }); -module.exports = Box; +export default Box; diff --git a/benchmarks/src/components/Box/reactxp.js b/benchmarks/src/components/Box/reactxp.js index a58fecba..474c7160 100644 --- a/benchmarks/src/components/Box/reactxp.js +++ b/benchmarks/src/components/Box/reactxp.js @@ -44,4 +44,4 @@ const styles = { }) }; -module.exports = Box; +export default Box; diff --git a/benchmarks/src/components/Box/styled-components-primitives.js b/benchmarks/src/components/Box/styled-components-primitives.js index fb7a5a19..63e0ac60 100644 --- a/benchmarks/src/components/Box/styled-components-primitives.js +++ b/benchmarks/src/components/Box/styled-components-primitives.js @@ -27,4 +27,4 @@ const Box = styled.View` background-color: ${props => getColor(props.color)}; `; -module.exports = Box; +export default Box; diff --git a/benchmarks/src/components/Box/styled-components.js b/benchmarks/src/components/Box/styled-components.js index 8cce6166..b25e9e1a 100644 --- a/benchmarks/src/components/Box/styled-components.js +++ b/benchmarks/src/components/Box/styled-components.js @@ -28,4 +28,4 @@ const Box = styled(View)` background-color: ${props => getColor(props.color)}; `; -module.exports = Box; +export default Box; diff --git a/benchmarks/src/components/Box/styletron.js b/benchmarks/src/components/Box/styletron.js index 25365812..2997f3c2 100644 --- a/benchmarks/src/components/Box/styletron.js +++ b/benchmarks/src/components/Box/styletron.js @@ -45,4 +45,4 @@ const styles = { }) }; -module.exports = Box; +export default Box; diff --git a/benchmarks/src/components/GridView/index.js b/benchmarks/src/components/GridView/index.js index b84718ac..63900244 100644 --- a/benchmarks/src/components/GridView/index.js +++ b/benchmarks/src/components/GridView/index.js @@ -1,5 +1,6 @@ +import PropTypes from 'prop-types'; import { StyleSheet, View } from 'react-native'; -import React, { Component, PropTypes } from 'react'; +import React, { Component } from 'react'; import theme from '../theme'; class GridView extends Component { diff --git a/benchmarks/src/components/NestedTree/index.js b/benchmarks/src/components/NestedTree/index.js index 5ebcf416..745eacfd 100644 --- a/benchmarks/src/components/NestedTree/index.js +++ b/benchmarks/src/components/NestedTree/index.js @@ -1,4 +1,5 @@ -import React, { Component, PropTypes } from 'react'; +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; class DeepTree extends Component { static propTypes = { @@ -40,4 +41,4 @@ class DeepTree extends Component { } } -module.exports = DeepTree; +export default DeepTree; diff --git a/benchmarks/src/components/Tweet/index.js b/benchmarks/src/components/Tweet/index.js index 1c99ce71..b4d682a6 100644 --- a/benchmarks/src/components/Tweet/index.js +++ b/benchmarks/src/components/Tweet/index.js @@ -1,11 +1,12 @@ import AspectRatio from '../AspectRatio'; import GridView from '../GridView'; +import PropTypes from 'prop-types'; import TweetActionsBar from '../TweetActionsBar'; import TweetText from '../TweetText'; import UserAvatar from '../UserAvatar'; import UserNames from '../UserNames'; import { Image, StyleSheet, Text, View } from 'react-native'; -import React, { Component, PropTypes } from 'react'; +import React, { Component } from 'react'; import theme from '../theme'; export class Tweet extends Component { diff --git a/benchmarks/src/components/TweetAction/index.js b/benchmarks/src/components/TweetAction/index.js index 0cb5e4ff..16d5bf6e 100644 --- a/benchmarks/src/components/TweetAction/index.js +++ b/benchmarks/src/components/TweetAction/index.js @@ -2,9 +2,10 @@ import IconReply from '../Icons/Reply'; import IconHeart from '../Icons/Heart'; import IconRetweet from '../Icons/Retweet'; import IconDirectMessage from '../Icons/DirectMessage'; -import { Text, View, StyleSheet } from 'react-native'; -import React, { PropTypes } from 'react'; +import PropTypes from 'prop-types'; +import React from 'react'; import theme from '../theme'; +import { Text, View, StyleSheet } from 'react-native'; const getIcon = (icon, highlighted) => { switch (icon) { diff --git a/benchmarks/src/components/TweetActionsBar/index.js b/benchmarks/src/components/TweetActionsBar/index.js index 72258a91..bd5d1dd1 100644 --- a/benchmarks/src/components/TweetActionsBar/index.js +++ b/benchmarks/src/components/TweetActionsBar/index.js @@ -1,6 +1,7 @@ +import PropTypes from 'prop-types'; import TweetAction from '../TweetAction'; import { View, StyleSheet } from 'react-native'; -import React, { PropTypes, PureComponent } from 'react'; +import React, { PureComponent } from 'react'; const actionNames = ['reply', 'retweet', 'like', 'directMessage']; diff --git a/benchmarks/src/components/TweetText/index.js b/benchmarks/src/components/TweetText/index.js index 854ce4d9..2cb09b34 100644 --- a/benchmarks/src/components/TweetText/index.js +++ b/benchmarks/src/components/TweetText/index.js @@ -1,15 +1,16 @@ import AppText from '../AppText'; +import React from 'react'; import TweetTextPart from '../TweetTextPart'; -import React, { PropTypes } from 'react'; +import { array, number, string } from 'prop-types'; class TweetText extends React.Component { static displayName = 'TweetText'; static propTypes = { displayMode: TweetTextPart.propTypes.displayMode, - lang: PropTypes.string, - numberOfLines: PropTypes.number, - textParts: PropTypes.array.isRequired + lang: string, + numberOfLines: number, + textParts: array.isRequired }; render() { diff --git a/benchmarks/src/components/TweetTextPart/index.js b/benchmarks/src/components/TweetTextPart/index.js index dc66671a..d74db412 100644 --- a/benchmarks/src/components/TweetTextPart/index.js +++ b/benchmarks/src/components/TweetTextPart/index.js @@ -1,6 +1,7 @@ /* eslint-disable react/prop-types */ import { Image, StyleSheet, Text } from 'react-native'; -import React, { PropTypes } from 'react'; +import PropTypes from 'prop-types'; +import React from 'react'; import theme from '../theme'; const createTextEntity = ({ part }) => {`${part.prefix}${part.text}`}; diff --git a/benchmarks/src/components/UserAvatar/index.js b/benchmarks/src/components/UserAvatar/index.js index d35c01a9..9fd064e6 100644 --- a/benchmarks/src/components/UserAvatar/index.js +++ b/benchmarks/src/components/UserAvatar/index.js @@ -1,6 +1,7 @@ import AspectRatio from '../AspectRatio'; +import PropTypes from 'prop-types'; import { Image, StyleSheet } from 'react-native'; -import React, { PropTypes, PureComponent } from 'react'; +import React, { PureComponent } from 'react'; import theme from '../theme'; class UserAvatar extends PureComponent { diff --git a/benchmarks/src/components/UserNames/index.js b/benchmarks/src/components/UserNames/index.js index aa2306e4..a29d6c14 100644 --- a/benchmarks/src/components/UserNames/index.js +++ b/benchmarks/src/components/UserNames/index.js @@ -1,6 +1,7 @@ import AppText from '../AppText'; +import PropTypes from 'prop-types'; import { StyleSheet } from 'react-native'; -import React, { PropTypes, PureComponent } from 'react'; +import React, { PureComponent } from 'react'; class UserNames extends PureComponent { static displayName = 'UserNames'; diff --git a/benchmarks/src/components/View/aphrodite.js b/benchmarks/src/components/View/aphrodite.js index e7fc2221..905f5fe1 100644 --- a/benchmarks/src/components/View/aphrodite.js +++ b/benchmarks/src/components/View/aphrodite.js @@ -28,4 +28,4 @@ const styles = StyleSheet.create({ } }); -module.exports = View; +export default View; diff --git a/benchmarks/src/components/View/css-modules.js b/benchmarks/src/components/View/css-modules.js index 6cd767b1..f9e850c6 100644 --- a/benchmarks/src/components/View/css-modules.js +++ b/benchmarks/src/components/View/css-modules.js @@ -10,4 +10,4 @@ class View extends React.Component { } } -module.exports = View; +export default View; diff --git a/benchmarks/src/components/View/glamor.js b/benchmarks/src/components/View/glamor.js index 038a58b7..485138a5 100644 --- a/benchmarks/src/components/View/glamor.js +++ b/benchmarks/src/components/View/glamor.js @@ -26,4 +26,4 @@ const viewStyle = { minWidth: 0 }; -module.exports = View; +export default View; diff --git a/benchmarks/src/components/View/jss.js b/benchmarks/src/components/View/jss.js index 9ea7ebd0..06800d20 100644 --- a/benchmarks/src/components/View/jss.js +++ b/benchmarks/src/components/View/jss.js @@ -29,4 +29,4 @@ const styles = { } }; -module.exports = injectSheet(styles)(View); +export default injectSheet(styles)(View); diff --git a/benchmarks/src/components/View/react-native-stylesheet.js b/benchmarks/src/components/View/react-native-stylesheet.js index d934ec70..3ca32733 100644 --- a/benchmarks/src/components/View/react-native-stylesheet.js +++ b/benchmarks/src/components/View/react-native-stylesheet.js @@ -32,4 +32,4 @@ const styles = StyleSheet.create({ } }); -module.exports = View; +export default View; diff --git a/benchmarks/src/components/View/styled-components.js b/benchmarks/src/components/View/styled-components.js index bb225c9a..f0da52e9 100644 --- a/benchmarks/src/components/View/styled-components.js +++ b/benchmarks/src/components/View/styled-components.js @@ -16,4 +16,4 @@ const View = styled.div` min-width: 0; `; -module.exports = View; +export default View; diff --git a/benchmarks/src/components/theme.js b/benchmarks/src/components/theme.js index 219d2cc5..9202bbd7 100644 --- a/benchmarks/src/components/theme.js +++ b/benchmarks/src/components/theme.js @@ -23,7 +23,7 @@ const fontSize = { large: '1.25rem' }; -module.exports = { +const theme = { colors, fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", sans-serif, ' + @@ -36,3 +36,5 @@ module.exports = { return `${num}${unit}`; } }; + +export default theme; diff --git a/benchmarks/src/css-modules.js b/benchmarks/src/css-modules.js index 8985ccf6..fc62f9ad 100644 --- a/benchmarks/src/css-modules.js +++ b/benchmarks/src/css-modules.js @@ -1,7 +1,9 @@ import Box from './components/Box/css-modules'; import View from './components/View/css-modules'; -export default { +const api = { Box, View }; + +export default api; diff --git a/benchmarks/src/jss.js b/benchmarks/src/jss.js index 8fc4206c..83867ad8 100644 --- a/benchmarks/src/jss.js +++ b/benchmarks/src/jss.js @@ -1,7 +1,9 @@ import Box from './components/Box/jss'; import View from './components/View/jss'; -export default { +const api = { Box, View }; + +export default api; diff --git a/benchmarks/src/react-native-stylesheet.js b/benchmarks/src/react-native-stylesheet.js index 5ce22637..f5da1099 100644 --- a/benchmarks/src/react-native-stylesheet.js +++ b/benchmarks/src/react-native-stylesheet.js @@ -1,7 +1,9 @@ import Box from './components/Box/react-native-stylesheet'; import View from './components/View/react-native-stylesheet'; -export default { +const api = { Box, View }; + +export default api; diff --git a/benchmarks/tests/renderTweet.js b/benchmarks/tests/renderTweet.js index cc125e5a..3243430a 100644 --- a/benchmarks/tests/renderTweet.js +++ b/benchmarks/tests/renderTweet.js @@ -96,7 +96,7 @@ const tweet2 = { } }; -const renderTweet = (label, components) => +const renderTweet = label => createRenderBenchmark({ name: `Tweet [${label}]`, runs: 10, diff --git a/package.json b/package.json index 1fe64e86..a1b81f0b 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "jest": "jest", "jest:watch": "yarn test -- --watch", "lint": "yarn lint:cmd -- benchmarks docs src", - "lint:cmd": "eslint --fix --ignore-path .gitignore", + "lint:cmd": "eslint --ignore-path .gitignore --fix", "precommit": "lint-staged", "release": "yarn lint && yarn test && yarn compile && yarn build && npm publish", "test": "flow && jest" diff --git a/yarn.lock b/yarn.lock index ff836987..64aa6acf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2053,7 +2053,7 @@ default-require-extensions@^1.0.0: dependencies: strip-bom "^2.0.0" -define-properties@^1.1.1, define-properties@^1.1.2: +define-properties@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94" dependencies: @@ -2307,7 +2307,7 @@ error-ex@^1.2.0: dependencies: is-arrayish "^0.2.1" -es-abstract@^1.3.2, es-abstract@^1.4.3, es-abstract@^1.5.0, es-abstract@^1.5.1, es-abstract@^1.6.1: +es-abstract@^1.4.3, es-abstract@^1.5.0, es-abstract@^1.5.1, es-abstract@^1.6.1: version "1.7.0" resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.7.0.tgz#dfade774e01bfcd97f96180298c449c8623fb94c" dependencies: @@ -4665,16 +4665,7 @@ object.assign@^4.0.4: function-bind "^1.1.0" object-keys "^1.0.10" -object.entries@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/object.entries/-/object.entries-1.0.3.tgz#f42cc75363a4f9aa7037bcfb3bab3be4ffc78027" - dependencies: - define-properties "^1.1.1" - es-abstract "^1.3.2" - function-bind "^1.0.2" - has "^1.0.1" - -object.entries@^1.0.4: +object.entries@^1.0.3, object.entries@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/object.entries/-/object.entries-1.0.4.tgz#1bf9a4dd2288f5b33f3a993d257661f05d161a5f" dependencies: @@ -4697,16 +4688,7 @@ object.omit@^2.0.0: for-own "^0.1.4" is-extendable "^0.1.1" -object.values@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.0.3.tgz#a7774ba050893fe6a5d5958acd05823e0f426bef" - dependencies: - define-properties "^1.1.1" - es-abstract "^1.3.2" - function-bind "^1.0.2" - has "^1.0.1" - -object.values@^1.0.4: +object.values@^1.0.3, object.values@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.0.4.tgz#e524da09b4f66ff05df457546ec72ac99f13069a" dependencies: @@ -6448,11 +6430,7 @@ uuid@^2.0.1, uuid@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.3.tgz#67e2e863797215530dff318e5bf9dcebfd47b21a" -uuid@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.0.tgz#6728fc0459c450d796a99c31837569bdf672d728" - -uuid@^3.0.1: +uuid@^3.0.0, uuid@^3.0.1: version "3.1.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04"