Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 885c66f

Browse files
committed
refactor: additional tweaks to eslint + prettier config
1 parent 1e99d25 commit 885c66f

File tree

3 files changed

+35
-26
lines changed

3 files changed

+35
-26
lines changed

.eslintrc.js

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,11 @@ module.exports = {
99
'prettier/@typescript-eslint',
1010
'plugin:prettier/recommended'
1111
],
12+
env: {
13+
"node": true,
14+
"es6": true
15+
},
1216
rules: {
13-
'no-unused-vars': 'off',
14-
'@typescript-eslint/no-unused-vars': [
15-
'error',
16-
{
17-
vars: 'all',
18-
args: 'after-used',
19-
ignoreRestSiblings: false,
20-
argsIgnorePattern: '^_',
21-
},
22-
],
23-
'prefer-arrow-callback': [ 'error', { 'allowNamedFunctions': true }],
24-
'@typescript-eslint/explicit-function-return-type': 'off',
2517
'import/order': [
2618
'error',
2719
{
@@ -36,6 +28,23 @@ module.exports = {
3628
"caseInsensitive": true
3729
}
3830
}
39-
]
31+
],
32+
'max-params': ["error", 5],
33+
'no-param-reassign': 'error',
34+
'no-var': 'error',
35+
"no-console": ["error", { "allow": ["warn", "error"] }],
36+
'no-unused-vars': 'off',
37+
'prefer-arrow-callback': [ 'error', { 'allowNamedFunctions': true }],
38+
"sort-keys": "warn",
39+
'@typescript-eslint/no-unused-vars': [
40+
'error',
41+
{
42+
vars: 'all',
43+
args: 'after-used',
44+
ignoreRestSiblings: false,
45+
argsIgnorePattern: '^_',
46+
},
47+
],
48+
'@typescript-eslint/explicit-function-return-type': 'off'
4049
},
4150
};

src/migration.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ export interface Migration {
5959

6060
export class Migrator {
6161
private defaultMigration = {
62-
version: 0,
62+
down: (_db: Db) => Promise.reject(`Can't go down from default`),
6363
name: 'default',
6464
up: (_db: Db) => Promise.resolve(),
65-
down: (_db: Db) => Promise.reject(`Can't go down from default`),
65+
version: 0,
6666
};
6767
private list: Migration[];
6868
private collection: Collection;
@@ -80,16 +80,16 @@ export class Migrator {
8080
this.options = opts
8181
? opts
8282
: {
83-
// False disables logging
84-
log: true,
85-
// Null or a function
86-
logger: null,
87-
// Enable/disable info log "already at latest."
88-
logIfLatest: true,
8983
// Migrations collection name
9084
collectionName: 'migrations',
9185
// Mongdb url or mongo Db instance
9286
db: null,
87+
// False disables logging
88+
log: true,
89+
// Enable/disable info log "already at latest."
90+
logIfLatest: true,
91+
// Null or a function
92+
logger: null,
9393
};
9494
}
9595

@@ -104,8 +104,8 @@ export class Migrator {
104104
this.options = Object.assign({}, this.options, opts);
105105

106106
if (!this.options.logger && this.options.log) {
107-
// tslint:disable-next-line: no-console
108107
this.options.logger = (level: string, ...args) =>
108+
// eslint-disable-next-line no-console
109109
console.log(level, ...args);
110110
}
111111

@@ -417,8 +417,8 @@ export class Migrator {
417417
return (
418418
con ||
419419
(await this.setControl({
420-
version: 0,
421420
locked: false,
421+
version: 0,
422422
}))
423423
);
424424
}
@@ -445,8 +445,8 @@ export class Migrator {
445445
},
446446
{
447447
$set: {
448-
version: control.version,
449448
locked: control.locked,
449+
version: control.version,
450450
},
451451
},
452452
{

test/test.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ describe('Migration', () => {
77

88
beforeAll(async () => {
99
migrator = new Migrator({
10-
log: true,
11-
logIfLatest: true,
1210
collectionName: '_migration',
1311
db: { connectionUrl: dbURL },
12+
log: true,
13+
logIfLatest: true,
1414
});
1515
await migrator.config();
1616
});

0 commit comments

Comments
 (0)