diff --git a/.prettierignore b/.prettierignore index 81cc5d99..fc8b2194 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,4 +2,4 @@ coverage dist node_modules packages/**/vendor/* -packages/examples +packages/examples/.next diff --git a/babel.config.js b/babel.config.js index 0b310a53..a1b505c2 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,4 +1,4 @@ -module.exports = function(api) { +module.exports = function (api) { api.cache(true); return { diff --git a/package.json b/package.json index 88c5154b..2e595862 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "jest-canvas-mock": "^2.3.1", "lint-staged": "^9.4.2", "npm-run-all": "^4.1.3", - "prettier": "^1.18.2", + "prettier": "^2.2.1", "react": "^17.0.1", "react-dom": "^17.0.1", "react-test-renderer": "^17.0.1" @@ -82,7 +82,8 @@ }, "prettier": { "printWidth": 100, - "singleQuote": true + "singleQuote": true, + "trailingComma": "none" }, "author": "Nicolas Gallagher", "license": "MIT" diff --git a/packages/babel-plugin-react-native-web/src/index.js b/packages/babel-plugin-react-native-web/src/index.js index e5199ee2..a501b6a9 100644 --- a/packages/babel-plugin-react-native-web/src/index.js +++ b/packages/babel-plugin-react-native-web/src/index.js @@ -1,6 +1,6 @@ const moduleMap = require('./moduleMap'); -const isCommonJS = opts => opts.commonjs === true; +const isCommonJS = (opts) => opts.commonjs === true; const getDistLocation = (importName, opts) => { const format = isCommonJS(opts) ? 'cjs/' : ''; @@ -33,7 +33,7 @@ const isReactNativeModule = ({ source, specifiers }) => (source.value === 'react-native' || source.value === 'react-native-web') && specifiers.length; -module.exports = function({ types: t }) { +module.exports = function ({ types: t }) { return { name: 'Rewrite react-native to react-native-web', visitor: { @@ -41,7 +41,7 @@ module.exports = function({ types: t }) { const { specifiers } = path.node; if (isReactNativeModule(path.node)) { const imports = specifiers - .map(specifier => { + .map((specifier) => { if (t.isImportSpecifier(specifier)) { const importName = specifier.imported.name; const distLocation = getDistLocation(importName, state.opts); @@ -67,7 +67,7 @@ module.exports = function({ types: t }) { const { specifiers } = path.node; if (isReactNativeModule(path.node)) { const exports = specifiers - .map(specifier => { + .map((specifier) => { if (t.isExportSpecifier(specifier)) { const exportName = specifier.exported.name; const localName = specifier.local.name; @@ -97,7 +97,7 @@ module.exports = function({ types: t }) { const { id } = path.node.declarations[0]; if (t.isObjectPattern(id)) { const imports = id.properties - .map(identifier => { + .map((identifier) => { const distLocation = getDistLocation(identifier.key.name, state.opts); if (distLocation) { return t.variableDeclaration(path.node.kind, [ diff --git a/packages/benchmarks/src/app/App.js b/packages/benchmarks/src/app/App.js index 90308caa..4af15943 100644 --- a/packages/benchmarks/src/app/App.js +++ b/packages/benchmarks/src/app/App.js @@ -45,7 +45,7 @@ export default class App extends Component { selectedValue={currentLibraryName} style={styles.picker} > - {Object.keys(tests[currentBenchmarkName]).map(libraryName => ( + {Object.keys(tests[currentBenchmarkName]).map((libraryName) => ( ))} @@ -60,7 +60,7 @@ export default class App extends Component { selectedValue={currentBenchmarkName} style={styles.picker} > - {Object.keys(tests).map(test => ( + {Object.keys(tests).map((test) => ( ))} @@ -156,11 +156,11 @@ export default class App extends Component { ); } - _handleChangeBenchmark = value => { + _handleChangeBenchmark = (value) => { this.setState(() => ({ currentBenchmarkName: value })); }; - _handleChangeLibrary = value => { + _handleChangeLibrary = (value) => { this.setState(() => ({ currentLibraryName: value })); }; @@ -187,9 +187,9 @@ export default class App extends Component { } }; - _createHandleComplete = ({ benchmarkName, libraryName, sampleCount }) => results => { + _createHandleComplete = ({ benchmarkName, libraryName, sampleCount }) => (results) => { this.setState( - state => ({ + (state) => ({ results: state.results.concat([ { ...results, @@ -210,15 +210,15 @@ export default class App extends Component { this.setState(() => ({ results: [] })); }; - _setBenchRef = ref => { + _setBenchRef = (ref) => { this._benchmarkRef = ref; }; - _setBenchWrapperRef = ref => { + _setBenchWrapperRef = (ref) => { this._benchWrapperRef = ref; }; - _setScrollRef = ref => { + _setScrollRef = (ref) => { this._scrollRef = ref; }; diff --git a/packages/benchmarks/src/app/Benchmark/index.js b/packages/benchmarks/src/app/Benchmark/index.js index ced2d228..1abe72ff 100644 --- a/packages/benchmarks/src/app/Benchmark/index.js +++ b/packages/benchmarks/src/app/Benchmark/index.js @@ -119,7 +119,7 @@ export default class Benchmark extends Component ({ componentProps: nextProps.getComponentProps(state.cycle) })); + this.setState((state) => ({ componentProps: nextProps.getComponentProps(state.cycle) })); } } diff --git a/packages/benchmarks/src/app/Icons.js b/packages/benchmarks/src/app/Icons.js index 05b66406..a5fb9e99 100644 --- a/packages/benchmarks/src/app/Icons.js +++ b/packages/benchmarks/src/app/Icons.js @@ -13,15 +13,12 @@ const styles = StyleSheet.create({ } }); -const createIcon = children => { - const Icon = props => +const createIcon = (children) => { + const Icon = (props) => createElement( 'svg', { - style: StyleSheet.compose( - styles.root, - props.style - ), + style: StyleSheet.compose(styles.root, props.style), width: 24, height: 24, viewBox: '0 0 24 24' diff --git a/packages/benchmarks/src/app/theme.js b/packages/benchmarks/src/app/theme.js index fb21b72a..f1b7416a 100644 --- a/packages/benchmarks/src/app/theme.js +++ b/packages/benchmarks/src/app/theme.js @@ -4,7 +4,7 @@ import { Dimensions, Platform } from 'react-native'; const baseFontSize = 14; const baseUnit = 1.3125; -const createPlatformLength = multiplier => +const createPlatformLength = (multiplier) => Platform.select({ web: `${multiplier}rem`, default: multiplier * baseFontSize }); /** @@ -87,7 +87,7 @@ export const spaces = { if (Platform.OS === 'web' && canUseDOM) { const { medium, large } = breakpoints; const htmlElement = document.documentElement; - const setFontSize = width => { + const setFontSize = (width) => { const fontSize = width > medium ? (width > large ? '18px' : '17px') : '16px'; if (htmlElement) { htmlElement.style.fontSize = fontSize; @@ -95,7 +95,7 @@ if (Platform.OS === 'web' && canUseDOM) { }; setFontSize(Dimensions.get('window').width); - Dimensions.addEventListener('change', dimensions => { + Dimensions.addEventListener('change', (dimensions) => { setFontSize(dimensions.window.width); }); } diff --git a/packages/benchmarks/src/impl.js b/packages/benchmarks/src/impl.js index 36f367f0..b926c25f 100644 --- a/packages/benchmarks/src/impl.js +++ b/packages/benchmarks/src/impl.js @@ -21,7 +21,7 @@ type ImplementationType = { }; const toImplementations = (context: Object): Array => - context.keys().map(path => { + context.keys().map((path) => { const components = context(path).default; const name = path.split('/')[1]; const version = dependencies[name] || ''; diff --git a/packages/benchmarks/src/implementations/inline-styles/View.js b/packages/benchmarks/src/implementations/inline-styles/View.js index 8b676e65..96ff0dba 100644 --- a/packages/benchmarks/src/implementations/inline-styles/View.js +++ b/packages/benchmarks/src/implementations/inline-styles/View.js @@ -11,15 +11,7 @@ const compose = (s1, s2) => { class View extends React.Component { render() { const { style, ...other } = this.props; - return ( -
- ); + return
; } } diff --git a/packages/benchmarks/src/implementations/styled-components/Box.js b/packages/benchmarks/src/implementations/styled-components/Box.js index 07ce5f29..97300fca 100644 --- a/packages/benchmarks/src/implementations/styled-components/Box.js +++ b/packages/benchmarks/src/implementations/styled-components/Box.js @@ -1,7 +1,7 @@ import styled from 'styled-components'; import View from './View'; -const getColor = color => { +const getColor = (color) => { switch (color) { case 0: return '#14171A'; @@ -22,10 +22,10 @@ const getColor = color => { const Box = styled(View)` align-self: flex-start; - flex-direction: ${props => (props.layout === 'column' ? 'column' : 'row')}; - padding: ${props => (props.outer ? '4px' : '0')}; - ${props => props.fixed && 'height:6px;'} ${props => - props.fixed && 'width:6px;'} background-color: ${props => getColor(props.color)}; + flex-direction: ${(props) => (props.layout === 'column' ? 'column' : 'row')}; + padding: ${(props) => (props.outer ? '4px' : '0')}; + ${(props) => props.fixed && 'height:6px;'} ${(props) => + props.fixed && 'width:6px;'} background-color: ${(props) => getColor(props.color)}; `; export default Box; diff --git a/packages/benchmarks/src/implementations/styled-components/Dot.js b/packages/benchmarks/src/implementations/styled-components/Dot.js index 41546759..108a0cc1 100644 --- a/packages/benchmarks/src/implementations/styled-components/Dot.js +++ b/packages/benchmarks/src/implementations/styled-components/Dot.js @@ -1,7 +1,7 @@ import styled from 'styled-components'; import View from './View'; -const Dot = styled(View).attrs(props => ({ +const Dot = styled(View).attrs((props) => ({ style: { marginLeft: `${props.x}px`, marginTop: `${props.y}px`, diff --git a/packages/benchmarks/src/implementations/styled-jsx/Box.js b/packages/benchmarks/src/implementations/styled-jsx/Box.js index c999195e..3da0f041 100644 --- a/packages/benchmarks/src/implementations/styled-jsx/Box.js +++ b/packages/benchmarks/src/implementations/styled-jsx/Box.js @@ -2,7 +2,7 @@ import classnames from 'classnames'; import React from 'react'; import View from './View'; -const getColor = color => { +const getColor = (color) => { switch (color) { case 0: return '#14171A'; @@ -21,7 +21,7 @@ const getColor = color => { } }; -const Box = props => { +const Box = (props) => { const { className, children: styles } = (