Skip to content

Commit b3bdab1

Browse files
committed
chore: Prettify
1 parent 72273c6 commit b3bdab1

18 files changed

Lines changed: 1055 additions & 373 deletions

.eslintignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Dependencies
2+
node_modules/
3+
lib/
4+
5+
# Generated files
6+
android/build/
7+
ios/build/
8+
9+
# Assets that shouldn't be linted
10+
ios/assets/
11+
android/src/main/assets/
12+
**/d3*.js
13+
**/chart.html
14+
example/ios/react-native-d3-chart-*
15+
example/android/app/src/main/assets/react-native-d3-chart/
16+

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
22
presets: ['module:react-native-builder-bob/babel-preset'],
3-
};
3+
}

example/babel.config.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
const path = require('path');
2-
const { getConfig } = require('react-native-builder-bob/babel-config');
3-
const pkg = require('../package.json');
1+
const path = require('path')
42

5-
const root = path.resolve(__dirname, '..');
3+
const { getConfig } = require('react-native-builder-bob/babel-config')
4+
5+
const pkg = require('../package.json')
6+
7+
const root = path.resolve(__dirname, '..')
68

79
module.exports = getConfig(
810
{
911
presets: ['module:@react-native/babel-preset'],
1012
},
1113
{ root, pkg }
12-
);
14+
)

example/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { AppRegistry } from 'react-native';
2-
import App from './src/App';
3-
import { name as appName } from './app.json';
1+
import { AppRegistry } from 'react-native'
42

5-
AppRegistry.registerComponent(appName, () => App);
3+
import { name as appName } from './app.json'
4+
import App from './src/App'
5+
6+
AppRegistry.registerComponent(appName, () => App)

example/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
22
preset: 'react-native',
3-
};
3+
}

example/metro.config.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
const path = require('path');
2-
const { getDefaultConfig } = require('@react-native/metro-config');
3-
const { getConfig } = require('react-native-builder-bob/metro-config');
4-
const pkg = require('../package.json');
1+
const path = require('path')
52

6-
const root = path.resolve(__dirname, '..');
3+
const { getDefaultConfig } = require('@react-native/metro-config')
4+
const { getConfig } = require('react-native-builder-bob/metro-config')
5+
6+
const pkg = require('../package.json')
7+
8+
const root = path.resolve(__dirname, '..')
79

