Skip to content

Commit 853151e

Browse files
authored
Merge pull request #55 from YsnKsy/refactor
refactor(*): upgrade deps & remove unnecessary code & fix lint warning [typescript]
2 parents b52b818 + 0a5e9a1 commit 853151e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+12560
-2561
lines changed

.github/workflows/pull-request.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,7 @@ jobs:
3535
run: yarn typescript
3636

3737
- name: Run Jest Unit Tests
38-
run: yarn test
38+
run: yarn test
39+
40+
- name: Compiled files
41+
run: yarn prepare

.github/workflows/release.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,8 @@ jobs:
5959
- name: Run Jest Unit Tests
6060
run: yarn test
6161

62+
- name: Compiled files
63+
run: yarn prepare
64+
6265
- name: New release
6366
run: NPM_TOKEN=${{ secrets.NPM_TOKEN }} GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} yarn release

.npmignore

Lines changed: 0 additions & 66 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ We want this community to be friendly and respectful to each other. Please follo
44

55
## Development workflow
66

7-
To get started with the project, run `yarn bootstrap` in the root directory to install the required dependencies for each package:
7+
To get started with the project, run `yarn` in the root directory to install the required dependencies for each package:
88

99
```sh
10-
yarn bootstrap
10+
yarn
1111
```
1212

13-
While developing, you can run the [example app](/example/) to test your changes.
13+
> While it's possible to use [`npm`](https://github.com/npm/cli), the tooling is built around [`yarn`](https://classic.yarnpkg.com/), so you'll have an easier time if you use `yarn` for development.
14+
15+
While developing, you can run the [example app](/example/) to test your changes. Any changes you make in your library's JavaScript code will be reflected in the example app without a rebuild. If you change any native code, then you'll need to rebuild the example app.
1416

1517
To start the packager:
1618

