ESlint: application générale des règles

This commit is contained in:
2020-03-09 14:49:56 +01:00
parent 21fe79684d
commit e5c5d9c8d2
40 changed files with 396 additions and 398 deletions

View File

@ -11,20 +11,20 @@ export function* loginSaga(action) {
result = yield call(client.login, action.username, action.password);
} catch(err) {
if (err instanceof UnauthorizedError) {
yield put(addMessage('warning', "Identifiants invalides."));
yield put(addMessage('warning', 'Identifiants invalides.'));
return;
}
yield put(loginFailure(action.username, err));
yield put(addMessage('danger', "Une erreur inconnue bloque le fonctionnement normal de l'application. Veuillez réessayer plus tard."));
return
yield put(addMessage('danger', 'Une erreur inconnue bloque le fonctionnement normal de l\'application. Veuillez réessayer plus tard.'));
return;
}
if ('error' in result) {
yield put(loginFailure(action.username, result.error));
const message = result.error.message ? result.error.message : result.error.toString();
yield put(addMessage('danger', message));
return
return;
}
yield put(loginSuccess(action.username));

View File

@ -1,8 +1,8 @@
import { history } from "../../util/history";
import { history } from '../../util/history';
import { addMessage } from '../../actions/message.actions';
import { put } from 'redux-saga/effects';
export function* logoutRedirectSaga() {
yield put(addMessage("success", "Vous êtes déconnecté."));
history.push('/login');
yield put(addMessage('success', 'Vous êtes déconnecté.'));
history.push('/login');
}

View File

@ -1,6 +1,6 @@
import { APIClient } from "../../services/api-client.service";
import { logoutFailure, logoutSuccess } from "../../actions/auth.actions";
import { addMessage } from "../../actions/message.actions";
import { APIClient } from '../../services/api-client.service';
import { logoutFailure, logoutSuccess } from '../../actions/auth.actions';
import { addMessage } from '../../actions/message.actions';
import { call, put } from 'redux-saga/effects';
export function* logoutSaga() {
@ -10,7 +10,7 @@ export function* logoutSaga() {
result = yield call(client.logout);
} catch(err) {
yield put(logoutFailure(err));
yield put(addMessage('danger', "Une erreur inconnue bloque le fonctionnement normal de l'application. Veuillez réessayer plus tard."));
yield put(addMessage('danger', 'Une erreur inconnue bloque le fonctionnement normal de l\'application. Veuillez réessayer plus tard.'));
return;
}
@ -18,7 +18,7 @@ export function* logoutSaga() {
yield put(logoutFailure(result.error));
const message = result.error.message ? result.error.message : result.error.toString();
yield put(addMessage('danger', message));
return
return;
}
yield put(logoutSuccess());

View File

@ -1,14 +1,14 @@
import { LOGIN_REQUEST, LOGOUT_REQUEST, LOGOUT_SUCCESS } from "../../actions/auth.actions";
import { loginSaga } from "./login.saga";
import { logoutSaga } from "./logout.saga";
import { logoutRedirectSaga } from "./logout-redirect.saga";
import { LOGIN_REQUEST, LOGOUT_REQUEST, LOGOUT_SUCCESS } from '../../actions/auth.actions';
import { loginSaga } from './login.saga';
import { logoutSaga } from './logout.saga';
import { logoutRedirectSaga } from './logout-redirect.saga';
import { all, takeLatest } from 'redux-saga/effects';
export function * rootSaga() {
yield all([
yield all([
takeLatest(LOGIN_REQUEST, loginSaga),
takeLatest(LOGOUT_REQUEST, logoutSaga),
// Redirect after logout success
takeLatest(LOGOUT_SUCCESS, logoutRedirectSaga),
]);
takeLatest(LOGOUT_REQUEST, logoutSaga),
// Redirect after logout success
takeLatest(LOGOUT_SUCCESS, logoutRedirectSaga),
]);
}

View File

@ -1,8 +1,8 @@
import { failureActionSaga } from "./failure.saga";
import { takeLatest, all } from "redux-saga/effects";
import { failureActionSaga } from './failure.saga';
import { takeLatest, all } from 'redux-saga/effects';
export function * rootSaga(action) {
yield all([
yield all([
takeLatest(action => /_FAILURE$/g.test(action.type), failureActionSaga),
]);
]);
}

View File

@ -1,8 +1,8 @@
import { all } from 'redux-saga/effects';
import { checkSessionSaga } from './session.saga';
import { refreshSessionSaga } from './session.saga';
export function* rootSaga() {
yield all([
checkSessionSaga(),
]);
yield all([
refreshSessionSaga(),
]);
}

View File

@ -1,11 +1,14 @@
import { APIClient } from '../../services/api-client.service';
import { call } from 'redux-saga/effects';
import { call, put } from 'redux-saga/effects';
import { refreshUserSessionFailure, refreshUserSessionSuccess } from '../../actions/auth.actions';
export function* checkSessionSaga() {
const client = new APIClient();
try {
yield call(client.retrieveSessionUser);
} catch(err) {
console.error(err);
}
export function* refreshSessionSaga() {
const client = new APIClient();
let user;
try {
user = yield call(client.retrieveSessionUser);
} catch(err) {
yield put(refreshUserSessionFailure(err));
}
yield put(refreshUserSessionSuccess(user));
}

View File

@ -2,17 +2,17 @@ import { call, put } from 'redux-saga/effects';
import { projectUserListFailure, projectUserListSuccess, projectListFailure, projectListSuccess } from '../actions/project';
export function* projectUserListSaga() {
let result
let result;
try {
result = yield call(projectUserList);
} catch(err) {
yield put(projectUserListFailure(err));
return
return;
}
if ('error' in result) {
yield put(projectUserListFailure(result.error));
return
return;
}
yield put(projectUserListSuccess(result.data));
@ -23,22 +23,22 @@ const projectUserList = () => {
method: 'GET',
mode: 'cors',
credentials: 'include'
}).then(res => res.json())
}
}).then(res => res.json());
};
export function* projectListSaga() {
let result
let result;
try {
result = yield call(projectList);
} catch(err) {
yield put(projectListFailure(err));
return
return;
}
if ('error' in result) {
yield put(projectListFailure(result.error));
return
return;
}
yield put(projectListSuccess(result.data));
@ -49,5 +49,5 @@ const projectList = () => {
method: 'GET',
mode: 'cors',
credentials: 'include'
}).then(res => res.json())
}
}).then(res => res.json());
};

View File

@ -5,10 +5,10 @@ import { rootSaga as initRootSaga } from './init/root.saga';
import { rootSaga as userRootSaga } from './user/root.saga';
export default function* rootSaga() {
yield all([
initRootSaga(),
authRootSaga(),
failureRootSaga(),
userRootSaga()
]);
yield all([
initRootSaga(),
authRootSaga(),
failureRootSaga(),
userRootSaga()
]);
}

View File

@ -3,7 +3,7 @@ import { CREATE_USER_REQUEST } from '../../actions/user.actions';
import { createUserSaga } from './user.saga';
export function* rootSaga() {
yield all([
takeLatest(CREATE_USER_REQUEST, createUserSaga),
]);
yield all([
takeLatest(CREATE_USER_REQUEST, createUserSaga),
]);
}

View File

@ -10,7 +10,7 @@ export function* createUserSaga({username, password}) {
} catch(err) {
console.error(err);
yield put(createUserFailure(err));
return
return;
}
yield put(createUserSuccess(user));