chore: activer ESLint sur le backend

Installe eslint, ajoute le script lint, modernise le parser
(retrait de babel-eslint obsolète) et applique l'autofix
(points-virgules manquants sur l'ensemble du code, conformément
à la règle "semi" déjà présente dans .eslintrc mais jamais
appliquée faute d'ESLint installé et d'un script pour l'exécuter).
This commit is contained in:
2026-07-04 20:00:51 +04:00
parent 90c048a282
commit 2224c8f3bb
29 changed files with 962 additions and 646 deletions
+8 -8
View File
@@ -1,23 +1,23 @@
'use strict';
const { UnauthorizedError } = require('@strapi/utils').errors
const { UnauthorizedError } = require('@strapi/utils').errors;
module.exports = async (policyContext, config, {strapi}) => {
const {request} = policyContext
const {request} = policyContext;
if (!request?.header?.authorization) {
throw new UnauthorizedError('Opération non autorisée')
throw new UnauthorizedError('Opération non autorisée');
}
try {
const {id} = await strapi.plugins['users-permissions'].services.jwt.getToken(policyContext)
const {id} = await strapi.plugins['users-permissions'].services.jwt.getToken(policyContext);
if (id !== request.body?.data?.user?.id) {
throw new UnauthorizedError('Opération non autorisée')
throw new UnauthorizedError('Opération non autorisée');
}
} catch (err) {
throw new UnauthorizedError('Opération non autorisée')
throw new UnauthorizedError('Opération non autorisée');
}
return true
}
return true;
};