Skip to content

Commit 29ce63f

Browse files
mxschmittmartijnrusschen
authored andcommitted
fix: lgtm issues (Hacker0x01#1861)
1 parent b1e90dd commit 29ce63f

File tree

4 files changed

+20
-28
lines changed

4 files changed

+20
-28
lines changed

docs-site/src/examples/date_range.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from "react";
22
import DatePicker from "react-datepicker";
3-
import isAfter from "date-fns/isAfter";
43

54
export default class DateRange extends React.Component {
65
constructor(props) {

docs-site/src/examples/locale_without_global_variable.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import DatePicker, { registerLocale } from "react-datepicker";
2+
import DatePicker from "react-datepicker";
33
import fi from "date-fns/locale/fi";
44

55
export default class LocaleWithoutGlobalVariable extends React.Component {

src/calendar.jsx

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -213,18 +213,18 @@ export default class Calendar extends React.Component {
213213

214214
increaseMonth = () => {
215215
this.setState(
216-
{
217-
date: addMonths(this.state.date, 1)
218-
},
216+
({ date }) => ({
217+
date: addMonths(date, 1)
218+
}),
219219
() => this.handleMonthChange(this.state.date)
220220
);
221221
};
222222

223223
decreaseMonth = () => {
224224
this.setState(
225-
{
226-
date: subMonths(this.state.date, 1)
227-
},
225+
({ date }) => ({
226+
date: subMonths(date, 1)
227+
}),
228228
() => this.handleMonthChange(this.state.date)
229229
);
230230
};
@@ -269,30 +269,27 @@ export default class Calendar extends React.Component {
269269

270270
changeYear = year => {
271271
this.setState(
272-
{
273-
date: setYear(this.state.date, year)
274-
},
272+
({ date }) => ({
273+
date: setYear(date, year)
274+
}),
275275
() => this.handleYearChange(this.state.date)
276276
);
277277
};
278278

279279
changeMonth = month => {
280280
this.setState(
281-
{
282-
date: setMonth(this.state.date, month)
283-
},
281+
({ date }) => ({
282+
date: setMonth(date, month)
283+
}),
284284
() => this.handleMonthChange(this.state.date)
285285
);
286286
};
287287

288288
changeMonthYear = monthYear => {
289289
this.setState(
290-
{
291-
date: setYear(
292-
setMonth(this.state.date, getMonth(monthYear)),
293-
getYear(monthYear)
294-
)
295-
},
290+
({ date }) => ({
291+
date: setYear(setMonth(date, getMonth(monthYear)), getYear(monthYear))
292+
}),
296293
() => this.handleMonthYearChange(this.state.date)
297294
);
298295
};
@@ -331,9 +328,9 @@ export default class Calendar extends React.Component {
331328

332329
decreaseYear = () => {
333330
this.setState(
334-
{
335-
date: subYears(this.state.date, 1)
336-
},
331+
({ date }) => ({
332+
date: subYears(date, 1)
333+
}),
337334
() => this.handleYearChange(this.state.date)
338335
);
339336
};
@@ -537,9 +534,7 @@ export default class Calendar extends React.Component {
537534
<div className="react-datepicker__header">
538535
{this.renderCurrentMonth(monthDate)}
539536
<div
540-
className={`react-datepicker__header__dropdown react-datepicker__header__dropdown--${
541-
this.props.dropdownMode
542-
}`}
537+
className={`react-datepicker__header__dropdown react-datepicker__header__dropdown--${this.props.dropdownMode}`}
543538
onFocus={this.handleDropdownFocus}
544539
>
545540
{this.renderMonthDropdown(i !== 0)}

src/date_utils.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import max from "date-fns/max";
3131
import differenceInCalendarDays from "date-fns/differenceInCalendarDays";
3232
import differenceInCalendarMonths from "date-fns/differenceInCalendarMonths";
3333
import differenceInCalendarWeeks from "date-fns/differenceInCalendarWeeks";
34-
import setDayOfYear from "date-fns/setDayOfYear";
3534
import startOfDay from "date-fns/startOfDay";
3635
import startOfWeek from "date-fns/startOfWeek";
3736
import startOfMonth from "date-fns/startOfMonth";
@@ -185,7 +184,6 @@ export {
185184
};
186185

187186
export function getWeek(date) {
188-
let firstDayOfYear = setDayOfYear(date, 1);
189187
if (!isSameYear(endOfWeek(date), date)) {
190188
return 1;
191189
}

0 commit comments

Comments
 (0)