Skip to content

Commit

Permalink
fix: lgtm issues (Hacker0x01#1861)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt authored and martijnrusschen committed Aug 22, 2019
1 parent b1e90dd commit 29ce63f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 28 deletions.
1 change: 0 additions & 1 deletion docs-site/src/examples/date_range.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from "react";
import DatePicker from "react-datepicker";
import isAfter from "date-fns/isAfter";

export default class DateRange extends React.Component {
constructor(props) {
Expand Down
2 changes: 1 addition & 1 deletion docs-site/src/examples/locale_without_global_variable.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import DatePicker, { registerLocale } from "react-datepicker";
import DatePicker from "react-datepicker";
import fi from "date-fns/locale/fi";

export default class LocaleWithoutGlobalVariable extends React.Component {
Expand Down
43 changes: 19 additions & 24 deletions src/calendar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,18 @@ export default class Calendar extends React.Component {

increaseMonth = () => {
this.setState(
{
date: addMonths(this.state.date, 1)
},
({ date }) => ({
date: addMonths(date, 1)
}),
() => this.handleMonthChange(this.state.date)
);
};

decreaseMonth = () => {
this.setState(
{
date: subMonths(this.state.date, 1)
},
({ date }) => ({
date: subMonths(date, 1)
}),
() => this.handleMonthChange(this.state.date)
);
};
Expand Down Expand Up @@ -269,30 +269,27 @@ export default class Calendar extends React.Component {

changeYear = year => {
this.setState(
{
date: setYear(this.state.date, year)
},
({ date }) => ({
date: setYear(date, year)
}),
() => this.handleYearChange(this.state.date)
);
};

changeMonth = month => {
this.setState(
{
date: setMonth(this.state.date, month)
},
({ date }) => ({
date: setMonth(date, month)
}),
() => this.handleMonthChange(this.state.date)
);
};

changeMonthYear = monthYear => {
this.setState(
{
date: setYear(
setMonth(this.state.date, getMonth(monthYear)),
getYear(monthYear)
)
},
({ date }) => ({
date: setYear(setMonth(date, getMonth(monthYear)), getYear(monthYear))
}),
() => this.handleMonthYearChange(this.state.date)
);
};
Expand Down Expand Up @@ -331,9 +328,9 @@ export default class Calendar extends React.Component {

decreaseYear = () => {
this.setState(
{
date: subYears(this.state.date, 1)
},
({ date }) => ({
date: subYears(date, 1)
}),
() => this.handleYearChange(this.state.date)
);
};
Expand Down Expand Up @@ -537,9 +534,7 @@ export default class Calendar extends React.Component {
<div className="react-datepicker__header">
{this.renderCurrentMonth(monthDate)}
<div
className={`react-datepicker__header__dropdown react-datepicker__header__dropdown--${
this.props.dropdownMode
}`}
className={`react-datepicker__header__dropdown react-datepicker__header__dropdown--${this.props.dropdownMode}`}
onFocus={this.handleDropdownFocus}
>
{this.renderMonthDropdown(i !== 0)}
Expand Down
2 changes: 0 additions & 2 deletions src/date_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import max from "date-fns/max";
import differenceInCalendarDays from "date-fns/differenceInCalendarDays";
import differenceInCalendarMonths from "date-fns/differenceInCalendarMonths";
import differenceInCalendarWeeks from "date-fns/differenceInCalendarWeeks";
import setDayOfYear from "date-fns/setDayOfYear";
import startOfDay from "date-fns/startOfDay";
import startOfWeek from "date-fns/startOfWeek";
import startOfMonth from "date-fns/startOfMonth";
Expand Down Expand Up @@ -185,7 +184,6 @@ export {
};

export function getWeek(date) {
let firstDayOfYear = setDayOfYear(date, 1);
if (!isSameYear(endOfWeek(date), date)) {
return 1;
}
Expand Down

0 comments on commit 29ce63f

Please sign in to comment.