Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: change 'var' to 'let' and 'const' #4379

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/calendar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -861,18 +861,18 @@ export default class Calendar extends React.Component {
return;
}

var monthList = [];
var monthsToSubtract = this.props.showPreviousMonths
const monthList = [];
const monthsToSubtract = this.props.showPreviousMonths
? this.props.monthsShown - 1
: 0;
var fromMonthDate = subMonths(this.state.date, monthsToSubtract);
var monthSelectedIn = this.props.monthSelectedIn ?? monthsToSubtract;
for (var i = 0; i < this.props.monthsShown; ++i) {
var monthsToAdd = i - monthSelectedIn + monthsToSubtract;
var monthDate = addMonths(fromMonthDate, monthsToAdd);
var monthKey = `month-${i}`;
var monthShowsDuplicateDaysEnd = i < this.props.monthsShown - 1;
var monthShowsDuplicateDaysStart = i > 0;
const fromMonthDate = subMonths(this.state.date, monthsToSubtract);
const monthSelectedIn = this.props.monthSelectedIn ?? monthsToSubtract;
for (let i = 0; i < this.props.monthsShown; ++i) {
const monthsToAdd = i - monthSelectedIn + monthsToSubtract;
const monthDate = addMonths(fromMonthDate, monthsToAdd);
const monthKey = `month-${i}`;
const monthShowsDuplicateDaysEnd = i < this.props.monthsShown - 1;
const monthShowsDuplicateDaysStart = i > 0;
monthList.push(
<div
key={monthKey}
Expand Down
10 changes: 5 additions & 5 deletions src/date_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const DEFAULT_YEAR_ITEM_NUMBER = 12;

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

// ** Date Constructors **

Expand Down Expand Up @@ -105,9 +105,9 @@ export function parseDate(value, dateFormat, locale, strictParsing, minDate) {
dateFormat = dateFormat
.match(longFormattingTokensRegExp)
.map(function (substring) {
var firstCharacter = substring[0];
const firstCharacter = substring[0];
if (firstCharacter === "p" || firstCharacter === "P") {
var longFormatter = longFormatters[firstCharacter];
const longFormatter = longFormatters[firstCharacter];
return localeObject
? longFormatter(substring, localeObject.formatLong)
: firstCharacter;
Expand Down Expand Up @@ -497,8 +497,8 @@ export function isQuarterDisabled(

/**
* @param {number} year
* @param {date} start
* @param {date} end
* @param {Date} start
* @param {Date} end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch

◽ Compliment

Image of Dallas Dallas

* @returns {boolean}
*/
export function isYearInRange(year, start, end) {
Expand Down
4 changes: 2 additions & 2 deletions src/month.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default class Month extends React.Component {
fixedHeight: PropTypes.bool,
formatWeekNumber: PropTypes.func,
highlightDates: PropTypes.instanceOf(Map),
holidays: PropTypes.PropTypes.instanceOf(Map),
holidays: PropTypes.instanceOf(Map),
includeDates: PropTypes.array,
includeDateIntervals: PropTypes.array,
inline: PropTypes.bool,
Expand Down Expand Up @@ -592,7 +592,7 @@ export default class Month extends React.Component {
minDate,
maxDate,
preSelection,
disabledKeyboardNavigation
disabledKeyboardNavigation,
} = this.props;
return classnames(
"react-datepicker__quarter-text",
Expand Down
2 changes: 1 addition & 1 deletion src/year_dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import YearDropdownOptions from "./year_dropdown_options";
import onClickOutside from "react-onclickoutside";
import { getYear } from "./date_utils";

var WrappedYearDropdownOptions = onClickOutside(YearDropdownOptions);
const WrappedYearDropdownOptions = onClickOutside(YearDropdownOptions);

export default class YearDropdown extends React.Component {
static propTypes = {
Expand Down
10 changes: 5 additions & 5 deletions src/year_dropdown_options.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import classNames from "classnames";
import { getYear } from "./date_utils";

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

Expand Down Expand Up @@ -73,8 +73,8 @@ export default class YearDropdownOptions extends React.Component {
}

renderOptions = () => {
var selectedYear = this.props.year;
var options = this.state.yearsList.map((year) => (
const selectedYear = this.props.year;
const options = this.state.yearsList.map((year) => (
<div
className={
selectedYear === year
Expand Down Expand Up @@ -133,7 +133,7 @@ export default class YearDropdownOptions extends React.Component {
};

shiftYears = (amount) => {
var years = this.state.yearsList.map(function (year) {
const years = this.state.yearsList.map(function (year) {
return year + amount;
});

Expand Down
Loading