Skip to content

Commit 240f2e3

Browse files
committed
lint
1 parent a77aeb3 commit 240f2e3

File tree

10 files changed

+19
-22
lines changed

10 files changed

+19
-22
lines changed

.eslintrc.json

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"plugin:@angular-eslint/template/all"
8383
],
8484
"rules": {
85+
"@angular-eslint/template/i18n": "off",
8586
"@angular-eslint/template/no-any": "error"
8687
}
8788
}

lib/schematics/ng-add/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export default function (): Rule {
1919
const rxjsMajorVersion = getDependencyMajorVersion("rxjs", host);
2020

2121
if (!rxjsMajorVersion) {
22-
// eslint-disable-next-line max-len
2322
context.logger.warn(`Not able to detect rxjs version. Be aware that rxjs version >= 7.4 is recommended for Angular 14 and required for Angular >= 15.`);
2423
}
2524

lib/schematics/ng-update/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export function updateToV15(): Rule {
5050
const rxjsMajorVersion = getDependencyMajorVersion("rxjs", host);
5151

5252
if (!rxjsMajorVersion) {
53-
// eslint-disable-next-line max-len
5453
context.logger.warn(`Not able to detect rxjs version. Be aware that rxjs version >= 7.4 is required for version 15 of this lib, rxjs 6 is not supported.`);
5554
}
5655

lib/schematics/utility/module.ts

-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export function updateModule(mainPath: string): Rule {
6060
/* If the file is still the same, it means we didn't catch the module
6161
* (for example, it can happen if the user aliased `StorageModule`) */
6262
if (updatedAppModuleFile === appModuleFile) {
63-
// eslint-disable-next-line max-len
6463
throw new SchematicsException(`We couldn't update AppModule automatically. Be sure to follow the documentation to update manually, otherwise previsouly stored data could be lost.`);
6564
}
6665

lib/src/lib/databases/indexeddb-database.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ export class IndexedDBDatabase implements LocalDatabase {
114114

115115
/* Prior to v8, the value was wrapped in an `{ value: ...}` object */
116116
if (!this.noWrap && (typeof request.result === "object") && (this.wrapIndex in request.result) &&
117-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
117+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- Required by indexedDb behavior
118118
(request.result[this.wrapIndex] !== undefined) && (request.result[this.wrapIndex] !== null)) {
119119

120-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
120+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- Required by indexedDb behavior
121121
return request.result[this.wrapIndex];
122122

123123
} else {
@@ -250,14 +250,14 @@ export class IndexedDBDatabase implements LocalDatabase {
250250
/* Listen to success event */
251251
const success$ = fromEvent(request, "success").pipe(
252252
/* Stop the `Observable` when the cursor is `null` */
253-
// eslint-disable-next-line rxjs/no-ignored-takewhile-value -- Due to how indexedDb works, getting the result from the event does not always work
253+
// eslint-disable-next-line rxjs/no-ignored-takewhile-value -- Required by indexedDb behavior, getting the result from the event does not always work
254254
takeWhile(() => (request.result !== null)),
255255
/* This lib only allows string keys, but user could have added other types of keys from outside
256256
* It's OK to cast as the cursor as been tested in the previous operator */
257-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-base-to-string
257+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-base-to-string -- Required by indexedDb behavior, and strings are enforced by the lib
258258
map(() => request.result!.key.toString()),
259259
/* Iterate on the cursor */
260-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
260+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- Required by indexedDb behavior
261261
tap(() => { request.result!.continue(); }),
262262
);
263263

lib/src/lib/databases/localstorage-database.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export class LocalStorageDatabase implements LocalDatabase {
138138
for (let index = 0; index < localStorage.length; index += 1) {
139139

140140
/* Cast as we are sure in this case the key is not `null` */
141-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
141+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- Ensured by the logic
142142
subscriber.next(this.getUnprefixedKey(index)!);
143143

144144
}

lib/src/lib/storage.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { IDB_DB_NAME, IDB_DB_VERSION, IDB_NO_WRAP, IDB_STORE_NAME, LS_PREFIX, ty
55
* This module is only here for backward compatibility, do not add it by yourself
66
*/
77
@NgModule()
8-
export class StorageModule { // eslint-disable-line @typescript-eslint/no-extraneous-class
8+
export class StorageModule {
99

1010
/**
1111
* Only useful to provide options, otherwise it does nothing.

lib/src/lib/storages/storage-map.service.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ export class StorageMap {
168168
get<T extends number = number>(key: string, schema: JSONSchemaInteger | JSONSchemaNumber): Observable<T | undefined>;
169169
get<T extends boolean = boolean>(key: string, schema: JSONSchemaBoolean): Observable<T | undefined>;
170170
get<T extends readonly string[] = string[]>(key: string, schema: JSONSchemaArrayOf<JSONSchemaString>): Observable<T | undefined>;
171-
// eslint-disable-next-line @typescript-eslint/unified-signatures
172-
get<T extends readonly number[] = number[]>(key: string, schema: JSONSchemaArrayOf<JSONSchemaInteger | JSONSchemaNumber>): Observable<T | undefined>; // eslint-disable-line max-len
173-
// eslint-disable-next-line @typescript-eslint/unified-signatures
171+
// eslint-disable-next-line @typescript-eslint/unified-signatures -- Better for documentation
172+
get<T extends readonly number[] = number[]>(key: string, schema: JSONSchemaArrayOf<JSONSchemaInteger | JSONSchemaNumber>): Observable<T | undefined>;
173+
// eslint-disable-next-line @typescript-eslint/unified-signatures -- Better for documentation
174174
get<T extends readonly boolean[] = boolean[]>(key: string, schema: JSONSchemaArrayOf<JSONSchemaBoolean>): Observable<T | undefined>;
175175
get<T>(key: string, schema: JSONSchema): Observable<T | undefined>;
176176
get<T = unknown>(key: string, schema?: JSONSchema): Observable<unknown> {
@@ -331,9 +331,9 @@ export class StorageMap {
331331
watch<T extends number = number>(key: string, schema: JSONSchemaInteger | JSONSchemaNumber): Observable<T | undefined>;
332332
watch<T extends boolean = boolean>(key: string, schema: JSONSchemaBoolean): Observable<T | undefined>;
333333
watch<T extends readonly string[] = string[]>(key: string, schema: JSONSchemaArrayOf<JSONSchemaString>): Observable<T | undefined>;
334-
// eslint-disable-next-line @typescript-eslint/unified-signatures
335-
watch<T extends readonly number[] = number[]>(key: string, schema: JSONSchemaArrayOf<JSONSchemaInteger | JSONSchemaNumber>): Observable<T | undefined>; // eslint-disable-line max-len
336-
// eslint-disable-next-line @typescript-eslint/unified-signatures
334+
// eslint-disable-next-line @typescript-eslint/unified-signatures -- Better for documentation
335+
watch<T extends readonly number[] = number[]>(key: string, schema: JSONSchemaArrayOf<JSONSchemaInteger | JSONSchemaNumber>): Observable<T | undefined>;
336+
// eslint-disable-next-line @typescript-eslint/unified-signatures -- Better for documentation
337337
watch<T extends readonly boolean[] = boolean[]>(key: string, schema: JSONSchemaArrayOf<JSONSchemaBoolean>): Observable<T | undefined>;
338338
watch<T>(key: string, schema: JSONSchema): Observable<T | undefined>;
339339
watch<T = unknown>(key: string, schema?: JSONSchema): Observable<unknown> {
@@ -344,7 +344,7 @@ export class StorageMap {
344344
}
345345

346346
/* Non-null assertion is required because TypeScript doesn't narrow `.has()` yet */
347-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
347+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- Ensured by the logic
348348
const notifier = this.#notifiers.get(key)!;
349349

350350
/* Get the current item value */
@@ -391,7 +391,7 @@ export class StorageMap {
391391
/* Check if `indexedDB` is broken based on error message (the specific error class seems to be lost in the process) */
392392
if ((error !== undefined) && (error !== null)
393393
&& (typeof error === "object") && ("message" in error)
394-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
394+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- Required because TypeScript narrowing is not working here
395395
&& (error.message === IDB_BROKEN_ERROR)) {
396396

397397
/* When storage is fully disabled in browser (via the "Block all cookies" option),
@@ -440,7 +440,7 @@ export class StorageMap {
440440
* @private
441441
* @ignore
442442
*/
443-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error
443+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error -- Silence the not used error, it is used in tests
444444
// @ts-ignore
445445
private ɵinternalGetDatabase(): LocalDatabase {
446446

lib/src/lib/validation/json-validator.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ export class JSONValidator {
236236

237237
for (let i = 0; i < schemas.length; i += 1) {
238238

239-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
239+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- Ensured by the logic
240240
if (!this.validate(data[i], schemas[i]!)) {
241241
return false;
242242
}
@@ -288,7 +288,7 @@ export class JSONValidator {
288288
/* Filter to keep only real properties (no internal JS stuff) and check if the data has the property too */
289289
if (Object.hasOwn(schema.properties, property) && Object.hasOwn(data, property)) {
290290

291-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
291+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- Ensured by the logic
292292
if (!this.validate((data as Record<string, unknown>)[property], schema.properties[property]!)) {
293293
return false;
294294
}

testing-apps/demo/src/app/app.component.ts

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ interface Data {
1414
standalone: true,
1515
imports: [AsyncPipe, JsonPipe],
1616
template: `
17-
<!-- eslint-disable @angular-eslint/template/cyclomatic-complexity -->
1817
@if (getItem$ | async; as getItem) {
1918
<p id="get-item">{{getItem.title}}</p>
2019
}

0 commit comments

Comments
 (0)