Skip to content

Commit ce41d5b

Browse files
committed
Run prettier
1 parent 39fdc2a commit ce41d5b

File tree

6 files changed

+23
-36
lines changed

6 files changed

+23
-36
lines changed

.eslintrc

+7-23
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
{
22
"root": true,
33
"parser": "@typescript-eslint/parser",
4-
"plugins": [
5-
"@typescript-eslint"
6-
],
7-
"extends": [
8-
"plugin:@typescript-eslint/recommended"
9-
],
4+
"plugins": ["@typescript-eslint"],
5+
"extends": ["plugin:@typescript-eslint/recommended"],
106
"rules": {
117
"indent": "off",
128
"@typescript-eslint/explicit-function-return-type": "off",
13-
"@typescript-eslint/indent": [
14-
"error",
15-
2
16-
],
9+
"@typescript-eslint/indent": ["error", 2],
1710
"@typescript-eslint/member-delimiter-style": [
1811
"error",
1912
{
@@ -43,18 +36,9 @@
4336
"ignoreDeclarationSort": true
4437
}
4538
],
46-
"object-curly-spacing": [
47-
"error",
48-
"never"
49-
],
50-
"quotes": [
51-
"error",
52-
"single"
53-
],
54-
"space-before-function-paren": [
55-
"error",
56-
"always"
57-
]
39+
"object-curly-spacing": ["error", "never"],
40+
"quotes": ["error", "single"],
41+
"space-before-function-paren": ["error", "always"]
5842
},
5943
"overrides": [
6044
{
@@ -64,4 +48,4 @@
6448
}
6549
}
6650
]
67-
}
51+
}

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ This project uses Typescript. Do not modify `index.js` or `index.d.ts` manually.
3737
Run `npm test` to make sure nothing broke. Run `npm run build` to export a new build.
3838

3939
## License
40+
4041
[MIT](https://choosealicense.com/licenses/mit/)

jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
22
preset: 'ts-jest',
33
testEnvironment: 'node',
4-
}
4+
}

src/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import HourParser from './'
55

6-
const {toDecimal, toHHMM} = HourParser
6+
const { toDecimal, toHHMM } = HourParser
77

88
describe('toHHMM', () => {
99
test('handles invalid values', () => {

src/index.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const parseNumber = (input: number | string): number => {
2-
const [hours, minutes] = input.toString()
2+
const [hours, minutes] = input
3+
.toString()
34
.replace(/,/g, '.')
45
.replace(/\s/g, '')
56
.split(':')
@@ -12,7 +13,10 @@ const parseNumber = (input: number | string): number => {
1213
const evalInput = (input: number | string): number => {
1314
const adder = (sum: number, match: string) => sum + parseNumber(match)
1415

15-
return input.toString().match(/\s*[+-]?[^+-]+/g)!.reduce(adder, 0)
16+
return input
17+
.toString()
18+
.match(/\s*[+-]?[^+-]+/g)!
19+
.reduce(adder, 0)
1620
}
1721

1822
export default {
@@ -21,24 +25,24 @@ export default {
2125
* @param {number|string} input? Timestamp to convert
2226
* @returns {string} A timestamp in decimal format (rounded/padded to 2 decimals places)
2327
*/
24-
toDecimal (input?: number | string): string {
28+
toDecimal(input?: number | string): string {
2529
if (!input && input !== 0) {
2630
return ''
2731
}
2832

29-
if (typeof (input) === 'number') {
33+
if (typeof input === 'number') {
3034
return input.toFixed(2)
3135
}
3236

3337
const hours = evalInput(input) / 60
34-
return (isNaN(hours) ? '' : hours.toFixed(2).toString())
38+
return isNaN(hours) ? '' : hours.toFixed(2).toString()
3539
},
3640

3741
/** Convert timestamp to hh:mm format
3842
* @param {number|string} input? Timestamp to convert
3943
* @returns {string} A timestamp in hh:mm format
4044
*/
41-
toHHMM (input?: number | string): string {
45+
toHHMM(input?: number | string): string {
4246
if (!input && input !== 0) {
4347
return ''
4448
}
@@ -55,5 +59,5 @@ export default {
5559
const paddedMinutes = minutes.toString().padStart(2, '0')
5660

5761
return `${sign}${hours}:${paddedMinutes}`
58-
}
62+
},
5963
}

tsconfig.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,5 @@
1111
"declaration": true,
1212
"outDir": "."
1313
},
14-
"files": [
15-
"src/index.ts"
16-
]
17-
}
14+
"files": ["src/index.ts"]
15+
}

0 commit comments

Comments
 (0)