1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-27 17:19:43 +02:00

Move from prettier-eslint to eslint-plugin-prettier, update dependencies

This commit is contained in:
Maksim Eltyshev 2020-02-03 18:42:31 +05:00
parent 1f43d4f214
commit 45bde7e7c0
254 changed files with 5539 additions and 5170 deletions

View file

@ -2,21 +2,22 @@ import socket from './socket';
/* Transformers */
export const transformAction = (action) => ({
export const transformAction = action => ({
...action,
createdAt: new Date(action.createdAt),
});
/* Actions */
const getActions = (cardId, data, headers) => socket.get(`/cards/${cardId}/actions`, data, headers).then((body) => ({
...body,
items: body.items.map(transformAction),
}));
const getActions = (cardId, data, headers) =>
socket.get(`/cards/${cardId}/actions`, data, headers).then(body => ({
...body,
items: body.items.map(transformAction),
}));
/* Event handlers */
const makeHandleActionCreate = (next) => (body) => {
const makeHandleActionCreate = next => body => {
next({
...body,
item: transformAction(body.item),

View file

@ -3,15 +3,17 @@ import { transformCard } from './cards';
/* Actions */
const createBoard = (projectId, data, headers) => socket.post(`/projects/${projectId}/boards`, data, headers);
const createBoard = (projectId, data, headers) =>
socket.post(`/projects/${projectId}/boards`, data, headers);
const getBoard = (id, headers) => socket.get(`/boards/${id}`, undefined, headers).then((body) => ({
...body,
included: {
...body.included,
cards: body.included.cards.map(transformCard),
},
}));
const getBoard = (id, headers) =>
socket.get(`/boards/${id}`, undefined, headers).then(body => ({
...body,
included: {
...body.included,
cards: body.included.cards.map(transformCard),
},
}));
const updateBoard = (id, data, headers) => socket.patch(`/boards/${id}`, data, headers);

View file

@ -2,9 +2,11 @@ import socket from './socket';
/* Actions */
const createCardLabel = (cardId, data, headers) => socket.post(`/cards/${cardId}/labels`, data, headers);
const createCardLabel = (cardId, data, headers) =>
socket.post(`/cards/${cardId}/labels`, data, headers);
const deleteCardLabel = (cardId, labelId, headers) => socket.delete(`/cards/${cardId}/labels/${labelId}`, undefined, headers);
const deleteCardLabel = (cardId, labelId, headers) =>
socket.delete(`/cards/${cardId}/labels/${labelId}`, undefined, headers);
export default {
createCardLabel,

View file

@ -2,9 +2,11 @@ import socket from './socket';
/* Actions */
const createCardMembership = (cardId, data, headers) => socket.post(`/cards/${cardId}/memberships`, data, headers);
const createCardMembership = (cardId, data, headers) =>
socket.post(`/cards/${cardId}/memberships`, data, headers);
const deleteCardMembership = (cardId, userId, headers) => socket.delete(`/cards/${cardId}/memberships?userId=${userId}`, undefined, headers);
const deleteCardMembership = (cardId, userId, headers) =>
socket.delete(`/cards/${cardId}/memberships?userId=${userId}`, undefined, headers);
export default {
createCardMembership,

View file

@ -2,7 +2,7 @@ import socket from './socket';
/* Transformers */
export const transformCard = (card) => ({
export const transformCard = card => ({
...card,
...(card.dueDate && {
dueDate: new Date(card.dueDate),
@ -17,7 +17,7 @@ export const transformCard = (card) => ({
}),
});
export const transformCardData = (data) => ({
export const transformCardData = data => ({
...data,
...(data.dueDate && {
dueDate: data.dueDate.toISOString(),
@ -34,29 +34,33 @@ export const transformCardData = (data) => ({
/* Actions */
const createCard = (listId, data, headers) => socket.post(`/lists/${listId}/cards`, transformCardData(data), headers).then((body) => ({
...body,
item: transformCard(body.item),
}));
const createCard = (listId, data, headers) =>
socket.post(`/lists/${listId}/cards`, transformCardData(data), headers).then(body => ({
...body,
item: transformCard(body.item),
}));
const getCard = (id, headers) => socket.get(`/cards/${id}`, undefined, headers).then((body) => ({
...body,
item: transformCard(body.item),
}));
const getCard = (id, headers) =>
socket.get(`/cards/${id}`, undefined, headers).then(body => ({
...body,
item: transformCard(body.item),
}));
const updateCard = (id, data, headers) => socket.patch(`/cards/${id}`, transformCardData(data), headers).then((body) => ({
...body,
item: transformCard(body.item),
}));
const updateCard = (id, data, headers) =>
socket.patch(`/cards/${id}`, transformCardData(data), headers).then(body => ({
...body,
item: transformCard(body.item),
}));
const deleteCard = (id, headers) => socket.delete(`/cards/${id}`, undefined, headers).then((body) => ({
...body,
item: transformCard(body.item),
}));
const deleteCard = (id, headers) =>
socket.delete(`/cards/${id}`, undefined, headers).then(body => ({
...body,
item: transformCard(body.item),
}));
/* Event handlers */
const makeHandleCardCreate = (next) => (body) => {
const makeHandleCardCreate = next => body => {
next({
...body,
item: transformCard(body.item),

View file

@ -3,20 +3,23 @@ import { transformAction } from './actions';
/* Actions */
const createCommentAction = (cardId, data, headers) => socket.post(`/cards/${cardId}/comment-actions`, data, headers).then((body) => ({
...body,
item: transformAction(body.item),
}));
const createCommentAction = (cardId, data, headers) =>
socket.post(`/cards/${cardId}/comment-actions`, data, headers).then(body => ({
...body,
item: transformAction(body.item),
}));
const updateCommentAction = (id, data, headers) => socket.patch(`/comment-actions/${id}`, data, headers).then((body) => ({
...body,
item: transformAction(body.item),
}));
const updateCommentAction = (id, data, headers) =>
socket.patch(`/comment-actions/${id}`, data, headers).then(body => ({
...body,
item: transformAction(body.item),
}));
const deleteCommentAction = (id, headers) => socket.delete(`/comment-actions/${id}`, undefined, headers).then((body) => ({
...body,
item: transformAction(body.item),
}));
const deleteCommentAction = (id, headers) =>
socket.delete(`/comment-actions/${id}`, undefined, headers).then(body => ({
...body,
item: transformAction(body.item),
}));
export default {
createCommentAction,

View file

@ -5,7 +5,7 @@ import Config from '../constants/Config';
const http = {};
// TODO: all methods
['POST'].forEach((method) => {
['POST'].forEach(method => {
http[method.toLowerCase()] = (url, data, headers) => {
const formData = Object.keys(data).reduce((result, key) => {
result.append(key, data[key]);
@ -18,10 +18,12 @@ const http = {};
headers,
body: formData,
})
.then((response) => response.json().then((body) => ({
body,
isError: response.status !== 200,
})))
.then(response =>
response.json().then(body => ({
body,
isError: response.status !== 200,
})),
)
.then(({ body, isError }) => {
if (isError) {
throw body;

View file

@ -2,7 +2,8 @@ import socket from './socket';
/* Actions */
const createLabel = (boardId, data, headers) => socket.post(`/boards/${boardId}/labels`, data, headers);
const createLabel = (boardId, data, headers) =>
socket.post(`/boards/${boardId}/labels`, data, headers);
const updateLabel = (id, data, headers) => socket.patch(`/labels/${id}`, data, headers);

View file

@ -2,7 +2,8 @@ import socket from './socket';
/* Actions */
const createList = (boardId, data, headers) => socket.post(`/boards/${boardId}/lists`, data, headers);
const createList = (boardId, data, headers) =>
socket.post(`/boards/${boardId}/lists`, data, headers);
const updateList = (id, data, headers) => socket.patch(`/lists/${id}`, data, headers);

View file

@ -4,20 +4,22 @@ import { transformAction } from './actions';
/* Actions */
const getNotifications = (headers) => socket.get('/notifications', undefined, headers).then((body) => ({
...body,
included: {
...body.included,
cards: body.included.cards.map(transformCard),
actions: body.included.actions.map(transformAction),
},
}));
const getNotifications = headers =>
socket.get('/notifications', undefined, headers).then(body => ({
...body,
included: {
...body.included,
cards: body.included.cards.map(transformCard),
actions: body.included.actions.map(transformAction),
},
}));
const updateNotifications = (ids, data, headers) => socket.patch(`/notifications/${ids.join(',')}`, data, headers);
const updateNotifications = (ids, data, headers) =>
socket.patch(`/notifications/${ids.join(',')}`, data, headers);
/* Event handlers */
const makeHandleNotificationCreate = (next) => (body) => {
const makeHandleNotificationCreate = next => body => {
next({
...body,
included: {

View file

@ -2,9 +2,11 @@ import socket from './socket';
/* Actions */
const createProjectMembership = (projectId, data, headers) => socket.post(`/projects/${projectId}/memberships`, data, headers);
const createProjectMembership = (projectId, data, headers) =>
socket.post(`/projects/${projectId}/memberships`, data, headers);
const deleteProjectMembership = (id, headers) => socket.delete(`/project-memberships/${id}`, undefined, headers);
const deleteProjectMembership = (id, headers) =>
socket.delete(`/project-memberships/${id}`, undefined, headers);
export default {
createProjectMembership,

View file

@ -2,7 +2,7 @@ import socket from './socket';
/* Actions */
const getProjects = (headers) => socket.get('/projects', undefined, headers);
const getProjects = headers => socket.get('/projects', undefined, headers);
const createProject = (data, headers) => socket.post('/projects', data, headers);

View file

@ -15,24 +15,25 @@ const { socket } = io;
socket.connect = socket._connect; // eslint-disable-line no-underscore-dangle
['GET', 'POST', 'PUT', 'PATCH', 'DELETE'].forEach((method) => {
socket[method.toLowerCase()] = (url, data, headers) => new Promise((resolve, reject) => {
socket.request(
{
method,
data,
headers,
url: `/api${url}`,
},
(_, { body, error }) => {
if (error) {
reject(body);
} else {
resolve(body);
}
},
);
});
['GET', 'POST', 'PUT', 'PATCH', 'DELETE'].forEach(method => {
socket[method.toLowerCase()] = (url, data, headers) =>
new Promise((resolve, reject) => {
socket.request(
{
method,
data,
headers,
url: `/api${url}`,
},
(_, { body, error }) => {
if (error) {
reject(body);
} else {
resolve(body);
}
},
);
});
});
export default socket;

View file

@ -3,25 +3,27 @@ import socket from './socket';
/* Actions */
const getUsers = (headers) => socket.get('/users', undefined, headers);
const getUsers = headers => socket.get('/users', undefined, headers);
const createUser = (data, headers) => socket.post('/users', data, headers);
const getCurrentUser = (headers) => socket.get('/users/me', undefined, headers);
const getCurrentUser = headers => socket.get('/users/me', undefined, headers);
const updateUser = (id, data, headers) => socket.patch(`/users/${id}`, data, headers);
const updateUserEmail = (id, data, headers) => socket.patch(`/users/${id}/email`, data, headers);
const updateUserPassword = (id, data, headers) => socket.patch(`/users/${id}/password`, data, headers);
const updateUserPassword = (id, data, headers) =>
socket.patch(`/users/${id}/password`, data, headers);
const uploadUserAvatar = (id, file, headers) => http.post(
`/users/${id}/upload-avatar`,
{
file,
},
headers,
);
const uploadUserAvatar = (id, file, headers) =>
http.post(
`/users/${id}/upload-avatar`,
{
file,
},
headers,
);
const deleteUser = (id, headers) => socket.delete(`/users/${id}`, undefined, headers);