Skip to content

Commit

Permalink
Passage à typescript-eslint strict
Browse files Browse the repository at this point in the history
  • Loading branch information
NerOcrO committed Apr 29, 2024
1 parent efd32ac commit 2e37ddf
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 34 deletions.
6 changes: 3 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"extends": [
"next/core-web-vitals",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:@typescript-eslint/strict-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked",
"plugin:react/all",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:jsx-a11y/recommended",
"plugin:jsx-a11y/strict",
"plugin:deprecation/recommended"
],
"parserOptions": {
Expand Down
8 changes: 4 additions & 4 deletions prisma/db.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Prisma, PrismaClient } from '@prisma/client'
import { DefaultArgs } from '@prisma/client/runtime/library'

const prismaClientSingleton = (): PrismaClient<Prisma.PrismaClientOptions, never, DefaultArgs> => {
const prismaClientSingleton = (): PrismaClient<Prisma.PrismaClientOptions, never> => {
const prisma = new PrismaClient({
log: [
{
Expand Down Expand Up @@ -36,12 +35,13 @@ declare global {
const prismaGlobal: undefined | ReturnType<typeof prismaClientSingleton>
}

// @ts-ignore
// @ts-expect-error
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const prisma = globalThis.prismaGlobal as PrismaClient ?? prismaClientSingleton()

export default prisma

if (process.env.NODE_ENV !== 'production') {
// @ts-ignore
// @ts-expect-error
globalThis.prismaGlobal = prisma
}
4 changes: 2 additions & 2 deletions src/app/(connecte)/indicateurs-cles/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function transformIndicateursModelToViewModel(indicateursModel: ind_indicateur_i
emissionsDeParticulesFines += indicateur.impact_unitaire
} else if (critere === Criteres.acidification) {
acidification += indicateur.impact_unitaire
} else if (critere === Criteres.empreinteCarbone) {
} else {
empreinteCarbone += indicateur.impact_unitaire / 1000

if (etapeacv === EtapesAcv.fabrication) {
Expand All @@ -94,7 +94,7 @@ function transformIndicateursModelToViewModel(indicateursModel: ind_indicateur_i
distribution += indicateur.impact_unitaire / 1000
} else if (etapeacv === EtapesAcv.utilisation) {
utilisation += indicateur.impact_unitaire / 1000
} else if (etapeacv === EtapesAcv.finDeVie) {
} else {
finDeVie += indicateur.impact_unitaire / 1000
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/(connecte)/liste-equipements/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ function transformEquipementModelToViewModel(
const types = {}

for (const equipementModel of equipementsModel.sort(sortByTypeEquipementAndEtapeAcv(referentielsEquipementsModel))) {
// @ts-ignore
// @ts-expect-error
types[equipementModel.type] = [
// @ts-ignore
// @ts-expect-error
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
...types[equipementModel.type] || [],
{
Expand Down
18 changes: 9 additions & 9 deletions src/authentification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const authOptions = {
callbacks: {
jwt({ token, profile }): JWT {
if (profile !== undefined) {
// @ts-ignore
// @ts-expect-error
token.profile_atih = profile.profile_atih
}

return token
},
session({ session, token }): Session {
if (session.user !== undefined) {
// @ts-ignore
// @ts-expect-error
session.user.profile_atih = token.profile_atih
}

Expand Down Expand Up @@ -69,27 +69,27 @@ export async function getProfileAtih(): Promise<ProfileAtih> {
nomEtablissement: '',
}

// @ts-ignore
// @ts-expect-error
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
for (const profil of Object.keys(session.user.profile_atih.profils)) {
let finess = ''

// @ts-ignore
// @ts-expect-error
if (Number(profil) === Number(session.user.profile_atih.idProfilSelectionne)) {
// @ts-ignore
// @ts-expect-error
finess = session.user.profile_atih.profils[profil].entite.finess

// @ts-ignore
// @ts-expect-error
if (session.user.profile_atih.profils[profil].entite.niveau === 'ET') {
// @ts-ignore
// @ts-expect-error
if (session.user.profile_atih.profils[profil].entite.statut[1] !== undefined) {
// @ts-ignore
// @ts-expect-error
finess = session.user.profile_atih.profils[profil].entite.finessJuridique
}
}

profile = {
// @ts-ignore
// @ts-expect-error
nomEtablissement: session.user.profile_atih.profils[profil].entite.libelle + '$$' + finess,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Connexion/Connexion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ClientSafeProvider, LiteralUnion, signIn } from 'next-auth/react'
import { ReactElement } from 'react'

type LoginProps = Readonly<{
providers: Record<LiteralUnion<BuiltInProviderType, string>, ClientSafeProvider> | null
providers: Record<LiteralUnion<BuiltInProviderType>, ClientSafeProvider> | null
}>

export default function Connexion({ providers }: LoginProps): ReactElement {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Inventaire/Actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type ModaleProps = Readonly<{
}>

export default function Actions({ enregistrerUnInventaireNonCalcule, quantiteGlobale, statut }: ModaleProps): ReactElement {
const isNonCalcule = statut && statut === StatutsInventaire.TRAITE
const isNonCalcule = statut === StatutsInventaire.TRAITE

return (
<div className="btn-group">
Expand Down
2 changes: 1 addition & 1 deletion src/components/Inventaire/modele.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const modelesSelectionnes = () => {
modeles.push({
modele: selects[index].value,
quantite: inputs[index].valueAsNumber,
type: selects[index].dataset.nomEquipement as string,
type: selects[index].dataset.nomEquipement ?? '',
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Inventaire/useEquipement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function useEquipement(setQuantiteGlobale: (quantite: number) => void, mo

type ActionReducer = Readonly<{
id: string
modele?: ModeleReducer
modele: ModeleReducer
type: string
}>

Expand All @@ -46,7 +46,7 @@ function modelesReducer(modeles: ModeleReducer[], action: ActionReducer): Modele
case 'changed': {
return modeles.map((modele: ModeleReducer): ModeleReducer => {
if (modele.id === action.id) {
return action.modele as ModeleReducer
return action.modele
} else {
return modele
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/viewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export type EquipementsAvecSesModelesViewModel = Readonly<{
type: string
}>

export type EquipementsViewModel = Readonly<{
[key: string]: EquipementViewModel[]
}>
export type EquipementsViewModel = Readonly<
Record<string, EquipementViewModel[]>
>

export type EquipementViewModel = Readonly<{
dateInventaire: Date
Expand Down
8 changes: 4 additions & 4 deletions src/repository/equipementsRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ export type EquipementPhysique = Readonly<{

export type EquipementPhysiqueModel = Readonly<{
type: string
modeles: ReadonlyArray<{
modeles: readonly {
ref_correspondance_ref_eqp: Readonly<{
modele_equipement_source: string
}>
}>
}[]
}>

export async function recupererLesReferentielsEquipementsRepository(): Promise<EquipementPhysiqueModel[]> {
Expand Down Expand Up @@ -96,7 +96,7 @@ async function ajouterEquipementsPhysiquesRepository(
method: 'POST',
})

if (responseEntrees.ok === false) {
if (!responseEntrees.ok) {
if (responseEntrees.status === 415) {
const data = await responseEntrees.json() as ApiErrorJava
throw new Error(`Status: ${responseEntrees.status}, Status text: ${data.detail}`)
Expand All @@ -121,7 +121,7 @@ async function lancerLeCalculRepository(nomEtablissement: string, nomInventaire:
method: 'POST',
})

if (responseCalculs.ok === false) {
if (!responseCalculs.ok) {
if (responseCalculs.status === 415) {
const data = await responseCalculs.json() as ApiErrorJava
throw new Error(`Status: ${responseCalculs.status}, Status text: ${data.detail}`)
Expand Down
2 changes: 1 addition & 1 deletion src/repository/indicateursRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function recupererIndicateursEquipementsPhysiquesSommesRepository(
nomEtablissement: string,
nomInventaire: string
): Promise<IndicateursSommesModel[]> {
// @ts-ignore
// @ts-expect-error
return await prisma.ind_indicateur_impact_equipement_physique.groupBy({
_sum: {
impact_unitaire: true,
Expand Down
2 changes: 1 addition & 1 deletion src/repository/inventairesRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ export async function supprimerInventaireRepository(nomEtablissement: string, no
await supprimerEquipementsPhysiquesRepository(nomEtablissement, nomInventaire)
await supprimerIndicateursEquipementsPhysiquesRepository(nomEtablissement, nomInventaire)

return inventaire?.date_lot || new Date()
return inventaire?.date_lot ?? new Date()
})
}

0 comments on commit 2e37ddf

Please sign in to comment.