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
+12 -12
View File
@@ -1,35 +1,35 @@
'use strict';
const { UnauthorizedError, NotFoundError } = require('@strapi/utils').errors
const { UnauthorizedError, NotFoundError } = require('@strapi/utils').errors;
module.exports = async (policyContext, config, {strapi}) => {
const {request, params} = policyContext
const {request, params} = policyContext;
if (!request?.header?.authorization) {
throw new UnauthorizedError('Opération non autorisée')
throw new UnauthorizedError('Opération non autorisée');
}
let jwtUserId
let jwtUserId;
try {
({id: jwtUserId} = await strapi.plugins['users-permissions'].services.jwt.getToken(policyContext))
({id: jwtUserId} = await strapi.plugins['users-permissions'].services.jwt.getToken(policyContext));
} catch (err) {
throw new UnauthorizedError('Opération non autorisée')
throw new UnauthorizedError('Opération non autorisée');
}
const documentId = params?.id ?? request.body?.data?.documentId
const documentId = params?.id ?? request.body?.data?.documentId;
const document = await strapi.db.query(config.uid).findOne({
where: {documentId},
populate: {user: true}
})
});
if (!document) {
throw new NotFoundError('Ressource introuvable.')
throw new NotFoundError('Ressource introuvable.');
}
if (document.user?.id !== jwtUserId) {
throw new UnauthorizedError('Opération non autorisée')
throw new UnauthorizedError('Opération non autorisée');
}
return true
}
return true;
};