Skip to content

Commit

Permalink
chore: bump ECMA version to 2020 for ESLint
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Jul 28, 2021
1 parent 550e8ce commit 65f17dc
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 48 deletions.
2 changes: 1 addition & 1 deletion lib/helpers/isAsyncFunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ module.exports = function isAsyncFunction(v) {
}

return inspect(v).startsWith('[AsyncFunction:');
}
};
42 changes: 0 additions & 42 deletions lib/schematype.js
Original file line number Diff line number Diff line change
Expand Up @@ -1270,48 +1270,6 @@ SchemaType.prototype.doValidate = function(value, fn, scope, options) {
}
};

/*!
* Handle async validators
*/

function asyncValidate(validator, scope, value, props, cb) {
let called = false;
const returnVal = validator.call(scope, value, function(ok, customMsg) {
if (called) {
return;
}
called = true;
if (customMsg) {
props.message = customMsg;
}
cb(ok, props);
});
if (typeof returnVal === 'boolean') {
called = true;
cb(returnVal, props);
} else if (returnVal && typeof returnVal.then === 'function') {
// Promise
returnVal.then(
function(ok) {
if (called) {
return;
}
called = true;
cb(ok, props);
},
function(error) {
if (called) {
return;
}
called = true;

props.reason = error;
props.message = error.message;
cb(false, props);
});
}
}

/**
* Performs a validation of `value` using the validators declared for this SchemaType.
*
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"mocha-no-only"
],
"parserOptions": {
"ecmaVersion": 2015
"ecmaVersion": 2020
},
"env": {
"node": true,
Expand Down
8 changes: 4 additions & 4 deletions test/typescript/discriminator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,25 @@ function test(): void {

const cardDbSchema: Schema = new Schema(
cardDbBaseSchemaDefinition,
cardDbSchemaOptions,
cardDbSchemaOptions
);

const cardDbModel: Model<CardDb> = mongoose.model<CardDb>(
'Card',
cardDbSchema,
'card',
'card'
);

const landDbAdditionalPropertiesSchemaDefinition: SchemaDefinition = {};

const landDbSchema: Schema = new Schema(
landDbAdditionalPropertiesSchemaDefinition,
landDbAdditionalPropertiesSchemaDefinition
);

const landDbModel: Model<LandDb> = cardDbModel.discriminator<LandDb>(
'Land',
landDbSchema,
CardType.Land,
CardType.Land
);

const sampleLandDb: LandDb = new landDbModel({
Expand Down

0 comments on commit 65f17dc

Please sign in to comment.