Skip to content

Commit 218b057

Browse files
hasezoeynodkz
authored andcommitted
fix: lint
1 parent 2782166 commit 218b057

File tree

12 files changed

+27
-41
lines changed

12 files changed

+27
-41
lines changed

.vscode/tasks.json

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
11
{
2-
// See https://go.microsoft.com/fwlink/?LinkId=733558
3-
// for the documentation about the tasks.json format
4-
"version": "2.0.0",
5-
"tasks": [
2+
"version": "2.0.0",
3+
"tasks": [
64
{
7-
"label": "Eslint checks",
8-
"type": "shell",
9-
"command": "./node_modules/.bin/eslint 'packages/*/src/**/*.{js,ts,tsx}'",
10-
"problemMatcher": ["$eslint-stylish"],
11-
"isBackground": true,
12-
"presentation": {
13-
"reveal": "never"
14-
},
15-
"runOptions": {
16-
"reevaluateOnRerun": true,
17-
"runOn": "folderOpen"
18-
},
19-
"group": {
20-
"kind": "build",
21-
"isDefault": true
22-
}
5+
"type": "npm",
6+
"script": "lint",
7+
"problemMatcher": [
8+
"$eslint-stylish"
9+
],
10+
"label": "npm: lint",
11+
"detail": "lerna run lint"
2312
}
2413
]
2514
}

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ module.exports = {
1414
roots: ['<rootDir>/src'],
1515
testPathIgnorePatterns: ['/node_modules/', '/lib/'],
1616
testMatch: ['**/__tests__/**/*-test.(ts|js)'],
17-
projects: ['packages/*'],
17+
projects: ['packages/**/*'],
1818
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
},
3131
"scripts": {
3232
"test": "lerna run test --stream",
33-
"lint": "lerna run lint --stream",
33+
"lint": "lerna run lint --stream --npm-client=yarn --no-prefix",
3434
"watch": "jest --env node --watch",
3535
"jest": "jest --env node",
3636
"build": "tsc --build tsconfig.build.json",

packages/mongodb-memory-server-core/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
"cleanup": "rimraf tmp lib coverage node_modules/.cache",
8484
"build": "npm-run-all build:*",
8585
"build:ts": "rimraf ./lib && tsc -p ./tsconfig.build.json",
86-
"disabled-build:flow": "find ./lib -name \"*.d.ts\" -exec bash -c './node_modules/.bin/flowgen --add-flow-header \"$1\" -o \"${1%.d.ts}\".js.flow' - '{}' \\;",
8786
"watch": "cross-env MONGOMS_DOWNLOAD_DIR=./tmp jest --watchAll",
8887
"coverage": "cross-env MONGOMS_DOWNLOAD_DIR=./tmp jest --coverage",
8988
"lint": "npm run eslint && npm run tscheck",

packages/mongodb-memory-server-core/src/MongoMemoryReplSet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ export default class MongoMemoryReplSet extends EventEmitter {
224224

225225
let MongoClient: typeof mongodb.MongoClient;
226226
try {
227-
MongoClient = require('mongodb').MongoClient;
227+
MongoClient = (await import('mongodb')).MongoClient;
228228
} catch (e) {
229229
throw new Error(
230230
`You need to install "mongodb" package. It's required for checking ReplicaSet state.`

packages/mongodb-memory-server-core/src/util/MongoBinary.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default class MongoBinary {
5151
return this.cache[version];
5252
}
5353

54-
static async getDownloadPath(options: any): Promise<string> {
54+
static async getDownloadPath(options: Required<MongoBinaryOpts>): Promise<string> {
5555
const { downloadDir, platform, arch, version } = options;
5656
// create downloadDir if not exists
5757
await mkdirp(downloadDir);

packages/mongodb-memory-server-core/src/util/MongoBinaryDownload.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export default class MongoBinaryDownload {
121121
return undefined;
122122
}
123123
const mongoDBArchiveMd5 = await this.download(urlForReferenceMD5);
124-
const signatureContent = fs.readFileSync(mongoDBArchiveMd5).toString('UTF-8');
124+
const signatureContent = fs.readFileSync(mongoDBArchiveMd5).toString('utf-8');
125125
const m = signatureContent.match(/(.*?)\s/);
126126
const md5Remote = m ? m[1] : null;
127127
const md5Local = md5File.sync(mongoDBArchive);
@@ -208,15 +208,17 @@ export default class MongoBinaryDownload {
208208
await this.extractZip(mongoDBArchive, extractDir, filter);
209209
} else {
210210
throw new Error(
211-
`MongoBinaryDownload: unsupported archive ${mongoDBArchive} (downloaded from ${this
212-
._downloadingUrl ?? 'unkown'}). Broken archive from MongoDB Provider?`
211+
`MongoBinaryDownload: unsupported archive ${mongoDBArchive} (downloaded from ${
212+
this._downloadingUrl ?? 'unkown'
213+
}). Broken archive from MongoDB Provider?`
213214
);
214215
}
215216

216217
if (!(await this.locationExists(path.resolve(this.downloadDir, this.version, binaryName)))) {
217218
throw new Error(
218-
`MongoBinaryDownload: missing mongod binary in ${mongoDBArchive} (downloaded from ${this
219-
._downloadingUrl ?? 'unkown'}). Broken archive from MongoDB Provider?`
219+
`MongoBinaryDownload: missing mongod binary in ${mongoDBArchive} (downloaded from ${
220+
this._downloadingUrl ?? 'unkown'
221+
}). Broken archive from MongoDB Provider?`
220222
);
221223
}
222224
return extractDir;
@@ -314,7 +316,8 @@ export default class MongoBinaryDownload {
314316
const fileStream = fs.createWriteStream(tempDownloadLocation);
315317

316318
https
317-
.get(httpOptions, (response) => {
319+
.get(httpOptions as any, (response) => {
320+
// "as any" because otherwise the "agent" wouldnt match
318321
if (response.statusCode != 200) {
319322
if (response.statusCode === 403) {
320323
reject(
@@ -376,7 +379,7 @@ export default class MongoBinaryDownload {
376379
* Print the Download Progress to STDOUT
377380
* @param chunk A chunk to get the length
378381
*/
379-
printDownloadProgress(chunk: any): void {
382+
printDownloadProgress(chunk: { length: number }): void {
380383
this.dlProgress.current += chunk.length;
381384

382385
const now = Date.now();

packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,7 @@ export default class MongoBinaryDownloadUrl {
234234
// confirm it is actually a version, otherwise throw an error
235235
parseFloat(ubuntuVersion.toString());
236236

237-
return `ubuntu${ubuntuVersion
238-
.toString()
239-
.replace('.', '')
240-
.trim()}`;
237+
return `ubuntu${ubuntuVersion.toString().replace('.', '').trim()}`;
241238
} catch (err) {
242239
console.error('ElementaryOS "lsb_relese -u -rs" couldnt be executed!');
243240
throw err;

packages/mongodb-memory-server-core/src/util/MongoInstance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default class MongoInstance {
4343

4444
childProcess: ChildProcess | null;
4545
killerProcess: ChildProcess | null;
46-
waitForPrimaryResolveFns: Function[];
46+
waitForPrimaryResolveFns: ((value: boolean) => void)[];
4747
isInstancePrimary: boolean = false;
4848
isInstanceReady: boolean = false;
4949
instanceReady: EmptyVoidCallback = () => {};

packages/mongodb-memory-server-core/src/util/db_util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function getHost(uri: string): string {
1919
/**
2020
* Basic MongoDB Connection string
2121
*/
22-
export function getUriBase(host: string, port: number, dbName: string) {
22+
export function getUriBase(host: string, port: number, dbName: string): string {
2323
return `mongodb://${host}:${port}/${dbName}?`;
2424
}
2525

0 commit comments

Comments
 (0)