Skip to content

Commit 4fb7bac

Browse files
chore: revert formatting
1 parent 44467ab commit 4fb7bac

File tree

3 files changed

+38
-38
lines changed

3 files changed

+38
-38
lines changed

packages/use-intl/src/core/IntlError.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export enum IntlErrorCode {
66
INVALID_MESSAGE = 'INVALID_MESSAGE',
77
INVALID_KEY = 'INVALID_KEY',
88
INVALID_FORMAT = 'INVALID_FORMAT',
9-
FORMATTING_ERROR = 'FORMATTING_ERROR',
9+
FORMATTING_ERROR = 'FORMATTING_ERROR'
1010
}
1111

1212
export default class IntlError extends Error {

packages/use-intl/src/core/createFormatter.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import DateTimeFormatOptions from './DateTimeFormatOptions';
22
import Formats from './Formats';
3-
import IntlError, { IntlErrorCode } from './IntlError';
3+
import IntlError, {IntlErrorCode} from './IntlError';
44
import NumberFormatOptions from './NumberFormatOptions';
55
import RelativeTimeFormatOptions from './RelativeTimeFormatOptions';
66
import TimeZone from './TimeZone';
7-
import { defaultOnError } from './defaults';
7+
import {defaultOnError} from './defaults';
88

99
const SECOND = 1;
1010
const MINUTE = SECOND * 60;
@@ -31,7 +31,7 @@ const UNIT_SECONDS: Record<Intl.RelativeTimeFormatUnit, number> = {
3131
quarter: QUARTER,
3232
quarters: QUARTER,
3333
year: YEAR,
34-
years: YEAR,
34+
years: YEAR
3535
} as const;
3636

3737
function resolveRelativeTimeUnit(seconds: number) {
@@ -75,7 +75,7 @@ export default function createFormatter({
7575
locale,
7676
now: globalNow,
7777
onError = defaultOnError,
78-
timeZone: globalTimeZone,
78+
timeZone: globalTimeZone
7979
}: Props) {
8080
function resolveFormatOrOptions<Options>(
8181
typeFormats: Record<string, Options> | undefined,
@@ -140,7 +140,7 @@ export default function createFormatter({
140140
(options) => {
141141
if (!options?.timeZone) {
142142
if (globalTimeZone) {
143-
options = { ...options, timeZone: globalTimeZone };
143+
options = {...options, timeZone: globalTimeZone};
144144
} else {
145145
onError(
146146
new IntlError(
@@ -235,7 +235,7 @@ export default function createFormatter({
235235
const value = calculateRelativeTimeValue(seconds, unit);
236236

237237
return new Intl.RelativeTimeFormat(locale, {
238-
numeric: 'auto',
238+
numeric: 'auto'
239239
}).format(value, unit);
240240
} catch (error) {
241241
onError(
@@ -254,5 +254,5 @@ export default function createFormatter({
254254
);
255255
}
256256

257-
return { dateTime, number, relativeTime, list };
257+
return {dateTime, number, relativeTime, list};
258258
}

packages/use-intl/test/core/createFormatter.test.tsx

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,74 @@
1-
import { parseISO } from 'date-fns';
2-
import { it, expect } from 'vitest';
3-
import { createFormatter } from '../../src';
1+
import {parseISO} from 'date-fns';
2+
import {it, expect} from 'vitest';
3+
import {createFormatter} from '../../src';
44

55
it('formats a date and time', () => {
66
const formatter = createFormatter({
77
locale: 'en',
8-
timeZone: 'Europe/Berlin',
8+
timeZone: 'Europe/Berlin'
99
});
1010
expect(
1111
formatter.dateTime(parseISO('2020-11-20T10:36:01.516Z'), {
12-
dateStyle: 'medium',
12+
dateStyle: 'medium'
1313
})
1414
).toBe('Nov 20, 2020');
1515
});
1616

1717
it('formats an ISO 8601 datetime string', () => {
1818
const formatter = createFormatter({
1919
locale: 'en',
20-
timeZone: 'Europe/Berlin',
20+
timeZone: 'Europe/Berlin'
2121
});
2222
expect(
2323
formatter.dateTime('2020-11-20T10:36:01.516Z', {
24-
dateStyle: 'medium',
24+
dateStyle: 'medium'
2525
})
2626
).toBe('Nov 20, 2020');
2727
});
2828

2929
it('formats a number', () => {
3030
const formatter = createFormatter({
3131
locale: 'en',
32-
timeZone: 'Europe/Berlin',
32+
timeZone: 'Europe/Berlin'
3333
});
3434
expect(formatter.number(123456)).toBe('123,456');
3535
});
3636

3737
it('formats a bigint', () => {
3838
const formatter = createFormatter({
3939
locale: 'en',
40-
timeZone: 'Europe/Berlin',
40+
timeZone: 'Europe/Berlin'
4141
});
4242
expect(formatter.number(123456789123456789n)).toBe('123,456,789,123,456,789');
4343
});
4444

4545
it('formats a number as currency', () => {
4646
const formatter = createFormatter({
4747
locale: 'en',
48-
timeZone: 'Europe/Berlin',
48+
timeZone: 'Europe/Berlin'
4949
});
5050
expect(
51-
formatter.number(123456.789, { style: 'currency', currency: 'USD' })
51+
formatter.number(123456.789, {style: 'currency', currency: 'USD'})
5252
).toBe('$123,456.79');
5353
});
5454

5555
it('formats a bigint as currency', () => {
5656
const formatter = createFormatter({
5757
locale: 'en',
58-
timeZone: 'Europe/Berlin',
58+
timeZone: 'Europe/Berlin'
5959
});
6060
expect(
6161
formatter.number(123456789123456789n, {
6262
style: 'currency',
63-
currency: 'USD',
63+
currency: 'USD'
6464
})
6565
).toBe('$123,456,789,123,456,789.00');
6666
});
6767

6868
it('formats a relative time with the second unit', () => {
6969
const formatter = createFormatter({
7070
locale: 'en',
71-
timeZone: 'Europe/Berlin',
71+
timeZone: 'Europe/Berlin'
7272
});
7373
expect(
7474
formatter.relativeTime(
@@ -81,7 +81,7 @@ it('formats a relative time with the second unit', () => {
8181
it('formats a relative time with the minute unit', () => {
8282
const formatter = createFormatter({
8383
locale: 'en',
84-
timeZone: 'Europe/Berlin',
84+
timeZone: 'Europe/Berlin'
8585
});
8686
expect(
8787
formatter.relativeTime(
@@ -94,7 +94,7 @@ it('formats a relative time with the minute unit', () => {
9494
it('formats a relative time with the hour unit', () => {
9595
const formatter = createFormatter({
9696
locale: 'en',
97-
timeZone: 'Europe/Berlin',
97+
timeZone: 'Europe/Berlin'
9898
});
9999
expect(
100100
formatter.relativeTime(
@@ -107,7 +107,7 @@ it('formats a relative time with the hour unit', () => {
107107
it('formats a relative time with the day unit', () => {
108108
const formatter = createFormatter({
109109
locale: 'en',
110-
timeZone: 'Europe/Berlin',
110+
timeZone: 'Europe/Berlin'
111111
});
112112
expect(
113113
formatter.relativeTime(
@@ -120,7 +120,7 @@ it('formats a relative time with the day unit', () => {
120120
it('formats a relative time with the month unit', () => {
121121
const formatter = createFormatter({
122122
locale: 'en',
123-
timeZone: 'Europe/Berlin',
123+
timeZone: 'Europe/Berlin'
124124
});
125125
expect(
126126
formatter.relativeTime(
@@ -133,7 +133,7 @@ it('formats a relative time with the month unit', () => {
133133
it('formats a relative time with the year unit', () => {
134134
const formatter = createFormatter({
135135
locale: 'en',
136-
timeZone: 'Europe/Berlin',
136+
timeZone: 'Europe/Berlin'
137137
});
138138
expect(
139139
formatter.relativeTime(
@@ -146,7 +146,7 @@ it('formats a relative time with the year unit', () => {
146146
it('supports the future relative time', () => {
147147
const formatter = createFormatter({
148148
locale: 'en',
149-
timeZone: 'Europe/Berlin',
149+
timeZone: 'Europe/Berlin'
150150
});
151151
expect(
152152
formatter.relativeTime(
@@ -159,25 +159,25 @@ it('supports the future relative time', () => {
159159
it('formats a relative time with options', () => {
160160
const formatter = createFormatter({
161161
locale: 'en',
162-
timeZone: 'Europe/Berlin',
162+
timeZone: 'Europe/Berlin'
163163
});
164164
expect(
165165
formatter.relativeTime(parseISO('2020-11-20T08:30:00.000Z'), {
166166
now: parseISO('2020-11-20T10:36:00.000Z'),
167-
unit: 'day',
167+
unit: 'day'
168168
})
169169
).toBe('today');
170170
});
171171

172172
it('supports the quarter unit', () => {
173173
const formatter = createFormatter({
174174
locale: 'en',
175-
timeZone: 'Europe/Berlin',
175+
timeZone: 'Europe/Berlin'
176176
});
177177
expect(
178178
formatter.relativeTime(parseISO('2020-01-01T00:00:00.000Z'), {
179179
now: parseISO('2020-11-01T01:00:00.000Z'),
180-
unit: 'quarter',
180+
unit: 'quarter'
181181
})
182182
).toBe('3 quarters ago');
183183
});
@@ -186,33 +186,33 @@ it('formats a relative time with a globally defined `now`', () => {
186186
const formatter = createFormatter({
187187
locale: 'en',
188188
now: parseISO('2020-11-20T01:00:00.000Z'),
189-
timeZone: 'Europe/Berlin',
189+
timeZone: 'Europe/Berlin'
190190
});
191191
expect(
192192
formatter.relativeTime(parseISO('2020-11-20T00:00:00.000Z'), {
193-
unit: 'day',
193+
unit: 'day'
194194
})
195195
).toBe('today');
196196
});
197197

198198
it('formats a list', () => {
199199
const formatter = createFormatter({
200200
locale: 'en',
201-
timeZone: 'Europe/Berlin',
201+
timeZone: 'Europe/Berlin'
202202
});
203203
expect(
204-
formatter.list(['apple', 'banana', 'orange'], { type: 'disjunction' })
204+
formatter.list(['apple', 'banana', 'orange'], {type: 'disjunction'})
205205
).toBe('apple, banana, or orange');
206206
});
207207

208208
it('formats a set', () => {
209209
const formatter = createFormatter({
210210
locale: 'en',
211-
timeZone: 'Europe/Berlin',
211+
timeZone: 'Europe/Berlin'
212212
});
213213
expect(
214214
formatter.list(new Set(['apple', 'banana', 'orange']), {
215-
type: 'disjunction',
215+
type: 'disjunction'
216216
})
217217
).toBe('apple, banana, or orange');
218218
});

0 commit comments

Comments
 (0)