@@ -53,7 +55,7 @@ We follow the [conventional commits specification](https://www.conventionalcommi
5355
- `feat`: new features, e.g. add new method to the module.
5456
- `refactor`: code refactor, e.g. migrate from class components to hooks.
5557
- `docs`: changes into documentation, e.g. add usage example for the module..
56-
- `test`: adding or updating tests, eg add integration tests using detox.
58+
- `test`: adding or updating tests, e.g. add integration tests using detox.
5759
- `chore`: tooling changes, e.g. change CI config.
5860

5961
Our pre-commit hooks verify that your commit message matches this format when committing.

README.md

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ yarn add react-native-location-enabler
3131
### Example using Hook (React Hooks API) :
3232

3333
```js
34-
import LocationEnabler from "react-native-location-enabler"
34+
import LocationEnabler from 'react-native-location-enabler';
3535

3636
const {
3737
PRIORITIES: { HIGH_ACCURACY },
3838
useLocationSettings,
39-
} = LocationEnabler
39+
} = LocationEnabler;
4040

4141
// React Component
4242
const App = () => {
@@ -46,17 +46,20 @@ const App = () => {
4646
alwaysShow: true, // default false
4747
needBle: true, // default false
4848
},
49-
false /* optional: default undefined */,
50-
)
49+
false /* optional: default undefined */
50+
);
5151

5252
return (
5353
<View>
5454
{!enabled && (
55-
<Button onPress={requestResolution} title="Request Resolution Location Settings" />
55+
<Button
56+
onPress={requestResolution}
57+
title="Request Resolution Location Settings"
58+
/>
5659
)}
5760
</View>
58-
)
59-
}
61+
);
62+
};
6063
```
6164

6265
---
@@ -138,9 +141,14 @@ yarn example android
138141
> `PRIORITIES`
139142
140143
```js
141-
import LocationEnabler from "react-native-location-enabler"
144+
import LocationEnabler from 'react-native-location-enabler';
142145

143-
const { HIGH_ACCURACY, BALANCED_POWER_ACCURACY, LOW_POWER, NO_POWER } = LocationEnabler.PRIORITIES
146+
const {
147+
HIGH_ACCURACY,
148+
BALANCED_POWER_ACCURACY,
149+
LOW_POWER,
150+
NO_POWER,
151+
} = LocationEnabler.PRIORITIES;
144152
```
145153

146154
Static object contain a list quality of service for location updates. If your application wants high accuracy location it should set prioprity to 'HIGH_ACCURACY'. If you want negligible power impact, but to still receive location updates when available, then set priority to 'NO_POWER'.
@@ -152,24 +160,24 @@ Static object contain a list quality of service for location updates. If your ap
152160
> ### `useLocationSettings({ priority, alwaysShow, needBle }, initialStatus?)`
153161
154162
```js
155-
import LocationEnabler from "react-native-location-enabler"
163+
import LocationEnabler from 'react-native-location-enabler';
156164

157165
const {
158166
useLocationSettings,
159167
PRIORITIES: { HIGH_ACCURACY },
160-
} = LocationEnabler
168+
} = LocationEnabler;
161169

162170
const [enabled, requestResolution] = useLocationSettings({
163171
priority: HIGH_ACCURACY, // optional: default BALANCED_POWER_ACCURACY
164172
alwaysShow: true, // optional: default false
165173
needBle: true, // optional: default false
166-
})
174+
});
167175

168-
console.log(`Location are ${enabled ? "enabled" : "disabled"}`)
176+
console.log(`Location are ${enabled ? 'enabled' : 'disabled'}`);
169177

170178
// ...
171179
if (!enabled) {
172-
requestResolution()
180+
requestResolution();
173181
}
174182
```
175183

@@ -180,18 +188,18 @@ Hook let you check the user's device location status 'on' / 'off' and method let
180188
> ### `checkSettings({ priority, alwaysShow, needBle })`
181189
182190
```js
183-
import LocationEnabler from "react-native-location-enabler"
191+
import LocationEnabler from 'react-native-location-enabler';
184192

185193
const {
186194
checkSettings,
187195
PRIORITIES: { HIGH_ACCURACY },
188-
} = LocationEnabler
196+
} = LocationEnabler;
189197

190198
checkSettings({
191199
priority: HIGH_ACCURACY, // optional: default BALANCED_POWER_ACCURACY
192200
alwaysShow: true, // optional: default false
193201
needBle: true, // optional: default false
194-
})
202+
});
195203
```
196204

197205
Checking if the user's device location is turned on / off.
@@ -201,18 +209,18 @@ Checking if the user's device location is turned on / off.
201209
> ### `requestResolutionSettings({ priority, alwaysShow, needBle })`
202210
203211
```js
204-
import LocationEnabler from "react-native-location-enabler"
212+
import LocationEnabler from 'react-native-location-enabler';
205213

206214
const {
207215
requestResolutionSettings,
208216
PRIORITIES: { HIGH_ACCURACY },
209-
} = LocationEnabler
217+
} = LocationEnabler;
210218

211219
requestResolutionSettings({
212220
priority: HIGH_ACCURACY, // optional: default BALANCED_POWER_ACCURACY
213221
alwaysShow: true, // optional: default false
214222
needBle: true, // optional: default false
215-
})
223+
});
216224
```
217225

218226
Display an activity where they can turn location 'on' using a location request.
@@ -222,22 +230,22 @@ Display an activity where they can turn location 'on' using a location request.
222230
> ### `addListener(callback, context?)`
223231
224232
```js
225-
import LocationEnabler from "react-native-location-enabler"
233+
import LocationEnabler from 'react-native-location-enabler';
226234

227-
let listener = null
235+
let listener = null;
228236

229237
function cb(result) {
230-
const { locationEnabled } = result
238+
const { locationEnabled } = result;
231239

232-
console.log(`Location are ${locationEnabled ? "enabled" : "disabled"}`)
240+
console.log(`Location are ${locationEnabled ? 'enabled' : 'disabled'}`);
233241

234242
if (listener !== null) {
235243
// remove listener when you finish
236-
listener.remove()
244+
listener.remove();
237245
}
238246
}
239247

240-
listener = LocationEnabler.addListener(cb)
248+
listener = LocationEnabler.addListener(cb);
241249
```
242250

243251
Adds a listener to be invoked when onChangeLocationSettings are emitted. An optional calling context may be provided. The data arguments emitted will be passed to the listener function.

SECURITY.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

android/.project

Lines changed: 0 additions & 17 deletions
This file was deleted.

android/.settings/org.eclipse.buildship.core.prefs

Lines changed: 0 additions & 13 deletions
This file was deleted.
-53.1 KB
Binary file not shown.

android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)