Skip to content

Commit f1d19e0

Browse files
12wrigjaptomato
authored andcommitted
Change let->const in several places to satisfy linter once sources are
migrated to TypeScript. The existing eslint config doesn't seem to mind the let currently, but does once the files are moved. Splitting this into a separate PR makes the TypeScript source migration PR easier to review.
1 parent 70ba681 commit f1d19e0

File tree

11 files changed

+44
-44
lines changed

11 files changed

+44
-44
lines changed

lib/calendar.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ const nonIsoHelperBase = {
450450
return this.formatter;
451451
},
452452
isoToCalendarDate(isoDate, cache) {
453-
let { year: isoYear, month: isoMonth, day: isoDay } = isoDate;
453+
const { year: isoYear, month: isoMonth, day: isoDay } = isoDate;
454454
const key = JSON.stringify({ func: 'isoToCalendarDate', isoYear, isoMonth, isoDay, id: this.id });
455455
const cached = cache.get(key);
456456
if (cached) return cached;
@@ -538,7 +538,7 @@ const nonIsoHelperBase = {
538538
return calendarDate;
539539
},
540540
validateCalendarDate(calendarDate) {
541-
let { era, month, year, day, eraYear, monthCode, monthExtra } = calendarDate;
541+
const { era, month, year, day, eraYear, monthCode, monthExtra } = calendarDate;
542542
// When there's a suffix (e.g. "5bis" for a leap month in Chinese calendar)
543543
// the derived class must deal with it.
544544
if (monthExtra !== undefined) throw new RangeError('Unexpected `monthExtra` value');
@@ -939,7 +939,7 @@ const nonIsoHelperBase = {
939939
const startDateIso = { year: 1972, month: 1, day: 1 };
940940
const { year: calendarYear } = this.isoToCalendarDate(startDateIso, cache);
941941
for (let i = 0; i < 100; i++) {
942-
let testCalendarDate = this.adjustCalendarDate({ day, monthCode, year: calendarYear - i }, cache);
942+
const testCalendarDate = this.adjustCalendarDate({ day, monthCode, year: calendarYear - i }, cache);
943943
const isoDate = this.calendarToIsoDate(testCalendarDate, 'constrain', cache);
944944
const roundTripCalendarDate = this.isoToCalendarDate(isoDate, cache);
945945
({ year: isoYear, month: isoMonth, day: isoDay } = isoDate);
@@ -1754,7 +1754,7 @@ const helperChinese = ObjectAssign({}, nonIsoHelperBase, {
17541754
const months = this.getMonthList(year, cache);
17551755
let numberPart = monthCode.replace('L', 'bis').slice(1);
17561756
if (numberPart[0] === '0') numberPart = numberPart.slice(1);
1757-
let monthInfo = months[numberPart];
1757+
const monthInfo = months[numberPart];
17581758
if (!monthInfo) throw new RangeError(`Unmatched monthCode ${monthCode} in Chinese year ${year}`);
17591759
if (month !== monthInfo.monthIndex) {
17601760
throw new RangeError(`monthCode ${monthCode} doesn't correspond to month ${month} in Chinese year ${year}`);

lib/duration.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class Duration {
170170
if (!props) {
171171
throw new TypeError('invalid duration-like');
172172
}
173-
let {
173+
const {
174174
years = GetSlot(this, YEARS),
175175
months = GetSlot(this, MONTHS),
176176
weeks = GetSlot(this, WEEKS),

lib/ecmascript.mjs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ export const ES = ObjectAssign({}, ES2020, {
376376
let minutes = ES.ToInteger(match[8]) * sign;
377377
let fMinutes = match[9];
378378
let seconds = ES.ToInteger(match[10]) * sign;
379-
let fSeconds = match[11] + '000000000';
379+
const fSeconds = match[11] + '000000000';
380380
let milliseconds = ES.ToInteger(fSeconds.slice(0, 3)) * sign;
381381
let microseconds = ES.ToInteger(fSeconds.slice(3, 6)) * sign;
382382
let nanoseconds = ES.ToInteger(fSeconds.slice(6, 9)) * sign;
@@ -509,7 +509,7 @@ export const ES = ObjectAssign({}, ES2020, {
509509
].forEach((val) => {
510510
if (val !== 0) throw new RangeError('only the smallest unit can be fractional');
511511
});
512-
let mins = fHours * 60;
512+
const mins = fHours * 60;
513513
minutes = MathTrunc(mins);
514514
fMinutes = mins % 1;
515515
}
@@ -520,7 +520,7 @@ export const ES = ObjectAssign({}, ES2020, {
520520
if (val !== 0) throw new RangeError('only the smallest unit can be fractional');
521521
}
522522
);
523-
let secs = fMinutes * 60;
523+
const secs = fMinutes * 60;
524524
seconds = MathTrunc(secs);
525525
fSeconds = secs % 1;
526526
}
@@ -529,7 +529,7 @@ export const ES = ObjectAssign({}, ES2020, {
529529
[milliseconds, fMilliseconds, microseconds, fMicroseconds, nanoseconds, fNanoseconds].forEach((val) => {
530530
if (val !== 0) throw new RangeError('only the smallest unit can be fractional');
531531
});
532-
let mils = fSeconds * 1000;
532+
const mils = fSeconds * 1000;
533533
milliseconds = MathTrunc(mils);
534534
fMilliseconds = mils % 1;
535535
}
@@ -538,7 +538,7 @@ export const ES = ObjectAssign({}, ES2020, {
538538
[microseconds, fMicroseconds, nanoseconds, fNanoseconds].forEach((val) => {
539539
if (val !== 0) throw new RangeError('only the smallest unit can be fractional');
540540
});
541-
let mics = fMilliseconds * 1000;
541+
const mics = fMilliseconds * 1000;
542542
microseconds = MathTrunc(mics);
543543
fMicroseconds = mics % 1;
544544
}
@@ -547,7 +547,7 @@ export const ES = ObjectAssign({}, ES2020, {
547547
[nanoseconds, fNanoseconds].forEach((val) => {
548548
if (val !== 0) throw new RangeError('only the smallest unit can be fractional');
549549
});
550-
let nans = fMicroseconds * 1000;
550+
const nans = fMicroseconds * 1000;
551551
nanoseconds = MathTrunc(nans);
552552
}
553553

@@ -591,7 +591,7 @@ export const ES = ObjectAssign({}, ES2020, {
591591
}
592592
);
593593
if (!props) throw new TypeError('invalid duration-like');
594-
let {
594+
const {
595595
years = 0,
596596
months = 0,
597597
weeks = 0,
@@ -684,7 +684,7 @@ export const ES = ObjectAssign({}, ES2020, {
684684
return ES.ToTemporalRoundingIncrement(options, maximumIncrements[smallestUnit], false);
685685
},
686686
ToSecondsStringPrecision: (options) => {
687-
let smallestUnit = ES.ToSmallestTemporalUnit(options, undefined, ['year', 'month', 'week', 'day', 'hour']);
687+
const smallestUnit = ES.ToSmallestTemporalUnit(options, undefined, ['year', 'month', 'week', 'day', 'hour']);
688688
switch (smallestUnit) {
689689
case 'minute':
690690
return { precision: 'minute', unit: 'minute', increment: 1 };
@@ -1043,7 +1043,7 @@ export const ES = ObjectAssign({}, ES2020, {
10431043
return ES.DateFromFields(calendar, fields, options);
10441044
}
10451045
ES.ToTemporalOverflow(options); // validate and ignore
1046-
let { year, month, day, calendar } = ES.ParseTemporalDateString(ES.ToString(item));
1046+
const { year, month, day, calendar } = ES.ParseTemporalDateString(ES.ToString(item));
10471047
const TemporalPlainDate = GetIntrinsic('%Temporal.PlainDate%');
10481048
return new TemporalPlainDate(year, month, day, calendar); // include validation
10491049
},
@@ -1850,7 +1850,7 @@ export const ES = ObjectAssign({}, ES2020, {
18501850
}
18511851
},
18521852
GetPossibleInstantsFor: (timeZone, dateTime) => {
1853-
let getPossibleInstantsFor = ES.GetMethod(timeZone, 'getPossibleInstantsFor');
1853+
const getPossibleInstantsFor = ES.GetMethod(timeZone, 'getPossibleInstantsFor');
18541854
const possibleInstants = ES.Call(getPossibleInstantsFor, timeZone, [dateTime]);
18551855
const result = [];
18561856
for (const instant of possibleInstants) {
@@ -1864,8 +1864,8 @@ export const ES = ObjectAssign({}, ES2020, {
18641864
ISOYearString: (year) => {
18651865
let yearString;
18661866
if (year < 1000 || year > 9999) {
1867-
let sign = year < 0 ? '-' : '+';
1868-
let yearNumber = MathAbs(year);
1867+
const sign = year < 0 ? '-' : '+';
1868+
const yearNumber = MathAbs(year);
18691869
yearString = sign + `000000${yearNumber}`.slice(-6);
18701870
} else {
18711871
yearString = `${year}`;
@@ -1956,7 +1956,7 @@ export const ES = ObjectAssign({}, ES2020, {
19561956
({ quotient: total, remainder: ns } = total.divmod(1000));
19571957
({ quotient: total, remainder: µs } = total.divmod(1000));
19581958
({ quotient: seconds, remainder: ms } = total.divmod(1000));
1959-
let fraction = MathAbs(ms.toJSNumber()) * 1e6 + MathAbs(µs.toJSNumber()) * 1e3 + MathAbs(ns.toJSNumber());
1959+
const fraction = MathAbs(ms.toJSNumber()) * 1e6 + MathAbs(µs.toJSNumber()) * 1e3 + MathAbs(ns.toJSNumber());
19601960
let decimalPart;
19611961
if (precision === 'auto') {
19621962
if (fraction !== 0) {
@@ -2179,7 +2179,7 @@ export const ES = ObjectAssign({}, ES2020, {
21792179
GetIANATimeZoneNextTransition: (epochNanoseconds, id) => {
21802180
const uppercap = ES.SystemUTCEpochNanoSeconds() + 366 * DAYMILLIS * 1e6;
21812181
let leftNanos = epochNanoseconds;
2182-
let leftOffsetNs = ES.GetIANATimeZoneOffsetNanoseconds(leftNanos, id);
2182+
const leftOffsetNs = ES.GetIANATimeZoneOffsetNanoseconds(leftNanos, id);
21832183
let rightNanos = leftNanos;
21842184
let rightOffsetNs = leftOffsetNs;
21852185
while (leftOffsetNs === rightOffsetNs && bigInt(leftNanos).compare(uppercap) === -1) {
@@ -2202,7 +2202,7 @@ export const ES = ObjectAssign({}, ES2020, {
22022202
GetIANATimeZonePreviousTransition: (epochNanoseconds, id) => {
22032203
const lowercap = BEFORE_FIRST_DST; // 1847-01-01T00:00:00Z
22042204
let rightNanos = bigInt(epochNanoseconds).minus(1);
2205-
let rightOffsetNs = ES.GetIANATimeZoneOffsetNanoseconds(rightNanos, id);
2205+
const rightOffsetNs = ES.GetIANATimeZoneOffsetNanoseconds(rightNanos, id);
22062206
let leftNanos = rightNanos;
22072207
let leftOffsetNs = rightOffsetNs;
22082208
while (rightOffsetNs === leftOffsetNs && bigInt(rightNanos).compare(lowercap) === 1) {
@@ -2240,7 +2240,7 @@ export const ES = ObjectAssign({}, ES2020, {
22402240
};
22412241
},
22422242
GetIANATimeZoneEpochValue: (id, year, month, day, hour, minute, second, millisecond, microsecond, nanosecond) => {
2243-
let ns = ES.GetEpochFromISOParts(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond);
2243+
const ns = ES.GetEpochFromISOParts(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond);
22442244
if (ns === null) throw new RangeError('DateTime outside of supported range');
22452245
const dayNanos = bigInt(DAYMILLIS).multiply(1e6);
22462246
let nsEarlier = ns.minus(dayNanos);
@@ -2310,9 +2310,9 @@ export const ES = ObjectAssign({}, ES2020, {
23102310
return days;
23112311
},
23122312
WeekOfYear: (year, month, day) => {
2313-
let doy = ES.DayOfYear(year, month, day);
2314-
let dow = ES.DayOfWeek(year, month, day) || 7;
2315-
let doj = ES.DayOfWeek(year, 1, 1);
2313+
const doy = ES.DayOfYear(year, month, day);
2314+
const dow = ES.DayOfWeek(year, month, day) || 7;
2315+
const doj = ES.DayOfWeek(year, 1, 1);
23162316

23172317
const week = MathFloor((doy - dow + 10) / 7);
23182318

@@ -2415,7 +2415,7 @@ export const ES = ObjectAssign({}, ES2020, {
24152415
hour += MathFloor(minute / 60);
24162416
minute = ES.NonNegativeModulo(minute, 60);
24172417

2418-
let deltaDays = MathFloor(hour / 24);
2418+
const deltaDays = MathFloor(hour / 24);
24192419
hour = ES.NonNegativeModulo(hour, 24);
24202420

24212421
return { deltaDays, hour, minute, second, millisecond, microsecond, nanosecond };
@@ -3180,14 +3180,14 @@ export const ES = ObjectAssign({}, ES2020, {
31803180
largestUnit,
31813181
options
31823182
);
3183-
let intermediateNs = ES.AddZonedDateTime(start, timeZone, calendar, years, months, weeks, 0, 0, 0, 0, 0, 0, 0);
3183+
const intermediateNs = ES.AddZonedDateTime(start, timeZone, calendar, years, months, weeks, 0, 0, 0, 0, 0, 0, 0);
31843184
// may disambiguate
31853185
let timeRemainderNs = ns2.subtract(intermediateNs);
31863186
const intermediate = ES.CreateTemporalZonedDateTime(intermediateNs, timeZone, calendar);
31873187
({ nanoseconds: timeRemainderNs, days } = ES.NanosecondsToDays(timeRemainderNs, intermediate));
31883188

31893189
// Finally, merge the date and time durations and return the merged result.
3190-
let { hours, minutes, seconds, milliseconds, microseconds, nanoseconds } = ES.BalanceDuration(
3190+
const { hours, minutes, seconds, milliseconds, microseconds, nanoseconds } = ES.BalanceDuration(
31913191
0,
31923192
0,
31933193
0,
@@ -3496,7 +3496,7 @@ export const ES = ObjectAssign({}, ES2020, {
34963496

34973497
// RFC 5545 requires the date portion to be added in calendar days and the
34983498
// time portion to be added in exact time.
3499-
let dt = ES.BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar);
3499+
const dt = ES.BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar);
35003500
const datePart = ES.CreateTemporalDate(
35013501
GetSlot(dt, ISO_YEAR),
35023502
GetSlot(dt, ISO_MONTH),
@@ -4155,7 +4155,7 @@ function bisect(getState, left, right, lstate = getState(left), rstate = getStat
41554155
left = bigInt(left);
41564156
right = bigInt(right);
41574157
while (right.minus(left).greater(1)) {
4158-
let middle = left.plus(right).divide(2);
4158+
const middle = left.plus(right).divide(2);
41594159
const mstate = getState(middle);
41604160
if (mstate === lstate) {
41614161
left = middle;

lib/intl.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ export function DateTimeFormat(locale = undefined, options = undefined) {
107107
this[INST] = instantAmend;
108108
}
109109

110-
DateTimeFormat.supportedLocalesOf = function (...args) {
111-
return IntlDateTimeFormat.supportedLocalesOf(...args);
110+
DateTimeFormat.supportedLocalesOf = function (locales, options) {
111+
return IntlDateTimeFormat.supportedLocalesOf(locales, options);
112112
};
113113

114114
const properties = {
@@ -194,7 +194,7 @@ function formatRangeToParts(a, b) {
194194

195195
function amend(options = {}, amended = {}) {
196196
options = ObjectAssign({}, options);
197-
for (let opt of [
197+
for (const opt of [
198198
'year',
199199
'month',
200200
'day',
@@ -476,7 +476,7 @@ function extractOverrides(temporalObj, main) {
476476
);
477477
}
478478

479-
let timeZone = GetSlot(temporalObj, TIME_ZONE);
479+
const timeZone = GetSlot(temporalObj, TIME_ZONE);
480480
const objTimeZone = ES.ToString(timeZone);
481481
if (main[TZ_GIVEN] && main[TZ_GIVEN] !== objTimeZone) {
482482
throw new RangeError(`timeZone option ${main[TZ_GIVEN]} doesn't match actual time zone ${objTimeZone}`);

lib/intrinsicclass.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ export function MakeIntrinsicClass(Class, name) {
4646
configurable: true
4747
});
4848
}
49-
for (let prop of Object.getOwnPropertyNames(Class)) {
49+
for (const prop of Object.getOwnPropertyNames(Class)) {
5050
const desc = Object.getOwnPropertyDescriptor(Class, prop);
5151
if (!desc.configurable || !desc.enumerable) continue;
5252
desc.enumerable = false;
5353
Object.defineProperty(Class, prop, desc);
5454
}
55-
for (let prop of Object.getOwnPropertyNames(Class.prototype)) {
55+
for (const prop of Object.getOwnPropertyNames(Class.prototype)) {
5656
const desc = Object.getOwnPropertyDescriptor(Class.prototype, prop);
5757
if (!desc.configurable || !desc.enumerable) continue;
5858
desc.enumerable = false;

lib/plaindate.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ export class PlainDate {
326326

327327
let timeZone, temporalTime;
328328
if (ES.Type(item) === 'Object') {
329-
let timeZoneLike = item.timeZone;
329+
const timeZoneLike = item.timeZone;
330330
if (timeZoneLike === undefined) {
331331
timeZone = ES.ToTemporalTimeZone(item);
332332
} else {

lib/plaindatetime.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ export class PlainDateTime {
278278
}
279279
add(temporalDurationLike, options = undefined) {
280280
if (!ES.IsTemporalDateTime(this)) throw new TypeError('invalid receiver');
281-
let duration = ES.ToLimitedTemporalDuration(temporalDurationLike);
282-
let { years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds } = duration;
281+
const duration = ES.ToLimitedTemporalDuration(temporalDurationLike);
282+
const { years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds } = duration;
283283
options = ES.GetOptionsObject(options);
284284
const calendar = GetSlot(this, CALENDAR);
285285
const { year, month, day, hour, minute, second, millisecond, microsecond, nanosecond } = ES.AddDateTime(
@@ -320,8 +320,8 @@ export class PlainDateTime {
320320
}
321321
subtract(temporalDurationLike, options = undefined) {
322322
if (!ES.IsTemporalDateTime(this)) throw new TypeError('invalid receiver');
323-
let duration = ES.ToLimitedTemporalDuration(temporalDurationLike);
324-
let { years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds } = duration;
323+
const duration = ES.ToLimitedTemporalDuration(temporalDurationLike);
324+
const { years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds } = duration;
325325
options = ES.GetOptionsObject(options);
326326
const calendar = GetSlot(this, CALENDAR);
327327
const { year, month, day, hour, minute, second, millisecond, microsecond, nanosecond } = ES.AddDateTime(

lib/plainmonthday.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class PlainMonthDay {
9595
const calendar = GetSlot(this, CALENDAR);
9696

9797
const receiverFieldNames = ES.CalendarFields(calendar, ['day', 'monthCode']);
98-
let fields = ES.ToTemporalMonthDayFields(this, receiverFieldNames);
98+
const fields = ES.ToTemporalMonthDayFields(this, receiverFieldNames);
9999

100100
const inputFieldNames = ES.CalendarFields(calendar, ['year']);
101101
const inputEntries = [['year', undefined]];

lib/plaintime.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export class PlainTime {
201201
}
202202
subtract(temporalDurationLike) {
203203
if (!ES.IsTemporalTime(this)) throw new TypeError('invalid receiver');
204-
let duration = ES.ToLimitedTemporalDuration(temporalDurationLike);
204+
const duration = ES.ToLimitedTemporalDuration(temporalDurationLike);
205205
const { hours, minutes, seconds, milliseconds, microseconds, nanoseconds } = duration;
206206
let hour = GetSlot(this, ISO_HOUR);
207207
let minute = GetSlot(this, ISO_MINUTE);

lib/plainyearmonth.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ export class PlainYearMonth {
298298
const calendar = GetSlot(this, CALENDAR);
299299

300300
const receiverFieldNames = ES.CalendarFields(calendar, ['monthCode', 'year']);
301-
let fields = ES.ToTemporalYearMonthFields(this, receiverFieldNames);
301+
const fields = ES.ToTemporalYearMonthFields(this, receiverFieldNames);
302302

303303
const inputFieldNames = ES.CalendarFields(calendar, ['day']);
304304
const inputEntries = [['day']];

0 commit comments

Comments
 (0)