Skip to content

Commit a201b67

Browse files
committed
chore(frontend): set up typescript
1 parent ab050f7 commit a201b67

38 files changed

+2100
-56
lines changed

frontend/.ember-cli

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
Setting `isTypeScriptProject` to true will force the blueprint generators to generate TypeScript
1212
rather than JavaScript by default, when a TypeScript version of a given blueprint is available.
1313
*/
14-
"isTypeScriptProject": false
14+
"isTypeScriptProject": true
1515
}

frontend/.eslintrc.js

+101-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,107 @@
11
"use-strict";
22

33
module.exports = {
4-
extends: ["@adfinis/eslint-config/ember-app"],
4+
root: true,
5+
parser: "@typescript-eslint/parser",
6+
parserOptions: {
7+
ecmaVersion: "latest",
8+
},
9+
plugins: ["ember", "@typescript-eslint", "import"],
10+
extends: [
11+
"eslint:recommended",
12+
"plugin:ember/recommended",
13+
"plugin:prettier/recommended",
14+
],
15+
env: {
16+
browser: true,
17+
},
518
rules: {
6-
"ember/no-actions-hash": "warn",
7-
"ember/no-component-lifecycle-hooks": "warn",
8-
"ember/no-mixins": "warn",
9-
"ember/no-new-mixins": "warn",
10-
"ember/no-classic-classes": "warn",
11-
"ember/no-classic-components": "warn",
12-
"ember/no-get": "warn",
13-
"ember/no-observers": "warn",
14-
"qunit/no-assert-equal": "warn",
15-
"ember/require-tagless-components": "warn",
19+
// possible errors
20+
"no-await-in-loop": "error",
21+
22+
// best practices
23+
"array-callback-return": "error",
24+
"dot-notation": "error",
25+
eqeqeq: "error",
26+
"no-alert": "error",
27+
"no-else-return": "error",
28+
"no-eval": "error",
29+
"no-extend-native": "error",
30+
"no-extra-bind": "error",
31+
"no-floating-decimal": "error",
32+
"one-var": ["error", "never"],
33+
curly: ["error", "multi-line"],
34+
35+
// ES6
36+
"no-var": "error",
37+
"object-shorthand": "error",
38+
"prefer-const": "error",
39+
"prefer-destructuring": [
40+
"error",
41+
{ AssignmentExpression: { array: false, object: false } },
42+
],
43+
"prefer-rest-params": "error",
44+
"prefer-spread": "error",
45+
"prefer-template": "error",
46+
47+
// import
48+
"import/no-duplicates": "error",
49+
"import/no-unresolved": "off",
50+
"import/order": [
51+
"error",
52+
{
53+
"newlines-between": "always",
54+
alphabetize: { order: "asc", caseInsensitive: true },
55+
},
56+
],
57+
58+
// tooling
59+
"no-console": ["error", { allow: ["warn", "error"] }],
60+
"no-debugger": "error",
1661
},
62+
overrides: [
63+
// js files
64+
{
65+
files: ["**/*.js"],
66+
extends: [
67+
"plugin:@typescript-eslint/eslint-recommended",
68+
"plugin:@typescript-eslint/recommended",
69+
],
70+
rules: {},
71+
},
72+
// ts files
73+
{
74+
files: ["**/*.ts"],
75+
extends: [
76+
"plugin:@typescript-eslint/eslint-recommended",
77+
"plugin:@typescript-eslint/recommended",
78+
],
79+
rules: {},
80+
},
81+
// node files
82+
{
83+
files: [
84+
"./.eslintrc.js",
85+
"./.prettierrc.js",
86+
"./.stylelintrc.js",
87+
"./.template-lintrc.js",
88+
"./ember-cli-build.js",
89+
"./testem.js",
90+
"./blueprints/*/index.js",
91+
"./config/**/*.js",
92+
"./lib/*/index.js",
93+
"./server/**/*.js",
94+
],
95+
env: {
96+
browser: false,
97+
node: true,
98+
},
99+
extends: ["plugin:n/recommended"],
100+
},
101+
{
102+
// test files
103+
files: ["tests/**/*-test.{js,ts}"],
104+
extends: ["plugin:qunit/recommended"],
105+
},
106+
],
17107
};

