Skip to content

Commit a520274

Browse files
committed
Merge branch 'main' into s2-notification-badge
2 parents 5f0d73e + 6835cce commit a520274

File tree

246 files changed

+1160
-734
lines changed

Some content is hidden

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

246 files changed

+1160
-734
lines changed

eslint.config.mjs

+24-1
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ export default [{
398398
"rsp-rules/no-getByRole-toThrow": ERROR,
399399
"rulesdir/imports": OFF,
400400
"monorepo/no-internal-import": OFF,
401-
"jsdoc/require-jsdoc": OFF,
401+
"jsdoc/require-jsdoc": OFF
402402
},
403403

404404
languageOptions: {
@@ -437,6 +437,29 @@ export default [{
437437
"jsdoc/require-jsdoc": OFF,
438438
"jsdoc/require-description": OFF,
439439
},
440+
}, {
441+
files: [
442+
"packages/**/*.ts",
443+
"packages/**/*.tsx"
444+
],
445+
446+
rules: {
447+
"@typescript-eslint/explicit-module-boundary-types": ERROR,
448+
},
449+
}, {
450+
files: [
451+
"**/dev/**",
452+
"**/test/**",
453+
"**/stories/**",
454+
"**/docs/**",
455+
"**/chromatic/**",
456+
"**/chromatic-fc/**",
457+
"**/__tests__/**"
458+
],
459+
460+
rules: {
461+
"@typescript-eslint/explicit-module-boundary-types": OFF,
462+
},
440463
}, {
441464
files: [
442465
"packages/@react-aria/focus/src/**/*.ts",

packages/@internationalized/date/src/CalendarDate.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -155,35 +155,35 @@ export class Time {
155155
}
156156

157157
/** Returns a new `Time` with the given duration added to it. */
158-
add(duration: TimeDuration) {
158+
add(duration: TimeDuration): Time {
159159
return addTime(this, duration);
160160
}
161161

162162
/** Returns a new `Time` with the given duration subtracted from it. */
163-
subtract(duration: TimeDuration) {
163+
subtract(duration: TimeDuration): Time {
164164
return subtractTime(this, duration);
165165
}
166166

167167
/** Returns a new `Time` with the given fields set to the provided values. Other fields will be constrained accordingly. */
168-
set(fields: TimeFields) {
168+
set(fields: TimeFields): Time {
169169
return setTime(this, fields);
170170
}
171171

172172
/**
173173
* Returns a new `Time` with the given field adjusted by a specified amount.
174174
* When the resulting value reaches the limits of the field, it wraps around.
175175
*/
176-
cycle(field: TimeField, amount: number, options?: CycleTimeOptions) {
176+
cycle(field: TimeField, amount: number, options?: CycleTimeOptions): Time {
177177
return cycleTime(this, field, amount, options);
178178
}
179179

180180
/** Converts the time to an ISO 8601 formatted string. */
181-
toString() {
181+
toString(): string {
182182
return timeToString(this);
183183
}
184184

185185
/** Compares this time with another. A negative result indicates that this time is before the given one, and a positive time indicates that it is after. */
186-
compare(b: AnyTime) {
186+
compare(b: AnyTime): number {
187187
return compareTime(this, b);
188188
}
189189
}
@@ -361,45 +361,45 @@ export class ZonedDateTime {
361361
}
362362

363363
/** Returns a new `ZonedDateTime` with the given duration added to it. */
364-
add(duration: DateTimeDuration) {
364+
add(duration: DateTimeDuration): ZonedDateTime {
365365
return addZoned(this, duration);
366366
}
367367

368368
/** Returns a new `ZonedDateTime` with the given duration subtracted from it. */
369-
subtract(duration: DateTimeDuration) {
369+
subtract(duration: DateTimeDuration): ZonedDateTime {
370370
return subtractZoned(this, duration);
371371
}
372372

373373
/** Returns a new `ZonedDateTime` with the given fields set to the provided values. Other fields will be constrained accordingly. */
374-
set(fields: DateFields & TimeFields, disambiguation?: Disambiguation) {
374+
set(fields: DateFields & TimeFields, disambiguation?: Disambiguation): ZonedDateTime {
375375
return setZoned(this, fields, disambiguation);
376376
}
377377

378378
/**
379379
* Returns a new `ZonedDateTime` with the given field adjusted by a specified amount.
380380
* When the resulting value reaches the limits of the field, it wraps around.
381381
*/
382-
cycle(field: DateField | TimeField, amount: number, options?: CycleTimeOptions) {
382+
cycle(field: DateField | TimeField, amount: number, options?: CycleTimeOptions): ZonedDateTime {
383383
return cycleZoned(this, field, amount, options);
384384
}
385385

386386
/** Converts the date to a native JavaScript Date object. */
387-
toDate() {
387+
toDate(): Date {
388388
return zonedToDate(this);
389389
}
390390

391391
/** Converts the date to an ISO 8601 formatted string, including the UTC offset and time zone identifier. */
392-
toString() {
392+
toString(): string {
393393
return zonedDateTimeToString(this);
394394
}
395395

396396
/** Converts the date to an ISO 8601 formatted string in UTC. */
397-
toAbsoluteString() {
397+
toAbsoluteString(): string {
398398
return this.toDate().toISOString();
399399
}
400400

401401
/** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */
402-
compare(b: CalendarDate | CalendarDateTime | ZonedDateTime) {
402+
compare(b: CalendarDate | CalendarDateTime | ZonedDateTime): number {
403403
// TODO: Is this a bad idea??
404404
return this.toDate().getTime() - toZoned(b, this.timeZone).toDate().getTime();
405405
}

packages/@internationalized/date/src/calendars/BuddhistCalendar.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ export class BuddhistCalendar extends GregorianCalendar {
3838
);
3939
}
4040

41-
toJulianDay(date: AnyCalendarDate) {
41+
toJulianDay(date: AnyCalendarDate): number {
4242
return super.toJulianDay(toGregorian(date));
4343
}
4444

45-
getEras() {
45+
getEras(): string[] {
4646
return ['BE'];
4747
}
4848

4949
getDaysInMonth(date: AnyCalendarDate): number {
5050
return super.getDaysInMonth(toGregorian(date));
5151
}
5252

53-
balanceDate() {}
53+
balanceDate(): void {}
5454
}
5555

5656
function toGregorian(date: AnyCalendarDate) {

packages/@internationalized/date/src/calendars/EthiopicCalendar.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class EthiopicCalendar implements Calendar {
7979
return new CalendarDate(this, era, year, month, day);
8080
}
8181

82-
toJulianDay(date: AnyCalendarDate) {
82+
toJulianDay(date: AnyCalendarDate): number {
8383
let year = date.year;
8484
if (date.era === 'AA') {
8585
year -= AMETE_MIHRET_DELTA;
@@ -107,7 +107,7 @@ export class EthiopicCalendar implements Calendar {
107107
return date.era === 'AA' ? 9999 : 9991;
108108
}
109109

110-
getEras() {
110+
getEras(): string[] {
111111
return ['AA', 'AM'];
112112
}
113113
}
@@ -125,7 +125,7 @@ export class EthiopicAmeteAlemCalendar extends EthiopicCalendar {
125125
return new CalendarDate(this, 'AA', year, month, day);
126126
}
127127

128-
getEras() {
128+
getEras(): string[] {
129129
return ['AA'];
130130
}
131131

@@ -154,7 +154,7 @@ export class CopticCalendar extends EthiopicCalendar {
154154
return new CalendarDate(this, era, year, month, day);
155155
}
156156

157-
toJulianDay(date: AnyCalendarDate) {
157+
toJulianDay(date: AnyCalendarDate): number {
158158
let year = date.year;
159159
if (date.era === 'BCE') {
160160
year = 1 - year;
@@ -176,14 +176,14 @@ export class CopticCalendar extends EthiopicCalendar {
176176
return date.era === 'BCE';
177177
}
178178

179-
balanceDate(date: Mutable<AnyCalendarDate>) {
179+
balanceDate(date: Mutable<AnyCalendarDate>): void {
180180
if (date.year <= 0) {
181181
date.era = date.era === 'BCE' ? 'CE' : 'BCE';
182182
date.year = 1 - date.year;
183183
}
184184
}
185185

186-
getEras() {
186+
getEras(): string[] {
187187
return ['BCE', 'CE'];
188188
}
189189

packages/@internationalized/date/src/calendars/GregorianCalendar.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,15 @@ export class GregorianCalendar implements Calendar {
118118
return 9999;
119119
}
120120

121-
getEras() {
121+
getEras(): string[] {
122122
return ['BC', 'AD'];
123123
}
124124

125125
isInverseEra(date: AnyCalendarDate): boolean {
126126
return date.era === 'BC';
127127
}
128128

129-
balanceDate(date: Mutable<AnyCalendarDate>) {
129+
balanceDate(date: Mutable<AnyCalendarDate>): void {
130130
if (date.year <= 0) {
131131
date.era = date.era === 'BC' ? 'AD' : 'BC';
132132
date.year = 1 - date.year;

packages/@internationalized/date/src/calendars/HebrewCalendar.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export class HebrewCalendar implements Calendar {
159159
return new CalendarDate(this, year, month, day);
160160
}
161161

162-
toJulianDay(date: AnyCalendarDate) {
162+
toJulianDay(date: AnyCalendarDate): number {
163163
let jd = startOfYear(date.year);
164164
for (let month = 1; month < date.month; month++) {
165165
jd += getDaysInMonth(date.year, month);
@@ -185,11 +185,11 @@ export class HebrewCalendar implements Calendar {
185185
return 9999;
186186
}
187187

188-
getEras() {
188+
getEras(): string[] {
189189
return ['AM'];
190190
}
191191

192-
balanceYearMonth(date: Mutable<AnyCalendarDate>, previousDate: AnyCalendarDate) {
192+
balanceYearMonth(date: Mutable<AnyCalendarDate>, previousDate: AnyCalendarDate): void {
193193
// Keep date in the same month when switching between leap years and non leap years
194194
if (previousDate.year !== date.year) {
195195
if (isLeapYear(previousDate.year) && !isLeapYear(date.year) && previousDate.month > 6) {

packages/@internationalized/date/src/calendars/IndianCalendar.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class IndianCalendar extends GregorianCalendar {
7575
return new CalendarDate(this, indianYear, indianMonth, indianDay);
7676
}
7777

78-
toJulianDay(date: AnyCalendarDate) {
78+
toJulianDay(date: AnyCalendarDate): number {
7979
let extendedYear = date.year + INDIAN_ERA_START;
8080
let [era, year] = fromExtendedYear(extendedYear);
8181

@@ -121,9 +121,9 @@ export class IndianCalendar extends GregorianCalendar {
121121
return 9919;
122122
}
123123

124-
getEras() {
124+
getEras(): string[] {
125125
return ['saka'];
126126
}
127127

128-
balanceDate() {}
128+
balanceDate(): void {}
129129
}

packages/@internationalized/date/src/calendars/IslamicCalendar.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class IslamicCivilCalendar implements Calendar {
5656
return julianDayToIslamic(this, CIVIL_EPOC, jd);
5757
}
5858

59-
toJulianDay(date: AnyCalendarDate) {
59+
toJulianDay(date: AnyCalendarDate): number {
6060
return islamicToJulianDay(CIVIL_EPOC, date.year, date.month, date.day);
6161
}
6262

@@ -82,7 +82,7 @@ export class IslamicCivilCalendar implements Calendar {
8282
return 9665;
8383
}
8484

85-
getEras() {
85+
getEras(): string[] {
8686
return ['AH'];
8787
}
8888
}
@@ -101,7 +101,7 @@ export class IslamicTabularCalendar extends IslamicCivilCalendar {
101101
return julianDayToIslamic(this, ASTRONOMICAL_EPOC, jd);
102102
}
103103

104-
toJulianDay(date: AnyCalendarDate) {
104+
toJulianDay(date: AnyCalendarDate): number {
105105
return islamicToJulianDay(ASTRONOMICAL_EPOC, date.year, date.month, date.day);
106106
}
107107
}

packages/@internationalized/date/src/calendars/JapaneseCalendar.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ export class JapaneseCalendar extends GregorianCalendar {
8585
);
8686
}
8787

88-
toJulianDay(date: AnyCalendarDate) {
88+
toJulianDay(date: AnyCalendarDate): number {
8989
return super.toJulianDay(toGregorian(date));
9090
}
9191

92-
balanceDate(date: Mutable<AnyCalendarDate>) {
92+
balanceDate(date: Mutable<AnyCalendarDate>): void {
9393
let gregorianDate = toGregorian(date);
9494
let era = findEraFromGregorianDate(gregorianDate);
9595

@@ -102,7 +102,7 @@ export class JapaneseCalendar extends GregorianCalendar {
102102
this.constrainDate(date);
103103
}
104104

105-
constrainDate(date: Mutable<AnyCalendarDate>) {
105+
constrainDate(date: Mutable<AnyCalendarDate>): void {
106106
let idx = ERA_NAMES.indexOf(date.era);
107107
let end = ERA_END_DATES[idx];
108108
if (end != null) {
@@ -131,7 +131,7 @@ export class JapaneseCalendar extends GregorianCalendar {
131131
}
132132
}
133133

134-
getEras() {
134+
getEras(): string[] {
135135
return ERA_NAMES;
136136
}
137137

packages/@internationalized/date/src/calendars/PersianCalendar.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class PersianCalendar implements Calendar {
8080
return isLeapYear ? 30 : 29;
8181
}
8282

83-
getEras() {
83+
getEras(): string[] {
8484
return ['AP'];
8585
}
8686

packages/@internationalized/date/src/calendars/TaiwanCalendar.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ export class TaiwanCalendar extends GregorianCalendar {
5050
return new CalendarDate(this, era, year, date.month, date.day);
5151
}
5252

53-
toJulianDay(date: AnyCalendarDate) {
53+
toJulianDay(date: AnyCalendarDate): number {
5454
return super.toJulianDay(toGregorian(date));
5555
}
5656

57-
getEras() {
57+
getEras(): string[] {
5858
return ['before_minguo', 'minguo'];
5959
}
6060

61-
balanceDate(date: Mutable<AnyCalendarDate>) {
61+
balanceDate(date: Mutable<AnyCalendarDate>): void {
6262
let [era, year] = gregorianToTaiwan(gregorianYear(date));
6363
date.era = era;
6464
date.year = year;

packages/@internationalized/date/src/conversion.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ import {getExtendedYear, GregorianCalendar} from './calendars/GregorianCalendar'
2020
import {getLocalTimeZone} from './queries';
2121
import {Mutable} from './utils';
2222

23-
export function epochFromDate(date: AnyDateTime) {
23+
export function epochFromDate(date: AnyDateTime): number {
2424
date = toCalendar(date, new GregorianCalendar());
2525
let year = getExtendedYear(date.era, date.year);
2626
return epochFromParts(year, date.month, date.day, date.hour, date.minute, date.second, date.millisecond);
2727
}
2828

29-
function epochFromParts(year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number) {
29+
function epochFromParts(year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number): number {
3030
// Note: Date.UTC() interprets one and two-digit years as being in the
3131
// 20th century, so don't use it
3232
let date = new Date();
@@ -35,7 +35,7 @@ function epochFromParts(year: number, month: number, day: number, hour: number,
3535
return date.getTime();
3636
}
3737

38-
export function getTimeZoneOffset(ms: number, timeZone: string) {
38+
export function getTimeZoneOffset(ms: number, timeZone: string): number {
3939
// Fast path for UTC.
4040
if (timeZone === 'UTC') {
4141
return 0;
@@ -292,7 +292,7 @@ export function toZoned(date: CalendarDate | CalendarDateTime | ZonedDateTime, t
292292
return fromAbsolute(ms, timeZone);
293293
}
294294

295-
export function zonedToDate(date: ZonedDateTime) {
295+
export function zonedToDate(date: ZonedDateTime): Date {
296296
let ms = epochFromDate(date) - date.offset;
297297
return new Date(ms);
298298
}

0 commit comments

Comments
 (0)