Skip to content

Commit 39609fd

Browse files
authored
chore(.eslintrc.json): add prefer-const, no-console (#3622)
1 parent 09eaf24 commit 39609fd

File tree

10 files changed

+27
-25
lines changed

10 files changed

+27
-25
lines changed

.eslintrc.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
"@typescript-eslint/no-explicit-any": "off",
4545
"@typescript-eslint/ban-ts-comment": "off",
4646
"no-duplicate-imports": "error",
47-
"require-await": "error"
47+
"require-await": "error",
48+
"prefer-const": "error",
49+
"no-console": ["error", { "allow": ["warn", "info", "error"] }]
4850
}
4951
},
5052
{

libs/shared/base-abstract-classes/src/service/editors/multi-row-editor.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ export abstract class MultiRowEditorService<T extends TableRow> extends EditorSe
163163
control.setValue(selectedRow[field]);
164164
} else {
165165
console.error(`Control '${field}' does not exist!`);
166-
console.log(`----------- DEBUG CONTROL KEYS:`);
166+
console.info(`----------- DEBUG CONTROL KEYS:`);
167167
for (const k of Object.keys(this._form.controls)) {
168-
console.log(k);
168+
console.info(k);
169169
}
170170
}
171171
}

libs/shared/base-abstract-classes/src/service/editors/single-row-editor.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Class, TableRow } from '@keira/shared/constants';
2-
import { distinctUntilChanged } from 'rxjs';
32
import { compareObjFn, getNumberOrString } from '@keira/shared/utils';
3+
import { distinctUntilChanged } from 'rxjs';
44
import { EditorService } from './editor.service';
55

66
export abstract class SingleRowEditorService<T extends TableRow> extends EditorService<T> {
@@ -90,9 +90,9 @@ export abstract class SingleRowEditorService<T extends TableRow> extends EditorS
9090
control.setValue(this._originalValue[field]);
9191
} else {
9292
console.error(`Control '${field}' does not exist!`);
93-
console.log(`----------- DEBUG CONTROL KEYS:`);
93+
console.info(`----------- DEBUG CONTROL KEYS:`);
9494
for (const k of Object.keys(this._form.controls)) {
95-
console.log(k);
95+
console.info(k);
9696
}
9797
}
9898
}

libs/shared/db-layer/src/mysql.service.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { TestBed } from '@angular/core/testing';
21
import { provideZonelessChangeDetection } from '@angular/core';
2+
import { TestBed } from '@angular/core/testing';
33
import { provideNoopAnimations } from '@angular/platform-browser/animations';
4+
import { ElectronService } from '@keira/shared/common-services';
45
import { Connection, ConnectionOptions, QueryError } from 'mysql2';
6+
import { tickAsync } from 'ngx-page-object-model';
57
import { Subscriber } from 'rxjs';
68
import { instance, mock, reset } from 'ts-mockito';
7-
import { ElectronService } from '@keira/shared/common-services';
89
import { MysqlService } from './mysql.service';
910
import Spy = jasmine.Spy;
10-
import { tickAsync } from 'ngx-page-object-model';
1111