810
/**
911
* Metro configuration
@@ -15,4 +17,4 @@ module.exports = getConfig(getDefaultConfig(__dirname), {
1517
root,
1618
pkg,
1719
project: __dirname,
18-
});
20+
})

example/src/App.tsx

Lines changed: 50 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import React, { useMemo, useState } from 'react';
2-
import { View, StyleSheet, TouchableOpacity, Text, Switch } from 'react-native';
3-
import Chart, { ChartProps, Dataset } from 'react-native-d3-chart';
1+
import React, { useMemo, useState } from 'react'
2+
import { View, StyleSheet, TouchableOpacity, Text, Switch } from 'react-native'
43

5-
type TimeDomainType = 'hour' | 'day' | 'week' | 'month';
4+
import Chart, { ChartProps, Dataset } from 'react-native-d3-chart'
65

7-
const TIME_DOMAIN_TYPES: TimeDomainType[] = ['hour', 'day', 'week', 'month'];
6+
type TimeDomainType = 'hour' | 'day' | 'week' | 'month'
7+
8+
const TIME_DOMAIN_TYPES: TimeDomainType[] = ['hour', 'day', 'week', 'month']
89

910
const chartColors: ChartProps['colors'] = {
1011
background: '#fff',
@@ -13,42 +14,42 @@ const chartColors: ChartProps['colors'] = {
1314
cursorStroke: '#0ff',
1415
highlightLabel: '#000',
1516
highlightTime: '#444',
16-
};
17+
}
1718

1819
// Generate data points every minute from a month ago to now
1920
const generateDataPoints = ({
2021
startingValue = 400,
2122
minimum = 0,
2223
radomFactor = 20,
2324
} = {}) => {
24-
const points = [];
25-
const now = Date.now();
26-
const monthAgo = now - 30 * 24 * 60 * 60 * 1000; // 30 days ago
27-
let value = startingValue;
25+
const points = []
26+
const now = Date.now()
27+
const monthAgo = now - 30 * 24 * 60 * 60 * 1000 // 30 days ago
28+
let value = startingValue
2829

2930
for (let timestamp = monthAgo; timestamp <= now; timestamp += 60 * 1000) {
30-
const randomVariation = (Math.random() - 0.5) * radomFactor;
31-
value += randomVariation;
31+
const randomVariation = (Math.random() - 0.5) * radomFactor
32+
value += randomVariation
3233

3334
// randomVariation was negative and value went below minimum
3435
if (value < minimum) {
3536
// invert direction to keep above minimum
36-
value -= 2 * randomVariation;
37+
value -= 2 * randomVariation
3738
}
3839

39-
points.push({ timestamp, value });
40+
points.push({ timestamp, value })
4041
}
4142

42-
return points;
43-
};
43+
return points
44+
}
4445

4546
enum Measurement {
4647
Red = 'Red',
4748
Blue = 'Blue',
4849
Green = 'Green',
4950
Pink = 'Pink',
5051
}
51-
const measurementKeys = Object.values(Measurement);
52+
const measurementKeys = Object.values(Measurement)
5253
const measurementsRecords: Record<Measurement, Dataset> = {
5354
[Measurement.Red]: {
5455
unit: '°C',
@@ -85,41 +86,41 @@ const measurementsRecords: Record<Measurement, Dataset> = {
8586
color: '#e0e',
8687
measurementName: Measurement.Pink,
8788
},
88-
};
89+
}
8990

9091
export default function App() {
91-
const [width, setWidth] = useState<number>(0);
92-
const height = width * 1.1;
93-
const [timeDomainType, setTimeDomainType] = useState<TimeDomainType>('hour');
92+
const [width, setWidth] = useState<number>(0)
93+
const height = width * 1.1
94+
const [timeDomainType, setTimeDomainType] = useState<TimeDomainType>('hour')
9495
const timeDomain = useMemo(() => {
95-
const now = new Date().valueOf();
96-
var hours = 1;
96+
const now = new Date().valueOf()
97+
let hours = 1
9798
if (timeDomainType !== 'hour') {
98-
hours *= 24;
99+
hours *= 24
99100

100101
if (timeDomainType === 'week') {
101-
hours *= 7;
102+
hours *= 7
102103
}
103104

104105
if (timeDomainType === 'month') {
105-
hours *= 30;
106+
hours *= 30
106107
}
107108
}
108109

109-
const start = now - hours * 60 * 60 * 1000;
110-
const end = now;
110+
const start = now - hours * 60 * 60 * 1000
111+
const end = now
111112

112-
return { start, end, type: timeDomainType };
113-
}, [timeDomainType]);
113+
return { start, end, type: timeDomainType }
114+
}, [timeDomainType])
114115

115116
const [enabledMeasurements, setEnabledMeasurements] = useState<Measurement[]>(
116117
[Measurement.Red]
117-
);
118+
)
118119

119120
const datasets = useMemo<Dataset[]>(
120121
() => enabledMeasurements.map((m) => measurementsRecords[m]),
121122
[enabledMeasurements]
122-
);
123+
)
123124

124125
return (
125126
<View
@@ -153,52 +154,39 @@ export default function App() {
153154
</View>
154155
{/* Measurement toggles */}
155156
{measurementKeys.map((measurement) => (
156-
<View
157-
key={measurement}
158-
style={{
159-
flexDirection: 'row',
160-
alignItems: 'center',
161-
marginVertical: 10,
162-
}}
163-
>
157+
<View key={measurement} style={styles.switchContainer}>
164158
<Switch
165159
value={enabledMeasurements.includes(measurement)}
166160
onValueChange={() =>
167161
setEnabledMeasurements((prev) => {
168162
if (!prev.includes(measurement))
169163
// enable
170-
return prev.concat(measurement);
164+
return prev.concat(measurement)
171165

172166
if (prev.length !== 1)
173167
// disable
174-
return prev.filter((m) => m !== measurement);
168+
return prev.filter((m) => m !== measurement)
175169

176170
// only one measurement was enabled, switch to next one
177171
const currentIndex = measurementKeys.findIndex(
178172
(m) => m === measurement
179-
);
180-
const nextIndex = (currentIndex + 1) % measurementKeys.length;
181-
const nextMeasurement = measurementKeys[nextIndex]!;
173+
)
174+
const nextIndex = (currentIndex + 1) % measurementKeys.length
175+
const nextMeasurement = measurementKeys[nextIndex]!
182176

183-
return [nextMeasurement];
177+
return [nextMeasurement]
184178
})
185179
}
186180
/>
187-
<Text style={{ marginLeft: 10 }}>{measurement}</Text>
181+
<Text style={styles.switchLabel}>{measurement}</Text>
188182
</View>
189183
))}
190184
</View>
191-
);
185+
)
192186
}
193187

