Skip to content

Commit

Permalink
chore(frontend): eslint v9 (#612)
Browse files Browse the repository at this point in the history
* chore(frontend): update linting

update to eslint v9
update most eslint-* deps
update stylelint
etc.

* fix(frontend): run eslint . --fix

* chore(frontend): manually fix remaining eslint errors
  • Loading branch information
c0rydoras authored Feb 18, 2025
1 parent 6349231 commit ef92873
Show file tree
Hide file tree
Showing 98 changed files with 853 additions and 620 deletions.
27 changes: 0 additions & 27 deletions frontend/.eslintignore

This file was deleted.

8 changes: 0 additions & 8 deletions frontend/.eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion frontend/.stylelintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
"at-rule-empty-line-before": ["never", { ignoreAtRules: ["import"] }], // we use empty lines to group/order imports (su)
"selector-class-pattern": null, // we can ignore this because most css is styling 3rd party components where we don't control the class names
"import-notation": null, // doesn't really work with postcss-import
"at-rule-no-unknown": [
"at-rule-no-deprecated": [
true,
{
ignoreAtRules: ["apply"], // ignore tailwind decorators
Expand Down
2 changes: 0 additions & 2 deletions frontend/app/abilities/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ export default class ReportAbility extends Ability {
const isEditable =
this.user?.isSuperuser ||
(!this.model?.verifiedBy?.get("id") &&
// eslint-disable-next-line ember/no-get
(this.model?.user?.get("id") === this.user?.get("id") ||
// eslint-disable-next-line ember/no-get
(this.model?.user?.get("supervisors") ?? [])
.map((s) => s.id)
.includes(this.user?.get("id"))));
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/analysis/edit/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { service } from "@ember/service";
import { dasherize } from "@ember/string";
import { tracked } from "@glimmer/tracking";
import { task } from "ember-concurrency";

import {
underscoreQueryParams,
serializeQueryParams,
Expand Down Expand Up @@ -205,7 +206,7 @@ export default class AnalysisEditController extends Controller {
});

this.notify.success("Reports were saved");
} catch (e) {
} catch {
this.notify.error("Error while saving the reports");
}

Expand Down
1 change: 1 addition & 0 deletions frontend/app/analysis/edit/route.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Route from "@ember/routing/route";

import { resetQueryParams } from "timed/utils/query-params";

export default class AnalysisEditRoute extends Route {
Expand Down
8 changes: 4 additions & 4 deletions frontend/app/analysis/index/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import {
} from "ember-concurrency";
import fetch from "fetch";
import moment from "moment";

import config from "../../config/environment";

import QPController from "timed/controllers/qpcontroller";
import parseDjangoDuration from "timed/utils/parse-django-duration";
import parseFileName from "timed/utils/parse-filename";
Expand All @@ -24,8 +27,6 @@ import {
import { serializeMoment } from "timed/utils/serialize-moment";
import { cleanParams, toQueryString } from "timed/utils/url";

import config from "../../config/environment";

export default class AnalysisController extends QPController {
queryParams = [
"customer",
Expand Down Expand Up @@ -341,8 +342,7 @@ export default class AnalysisController extends QPController {
download(file, filename, file.type);

this.notify.success("File was downloaded");
} catch (e) {
/* istanbul ignore next */
} catch {
this.notify.error(
"Error while downloading, try again or try reducing results",
);
Expand Down
1 change: 1 addition & 0 deletions frontend/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { registerDateLibrary } from "ember-power-calendar";
import DateUtils from "ember-power-calendar-moment";
import Resolver from "ember-resolver";
import fastRedact from "fast-redact";

import config from "timed/config/environment";

import "simplebar";
Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/attendance-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { dropTask } from "ember-concurrency";
import moment from "moment";

import formatDuration from "timed/utils/format-duration";
import { pad2joincolon } from "timed/utils/pad";

Expand Down
3 changes: 2 additions & 1 deletion frontend/app/components/datepicker-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
*/

import { action } from "@ember/object";
import Datepicker from "timed/components/datepicker";
import { localCopy } from "tracked-toolbox";

import Datepicker from "timed/components/datepicker";

/**
* The datepicker buttn component
*
Expand Down
1 change: 0 additions & 1 deletion frontend/app/components/duration-since.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export default class DurationSinceComponent extends Component {
* @public
*/
timer = task(async () => {
// eslint-disable-next-line no-constant-condition
while (true) {
this._compute();

Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/durationpicker-day.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { action } from "@ember/object";
import moment from "moment";

import DurationpickerComponent from "timed/components/durationpicker";
import parseDayTime from "timed/utils/parse-daytime";

Expand Down
3 changes: 2 additions & 1 deletion frontend/app/components/durationpicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { action } from "@ember/object";
import { guidFor } from "@ember/object/internals";
import { tracked } from "@glimmer/tracking";
import moment from "moment";
import { localCopy } from "tracked-toolbox";

import TimepickerComponent from "timed/components/timepicker";
import formatDuration from "timed/utils/format-duration";
import { localCopy } from "tracked-toolbox";

const { MIN_SAFE_INTEGER, MAX_SAFE_INTEGER } = Number;
const { abs } = Math;
Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/report-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { action } from "@ember/object";
import { service } from "@ember/service";
import Component from "@glimmer/component";
import { dropTask } from "ember-concurrency";

import ReportValidations from "timed/validations/report";

export default class ReportRowComponent extends Component {
Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/statistic-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { get } from "@ember/object";
import { capitalize } from "@ember/string";
import Component from "@glimmer/component";
import moment from "moment";

import parseDjangoDuration from "timed/utils/parse-django-duration";

const PLAIN_LAYOUT = "PLAIN";
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/components/task-selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import Component from "@glimmer/component";
import { restartableTask, timeout, dropTask } from "ember-concurrency";
import { trackedTask } from "reactiveweb/ember-concurrency";
import { resolve } from "rsvp";
import { localCopy } from "tracked-toolbox";

import customerOptionTemplate from "timed/components/optimized-power-select/custom-options/customer-option";
import projectOptionTemplate from "timed/components/optimized-power-select/custom-options/project-option";
import taskOptionTemplate from "timed/components/optimized-power-select/custom-options/task-option";
import customSelectedTemplate from "timed/components/optimized-power-select/custom-select/task-selection";
import { localCopy } from "tracked-toolbox";
/**
* Component for selecting a task, which consists of selecting a customer and
* project first.
Expand Down
1 change: 0 additions & 1 deletion frontend/app/components/timed-clock.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default class TimedClock extends Component {
}

timer = task(async () => {
// eslint-disable-next-line no-constant-condition
while (true) {
this._update();

Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/user-selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { restartableTask } from "ember-concurrency";
import { trackedTask } from "reactiveweb/ember-concurrency";

import customOptionTemplate from "timed/components/optimized-power-select/custom-options/user-option";
import customSelectedTemplate from "timed/components/optimized-power-select/custom-select/user-selection";

Expand Down
1 change: 1 addition & 0 deletions frontend/app/components/worktime-balance-chart.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Component from "@glimmer/component";
import moment from "moment";

import humanizeDuration from "timed/utils/humanize-duration";

// TODO: take this from tailwind.config.js
Expand Down
1 change: 1 addition & 0 deletions frontend/app/helpers/format-duration.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* @public
*/
import { helper } from "@ember/component/helper";

import formatDuration from "timed/utils/format-duration";

/**
Expand Down
1 change: 1 addition & 0 deletions frontend/app/helpers/humanize-duration.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* @public
*/
import { helper } from "@ember/component/helper";

import humanizeDuration from "timed/utils/humanize-duration";

/**
Expand Down
1 change: 1 addition & 0 deletions frontend/app/helpers/parse-django-duration.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* @public
*/
import { helper } from "@ember/component/helper";

import parseDjangoDuration from "timed/utils/parse-django-duration";

/**
Expand Down
3 changes: 1 addition & 2 deletions frontend/app/index/activities/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ export default class ActivitiesIndexController extends Controller {
}, resolve());

this.router.transitionTo("index.reports");
} catch (e) {
/* istanbul ignore next */
} catch {
this.notify.error("Error while generating reports");
} finally {
this.tracking.generatingReports = false;
Expand Down
1 change: 1 addition & 0 deletions frontend/app/index/activities/edit/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Route from "@ember/routing/route";
import { service } from "@ember/service";
import Changeset from "ember-changeset";
import lookupValidator from "ember-changeset-validations";

import ActivityValidator from "timed/validations/activity";

/**
Expand Down
10 changes: 4 additions & 6 deletions frontend/app/index/attendances/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import Controller from "@ember/controller";
import { action } from "@ember/object";
import { service } from "@ember/service";

import AttendanceValidator from "timed/validations/attendance";

/**
Expand Down Expand Up @@ -73,8 +74,7 @@ export default class AttendanceController extends Controller {
await attendance.save();

this.notify.success("Attendance was saved");
} catch (e) {
/* istanbul ignore next */
} catch {
this.notify.error("Error while saving the attendance");
}
}
Expand All @@ -92,8 +92,7 @@ export default class AttendanceController extends Controller {
await this.store.peekRecord("attendance", attendance.id).destroyRecord();

this.notify.success("Attendance was deleted");
} catch (e) {
/* istanbul ignore next */
} catch {
this.notify.error("Error while deleting the attendance");
}
}
Expand Down Expand Up @@ -121,8 +120,7 @@ export default class AttendanceController extends Controller {
await attendance.save();

this.notify.success("Attendance was added");
} catch (e) {
/* istanbul ignore next */
} catch {
this.notify.error("Error while adding the attendance");
}
}
Expand Down
16 changes: 7 additions & 9 deletions frontend/app/index/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import { tracked } from "@glimmer/tracking";
import { dropTask, timeout } from "ember-concurrency";
import moment from "moment";
import { trackedFunction } from "reactiveweb/function";
import AbsenceValidations from "timed/validations/absence";
import MultipleAbsenceValidations from "timed/validations/multiple-absence";
import { tracked as trackedWrapper } from "tracked-built-ins";
import { cached } from "tracked-toolbox";

import AbsenceValidations from "timed/validations/absence";
import MultipleAbsenceValidations from "timed/validations/multiple-absence";

/**
* The index controller
*
Expand Down Expand Up @@ -138,7 +139,6 @@ export default class IndexController extends Controller {
* @private
*/
_activitySumTask = dropTask(async () => {
// eslint-disable-next-line no-constant-condition
while (true) {
this._activitySum();

Expand Down Expand Up @@ -449,7 +449,7 @@ export default class IndexController extends Controller {

const publicHolidays = await this.store.query("public-holiday", {
...params,
// eslint-disable-next-line ember/no-get

location: this.currentUser.user.activeEmployment.location.get("id"),
});

Expand Down Expand Up @@ -519,8 +519,7 @@ export default class IndexController extends Controller {
await changeset.save();

this.showEditModal = false;
} catch (e) {
/* istanbul ignore next */
} catch {
this.notify.error("Error while saving the absence");
} finally {
this.send("finished");
Expand All @@ -542,8 +541,7 @@ export default class IndexController extends Controller {
await absence.destroyRecord();

this.showEditModal = false;
} catch (e) {
/* istanbul ignore next */
} catch {
this.notify.error("Error while deleting the absence");
} finally {
this.send("finished");
Expand Down Expand Up @@ -579,7 +577,7 @@ export default class IndexController extends Controller {
changeset.rollback();

this.showAddModal = false;
} catch (e) {
} catch {
this.notify.error("Error while adding the absence");
} finally {
this.send("finished");
Expand Down
9 changes: 5 additions & 4 deletions frontend/app/index/reports/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import { service } from "@ember/service";
import { tracked } from "@glimmer/tracking";
import moment from "moment";
import { all } from "rsvp";
import ReportValidations from "timed/validations/report";
import { cached } from "tracked-toolbox";

import ReportValidations from "timed/validations/report";
/**
* The index reports controller
*
Expand Down Expand Up @@ -121,7 +122,7 @@ export default class IndexReportController extends Controller {
if (this.absence) {
await this.absence.reload();
}
} catch (e) {
} catch {
this.notify.error("Error while saving the report");
} finally {
this.send("finished");
Expand All @@ -147,7 +148,7 @@ export default class IndexReportController extends Controller {
await this.absence.reload();
}
}
} catch (e) {
} catch {
this.notify.error("Error while deleting the report");
} finally {
this.send("finished");
Expand Down Expand Up @@ -180,7 +181,7 @@ export default class IndexReportController extends Controller {
this.router.transitionTo({
queryParams: { day: date.format("YYYY-MM-DD") },
});
} catch (e) {
} catch {
this.notify.error("Error while rescheduling the timesheet");
}
}
Expand Down
Loading

0 comments on commit ef92873

Please sign in to comment.