Skip to content

Commit e17dcac

Browse files
Merge pull request #4379 from Sauter001/for-refactor
refactor: change 'var' to 'let' and 'const'
2 parents 095796e + 39544b9 commit e17dcac

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

src/calendar.jsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -862,18 +862,18 @@ export default class Calendar extends React.Component {
862862
return;
863863
}
864864

865-
var monthList = [];
866-
var monthsToSubtract = this.props.showPreviousMonths
865+
const monthList = [];
866+
const monthsToSubtract = this.props.showPreviousMonths
867867
? this.props.monthsShown - 1
868868
: 0;
869-
var fromMonthDate = subMonths(this.state.date, monthsToSubtract);
870-
var monthSelectedIn = this.props.monthSelectedIn ?? monthsToSubtract;
871-
for (var i = 0; i < this.props.monthsShown; ++i) {
872-
var monthsToAdd = i - monthSelectedIn + monthsToSubtract;
873-
var monthDate = addMonths(fromMonthDate, monthsToAdd);
874-
var monthKey = `month-${i}`;
875-
var monthShowsDuplicateDaysEnd = i < this.props.monthsShown - 1;
876-
var monthShowsDuplicateDaysStart = i > 0;
869+
const fromMonthDate = subMonths(this.state.date, monthsToSubtract);
870+
const monthSelectedIn = this.props.monthSelectedIn ?? monthsToSubtract;
871+
for (let i = 0; i < this.props.monthsShown; ++i) {
872+
const monthsToAdd = i - monthSelectedIn + monthsToSubtract;
873+
const monthDate = addMonths(fromMonthDate, monthsToAdd);
874+
const monthKey = `month-${i}`;
875+
const monthShowsDuplicateDaysEnd = i < this.props.monthsShown - 1;
876+
const monthShowsDuplicateDaysStart = i > 0;
877877
monthList.push(
878878
<div
879879
key={monthKey}

src/date_utils.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const DEFAULT_YEAR_ITEM_NUMBER = 12;
6060

6161
// This RegExp catches symbols escaped by quotes, and also
6262
// sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
63-
var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
63+
const longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
6464

6565
// ** Date Constructors **
6666

@@ -105,9 +105,9 @@ export function parseDate(value, dateFormat, locale, strictParsing, minDate) {
105105
dateFormat = dateFormat
106106
.match(longFormattingTokensRegExp)
107107
.map(function (substring) {
108-
var firstCharacter = substring[0];
108+
const firstCharacter = substring[0];
109109
if (firstCharacter === "p" || firstCharacter === "P") {
110-
var longFormatter = longFormatters[firstCharacter];
110+
const longFormatter = longFormatters[firstCharacter];
111111
return localeObject
112112
? longFormatter(substring, localeObject.formatLong)
113113
: firstCharacter;
@@ -497,8 +497,8 @@ export function isQuarterDisabled(
497497

498498
/**
499499
* @param {number} year
500-
* @param {date} start
501-
* @param {date} end
500+
* @param {Date} start
501+
* @param {Date} end
502502
* @returns {boolean}
503503
*/
504504
export function isYearInRange(year, start, end) {

src/month.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default class Month extends React.Component {
7474
fixedHeight: PropTypes.bool,
7575
formatWeekNumber: PropTypes.func,
7676
highlightDates: PropTypes.instanceOf(Map),
77-
holidays: PropTypes.PropTypes.instanceOf(Map),
77+
holidays: PropTypes.instanceOf(Map),
7878
includeDates: PropTypes.array,
7979
includeDateIntervals: PropTypes.array,
8080
inline: PropTypes.bool,
@@ -594,7 +594,7 @@ export default class Month extends React.Component {
594594
minDate,
595595
maxDate,
596596
preSelection,
597-
disabledKeyboardNavigation
597+
disabledKeyboardNavigation,
598598
} = this.props;
599599
return classnames(
600600
"react-datepicker__quarter-text",

src/year_dropdown.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import YearDropdownOptions from "./year_dropdown_options";
44
import onClickOutside from "react-onclickoutside";
55
import { getYear } from "./date_utils";
66

7-
var WrappedYearDropdownOptions = onClickOutside(YearDropdownOptions);
7+
const WrappedYearDropdownOptions = onClickOutside(YearDropdownOptions);
88

99
export default class YearDropdown extends React.Component {
1010
static propTypes = {

src/year_dropdown_options.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import classNames from "classnames";
44
import { getYear } from "./date_utils";
55

66
function generateYears(year, noOfYear, minDate, maxDate) {
7-
var list = [];
8-
for (var i = 0; i < 2 * noOfYear + 1; i++) {
7+
const list = [];
8+
for (let i = 0; i < 2 * noOfYear + 1; i++) {
99
const newYear = year + noOfYear - i;
1010
let isInRange = true;
1111

@@ -73,8 +73,8 @@ export default class YearDropdownOptions extends React.Component {
7373
}
7474

7575
renderOptions = () => {
76-
var selectedYear = this.props.year;
77-
var options = this.state.yearsList.map((year) => (
76+
const selectedYear = this.props.year;
77+
const options = this.state.yearsList.map((year) => (
7878
<div
7979
className={
8080
selectedYear === year
@@ -133,7 +133,7 @@ export default class YearDropdownOptions extends React.Component {
133133
};
134134

135135
shiftYears = (amount) => {
136-
var years = this.state.yearsList.map(function (year) {
136+
const years = this.state.yearsList.map(function (year) {
137137
return year + amount;
138138
});
139139

0 commit comments

Comments
 (0)