mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
start upgrading eslint
This commit is contained in:
@@ -1,23 +1,21 @@
|
||||
import get from 'lodash/get';
|
||||
import findIndex from 'lodash/findIndex';
|
||||
import i18n from '../i18n';
|
||||
import preenTodos from '../libs/preenTodos';
|
||||
import {
|
||||
NotFound,
|
||||
BadRequest,
|
||||
} from '../libs/errors';
|
||||
import get from 'lodash/get';
|
||||
import findIndex from 'lodash/findIndex';
|
||||
|
||||
// TODO used only in client, move there?
|
||||
|
||||
export default function sortTask (user, req = {}) {
|
||||
let id = get(req, 'params.id');
|
||||
const id = get(req, 'params.id');
|
||||
let to = get(req, 'query.to');
|
||||
let fromParam = get(req, 'query.from');
|
||||
let taskType = get(req, 'params.taskType');
|
||||
const taskType = get(req, 'params.taskType');
|
||||
|
||||
let index = findIndex(user[`${taskType}s`], function findById (task) {
|
||||
return task._id === id;
|
||||
});
|
||||
const index = findIndex(user[`${taskType}s`], task => task._id === id);
|
||||
|
||||
if (index === -1) {
|
||||
throw new NotFound(i18n.t('messageTaskNotFound', req.language));
|
||||
@@ -26,10 +24,10 @@ export default function sortTask (user, req = {}) {
|
||||
throw new BadRequest('?to=__&from=__ are required');
|
||||
}
|
||||
|
||||
let tasks = user[`${taskType}s`];
|
||||
const tasks = user[`${taskType}s`];
|
||||
|
||||
if (taskType === 'todo') {
|
||||
let preenedTasks = preenTodos(tasks);
|
||||
const preenedTasks = preenTodos(tasks);
|
||||
|
||||
if (to !== -1) {
|
||||
to = tasks.indexOf(preenedTasks[to]);
|
||||
@@ -38,7 +36,7 @@ export default function sortTask (user, req = {}) {
|
||||
fromParam = tasks.indexOf(preenedTasks[fromParam]);
|
||||
}
|
||||
|
||||
let movedTask = tasks.splice(fromParam, 1)[0];
|
||||
const movedTask = tasks.splice(fromParam, 1)[0];
|
||||
|
||||
if (to === -1) {
|
||||
tasks.push(movedTask);
|
||||
|
||||
Reference in New Issue
Block a user