Skip to content

Commit 5ac2398

Browse files
chore: update ci config, upgrade eslint
1 parent 4002847 commit 5ac2398

File tree

10 files changed

+164
-2193
lines changed

10 files changed

+164
-2193
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
key: dependency-cache-{{ checksum "package.json" }}
2525
- run:
2626
name: Install dependencies
27-
command: npm ci --ignore-scripts
27+
command: npm install --ignore-scripts
2828
- save_cache:
2929
key: dependency-cache-{{ checksum "package.json" }}
3030
paths:
@@ -45,9 +45,9 @@ jobs:
4545
- run:
4646
name: Upgrade Node.js
4747
command: |
48-
nvm install v16
48+
nvm install v20
4949
node -v
50-
nvm alias default v16
50+
nvm alias default v20
5151
- run:
5252
name: Install Docker Compose
5353
command: |

.eslintrc.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// @ts-check
2+
import eslint from '@eslint/js';
3+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
4+
import globals from 'globals';
5+
import tseslint from 'typescript-eslint';
6+
7+
export default tseslint.config(
8+
{
9+
ignores: [],
10+
},
11+
eslint.configs.recommended,
12+
...tseslint.configs.recommendedTypeChecked,
13+
eslintPluginPrettierRecommended,
14+
{
15+
languageOptions: {
16+
globals: {
17+
...globals.node,
18+
...globals.jest,
19+
},
20+
ecmaVersion: 5,
21+
sourceType: 'module',
22+
parserOptions: {
23+
projectService: true,
24+
tsconfigRootDir: import.meta.dirname,
25+
},
26+
},
27+
},
28+
{
29+
rules: {
30+
'@typescript-eslint/no-explicit-any': 'off',
31+
'@typescript-eslint/no-unsafe-assignment': 'off',
32+
'@typescript-eslint/no-unsafe-call': 'off',
33+
'@typescript-eslint/no-unsafe-member-access': 'off',
34+
'@typescript-eslint/no-unsafe-function-type': 'off',
35+
'@typescript-eslint/no-unsafe-argument': 'off',
36+
'@typescript-eslint/no-unsafe-return': 'off',
37+
'@typescript-eslint/require-await': 'warn',
38+
'@typescript-eslint/no-misused-promises': 'warn',
39+
'no-self-assign': 'warn',
40+
'@typescript-eslint/restrict-template-expressions': 'warn',
41+
'@typescript-eslint/no-redundant-type-constituents': 'warn'
42+
},
43+
},
44+
);

lib/common/mongoose.decorators.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Inject } from '@nestjs/common';
22
import { getConnectionToken, getModelToken } from './mongoose.utils';
33

4-
export const InjectModel = (model: string, connectionName?: string) => Inject(getModelToken(model, connectionName));
4+
export const InjectModel = (model: string, connectionName?: string) =>
5+
Inject(getModelToken(model, connectionName));
56

67
export const InjectConnection = (name?: string) =>
78
Inject(getConnectionToken(name));

lib/common/mongoose.utils.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Logger } from "@nestjs/common";
2-
import { Observable } from "rxjs";
3-
import { delay, retryWhen, scan } from "rxjs/operators";
4-
import { DEFAULT_DB_CONNECTION } from "../mongoose.constants";
1+
import { Logger } from '@nestjs/common';
2+
import { Observable } from 'rxjs';
3+
import { delay, retryWhen, scan } from 'rxjs/operators';
4+
import { DEFAULT_DB_CONNECTION } from '../mongoose.constants';
55

66
export function getModelToken(model: string, connectionName?: string) {
77
if (connectionName === undefined) {
@@ -29,17 +29,16 @@ export function handleRetry(
2929
scan((errorCount, error) => {
3030
const verboseMessage = verboseRetryLog
3131
? ` Message: ${error.message}.`
32-
: "";
33-
const retryMessage = retryAttempts > 0
34-
? ` Retrying (${errorCount + 1})...`
35-
: "";
32+
: '';
33+
const retryMessage =
34+
retryAttempts > 0 ? ` Retrying (${errorCount + 1})...` : '';
3635

3736
logger.error(
3837
[
39-
"Unable to connect to the database.",
38+
'Unable to connect to the database.',
4039
verboseMessage,
4140
retryMessage,
42-
].join(""),
41+
].join(''),
4342
error.stack,
4443
);
4544
if (errorCount + 1 >= retryAttempts) {

lib/mongoose-core.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ export class MongooseCoreModule implements OnApplicationShutdown {
211211

212212
async onApplicationShutdown() {
213213
const connection = this.moduleRef.get<any>(this.connectionName);
214-
connection && (await connection.close());
214+
if (connection) {
215+
await connection.close();
216+
}
215217
}
216218
}

lib/mongoose.providers.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ export function createMongooseProviders(
1919
{
2020
provide: getModelToken(option.name, connectionName),
2121
useFactory: (connection: Connection) => {
22-
const model = connection.models[option.name] ? connection.models[option.name] : connection.model(
23-
option.name,
24-
option.schema,
25-
option.collection,
26-
);
22+
const model = connection.models[option.name]
23+
? connection.models[option.name]
24+
: connection.model(option.name, option.schema, option.collection);
2725
return model;
2826
},
2927
inject: [getConnectionToken(connectionName)],

lib/utils/is-target-equal-util.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ export function isTargetEqual<T extends TargetHost, U extends TargetHost>(
33
a: T,
44
b: U,
55
) {
6-
return a.target === b.target || (
7-
a.target.prototype ?
8-
isTargetEqual({ target: (a.target as any).__proto__ }, b) :
9-
false
6+
return (
7+
a.target === b.target ||
8+
(a.target.prototype
9+
? isTargetEqual({ target: (a.target as any).__proto__ }, b)
10+
: false)
1011
);
1112
}

0 commit comments

Comments
 (0)