194-
const PADDING = 20;
188+
const PADDING = 20
195189
const styles = StyleSheet.create({
196-
container: {
197-
flex: 1,
198-
alignItems: 'center',
199-
justifyContent: 'center',
200-
backgroundColor: '#eee',
201-
},
202190
holder: {
203191
width: '100%',
204192
flex: 1,
@@ -226,4 +214,10 @@ const styles = StyleSheet.create({
226214
timeDomainItemText: {
227215
fontSize: 13,
228216
},
229-
});
217+
switchContainer: {
218+
marginVertical: 10,
219+
flexDirection: 'row',
220+
alignItems: 'center',
221+
},
222+
switchLabel: { marginLeft: 10 },
223+
})

package.json

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"devDependencies": {
7373
"@commitlint/config-conventional": "^17.0.2",
7474
"@evilmartians/lefthook": "^1.5.0",
75+
"@mitigate-dev/eslint-config-react-native": "^0.0.13",
7576
"@react-native/eslint-config": "^0.73.1",
7677
"@release-it/conventional-changelog": "^9.0.2",
7778
"@types/jest": "^29.5.5",
@@ -82,7 +83,7 @@
8283
"eslint-config-prettier": "^9.0.0",
8384
"eslint-plugin-prettier": "^5.0.1",
8485
"jest": "^29.7.0",
85-
"prettier": "^3.0.3",
86+
"prettier": "^3.6.2",
8687
"react": "19.0.0",
8788
"react-native": "0.78.0",
8889
"react-native-builder-bob": "^0.37.0",
@@ -138,7 +139,17 @@
138139
"root": true,
139140
"extends": [
140141
"@react-native",
141-
"prettier"
142+
"prettier",
143+
"@mitigate-dev/eslint-config-react-native"
144+
],
145+
"ignorePatterns": [
146+
"ios/assets/**",
147+
"android/src/main/assets/**",
148+
"**/d3*.js",
149+
"**/chart.html",
150+
"src/drawFunction.js",
151+
"example/ios/react-native-d3-chart-*",
152+
"example/android/app/src/main/assets/react-native-d3-chart/**"
142153
],
143154
"rules": {
144155
"react/react-in-jsx-scope": "off",
@@ -149,21 +160,19 @@
149160
"singleQuote": true,
150161
"tabWidth": 2,
151162
"trailingComma": "es5",
152-
"useTabs": false
163+
"useTabs": false,
164+
"semi": false
153165
}
154166
]
155167
}
156168
},
157-
"eslintIgnore": [
158-
"node_modules/",
159-
"lib/"
160-
],
161169
"prettier": {
162170
"quoteProps": "consistent",
163171
"singleQuote": true,
164172
"tabWidth": 2,
165173
"trailingComma": "es5",
166-
"useTabs": false
174+
"useTabs": false,
175+
"semi": false
167176
},
168177
"react-native-builder-bob": {
169178
"source": "src",

react-native.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ module.exports = {
1111
},
1212
assets: ['android/src/main/assets', 'ios/assets'], // Note: relative to library root
1313
},
14-
};
14+
}

0 commit comments

Comments
 (0)