1212
class MockMySql {
1313
createConnection() {}
@@ -213,7 +213,7 @@ describe('MysqlService', () => {
213213
it('reconnect() should correctly work ', async () => {
214214
service['_reconnecting'] = false;
215215
spyOn(service['_connectionLostSubject'], 'next');
216-
spyOn(console, 'log');
216+
spyOn(console, 'info');
217217
(service as any).mysql = new MockMySql();
218218
const mockConnection = new MockConnection();
219219
spyOn((service as any).mysql, 'createConnection').and.returnValue(mockConnection);
@@ -223,8 +223,8 @@ describe('MysqlService', () => {
223223
expect(service['_reconnecting']).toBe(true);
224224
expect(service['_connectionLostSubject'].next).toHaveBeenCalledTimes(1);
225225
expect(service['_connectionLostSubject'].next).toHaveBeenCalledWith(false);
226-
expect(console.log).toHaveBeenCalledTimes(1);
227-
expect(console.log).toHaveBeenCalledWith(`DB connection lost. Reconnecting in 500 ms...`);
226+
expect(console.info).toHaveBeenCalledTimes(1);
227+
expect(console.info).toHaveBeenCalledWith(`DB connection lost. Reconnecting in 500 ms...`);
228228

229229
await tickAsync(500);
230230
expect(service['_connection']).toEqual(mockConnection as unknown as Connection);

libs/shared/db-layer/src/mysql.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export class MysqlService {
8181
this._reconnecting = true;
8282
this._connectionLostSubject.next(false);
8383
const RECONNECTION_TIME_MS = 500;
84-
console.log(`DB connection lost. Reconnecting in ${RECONNECTION_TIME_MS} ms...`);
84+
console.info(`DB connection lost. Reconnecting in ${RECONNECTION_TIME_MS} ms...`);
8585

8686
setTimeout(() => {
8787
this._connection = this.mysql.createConnection(this.config);
@@ -129,7 +129,7 @@ export class MysqlService {
129129
return (err: QueryError | null, result?: T[], fields?: FieldInfo[]) => {
130130
this.ngZone.run(() => {
131131
if (err) {
132-
console.log(`Error when executing query: \n\n${err.stack}`);
132+
console.info(`Error when executing query: \n\n${err.stack}`);
133133
subscriber.error(err);
134134
} else {
135135
subscriber.next({ result, fields });

libs/shared/db-layer/src/query/mysql-query.service.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ describe('MysqlQueryService', () => {
5454
});
5555

5656
it('query() should call mysqlService.dbQuery() and output query and results if debug mode is enabled', () => {
57-
const logSpy = spyOn(console, 'log');
57+
const infoSpy = spyOn(console, 'info');
5858
configService.debugMode.set(true);
5959
const querySpy = spyOn(TestBed.inject(MysqlService), 'dbQuery').and.returnValue(of({ id: 'mock value' } as TableRow));
6060
const myQuery = 'SELECT azerothcore FROM projects;';
6161

6262
service.query(myQuery).subscribe(() => {
63-
expect(logSpy).toHaveBeenCalledTimes(2);
63+
expect(infoSpy).toHaveBeenCalledTimes(2);
6464
});
6565

6666
expect(querySpy).toHaveBeenCalledWith(myQuery, undefined);

libs/shared/db-layer/src/query/mysql-query.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export class MysqlQueryService extends BaseQueryService {
2525
return this.mysqlService.dbQuery<T>(queryString, values).pipe(
2626
tap((val) => {
2727
if (this.configService.debugMode()) {
28-
console.log(`\n${queryString}`);
29-
console.log(val);
28+
console.info(`\n${queryString}`);
29+
console.info(val);
3030
}
3131
}),
3232
map((val) => val?.result),

libs/shared/db-layer/src/query/sqlite-query.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export class SqliteQueryService extends BaseQueryService {
2121
return this.sqliteService.dbQuery<T>(queryString).pipe(
2222
tap((val) => {
2323
if (this.configService.debugMode() && !silent) {
24-
console.log(`\n${queryString}`);
25-
console.log(val);
24+
console.info(`\n${queryString}`);
25+
console.info(val);
2626
}
2727
}),
2828
);

libs/shared/db-layer/src/sqlite.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Injectable, NgZone, inject } from '@angular/core';
22

3+
import { ElectronService } from '@keira/shared/common-services';
34
import { KEIRA_APP_CONFIG_TOKEN, KeiraAppConfig } from '@keira/shared/config';
45
import { TableRow } from '@keira/shared/constants';
56
import { Observable, Subscriber } from 'rxjs';
6-
import { ElectronService } from '@keira/shared/common-services';
77

88
/* istanbul ignore next */ // Note: will be tested in e2e
99
@Injectable({
@@ -23,7 +23,7 @@ export class SqliteService {
2323
const sqlite = window.require('sqlite3');
2424
this.db = new sqlite.Database(KEIRA_APP_CONFIG.sqlitePath, sqlite.OPEN_READONLY, (error: unknown) => {
2525
if (error) {
26-
console.log(`Error when opening sqlite database at ${KEIRA_APP_CONFIG.sqlitePath}`);
26+
console.info(`Error when opening sqlite database at ${KEIRA_APP_CONFIG.sqlitePath}`);
2727
console.error(error);
2828
}
2929
});
@@ -45,7 +45,7 @@ export class SqliteService {
4545
return (err: Error | null, results: T[]) => {
4646
this.ngZone.run(() => {
4747
if (err) {
48-
console.log(`Error when executing sqlite query: \n\n`);
48+
console.info(`Error when executing sqlite query: \n\n`);
4949
console.error(err);
5050
subscriber.error(err);
5151
} else {

libs/shared/model-3d-viewer/src/helper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export function getShadowlandDisplayId(
133133
const sqlite = window.require('sqlite3');
134134
const db = new sqlite.Database(sqliteItem3dPath, sqlite.OPEN_READONLY, (error: unknown) => {
135135
if (error) {
136-
console.log(`Error when opening sqlite database at DISPLAY ID`);
136+
console.info(`Error when opening sqlite database at DISPLAY ID`);
137137
console.error(error);
138138
}
139139
});
@@ -148,7 +148,7 @@ export function getShadowlandDisplayId(
148148
if (data.length && 'ItemDisplayInfoID' in data[0]) {
149149
resolve({ displayId: data[0].ItemDisplayInfoID, displayType: data[0].DisplayType });
150150
} else {
151-
console.log('no ItemDisplayInfoID available for this item');
151+
console.info('no ItemDisplayInfoID available for this item');
152152
}
153153
}
154154
},

0 commit comments

Comments
 (0)