start upgrading eslint

This commit is contained in:
Matteo Pagliazzi
2019-10-08 16:57:10 +02:00
parent 90c917f69e
commit 621787915c
304 changed files with 5992 additions and 6394 deletions

View File

@@ -1,15 +1,15 @@
import mongoose from 'mongoose';
import validator from 'validator';
import { v4 as uuid } from 'uuid';
import _ from 'lodash';
import nconf from 'nconf';
import baseModel from '../libs/baseModel';
import shared from '../../common';
import {v4 as uuid} from 'uuid';
import _ from 'lodash';
import { BadRequest } from '../libs/errors';
import nconf from 'nconf';
import apiError from '../libs/apiError';
const IS_PRODUCTION = nconf.get('IS_PROD');
const Schema = mongoose.Schema;
const { Schema } = mongoose;
const TASK_ACTIVITY_DEFAULT_OPTIONS = Object.freeze({
created: false,
@@ -30,7 +30,7 @@ const QUEST_ACTIVITY_DEFAULT_OPTIONS = Object.freeze({
questFinished: false,
});
export let schema = new Schema({
export const schema = new Schema({
id: {
$type: String,
required: true,
@@ -55,11 +55,9 @@ export let schema = new Schema({
url: {
$type: String,
required: true,
validate: [(v) => {
return validator.isURL(v, {
require_tld: IS_PRODUCTION ? true : false, // eslint-disable-line camelcase
});
}, shared.i18n.t('invalidUrl')],
validate: [v => validator.isURL(v, {
require_tld: !!IS_PRODUCTION, // eslint-disable-line camelcase
}), shared.i18n.t('invalidUrl')],
},
enabled: { $type: Boolean, required: true, default: true },
options: {
@@ -87,7 +85,7 @@ schema.methods.formatOptions = function formatOptions (res) {
_.defaults(this.options, TASK_ACTIVITY_DEFAULT_OPTIONS);
this.options = _.pick(this.options, Object.keys(TASK_ACTIVITY_DEFAULT_OPTIONS));
let invalidOption = Object.keys(this.options)
const invalidOption = Object.keys(this.options)
.find(option => typeof this.options[option] !== 'boolean');
if (invalidOption) {
@@ -103,7 +101,7 @@ schema.methods.formatOptions = function formatOptions (res) {
_.defaults(this.options, USER_ACTIVITY_DEFAULT_OPTIONS);
this.options = _.pick(this.options, Object.keys(USER_ACTIVITY_DEFAULT_OPTIONS));
let invalidOption = Object.keys(this.options)
const invalidOption = Object.keys(this.options)
.find(option => typeof this.options[option] !== 'boolean');
if (invalidOption) {
@@ -113,7 +111,7 @@ schema.methods.formatOptions = function formatOptions (res) {
_.defaults(this.options, QUEST_ACTIVITY_DEFAULT_OPTIONS);
this.options = _.pick(this.options, Object.keys(QUEST_ACTIVITY_DEFAULT_OPTIONS));
let invalidOption = Object.keys(this.options)
const invalidOption = Object.keys(this.options)
.find(option => typeof this.options[option] !== 'boolean');
if (invalidOption) {
@@ -125,4 +123,4 @@ schema.methods.formatOptions = function formatOptions (res) {
}
};
export let model = mongoose.model('Webhook', schema);
export const model = mongoose.model('Webhook', schema);