Skip to content

Add Eslint and Prettier #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
extends: ['@react-native-community'],
rules: {
semi: 0,
},
}
7 changes: 7 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
bracketSpacing: false,
jsxBracketSameLine: true,
singleQuote: true,
trailingComma: 'all',
semi: false,
};
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"prepare":"yarn build",
"build": "yarn tsc",
"release": "release-it",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint src/**/*.ts"
},
"author": "Nader Dabit",
"license": "ISC",
Expand All @@ -17,12 +18,16 @@
"react-native": ">=0.59"
},
"devDependencies": {
"@react-native-community/eslint-config": "^0.0.7",
"@types/react": "^16.9.10",
"@types/react-native": "^0.60.21",
"eslint": "^6.8.0",
"eslint-plugin-prettier": "^3.1.2",
"prettier": "^1.19.1",
"release-it": "^12.3.5",
"typescript": "^3.6.4"
},
"files": [
"lib"
]
}
}
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ export {
useKeyboard,
useInteractionManager,
useDeviceOrientation,
useLayout
useLayout,
}
4 changes: 2 additions & 2 deletions src/useAccessibilityInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react'
import {useEffect, useState} from 'react'
import {
AccessibilityInfo,
AccessibilityChangeEvent,
Expand Down Expand Up @@ -39,5 +39,5 @@ export default function useAccessibilityInfo() {
}
}, [])

return { reduceMotionEnabled, screenReaderEnabled }
return {reduceMotionEnabled, screenReaderEnabled}
}
4 changes: 2 additions & 2 deletions src/useAppState.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react'
import { AppState, AppStateStatus } from 'react-native'
import {useEffect, useState} from 'react'
import {AppState, AppStateStatus} from 'react-native'

export default function useAppState() {
const currentState = AppState.currentState
Expand Down
4 changes: 2 additions & 2 deletions src/useBackHandler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react'
import { BackHandler } from 'react-native'
import {useEffect} from 'react'
import {BackHandler} from 'react-native'

export default function useBackHandler(handler: () => void) {
useEffect(() => {
Expand Down
8 changes: 2 additions & 6 deletions src/useCameraRoll.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import React, { useState } from 'react'
import {
CameraRoll,
GetPhotosParamType,
GetPhotosReturnType,
} from 'react-native'
import {useState} from 'react'
import {CameraRoll, GetPhotosParamType, GetPhotosReturnType} from 'react-native'

const initialState: GetPhotosReturnType = {
edges: [],
Expand Down
4 changes: 2 additions & 2 deletions src/useClipboard.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react'
import { Clipboard } from 'react-native'
import {useEffect, useState} from 'react'
import {Clipboard} from 'react-native'

export default function useClipBoard() {
const [data, updateClipboardData] = useState('')
Expand Down
10 changes: 5 additions & 5 deletions src/useDeviceOrientation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react'
import { Dimensions, ScaledSize } from 'react-native'
import {useEffect, useState, useCallback} from 'react'
import {Dimensions, ScaledSize} from 'react-native'

const screen = Dimensions.get('screen')

Expand All @@ -24,20 +24,20 @@ export default function() {
landscape: isOrientationLandscape(screen),
})

const onChange = ({ screen }: { screen: ScaledSize }) => {
const onChange = useCallback(({screen}: {screen: ScaledSize}) => {
setOrientation({
portrait: isOrientationPortrait(screen),
landscape: isOrientationLandscape(screen),
})
}
}, [])

useEffect(() => {
Dimensions.addEventListener('change', onChange)

return () => {
Dimensions.removeEventListener('change', onChange)
}
}, [orientation.portrait, orientation.landscape])
}, [orientation.portrait, orientation.landscape, onChange])

return orientation
}
6 changes: 3 additions & 3 deletions src/useDimensions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react'
import { Dimensions, ScaledSize } from 'react-native'
import {useEffect, useState} from 'react'
import {Dimensions, ScaledSize} from 'react-native'

const window = Dimensions.get('window')
const screen = Dimensions.get('screen')
Expand All @@ -17,7 +17,7 @@ export default function useDimensions() {
window: ScaledSize
screen: ScaledSize
}) => {
setDimensions({ window, screen })
setDimensions({window, screen})
}

useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/useInteractionManager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react'
import { InteractionManager } from 'react-native'
import {useEffect, useState} from 'react'
import {InteractionManager} from 'react-native'

export default function useInteractionManager() {
const [complete, updateInteractionStatus] = useState(false)
Expand Down
26 changes: 13 additions & 13 deletions src/useKeyboard.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import React, { useEffect, useState } from 'react'
import { Keyboard, KeyboardEventListener, ScreenRect } from 'react-native'
import {useEffect, useState} from 'react'
import {Keyboard, KeyboardEventListener, ScreenRect} from 'react-native'

export default function useKeyboard() {
const [shown, setShown] = useState(false)
const [coordinates, setCoordinates] = useState<{
start: ScreenRect
end: ScreenRect
}>({
start: { screenX: 0, screenY: 0, width: 0, height: 0 },
end: { screenX: 0, screenY: 0, width: 0, height: 0 },
start: {screenX: 0, screenY: 0, width: 0, height: 0},
end: {screenX: 0, screenY: 0, width: 0, height: 0},
})
const [keyboardHeight, setKeyboardHeight] = useState<number>(0)

const handleKeyboardWillShow: KeyboardEventListener = (e) => {
setCoordinates({ start: e.startCoordinates, end: e.endCoordinates })
const handleKeyboardWillShow: KeyboardEventListener = e => {
setCoordinates({start: e.startCoordinates, end: e.endCoordinates})
}
const handleKeyboardDidShow: KeyboardEventListener = (e) => {
const handleKeyboardDidShow: KeyboardEventListener = e => {
setShown(true)
setCoordinates({ start: e.startCoordinates, end: e.endCoordinates })
setCoordinates({start: e.startCoordinates, end: e.endCoordinates})
setKeyboardHeight(e.endCoordinates.height)
}
const handleKeyboardWillHide: KeyboardEventListener = (e) => {
setCoordinates({ start: e.startCoordinates, end: e.endCoordinates })
const handleKeyboardWillHide: KeyboardEventListener = e => {
setCoordinates({start: e.startCoordinates, end: e.endCoordinates})
}
const handleKeyboardDidHide: KeyboardEventListener = (e) => {
const handleKeyboardDidHide: KeyboardEventListener = e => {
setShown(false)
setCoordinates({ start: e.startCoordinates, end: e.endCoordinates })
setCoordinates({start: e.startCoordinates, end: e.endCoordinates})
setKeyboardHeight(0)
}

Expand Down Expand Up @@ -58,6 +58,6 @@ export default function useKeyboard() {
return {
keyboardShown: shown,
coordinates,
keyboardHeight
keyboardHeight,
}
}
6 changes: 3 additions & 3 deletions src/useLayout.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react'
import {useState, useCallback} from 'react'

export default function useLayout() {
const [layout, setLayout] = React.useState({
const [layout, setLayout] = useState({
x: 0,
y: 0,
width: 0,
height: 0,
})
const onLayout = React.useCallback((e) => setLayout(e.nativeEvent.layout), [])
const onLayout = useCallback(e => setLayout(e.nativeEvent.layout), [])

return {
onLayout,
Expand Down
Loading