frontend/app/config/environment.d.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Type declarations for
3+
* import config from 'my-app/config/environment'
4+
*/
5+
declare const config: {
6+
environment: string;
7+
modulePrefix: string;
8+
podModulePrefix: string;
9+
locationType: "history" | "hash" | "none" | "auto";
10+
rootURL: string;
11+
APP: Record<string, unknown>;
12+
};
13+
14+
export default config;
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import Model, { attr, belongsTo, hasMany } from "@ember-data/model";
2+
3+
export default class AbsenceBalance extends Model {
4+
@attr("number")
5+
declare credit: number;
6+
7+
@attr("number")
8+
declare usedDays: number;
9+
10+
@attr("django-duration") usedDuration;
11+
@attr("number") balance;
12+
@belongsTo("user", { async: false, inverse: "absenceBalances" }) user;
13+
@belongsTo("absence-type", { async: false, inverse: "absenceBalances" })
14+
absenceType;
15+
@hasMany("absence-credit", { async: true, inverse: null }) absenceCredits;
16+
}

frontend/app/models/absence-credit.ts

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* @module timed
3+
* @submodule timed-models
4+
* @public
5+
*/
6+
import Model, { attr, belongsTo } from "@ember-data/model";
7+
8+
/**
9+
* The absence credit model
10+
*
11+
* @class AbsenceCredit
12+
* @extends DS.Model
13+
* @public
14+
*/
15+
export default class AbsenceCredit extends Model {
16+
/**
17+
* The days
18+
*
19+
* @property {Number} days
20+
* @public
21+
*/
22+
@attr("number") days;
23+
24+
/**
25+
* The date
26+
*
27+
* @property {moment} date
28+
* @public
29+
*/
30+
@attr("django-date") date;
31+
32+
/**
33+
* The comment
34+
*
35+
* @property {String} comment
36+
* @public
37+
*/
38+
@attr("string", { defaultValue: "" }) comment;
39+
40+
/**
41+
* The absence type for which this credit counts
42+
*
43+
* @property {AbsenceType} absenceType
44+
* @public
45+
*/
46+
@belongsTo("absence-type", { async: false, inverse: null }) absenceType;
47+
48+
/**
49+
* The user to which this credit belongs to
50+
*
51+
* @property {User} user
52+
* @public
53+
*/
54+
@belongsTo("user", { async: false, inverse: null }) user;
55+
}

frontend/app/models/absence-type.ts

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* @module timed
3+
* @submodule timed-models
4+
* @public
5+
*/
6+
import Model, { attr, hasMany } from "@ember-data/model";
7+
8+
/**
9+
* The absence type model
10+
*
11+
* @class AbsenceType
12+
* @extends DS.Model
13+
* @public
14+
*/
15+
export default class AbsenceType extends Model {
16+
/**
17+
* The name of the absence type
18+
*
19+
* E.g Military, Holiday or Sickness
20+
*
21+
* @property {String} name
22+
* @public
23+
*/
24+
@attr("string") name;
25+
26+
/**
27+
* Whether the absence type only fills the worktime
28+
*
29+
* @property {Boolean} fillWorktime
30+
* @public
31+
*/
32+
@attr("boolean") fillWorktime;
33+
34+
/**
35+
* The balances for this type
36+
*
37+
* @property {AbsenceBalance[]} absenceBalances
38+
* @public
39+
*/
40+
@hasMany("absence-balance", { async: true, inverse: "absenceType" })
41+
absenceBalances;
42+
}

frontend/app/models/absence.ts

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* @module timed
3+
* @submodule timed-models
4+
* @public
5+
*/
6+
import Model, { attr, belongsTo } from "@ember-data/model";
7+
import moment from "moment";
8+
9+
/**
10+
* The report model
11+
*
12+
* @class Report
13+
* @extends DS.Model
14+
* @public
15+
*/
16+
export default class Absence extends Model {
17+
/**
18+
* The comment
19+
*
20+
* @property {String} comment
21+
* @public
22+
*/
23+
@attr("string", { defaultValue: "" }) comment;
24+
25+
/**
26+
* The duration
27+
*
28+
* @property {moment.duration} duration
29+
* @public
30+
*/
31+
@attr("django-duration", { defaultValue: () => moment.duration() }) duration;
32+
33+
/**
34+
* The date
35+
*
36+
* @property {moment} date
37+
* @public
38+
*/
39+
@attr("django-date") date;
40+
41+
/**
42+
* The type of the absence
43+
*
44+
* @property {AbsenceType} absenceType
45+
* @public
46+
*/
47+
@belongsTo("absence-type", { async: false, inverse: null }) absenceType;
48+
49+
/**
50+
* The user
51+
*
52+
* @property {User} user
53+
* @public
54+
*/
55+
@belongsTo("user", { async: true, inverse: null }) user;
56+
}

0 commit comments

Comments
 (0)