Skip to content

Commit cab8fcb

Browse files
authored
style(eslint): enable prefer-nullish-coalescing rule (#12340)
1 parent 7606c21 commit cab8fcb

123 files changed

Lines changed: 1284 additions & 1558 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎eslint.config.mjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export default defineConfig([
3737
// custom rules
3838
"@typescript-eslint/consistent-type-exports": "error",
3939
"@typescript-eslint/consistent-type-imports": "error",
40+
"@typescript-eslint/prefer-nullish-coalescing": "error",
4041
"@typescript-eslint/prefer-optional-chain": "error",
4142

4243
// exceptions from typescript-eslint/recommended

‎sample/sample10-mixed/app.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ dataSource
5151
postRepository
5252
.save(post)
5353
.then((result) => console.log(result))
54-
.catch((error) => console.log(error.stack ? error.stack : error))
54+
.catch((error) => console.log(error.stack ?? error))
5555
})
56-
.catch((error) => console.log(error.stack ? error.stack : error))
56+
.catch((error) => console.log(error.stack ?? error))

‎sample/sample13-everywhere-abstraction/app.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,8 @@ dataSource.initialize().then(
7777
return blogRepository.save(blog)
7878
})
7979
.catch((error) =>
80-
console.log(
81-
"Cannot save. Error: ",
82-
error.stack ? error.stack : error,
83-
),
80+
console.log("Cannot save. Error: ", error.stack ?? error),
8481
)
8582
},
86-
(error) =>
87-
console.log("Cannot connect: ", error.stack ? error.stack : error),
83+
(error) => console.log("Cannot connect: ", error.stack ?? error),
8884
)

‎sample/sample24-schemas/app.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ dataSource
6666
.then((result) => {
6767
console.log(result)
6868
})
69-
.catch((error) => console.log(error.stack ? error.stack : error))
69+
.catch((error) => console.log(error.stack ?? error))
7070
})
71-
.catch((error) => console.log(error.stack ? error.stack : error))
71+
.catch((error) => console.log(error.stack ?? error))

‎sample/sample5-subscribers/app.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,8 @@ dataSource.initialize().then(
7272
console.log("post removed.")
7373
})
7474
.catch((error) =>
75-
console.log(
76-
"Cannot save. Error: ",
77-
error.stack ? error.stack : error,
78-
),
75+
console.log("Cannot save. Error: ", error.stack ?? error),
7976
)
8077
},
81-
(error) =>
82-
console.log("Cannot connect: ", error.stack ? error.stack : error),
78+
(error) => console.log("Cannot connect: ", error.stack ?? error),
8379
)

‎sample/sample6-abstract-table/app.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,8 @@ dataSource.initialize().then(
7272
return blogRepository.save(blog)
7373
})
7474
.catch((error) =>
75-
console.log(
76-
"Cannot save. Error: ",
77-
error.stack ? error.stack : error,
78-
),
75+
console.log("Cannot save. Error: ", error.stack ?? error),
7976
)
8077
},
81-
(error) =>
82-
console.log("Cannot connect: ", error.stack ? error.stack : error),
78+
(error) => console.log("Cannot connect: ", error.stack ?? error),
8379
)

‎sample/sample7-pagination/app.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,8 @@ dataSource.initialize().then(
7171
console.log("count: ", entitiesWithCount[1])
7272
})
7373
.catch((error) =>
74-
console.log(
75-
"Cannot save. Error: ",
76-
error.stack ? error.stack : error,
77-
),
74+
console.log("Cannot save. Error: ", error.stack ?? error),
7875
)
7976
},
80-
(error) =>
81-
console.log("Cannot connect: ", error.stack ? error.stack : error),
77+
(error) => console.log("Cannot connect: ", error.stack ?? error),
8278
)

‎sample/sample8-self-referencing/app.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,8 @@ dataSource.initialize().then(
3535
console.log("saved category: ", savedCategory)
3636
})
3737
.catch((error) =>
38-
console.log(
39-
"Cannot save. Error: ",
40-
error.stack ? error.stack : error,
41-
),
38+
console.log("Cannot save. Error: ", error.stack ?? error),
4239
)
4340
},
44-
(error) =>
45-
console.log("Cannot connect: ", error.stack ? error.stack : error),
41+
(error) => console.log("Cannot connect: ", error.stack ?? error),
4642
)

‎sample/sample9-entity-listeners/app.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,8 @@ dataSource.initialize().then(
7171
console.log("post removed.")
7272
})
7373
.catch((error) =>
74-
console.log(
75-
"Cannot save. Error: ",
76-
error.stack ? error.stack : error,
77-
),
74+
console.log("Cannot save. Error: ", error.stack ?? error),
7875
)
7976
},
80-
(error) =>
81-
console.log("Cannot connect: ", error.stack ? error.stack : error),
77+
(error) => console.log("Cannot connect: ", error.stack ?? error),
8278
)

‎src/cache/DbQueryResultCache.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ export class DbQueryResultCache implements QueryResultCache {
3232
typeof this.dataSource.options.cache === "object"
3333
? this.dataSource.options.cache
3434
: {}
35-
const cacheTableName = cacheOptions.tableName || "query-result-cache"
35+
const tableName =
36+
cacheOptions.tableName === "" ? undefined : cacheOptions.tableName
37+
const cacheTableName = tableName ?? "query-result-cache"
3638

3739
this.queryResultCacheDatabase = database
3840
this.queryResultCacheSchema = schema
@@ -317,7 +319,7 @@ export class DbQueryResultCache implements QueryResultCache {
317319
identifiers: string[],
318320
queryRunner?: QueryRunner,
319321
): Promise<void> {
320-
const _queryRunner: QueryRunner = queryRunner || this.getQueryRunner()
322+
const _queryRunner: QueryRunner = queryRunner ?? this.getQueryRunner()
321323
await Promise.all(
322324
identifiers.map((identifier) => {
323325
const qb = _queryRunner.manager.createQueryBuilder()

0 commit comments

Comments
 (0)