diff --git a/.eslintrc b/.eslintrc index 3f354a7..9e021c5 100644 --- a/.eslintrc +++ b/.eslintrc @@ -6,13 +6,10 @@ "sourceType": "module", "ecmaFeatures": { "jsx": true, - "modules": true, - "experimentalObjectRestSpread": true + "modules": true } }, - "plugins": [ - "react" - ], + "plugins": ["react"], "env": { "node": true, @@ -22,7 +19,7 @@ "rules": { "no-console": 0, - "comma-dangle": 0, + "comma-dangle": ["error", "always-multiline"], "no-unused-vars": ["error", { "ignoreRestSiblings": true }], "react/prop-types": 0, "react/no-did-mount-set-state": 0, diff --git a/__mocks__/react-native.js b/__mocks__/react-native.js index a49cb68..45870fa 100644 --- a/__mocks__/react-native.js +++ b/__mocks__/react-native.js @@ -4,7 +4,7 @@ const ReactNative = React; ReactNative.StyleSheet = { create: function create(styles) { return styles; - } + }, }; class View extends React.Component { @@ -12,7 +12,7 @@ class View extends React.Component { } View.propTypes = { - style: () => null + style: () => null, }; class ListView extends React.Component { @@ -28,7 +28,7 @@ class AppRegistry { const Animated = { timing: () => ({ start: () => undefined }), Value: () => ({ interpolate: () => false }), - View: View + View: View, }; const I18nManager = { diff --git a/__tests__/Menu-test.js b/__tests__/Menu-test.js index c93a34c..679e30f 100644 --- a/__tests__/Menu-test.js +++ b/__tests__/Menu-test.js @@ -32,7 +32,7 @@ describe('Menu', () => { }, menuActions: { _notify: createSpy(), - } + }, } } @@ -64,8 +64,8 @@ describe('Menu', () => { expect(output.props.children[1]).toEqual(objectContaining({ type: MenuTrigger, props: objectContaining({ - onRef: any(Function) - }) + onRef: any(Function), + }), })); expect(output.props.children[2]).toEqual(expectedChildren[3]); }); @@ -99,7 +99,7 @@ describe('Menu', () => { ]); expect(output.props.children[0]).toEqual( objectContaining({ - type: MenuTrigger + type: MenuTrigger, }) ); expect(output.props.children[1]).toEqual(expectedChildren[1]); diff --git a/__tests__/MenuOption-test.js b/__tests__/MenuOption-test.js index 91ff84e..bbb8f95 100644 --- a/__tests__/MenuOption-test.js +++ b/__tests__/MenuOption-test.js @@ -13,7 +13,7 @@ describe('MenuOption', () => { menuActions: { _getOpenedMenu: () => ({ optionsCustomStyles: optionsCustomStyles || {}, - instance: { props: { onSelect: onSelect } } + instance: { props: { onSelect: onSelect } }, }), closeMenu: closeMenu || createSpy(), }, diff --git a/__tests__/MenuOptions-test.js b/__tests__/MenuOptions-test.js index 3ccf5bd..24681fb 100644 --- a/__tests__/MenuOptions-test.js +++ b/__tests__/MenuOptions-test.js @@ -12,7 +12,7 @@ describe('MenuOptions', () => { return { menuActions: { _getOpenedMenu: () => ({ - instance: { getName: () => 'menu1' } + instance: { getName: () => 'menu1' }, }), }, menuRegistry: { diff --git a/__tests__/MenuProvider-test.js b/__tests__/MenuProvider-test.js index 93e79fc..af32bf3 100644 --- a/__tests__/MenuProvider-test.js +++ b/__tests__/MenuProvider-test.js @@ -18,8 +18,8 @@ jest.mock('../src/helpers', () => ({ x: 0, y: 0, width: 100, - height: 50 - }) + height: 50, + }), }), lo: x => x, iterator2array: it => [...it], @@ -53,9 +53,9 @@ describe('MenuProvider', () => { nativeEvent: { layout: { width: 400, - height: 600 - } - } + height: 600, + }, + }, }; let menu1; @@ -128,7 +128,7 @@ describe('MenuProvider', () => { expect(placeholder.type).toEqual(MenuPlaceholder); expect(components.props.children).toEqual([ , - Some text + Some text, ]); }); @@ -227,16 +227,16 @@ describe('MenuProvider', () => { nativeEvent: { layout: { width: 22, - height: 33 - } - } + height: 33, + }, + }, }); expect(menuRegistry.getMenu('menu1')).toEqual(objectContaining({ optionsLayout: { width: 22, isOutside: true, - height: 33 - } + height: 33, + }, })); }); }); diff --git a/__tests__/helpers-test.js b/__tests__/helpers-test.js index b7214d0..386d8e4 100644 --- a/__tests__/helpers-test.js +++ b/__tests__/helpers-test.js @@ -23,12 +23,12 @@ describe('helpers test', () => { it('should promisify measure callback', done => { const ref = { - measure: callback => callback(0, 0, 100, 200, 50, 20) + measure: callback => callback(0, 0, 100, 200, 50, 20), }; measure(ref).then(layout => { expect(layout).to.be.an('object'); expect(layout).to.eql({ - x: 50, y: 20, width: 100, height: 200 + x: 50, y: 20, width: 100, height: 200, }); done(); }).catch((err = 'promise rejected') => done(err)); diff --git a/__tests__/helpers.js b/__tests__/helpers.js index b26c88f..644e5a4 100644 --- a/__tests__/helpers.js +++ b/__tests__/helpers.js @@ -41,7 +41,7 @@ Creates a mock of react instance */ export function mockReactInstance() { const instance = { - state: {} + state: {}, }; instance.setState = (newState, after) => { Object.assign(instance.state, newState); diff --git a/__tests__/menuRegistry-test.js b/__tests__/menuRegistry-test.js index e69642e..2110ea8 100644 --- a/__tests__/menuRegistry-test.js +++ b/__tests__/menuRegistry-test.js @@ -24,7 +24,7 @@ describe('menuRegistry tests', () => { describe('getMenu', () => { it('should return menu', () => { const menus = new Map([ - ['menu1', {instance: menu1}] + ['menu1', {instance: menu1}], ]); const registry = makeMenuRegistry(menus); expect(registry.getMenu('menu1').instance).to.eql(menu1); @@ -43,7 +43,7 @@ describe('menuRegistry tests', () => { it('should unsubscribe menu', () => { const menus = new Map([ ['menu1', {name:'menu1', instance: menu1}], - ['menu2', {name:'menu2', instance: menu2}] + ['menu2', {name:'menu2', instance: menu2}], ]); const registry = makeMenuRegistry(menus); registry.unsubscribe(menu1); @@ -109,7 +109,7 @@ describe('menuRegistry tests', () => { it('should return all registered menus with its associated data', () => { const menus = new Map([ ['menu1', {name: 'menu1', instance: menu1}], - ['menu2', {name: 'menu2', instance: menu2, triggerLayout: 5}] + ['menu2', {name: 'menu2', instance: menu2, triggerLayout: 5}], ]); const registry = makeMenuRegistry(menus); const allMenus = registry.getAll(); diff --git a/__tests__/renderers/ContextMenu-test.js b/__tests__/renderers/ContextMenu-test.js index 6b83a78..ea9caa4 100644 --- a/__tests__/renderers/ContextMenu-test.js +++ b/__tests__/renderers/ContextMenu-test.js @@ -25,7 +25,7 @@ describe('ContextMenu', () => { expect(output.type).toEqual(Animated.View); expect(output.props.children).toEqual([ Some text, - Other text + Other text, ]); }); }); @@ -40,7 +40,7 @@ describe('ContextMenu', () => { const optionsLayout = { width: 50, height: 50 }; const layouts = { windowLayout, triggerLayout, optionsLayout }; expect(computePosition(layouts)).toEqual({ - top: 100, left: 100 + top: 100, left: 100, }); }); @@ -49,7 +49,7 @@ describe('ContextMenu', () => { const optionsLayout = { width: 50, height: 50 }; const layouts = { windowLayout, triggerLayout, optionsLayout }; expect(computePosition(layouts)).toEqual({ - top: 10, left: 10 + top: 10, left: 10, }); }); @@ -58,7 +58,7 @@ describe('ContextMenu', () => { const optionsLayout = { width: 150, height: 100 }; const layouts = { windowLayout, triggerLayout, optionsLayout }; expect(computePosition(layouts)).toEqual({ - top: 0, left: 250 + top: 0, left: 250, }); }); @@ -67,7 +67,7 @@ describe('ContextMenu', () => { const optionsLayout = { width: 150, height: 150 }; const layouts = { windowLayout, triggerLayout, optionsLayout }; expect(computePosition(layouts)).toEqual({ - top: 450, left: 10 + top: 450, left: 10, }); }); @@ -76,7 +76,7 @@ describe('ContextMenu', () => { const optionsLayout = { width: 150, height: 150 }; const layouts = { windowLayout, triggerLayout, optionsLayout }; expect(computePosition(layouts)).toEqual({ - top: 450, left: 250 + top: 450, left: 250, }); }); @@ -85,7 +85,7 @@ describe('ContextMenu', () => { const optionsLayout = { width: 150, height: 500 }; const layouts = { windowLayout, triggerLayout, optionsLayout }; expect(computePosition(layouts)).toEqual({ - top: 50, left: 10 + top: 50, left: 10, }); }); @@ -94,7 +94,7 @@ describe('ContextMenu', () => { const optionsLayout = { width: 300, height: 100 }; const layouts = { windowLayout, triggerLayout, optionsLayout }; expect(computePosition(layouts)).toEqual({ - top: 10, left: 50 + top: 10, left: 50, }); }); @@ -103,7 +103,7 @@ describe('ContextMenu', () => { const optionsLayout = { width: 150, height: 700 }; const layouts = { windowLayout, triggerLayout, optionsLayout }; expect(computePosition(layouts)).toEqual({ - top: 0, left: 10 + top: 0, left: 10, }); }); @@ -112,7 +112,7 @@ describe('ContextMenu', () => { const optionsLayout = { width: 500, height: 100 }; const layouts = { windowLayout, triggerLayout, optionsLayout }; expect(computePosition(layouts)).toEqual({ - top: 10, left: 0 + top: 10, left: 0, }); }); @@ -121,7 +121,7 @@ describe('ContextMenu', () => { const optionsLayout = { width: 150, height: 500 }; const layouts = { windowLayout, triggerLayout, optionsLayout }; expect(computePosition(layouts)).toEqual({ - top: 0, left: 10 + top: 0, left: 10, }); }); @@ -130,7 +130,7 @@ describe('ContextMenu', () => { const optionsLayout = { width: 150, height: 500 }; const layouts = { windowLayout, triggerLayout, optionsLayout }; expect(computePosition(layouts)).toEqual({ - top: 100, left: 10 + top: 100, left: 10, }); }); @@ -139,7 +139,7 @@ describe('ContextMenu', () => { const optionsLayout = { width: 350, height: 50 }; const layouts = { windowLayout, triggerLayout, optionsLayout }; expect(computePosition(layouts)).toEqual({ - top: 10, left: 0 + top: 10, left: 0, }); }); @@ -149,7 +149,7 @@ describe('ContextMenu', () => { const optionsLayout = { width: 50, height: 50 }; const layouts = { windowLayout, triggerLayout, optionsLayout }; expect(computePosition(layouts)).toEqual({ - top: 70, left: 80 + top: 70, left: 80, }); }); diff --git a/__tests__/renderers/MenuOutside-test.js b/__tests__/renderers/MenuOutside-test.js index 15f5da7..edb6dcc 100644 --- a/__tests__/renderers/MenuOutside-test.js +++ b/__tests__/renderers/MenuOutside-test.js @@ -24,7 +24,7 @@ describe('MenuOutside', () => { expect(output.type).toEqual(View); expect(output.props.children).toEqual([ Some text, - Other text + Other text, ]); }); }); @@ -34,7 +34,7 @@ describe('MenuOutside', () => { const windowLayout = { width: 400, height: 600 }; const layouts = { windowLayout }; expect(computePosition(layouts)).toEqual({ - top: 600, left: 400 + top: 600, left: 400, }); }); }); diff --git a/__tests__/renderers/NotAnimatedContextMenu-test.js b/__tests__/renderers/NotAnimatedContextMenu-test.js index 553adc1..65a9920 100644 --- a/__tests__/renderers/NotAnimatedContextMenu-test.js +++ b/__tests__/renderers/NotAnimatedContextMenu-test.js @@ -24,7 +24,7 @@ describe('NotAnimatedContextMenu', () => { expect(output.type).toEqual(View); expect(output.props.children).toEqual([ Some text, - Other text + Other text, ]); }); }); diff --git a/__tests__/renderers/Popover-test.js b/__tests__/renderers/Popover-test.js index 2b233b2..f30dacf 100644 --- a/__tests__/renderers/Popover-test.js +++ b/__tests__/renderers/Popover-test.js @@ -28,7 +28,7 @@ describe('Popover', () => { expect(content.type).toEqual(View); expect(content.props.children).toEqual([ Some text, - Other text + Other text, ]); }); }); diff --git a/__tests__/renderers/SlideInMenu-test.js b/__tests__/renderers/SlideInMenu-test.js index b15f5f0..4db3963 100644 --- a/__tests__/renderers/SlideInMenu-test.js +++ b/__tests__/renderers/SlideInMenu-test.js @@ -22,7 +22,7 @@ describe('SlideInMenu', () => { expect(output.type).toEqual(Animated.View); expect(output.props.children).toEqual([ Some text, - Other text + Other text, ]); }); @@ -32,7 +32,7 @@ describe('SlideInMenu', () => { const optionsLayout = { width: 400, height: 100 }; const layouts = { windowLayout, optionsLayout }; expect(computePosition(layouts)).toEqual({ - top: 500, left: 0 + top: 500, left: 0, }); }); }); diff --git a/examples/BasicExample.js b/examples/BasicExample.js index fc3a6e9..698d492 100644 --- a/examples/BasicExample.js +++ b/examples/BasicExample.js @@ -5,7 +5,7 @@ import { MenuProvider, MenuOptions, MenuOption, - MenuTrigger + MenuTrigger, } from 'react-native-popup-menu'; const BasicExample = () => ( diff --git a/examples/CloseOnBackExample.js b/examples/CloseOnBackExample.js index e224165..763a4ea 100644 --- a/examples/CloseOnBackExample.js +++ b/examples/CloseOnBackExample.js @@ -5,7 +5,7 @@ import { MenuProvider, MenuOptions, MenuOption, - MenuTrigger + MenuTrigger, } from 'react-native-popup-menu'; class CloseOnBackExample extends Component { diff --git a/examples/ControlledExample.js b/examples/ControlledExample.js index 33338f5..0101b76 100644 --- a/examples/ControlledExample.js +++ b/examples/ControlledExample.js @@ -4,7 +4,7 @@ import Menu, { MenuProvider, MenuOptions, MenuOption, - MenuTrigger + MenuTrigger, } from 'react-native-popup-menu'; export default class ControlledExample extends Component { diff --git a/examples/Example.js b/examples/Example.js index 9b746f7..1d9a9e7 100644 --- a/examples/Example.js +++ b/examples/Example.js @@ -5,7 +5,7 @@ import Menu, { MenuTrigger, MenuOptions, MenuOption, - renderers + renderers, } from 'react-native-popup-menu'; let unique = 0; @@ -32,8 +32,8 @@ export default class Example extends Component { this.setState({ log: [...this.state.log, { value, - id: ++unique - }] + id: ++unique, + }], }); } @@ -142,7 +142,7 @@ const styles = StyleSheet.create({ marginVertical: 5, marginHorizontal: 2, borderBottomWidth: 1, - borderColor: '#ccc' + borderColor: '#ccc', }, logView: { flex: 1, @@ -157,5 +157,5 @@ const styles = StyleSheet.create({ }, text: { fontSize: 18, - } + }, }); diff --git a/examples/ModalExample.js b/examples/ModalExample.js index 209b6ef..1ce68ad 100644 --- a/examples/ModalExample.js +++ b/examples/ModalExample.js @@ -4,7 +4,7 @@ import Menu, { MenuProvider, MenuOptions, MenuOption, - MenuTrigger + MenuTrigger, } from 'react-native-popup-menu'; class ModalExample extends Component { diff --git a/examples/NavigatorExample.js b/examples/NavigatorExample.js index aa84bab..e5fa28a 100644 --- a/examples/NavigatorExample.js +++ b/examples/NavigatorExample.js @@ -1,10 +1,10 @@ import React from 'react'; -import { Text, View, } from 'react-native'; +import { Text, View } from 'react-native'; import Menu, { MenuProvider, MenuOptions, MenuOption, - MenuTrigger + MenuTrigger, } from 'react-native-popup-menu'; import {Scene, Router, Actions} from 'react-native-router-flux'; diff --git a/examples/NonRootExample.js b/examples/NonRootExample.js index 33494e6..132c6ed 100644 --- a/examples/NonRootExample.js +++ b/examples/NonRootExample.js @@ -4,7 +4,7 @@ import Menu, { MenuProvider, MenuOptions, MenuOption, - MenuTrigger + MenuTrigger, } from 'react-native-popup-menu'; const NonRootExample = () => ( diff --git a/examples/TouchableExample.js b/examples/TouchableExample.js index e919a69..fea74ef 100644 --- a/examples/TouchableExample.js +++ b/examples/TouchableExample.js @@ -16,7 +16,7 @@ class TouchableExample extends React.Component { constructor(props) { super(props); this.state = { - Touchable: Button + Touchable: Button, }; } @@ -30,7 +30,7 @@ class TouchableExample extends React.Component { @@ -54,7 +54,7 @@ class TouchableExample extends React.Component { /> @@ -65,7 +65,7 @@ class TouchableExample extends React.Component { diff --git a/setup-jasmine-env.js b/setup-jasmine-env.js index 55f8e8c..0af8b87 100644 --- a/setup-jasmine-env.js +++ b/setup-jasmine-env.js @@ -7,6 +7,6 @@ require('jasmine-reporters'); const reporters = require('jasmine-reporters'); const junitReporter = new reporters.JUnitXmlReporter({ savePath: __dirname + '/target/', - consolidateAll: false + consolidateAll: false, }); jasmine.getEnv().addReporter(junitReporter); diff --git a/src/Menu.js b/src/Menu.js index 9da29e2..27f58f4 100644 --- a/src/Menu.js +++ b/src/Menu.js @@ -79,7 +79,7 @@ export class Menu extends Component { r.push(React.cloneElement(child, { key: null, menuName: this._name, - onRef: (t => this._trigger = t) + onRef: (t => this._trigger = t), })); } if (isRegularComponent(child)) { diff --git a/src/MenuPlaceholder.js b/src/MenuPlaceholder.js index c989f1c..5f19d8f 100644 --- a/src/MenuPlaceholder.js +++ b/src/MenuPlaceholder.js @@ -43,5 +43,5 @@ const styles = StyleSheet.create({ left: 0, right: 0, bottom: 0, - } + }, }); diff --git a/src/helpers.js b/src/helpers.js index a0e50cd..0294947 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -8,7 +8,7 @@ export const measure = ref => new Promise((resolve) => { ref.measure((x, y, width, height, pageX, pageY) => { resolve({ x: pageX, y: pageY, - width, height + width, height, }) }); }); diff --git a/src/renderers/ContextMenu.js b/src/renderers/ContextMenu.js index 28ebe32..8aa5fdb 100644 --- a/src/renderers/ContextMenu.js +++ b/src/renderers/ContextMenu.js @@ -53,7 +53,7 @@ export default class ContextMenu extends React.Component { duration: OPEN_ANIM_DURATION, toValue: 1, easing: Easing.out(Easing.cubic), - useNativeDriver: true + useNativeDriver: true, }).start(); } @@ -63,7 +63,7 @@ export default class ContextMenu extends React.Component { duration: CLOSE_ANIM_DURATION, toValue: 0, easing: Easing.in(Easing.cubic), - useNativeDriver: true + useNativeDriver: true, }).start(resolve); }); } diff --git a/src/renderers/MenuOutside.js b/src/renderers/MenuOutside.js index 5e38ed0..865ca96 100644 --- a/src/renderers/MenuOutside.js +++ b/src/renderers/MenuOutside.js @@ -3,7 +3,7 @@ import { View, StyleSheet } from 'react-native'; export const computePosition = ({ windowLayout }) => ({ top: windowLayout.height, - left: windowLayout.width + left: windowLayout.width, }); diff --git a/src/renderers/Popover.js b/src/renderers/Popover.js index 811cd0c..10d9fc0 100644 --- a/src/renderers/Popover.js +++ b/src/renderers/Popover.js @@ -235,7 +235,7 @@ export default class Popover extends React.Component { anchorStyle, preferredPlacement, placement: userPlacement, - ...other, + ...other } = this.props; const isRTL = I18nManager.isRTL; const animation = { diff --git a/src/renderers/SlideInMenu.js b/src/renderers/SlideInMenu.js index ba10ecc..ab715d4 100644 --- a/src/renderers/SlideInMenu.js +++ b/src/renderers/SlideInMenu.js @@ -24,7 +24,7 @@ export default class SlideInMenu extends React.Component { duration: OPEN_ANIM_DURATION, toValue: 1, easing: Easing.out(Easing.cubic), - useNativeDriver: true + useNativeDriver: true, }).start(); } @@ -34,7 +34,7 @@ export default class SlideInMenu extends React.Component { duration: CLOSE_ANIM_DURATION, toValue: 0, easing: Easing.in(Easing.cubic), - useNativeDriver: true + useNativeDriver: true, }).start(resolve); }); } @@ -47,9 +47,9 @@ export default class SlideInMenu extends React.Component { transform: [{ translateY: this.state.slide.interpolate({ inputRange: [0, 1], - outputRange: [oHeight, 0] + outputRange: [oHeight, 0], }), - }] + }], }; const position = computePosition(layouts); return ( diff --git a/src/with-context.js b/src/with-context.js index 0dd5a38..642fecb 100644 --- a/src/with-context.js +++ b/src/with-context.js @@ -11,7 +11,7 @@ export function withContext(Context, propName = "context") { {value => { const custom = { [propName]: value, - ref: forwardedRef + ref: forwardedRef, }; return ; }}