aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores
diff options
context:
space:
mode:
authorLibravatar MCMXC <16797721+mcmxcdev@users.noreply.github.com>2023-07-23 20:08:52 -0600
committerLibravatar Vijay Aravamudhan <vraravam@users.noreply.github.com>2023-07-25 07:45:23 +0000
commit8c131073730ec684145c2cc8ee8d6b39bbe9278d (patch)
tree1129d432ae88475909f0e5d38960395b75364902 /src/stores
parent6.4.1-nightly.11 [skip ci] (diff)
downloadferdium-app-8c131073730ec684145c2cc8ee8d6b39bbe9278d.tar.gz
ferdium-app-8c131073730ec684145c2cc8ee8d6b39bbe9278d.tar.zst
ferdium-app-8c131073730ec684145c2cc8ee8d6b39bbe9278d.zip
chore: improve lint setup
- update eslint config - merged eslint rules for JS and TS to avoid duplicates - extended stricter lint ruleset from typescript-eslint - corrected wrong setup for certain eslint rulesets - opt in to reportUnusedDisableDirectives config option - fix or disable a lot of lint issues throughout codebase - remove trailingComma: all from prettier config which is default in prettier v3 - add volta configuration to package.json to autoload correct node and pnpm versions - upgrade all eslint and prettier related dependencies to latest - remove config options from settings.json which are default anyways - remove config options from settings.json which are outdated/unknown - set up prettier as default formatter in settings.json
Diffstat (limited to 'src/stores')
-rw-r--r--src/stores/AppStore.ts2
-rw-r--r--src/stores/GlobalErrorStore.ts12
-rw-r--r--src/stores/RecipesStore.ts1
-rw-r--r--src/stores/ServicesStore.ts2
-rw-r--r--src/stores/SettingsStore.ts21
-rw-r--r--src/stores/UserStore.ts4
-rw-r--r--src/stores/lib/TypedStore.ts2
7 files changed, 27 insertions, 17 deletions
diff --git a/src/stores/AppStore.ts b/src/stores/AppStore.ts
index 82591a2a4..412c52ecf 100644
--- a/src/stores/AppStore.ts
+++ b/src/stores/AppStore.ts
@@ -351,6 +351,7 @@ export default class AppStore extends TypedStore {
351 351
352 // TODO: is there a simple way to use blobs for notifications without storing them on disk? 352 // TODO: is there a simple way to use blobs for notifications without storing them on disk?
353 if (options.icon?.startsWith('blob:')) { 353 if (options.icon?.startsWith('blob:')) {
354 // eslint-disable-next-line no-param-reassign
354 delete options.icon; 355 delete options.icon;
355 } 356 }
356 357
@@ -493,6 +494,7 @@ export default class AppStore extends TypedStore {
493 allOrphanedServiceIds.map(id => removeServicePartitionDirectory(id)), 494 allOrphanedServiceIds.map(id => removeServicePartitionDirectory(id)),
494 ); 495 );
495 } catch (error) { 496 } catch (error) {
497 // eslint-disable-next-line no-console
496 console.log('Error while deleting service partition directory -', error); 498 console.log('Error while deleting service partition directory -', error);
497 } 499 }
498 await Promise.all( 500 await Promise.all(
diff --git a/src/stores/GlobalErrorStore.ts b/src/stores/GlobalErrorStore.ts
index 8547fec72..74a43100b 100644
--- a/src/stores/GlobalErrorStore.ts
+++ b/src/stores/GlobalErrorStore.ts
@@ -27,34 +27,36 @@ export default class GlobalErrorStore extends TypedStore {
27 27
28 @observable response: Response = {} as Response; 28 @observable response: Response = {} as Response;
29 29
30 // TODO: Get rid of the @ts-ignores in this function. 30 // TODO: Get rid of the @ts-expect-errors in this function.
31 constructor(stores: Stores, api: ApiInterface, actions: Actions) { 31 constructor(stores: Stores, api: ApiInterface, actions: Actions) {
32 super(stores, api, actions); 32 super(stores, api, actions);
33 33
34 makeObservable(this); 34 makeObservable(this);
35 35
36 window.addEventListener('error', (...errorArgs: any[]): void => { 36 window.addEventListener('error', (...errorArgs: any[]): void => {
37 // @ts-ignore ts-message: Expected 5 arguments, but got 2. 37 // @ts-expect-error ts-message: Expected 5 arguments, but got 2.
38 this._handleConsoleError.call(this, ['error', ...errorArgs]); 38 this._handleConsoleError.call(this, ['error', ...errorArgs]);
39 }); 39 });
40 40
41 const origConsoleError = console.error; 41 const origConsoleError = console.error;
42 window.console.error = (...errorArgs: any[]) => { 42 window.console.error = (...errorArgs: any[]) => {
43 // @ts-ignore ts-message: Expected 5 arguments, but got 2. 43 // @ts-expect-error ts-message: Expected 5 arguments, but got 2.
44 this._handleConsoleError.call(this, ['error', ...errorArgs]); 44 this._handleConsoleError.call(this, ['error', ...errorArgs]);
45 origConsoleError.apply(this, errorArgs); 45 origConsoleError.apply(this, errorArgs);
46 }; 46 };
47 47
48 // eslint-disable-next-line no-console
48 const origConsoleLog = console.log; 49 const origConsoleLog = console.log;
49 window.console.log = (...logArgs: any[]) => { 50 window.console.log = (...logArgs: any[]) => {
50 // @ts-ignore ts-message: Expected 5 arguments, but got 2. 51 // @ts-expect-error ts-message: Expected 5 arguments, but got 2.
51 this._handleConsoleError.call(this, ['log', ...logArgs]); 52 this._handleConsoleError.call(this, ['log', ...logArgs]);
52 origConsoleLog.apply(this, logArgs); 53 origConsoleLog.apply(this, logArgs);
53 }; 54 };
54 55
56 // eslint-disable-next-line no-console
55 const origConsoleInfo = console.info; 57 const origConsoleInfo = console.info;
56 window.console.info = (...infoArgs: any[]) => { 58 window.console.info = (...infoArgs: any[]) => {
57 // @ts-ignore ts-message: Expected 5 arguments, but got 2. 59 // @ts-expect-error ts-message: Expected 5 arguments, but got 2.
58 this._handleConsoleError.call(this, ['info', ...infoArgs]); 60 this._handleConsoleError.call(this, ['info', ...infoArgs]);
59 origConsoleInfo.apply(this, infoArgs); 61 origConsoleInfo.apply(this, infoArgs);
60 }; 62 };
diff --git a/src/stores/RecipesStore.ts b/src/stores/RecipesStore.ts
index 07f1343f8..b645a5989 100644
--- a/src/stores/RecipesStore.ts
+++ b/src/stores/RecipesStore.ts
@@ -36,6 +36,7 @@ export default class RecipesStore extends TypedStore {
36 36
37 async setup(): Promise<void> { 37 async setup(): Promise<void> {
38 // Initially load all recipes 38 // Initially load all recipes
39 // eslint-disable-next-line @typescript-eslint/no-unused-expressions
39 this.all; 40 this.all;
40 } 41 }
41 42
diff --git a/src/stores/ServicesStore.ts b/src/stores/ServicesStore.ts
index 44f8b277c..7f4693cad 100644
--- a/src/stores/ServicesStore.ts
+++ b/src/stores/ServicesStore.ts
@@ -435,7 +435,7 @@ export default class ServicesStore extends TypedStore {
435 435
436 // TODO: This can actually return undefined as well 436 // TODO: This can actually return undefined as well
437 one(id: string): Service { 437 one(id: string): Service {
438 return this.all.find(service => service.id === id) as Service; 438 return this.all.find(service => service.id === id)!;
439 } 439 }
440 440
441 async _showAddServiceInterface({ recipeId }) { 441 async _showAddServiceInterface({ recipeId }) {
diff --git a/src/stores/SettingsStore.ts b/src/stores/SettingsStore.ts
index 5ca499160..90cd82690 100644
--- a/src/stores/SettingsStore.ts
+++ b/src/stores/SettingsStore.ts
@@ -70,14 +70,17 @@ export default class SettingsStore extends TypedStore {
70 this.all.app.lockingFeatureEnabled && 70 this.all.app.lockingFeatureEnabled &&
71 this.all.app.inactivityLock !== 0 71 this.all.app.inactivityLock !== 0
72 ) { 72 ) {
73 inactivityTimer = setTimeout(() => { 73 inactivityTimer = setTimeout(
74 this.actions.settings.update({ 74 () => {
75 type: 'app', 75 this.actions.settings.update({
76 data: { 76 type: 'app',
77 locked: true, 77 data: {
78 }, 78 locked: true,
79 }); 79 },
80 }, this.all.app.inactivityLock * 1000 * 60); 80 });
81 },
82 this.all.app.inactivityLock * 1000 * 60,
83 );
81 } 84 }
82 }); 85 });
83 getCurrentWindow().on('focus', () => { 86 getCurrentWindow().on('focus', () => {
@@ -176,6 +179,7 @@ export default class SettingsStore extends TypedStore {
176 179
177 const appSettings = this.all[type]; 180 const appSettings = this.all[type];
178 if (Object.hasOwnProperty.call(appSettings, key)) { 181 if (Object.hasOwnProperty.call(appSettings, key)) {
182 // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
179 delete appSettings[key]; 183 delete appSettings[key];
180 184
181 this.actions.settings.update({ 185 this.actions.settings.update({
@@ -185,6 +189,7 @@ export default class SettingsStore extends TypedStore {
185 } 189 }
186 } 190 }
187 191
192 // eslint-disable-next-line @typescript-eslint/ban-types
188 _ensureMigrationAndMarkDone(migrationName: string, callback: Function): void { 193 _ensureMigrationAndMarkDone(migrationName: string, callback: Function): void {
189 if (!this.all.migration[migrationName]) { 194 if (!this.all.migration[migrationName]) {
190 callback(); 195 callback();
diff --git a/src/stores/UserStore.ts b/src/stores/UserStore.ts
index 7ba8f4222..0616acdad 100644
--- a/src/stores/UserStore.ts
+++ b/src/stores/UserStore.ts
@@ -210,7 +210,7 @@ export default class UserStore extends TypedStore {
210 currency, 210 currency,
211 }): Promise<void> { 211 }): Promise<void> {
212 // TODO: [TS DEBT] Need to find a way proper to implement promise's then and catch in request class 212 // TODO: [TS DEBT] Need to find a way proper to implement promise's then and catch in request class
213 // @ts-ignore 213 // @ts-expect-error Fix me
214 const authToken = await this.signupRequest.execute({ 214 const authToken = await this.signupRequest.execute({
215 firstname, 215 firstname,
216 lastname, 216 lastname,
@@ -400,7 +400,7 @@ export default class UserStore extends TypedStore {
400 const params = new URLSearchParams(parsedUrl.search.slice(1)); 400 const params = new URLSearchParams(parsedUrl.search.slice(1));
401 401
402 // TODO: Remove the neccesity for `as string` 402 // TODO: Remove the neccesity for `as string`
403 params.append('authToken', this.authToken as string); 403 params.append('authToken', this.authToken!);
404 404
405 return `${parsedUrl.origin}${parsedUrl.pathname}?${params.toString()}`; 405 return `${parsedUrl.origin}${parsedUrl.pathname}?${params.toString()}`;
406 } 406 }
diff --git a/src/stores/lib/TypedStore.ts b/src/stores/lib/TypedStore.ts
index 0a669e669..8bae529ba 100644
--- a/src/stores/lib/TypedStore.ts
+++ b/src/stores/lib/TypedStore.ts
@@ -41,7 +41,7 @@ export default abstract class TypedStore {
41 this.actions = actions; 41 this.actions = actions;
42 } 42 }
43 43
44 registerReactions(reactions: { (r: IReactionPublic): void }[]): void { 44 registerReactions(reactions: ((r: IReactionPublic) => void)[]): void {
45 for (const reaction of reactions) { 45 for (const reaction of reactions) {
46 this._reactions.push(new Reaction(reaction)); 46 this._reactions.push(new Reaction(reaction));
47 } 47 }