From b70426a855fac2091de0fbca9776ea725f30fea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Pailharey?= <rpailharey@grandlyon.com> Date: Wed, 17 Aug 2022 17:07:06 +0200 Subject: [PATCH] fix: eslint --- .eslintrc.js | 1 + src/components/Consents/Consents.tsx | 4 +++- src/components/DateSelector/DateSelector.tsx | 5 +++-- src/components/ImagePicker/ImagePicker.tsx | 14 +++++++------- src/components/Login/Login.tsx | 2 +- src/components/Prices/PriceSection.tsx | 2 +- src/components/Settings/Settings.tsx | 2 +- src/reportWebVitals.ts | 18 +++++++++--------- 8 files changed, 26 insertions(+), 22 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 8ba8636d..f899dd41 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -17,6 +17,7 @@ module.exports = { rules: { // Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs '@typescript-eslint/explicit-function-return-type': 'off', + 'react/react-in-jsx-scope': 'off', 'react/prop-types': 'warn', }, settings: { diff --git a/src/components/Consents/Consents.tsx b/src/components/Consents/Consents.tsx index 5f7f81d5..9d459daa 100644 --- a/src/components/Consents/Consents.tsx +++ b/src/components/Consents/Consents.tsx @@ -245,7 +245,9 @@ const Consents: React.FC = () => { } } getConsentsData() - }, [user, consentService, rowsPerPage, page, checkSelectedNodes]) + // /!\ Do not add checkSelected in dependencies or effect will trigger on each selection + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [user, consentService, rowsPerPage, page]) return ( <> diff --git a/src/components/DateSelector/DateSelector.tsx b/src/components/DateSelector/DateSelector.tsx index 8a3e4bc7..0b501077 100644 --- a/src/components/DateSelector/DateSelector.tsx +++ b/src/components/DateSelector/DateSelector.tsx @@ -63,8 +63,9 @@ const DateSelector: React.FC<DateSelectorProps> = ({ <Modal> <> <div className="modal-text"> - Attention, vous n'avez pas enregistré vos modifications. Celles-ci - seront annulées en changeant de mois. Voulez-vous continuer ? + Attention, vous n'avez pas enregistré vos modifications. + Celles-ci seront annulées en changeant de mois. Voulez-vous + continuer ? </div> <div className="buttons"> <button className="btnCancel" onClick={() => setopenModal(false)}> diff --git a/src/components/ImagePicker/ImagePicker.tsx b/src/components/ImagePicker/ImagePicker.tsx index df90034f..c3625b96 100644 --- a/src/components/ImagePicker/ImagePicker.tsx +++ b/src/components/ImagePicker/ImagePicker.tsx @@ -33,7 +33,7 @@ const ImagePicker: React.FC<ImagePickerProps> = ({ const [currentPage, setCurrentPage] = useState(1) const [pageCount, setpageCount] = useState<number>(1) const [preSelectImage, setPreSelectImage] = useState<string>('') - let imagePerPage = 10 + const imagePerPage = 10 const toggleModal = () => { setOpenModal((prev) => !prev) @@ -76,7 +76,7 @@ const ImagePicker: React.FC<ImagePickerProps> = ({ <> {selectedImageURL === '' || !selectedImageURL ? ( <> - <p>Pas d'image sélectionnée</p> + <p>Pas d'image sélectionnée</p> <button className="btnValid" onClick={toggleModal}> Choisir une image </button> @@ -91,7 +91,7 @@ const ImagePicker: React.FC<ImagePickerProps> = ({ alt="selected" /> <button className="btnDelete" onClick={toggleModal}> - Modifier l'image + Modifier l'image </button> </> )} @@ -103,10 +103,10 @@ const ImagePicker: React.FC<ImagePickerProps> = ({ {imageNames && imageNames !== [] && imageNames[currentPage - 1] !== [] && - imageNames[currentPage - 1].map((imageURL) => ( + imageNames[currentPage - 1].map((imageName) => ( <SingleImage - imageURL={imageURL} - key={imageURL} + imageURL={imageName} + key={imageName} selectedImage={preSelectImage} setSelectedImageURL={setPreSelectImage} /> @@ -116,7 +116,7 @@ const ImagePicker: React.FC<ImagePickerProps> = ({ <Pagination count={pageCount} siblingCount={0} - onChange={(e, page) => handleChangePage(page)} + onChange={(_e, page) => handleChangePage(page)} /> <div className="buttons"> <button diff --git a/src/components/Login/Login.tsx b/src/components/Login/Login.tsx index 9bb9f893..1f20b820 100644 --- a/src/components/Login/Login.tsx +++ b/src/components/Login/Login.tsx @@ -8,7 +8,7 @@ const Login: React.FC = () => { return ( <div className="login"> <div className="container"> - <h1>Bienvenue sur le Backoffice d'Ecolyo !</h1> + <h1>Bienvenue sur le Backoffice d'Ecolyo !</h1> <button className="btnValid" onClick={loginUser}> Login </button> diff --git a/src/components/Prices/PriceSection.tsx b/src/components/Prices/PriceSection.tsx index 20e70cb9..51aee446 100644 --- a/src/components/Prices/PriceSection.tsx +++ b/src/components/Prices/PriceSection.tsx @@ -156,7 +156,7 @@ const PriceSection: React.FC<PriceSectionProps> = ({ </button> <div className="history"> <button onClick={toggleHistory} className={showHistory ? 'active' : ''}> - <span>Voir l'historique</span> + <span>Voir l'historique</span> <img src={arrowDown} className={showHistory ? 'icon-active' : ''} diff --git a/src/components/Settings/Settings.tsx b/src/components/Settings/Settings.tsx index 444d3842..e7aaaa50 100644 --- a/src/components/Settings/Settings.tsx +++ b/src/components/Settings/Settings.tsx @@ -5,7 +5,7 @@ const Settings: React.FC = () => { return ( <> <div className="header"> - <p className="title pagetitle">Paramètres de l'appli</p> + <p className="title pagetitle">Paramètres de l'appli</p> </div> <div className="content"> diff --git a/src/reportWebVitals.ts b/src/reportWebVitals.ts index 49a2a16e..57a24a21 100644 --- a/src/reportWebVitals.ts +++ b/src/reportWebVitals.ts @@ -1,15 +1,15 @@ -import { ReportHandler } from 'web-vitals'; +import { ReportHandler } from 'web-vitals' const reportWebVitals = (onPerfEntry?: ReportHandler) => { if (onPerfEntry && onPerfEntry instanceof Function) { import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { - getCLS(onPerfEntry); - getFID(onPerfEntry); - getFCP(onPerfEntry); - getLCP(onPerfEntry); - getTTFB(onPerfEntry); - }); + getCLS(onPerfEntry) + getFID(onPerfEntry) + getFCP(onPerfEntry) + getLCP(onPerfEntry) + getTTFB(onPerfEntry) + }) } -}; +} -export default reportWebVitals; +export default reportWebVitals -- GitLab