Skip to content

Commit c422e6f

Browse files
committed
chore: Prettier
Restoring prettier functionality and fixing all warnings via yarn lint:fix Updating prettier to latest version Updating prettierrc.js rules making generateCodeWithEjs function an async function, to meet the new requirement from prettier.format which returns a Promise<string> in prettier v3
1 parent f6076be commit c422e6f

File tree

105 files changed

+800
-577
lines changed

Some content is hidden

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

105 files changed

+800
-577
lines changed

.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ module.exports = {
122122
'no-shadow': 'off',
123123
'import/named': 'off',
124124
'react-native/no-inline-styles': 0,
125+
'no-unused-vars': 'off',
126+
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
125127
'@typescript-eslint/no-explicit-any': [
126128
'warn',
127129
{ ignoreRestArgs: true },

.prettierrc.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
/** @type {import('prettier').Config} */
12
module.exports = {
2-
singleQuote: true,
3-
trailingComma: 'all',
4-
};
3+
arrowParens: 'avoid', // (x) => x ⟶ x => x
4+
singleQuote: true, // prefer 'test' over "test"
5+
trailingComma: 'all', // multi-line trailing commas
6+
semi: true, // for compatibility and clarity with ESLint default
7+
tabWidth: 2,
8+
};

__tests__/__mocks__/react-native.mock.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ jest.mock('react-native/Libraries/Image/resolveAssetSource', () => {
44

55
jest.mock('../../src/assets/heading.png', () => 'heading.png');
66

7-
87
jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter', () => {
98
function MockEventEmitter() {}
109
MockEventEmitter.prototype.addListener = jest.fn(() => ({
@@ -16,12 +15,11 @@ jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter', () => {
1615
};
1716
});
1817

19-
2018
jest.mock('react-native/Libraries/Utilities/Platform', () => ({
2119
__esModule: true,
2220
default: {
2321
OS: 'ios', // or 'android'
24-
select: (x) => {
22+
select: x => {
2523
if (x.android) {
2624
return x.android;
2725
} else if (x.native) {
@@ -30,7 +28,7 @@ jest.mock('react-native/Libraries/Utilities/Platform', () => ({
3028
return x.default;
3129
}
3230
},
33-
}
31+
},
3432
}));
3533

3634
jest.mock('react-native/src/private/animated/NativeAnimatedHelper', () => ({
@@ -40,4 +38,3 @@ jest.mock('react-native/src/private/animated/NativeAnimatedHelper', () => ({
4038
},
4139
shouldUseNativeDriver: jest.fn(),
4240
}));
43-

__tests__/components/Callout.test.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import { render } from '@testing-library/react-native';
3-
import type { ReactTestInstance } from 'react-test-renderer';
43
import { Text, View } from 'react-native';
54

65
import Callout from '../../src/components/Callout';
@@ -31,29 +30,35 @@ describe('Callout', () => {
3130
tipStyle: { height: 4 },
3231
textStyle: { height: 5 },
3332
};
34-
const result = render(
35-
<Callout {...testProps} />,
36-
);
37-
const { UNSAFE_getByType, UNSAFE_getAllByType } = result
33+
const result = render(<Callout {...testProps} />);
34+
const { UNSAFE_getByType, UNSAFE_getAllByType } = result;
3835
const callout = UNSAFE_getByType('RNMBXCallout');
3936
const views = UNSAFE_getAllByType(View);
4037
const text = UNSAFE_getByType(Text);
41-
42-
function getStyleHeightForViewWithProps(props: { [propName: string]: any }): ReactTestInstance {
38+
39+
function getStyleHeightForViewWithProps(props) {
4340
if (Array.isArray(props.style)) {
4441
return props.style[1].height;
4542
}
4643
// Animated views returned from Callouts have the style being an object, whilst other views have an array of style objects instead
4744
return props.style.height;
4845
}
4946

50-
const calloutWrapperTestStyle = getStyleHeightForViewWithProps(callout.props);
51-
const animatedViewTestStyle = getStyleHeightForViewWithProps(views[0].props);
52-
const wrapperViewTestStyle = getStyleHeightForViewWithProps(views[1].props);
47+
const calloutWrapperTestStyle = getStyleHeightForViewWithProps(
48+
callout.props,
49+
);
50+
const animatedViewTestStyle = getStyleHeightForViewWithProps(
51+
views[0].props,
52+
);
53+
const wrapperViewTestStyle = getStyleHeightForViewWithProps(
54+
views[1].props,
55+
);
5356
const tipViewTestStyle = getStyleHeightForViewWithProps(views[2].props);
5457
const textTestStyle = getStyleHeightForViewWithProps(text.props);
5558

56-
expect(calloutWrapperTestStyle).toStrictEqual(testProps.containerStyle.height);
59+
expect(calloutWrapperTestStyle).toStrictEqual(
60+
testProps.containerStyle.height,
61+
);
5762
expect(animatedViewTestStyle).toStrictEqual(testProps.style.height);
5863
expect(wrapperViewTestStyle).toStrictEqual(testProps.contentStyle.height);
5964
expect(tipViewTestStyle).toStrictEqual(testProps.tipStyle.height);

__tests__/components/Camera.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const bounds1 = {
1010
sw: [-74.143727, 40.772177],
1111
};
1212

13-
const toFeature = (position) => {
13+
const toFeature = position => {
1414
return {
1515
type: 'Feature',
1616
geometry: {
@@ -21,7 +21,7 @@ const toFeature = (position) => {
2121
};
2222
};
2323

24-
const toFeatureCollection = (bounds) => {
24+
const toFeatureCollection = bounds => {
2525
return {
2626
type: 'FeatureCollection',
2727
features: [toFeature(bounds.ne), toFeature(bounds.sw)],

__tests__/components/UserLocation.test.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ describe('UserLocation', () => {
3939
});
4040

4141
test('renders with CircleLayers by default', async () => {
42-
const { UNSAFE_getAllByType, UNSAFE_queryByType } = render(<UserLocation />);
42+
const { UNSAFE_getAllByType, UNSAFE_queryByType } = render(
43+
<UserLocation />,
44+
);
4345
await waitFor(() => {
4446
expect(() => UNSAFE_queryByType(UserLocation)).not.toThrow();
4547
});
@@ -79,9 +81,9 @@ describe('UserLocation', () => {
7981

8082
const { UNSAFE_queryByType, UNSAFE_queryAllByType } = render(
8183
<UserLocation>
82-
<CircleLayer key='testUserLocationCircle' {...circleLayerProps} />
83-
</UserLocation>
84-
)
84+
<CircleLayer key="testUserLocationCircle" {...circleLayerProps} />
85+
</UserLocation>,
86+
);
8587
await waitFor(() => {
8688
expect(() => UNSAFE_queryByType(UserLocation)).not.toThrow();
8789
});
@@ -99,7 +101,9 @@ describe('UserLocation', () => {
99101
test('calls onUpdate callback when new location is received', async () => {
100102
const onUpdateCallback = jest.fn();
101103

102-
const { UNSAFE_getByType } = render(<UserLocation onUpdate={onUpdateCallback} />);
104+
const { UNSAFE_getByType } = render(
105+
<UserLocation onUpdate={onUpdateCallback} />,
106+
);
103107

104108
await waitFor(() => {
105109
expect(() => UNSAFE_getByType(UserLocation)).not.toThrow();
@@ -118,7 +122,7 @@ describe('UserLocation', () => {
118122
},
119123
timestamp: 1573730357879,
120124
});
121-
})
125+
});
122126

123127
expect(onUpdateCallback).toHaveBeenCalled();
124128
});
@@ -152,7 +156,7 @@ describe('UserLocation', () => {
152156
const ul = UNSAFE_queryByType(UserLocation);
153157

154158
const lastKnownLocation = [4.1036916, 51.5462244];
155-
locationManager._lastKnownLocation = lastKnownLocation
159+
locationManager._lastKnownLocation = lastKnownLocation;
156160

157161
expect(locationManager.start).toHaveBeenCalledTimes(0);
158162
expect(locationManager._isListening).toStrictEqual(false);
@@ -219,13 +223,13 @@ describe('UserLocation', () => {
219223
test('called with "running" true', async () => {
220224
const lastKnownLocation = [4.1036916, 51.5462244];
221225
const heading = 251.5358428955078;
222-
locationManager._lastKnownLocation = lastKnownLocation
226+
locationManager._lastKnownLocation = lastKnownLocation;
223227

224228
expect(ul.locationManagerRunning).toStrictEqual(false);
225229

226230
await act(async () => {
227231
await ul.setLocationManager({ running: true });
228-
})
232+
});
229233

230234
expect(ul.locationManagerRunning).toStrictEqual(true);
231235
expect(locationManager.start).toHaveBeenCalledTimes(1);
@@ -243,14 +247,14 @@ describe('UserLocation', () => {
243247
expect(ul.locationManagerRunning).toStrictEqual(false);
244248
await act(async () => {
245249
await ul.setLocationManager({ running: true });
246-
})
250+
});
247251

248252
expect(ul.locationManagerRunning).toStrictEqual(true);
249253

250254
// stop
251255
await act(async () => {
252256
await ul.setLocationManager({ running: false });
253-
})
257+
});
254258

255259
expect(ul.locationManagerRunning).toStrictEqual(false);
256260
// only once from start

__tests__/interface.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,6 @@ describe('Public Interface', () => {
115115

116116
'__experimental',
117117
];
118-
actualKeys.forEach((key) => expect(expectedKeys).toContain(key));
118+
actualKeys.forEach(key => expect(expectedKeys).toContain(key));
119119
});
120120
});

__tests__/modules/location/locationManager.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,13 @@ describe('LocationManager', () => {
261261
test('calls listeners with location', () => {
262262
const listeners = [jest.fn(), jest.fn(), jest.fn()];
263263

264-
listeners.forEach((listener) => {
264+
listeners.forEach(listener => {
265265
locationManager.addListener(listener);
266266
});
267267

268268
locationManager._onUpdate(location);
269269

270-
listeners.forEach((listener) => {
270+
listeners.forEach(listener => {
271271
expect(listener).toHaveBeenCalledTimes(1);
272272
expect(listener).toHaveBeenCalledWith(location);
273273
});

__tests__/modules/snapshot/SnapshotOptions.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('SnapshotOptions', () => {
6262
};
6363

6464
const geoJSONBounds = JSON.stringify(
65-
makeFeatureCollection(expectedOptions.bounds.map((c) => makePoint(c))),
65+
makeFeatureCollection(expectedOptions.bounds.map(c => makePoint(c))),
6666
);
6767

6868
const options = new SnapshotOptions(expectedOptions);

__tests__/utils/animated/AnimatedCoordinatesArray.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ let oldNodeEnv = null;
1313
beforeAll(() => {
1414
clock = FakeTimers.install();
1515
clock._requestedAnimationFrames = [];
16-
clock.requestAnimationFrame = (callback) => {
16+
clock.requestAnimationFrame = callback => {
1717
clock._requestedAnimationFrames.push(callback);
1818
};
1919
clock.fireRequestAnimationFrames = () => {
2020
const oldRAF = clock._requestedAnimationFrames;
2121
clock._requestedAnimationFrames = [];
22-
oldRAF.forEach((cb) => cb(Date.now()));
22+
oldRAF.forEach(cb => cb(Date.now()));
2323
};
2424

2525
// animated will not call nativeProps in test mode
@@ -53,7 +53,7 @@ describe('AnimatedShapeSource', () => {
5353
const testRenderer = TestRenderer.create(
5454
<AnimatedShapeSource
5555
shape={new AnimatedShape({ type: 'LineString', coordinates })}
56-
ref={(ref) => (shapeSourceRef = ref)}
56+
ref={ref => (shapeSourceRef = ref)}
5757
/>,
5858
);
5959
});
@@ -104,10 +104,10 @@ describe('AnimatedShapeSource', () => {
104104
const testRenderer = TestRenderer.create(
105105
<AnimatedShapeSource
106106
shape={new AnimatedShape({ type: 'LineString', coordinates })}
107-
ref={(ref) => (shapeSourceRef = ref)}
107+
ref={ref => (shapeSourceRef = ref)}
108108
/>,
109109
);
110-
})
110+
});
111111
const setNativeProps = jest.fn();
112112
_nativeRef(shapeSourceRef).setNativeProps = setNativeProps;
113113

@@ -158,10 +158,10 @@ describe('AnimatedShapeSource', () => {
158158
const testRenderer = TestRenderer.create(
159159
<AnimatedShapeSource
160160
shape={new AnimatedShape({ type: 'LineString', coordinates })}
161-
ref={(ref) => (shapeSourceRef = ref)}
161+
ref={ref => (shapeSourceRef = ref)}
162162
/>,
163163
);
164-
})
164+
});
165165
const setNativeProps = jest.fn();
166166
_nativeRef(shapeSourceRef).setNativeProps = setNativeProps;
167167

0 commit comments

Comments
 (0)