Implemented ESlint and passed down the rules

This commit is contained in:
Alexis
2021-01-20 19:07:56 +01:00
parent 615cced6ed
commit b318a88023
37 changed files with 2119 additions and 568 deletions

View File

@@ -1,17 +1,16 @@
'use strict'
// Bookshelf
const bookshelf = require('../database/bookshelf').bookshelf
const model = require('../models/ingredient-model')
const bookshelf = require('../database/bookshelf').bookshelf;
const model = require('../models/ingredient-model');
// Model validation
const Validator = require('jsonschema').Validator
const validator = new Validator()
const IngredientValidation = require("../validations/IngredientValidation")
validator.addSchema(IngredientValidation, "/IngredientValidation")
const Validator = require('jsonschema').Validator;
const validator = new Validator();
const IngredientValidation = require("../validations/IngredientValidation");
validator.addSchema(IngredientValidation, "/IngredientValidation");
// Validations
const isXSSAttempt = require('../functions').isXSSAttempt
const isEmptyObject = require('../functions').isEmptyObject
const isXSSAttempt = require('../functions').isXSSAttempt;
const isEmptyObject = require('../functions').isEmptyObject;
class IngredientRepository {
@@ -23,16 +22,16 @@ class IngredientRepository {
new model()
.fetchAll({ withRelated: ['spells'] })
.then(v => {
resolve(v.toJSON({ omitPivot: true }))
resolve(v.toJSON({ omitPivot: true }));
})
.catch(err => {
console.log(err)
console.log(err);
reject({
"message": "Il n'existe aucun ingrédient disponible.",
"code": 404,
});
})
})
});
});
}
@@ -42,16 +41,16 @@ class IngredientRepository {
.where({ 'id': id })
.fetch({ withRelated: ['spells'] })
.then(v => {
resolve(v.toJSON({ omitPivot: true }))
resolve(v.toJSON({ omitPivot: true }));
})
.catch(err => {
console.log(err)
console.log(err);
reject({
"message": "L'ingrédient en question n'a pas pu être trouvé.",
"code": 404,
});
})
})
});
});
}
getSpellsFromOne(id) {
@@ -60,16 +59,16 @@ class IngredientRepository {
.where({ 'id': id })
.fetch({ withRelated: ['spells', 'spells.schools', 'spells.variables', 'spells.ingredients', 'spells.schools.meta_schools'] })
.then(v => {
resolve(v.toJSON({ omitPivot: true }))
resolve(v.toJSON({ omitPivot: true }));
})
.catch(err => {
console.log(err)
console.log(err);
reject({
"message": "Les sortilèges liés à cet ingrédient n'ont pas pu être récupérés.",
"code": 404,
});
})
})
});
});
}
addOne(igr) {
@@ -99,24 +98,24 @@ class IngredientRepository {
transacting: t
})
.catch(err => {
throw err
})
throw err;
});
})
.then(v => {
return v.load(['spells'])
return v.load(['spells']);
})
.then(v => {
resolve(this.getOne(v.id))
resolve(this.getOne(v.id));
})
.catch(err => {
console.log(err)
console.log(err);
reject({
"message": "Une erreur d'insertion s'est produite.",
"code": 500,
});
})
});
}
})
});
}
updateOne(id, igr) {
@@ -150,33 +149,33 @@ class IngredientRepository {
transacting: t
})
.catch(err => {
console.log(err)
throw err
})
console.log(err);
throw err;
});
})
.then(v => {
return v.load(['spells'])
return v.load(['spells']);
})
.then(v => {
resolve(this.getOne(v.id))
resolve(this.getOne(v.id));
})
.catch(err => {
console.log(err)
console.log(err);
reject({
"message": "Une erreur d'insertion s'est produite.",
"code": 500,
});
})
});
})
.catch(err => {
console.log(err)
console.log(err);
reject({
"message": "L'ingrédient en question n'a pas été trouvé.",
"code": 404,
});
})
});
}
})
});
}
deleteOne(id) {
@@ -185,23 +184,23 @@ class IngredientRepository {
.where({ 'id': id })
.fetch({ require: true, withRelated: ['spells'] })
.then(v => {
v.spells().detach()
v.destroy()
v.spells().detach();
v.destroy();
})
.then(() => {
resolve({
'message': 'Ingredient with ID ' + id + ' successfully deleted !'
})
});
})
.catch(err => {
console.log(err)
console.log(err);
reject({
"message": "L'ingrédient en question n'a pas été trouvé.",
"code": 404,
});
})
})
});
});
}
}
module.exports = IngredientRepository
module.exports = IngredientRepository;