Skip to content

Commit d3a4a87

Browse files
committed
fix: enable require-await
1 parent 12c8a1e commit d3a4a87

File tree

40 files changed

+1068
-1165
lines changed

40 files changed

+1068
-1165
lines changed

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export default tseslint.config([
6363
"@typescript-eslint/no-unsafe-member-access": "off",
6464
"@typescript-eslint/no-unsafe-return": "off",
6565
"@typescript-eslint/prefer-promise-reject-errors": "off",
66+
"@typescript-eslint/require-await": "warn",
6667
"@typescript-eslint/restrict-plus-operands": "warn",
6768
"@typescript-eslint/restrict-template-expressions": "warn",
6869
"@typescript-eslint/unbound-method": [
@@ -72,7 +73,6 @@ export default tseslint.config([
7273

7374
// temporary exceptions
7475
"@typescript-eslint/no-unnecessary-type-assertion": "off",
75-
"@typescript-eslint/require-await": "off",
7676

7777
// exceptions for eslint
7878
"no-async-promise-executor": "warn",

sample/sample1-simple-entity/app.ts

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,31 @@ const options: DataSourceOptions = {
1515
entities: [Post],
1616
}
1717

18-
const dataSource = new DataSource(options)
19-
dataSource.initialize().then(
20-
async (dataSource) => {
21-
const post = new Post()
22-
post.text = "Hello how are you?"
23-
post.title = "hello"
24-
post.likesCount = 100
25-
26-
const postRepository = dataSource.getRepository(Post)
27-
28-
postRepository
29-
.save(post)
30-
.then((post) => console.log("Post has been saved: ", post))
31-
.catch((error) => console.log("Cannot save. Error: ", error))
32-
},
33-
(error) => console.log("Cannot connect: ", error),
34-
)
18+
async function main() {
19+
const dataSource = new DataSource(options)
20+
21+
try {
22+
await dataSource.initialize()
23+
} catch (error) {
24+
console.log("Cannot connect: ", error)
25+
return
26+
}
27+
28+
const post = new Post()
29+
post.text = "Hello how are you?"
30+
post.title = "hello"
31+
post.likesCount = 100
32+
33+
const postRepository = dataSource.getRepository(Post)
34+
35+
try {
36+
await postRepository.save(post)
37+
console.log("Post has been saved: ", post)
38+
} catch (error) {
39+
console.log("Cannot save. Error: ", error)
40+
}
41+
42+
await dataSource.destroy()
43+
}
44+
45+
void main()

src/connection/ConnectionOptionsReader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export class ConnectionOptionsReader {
138138
PlatformTools.getEnvVariable("TYPEORM_CONNECTION") ||
139139
PlatformTools.getEnvVariable("TYPEORM_URL")
140140
) {
141-
connectionOptions = await new ConnectionOptionsEnvReader().read()
141+
connectionOptions = new ConnectionOptionsEnvReader().read()
142142
} else if (
143143
foundFileFormat === "js" ||
144144
foundFileFormat === "mjs" ||

src/connection/options-reader/ConnectionOptionsEnvReader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class ConnectionOptionsEnvReader {
1717
/**
1818
* Reads connection options from environment variables.
1919
*/
20-
async read(): Promise<DataSourceOptions[]> {
20+
read(): DataSourceOptions[] {
2121
return [
2222
{
2323
type:

src/driver/aurora-mysql/AuroraMysqlQueryRunner.ts

Lines changed: 295 additions & 313 deletions
Large diffs are not rendered by default.

src/driver/cordova/CordovaQueryRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class CordovaQueryRunner extends AbstractSqliteQueryRunner {
6161
const queryStartTime = Date.now()
6262

6363
try {
64-
const raw = await new Promise<any>(async (ok, fail) => {
64+
const raw = await new Promise<any>((ok, fail) => {
6565
databaseConnection.executeSql(
6666
query,
6767
parameters,

src/driver/mysql/MysqlQueryRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ export class MysqlQueryRunner extends BaseQueryRunner implements QueryRunner {
208208
databaseConnection.query(
209209
queryPayload,
210210
parameters,
211-
async (err: any, raw: any) => {
211+
(err: any, raw: any) => {
212212
// log slow queries if maxQueryExecution time is set
213213
const maxQueryExecutionTime =
214214
this.driver.options.maxQueryExecutionTime

src/driver/nativescript/NativescriptQueryRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class NativescriptQueryRunner extends AbstractSqliteQueryRunner {
5656

5757
const databaseConnection = await this.connect()
5858

59-
return new Promise(async (ok, fail) => {
59+
return new Promise((ok, fail) => {
6060
const isInsertQuery = query.substr(0, 11) === "INSERT INTO"
6161
connection.logger.logQuery(query, parameters, this)
6262

src/driver/react-native/ReactNativeQueryRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class ReactNativeQueryRunner extends AbstractSqliteQueryRunner {
123123
ok(result.raw)
124124
}
125125
},
126-
async (err: any) => {
126+
(err: any) => {
127127
this.driver.connection.logger.logQueryError(
128128
err,
129129
query,

0 commit comments

Comments
 (0)