Skip to content

Commit 99518fb

Browse files
committed
Start fixing or hidding eslint v8+ and eslint-plugin-react-hooks v7+ new code errors
1 parent 0996cbe commit 99518fb

9 files changed

Lines changed: 294 additions & 268 deletions

File tree

eslint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ export default tseslint.config(
4040
'@typescript-eslint/no-unused-vars': ['warn'],
4141
'@typescript-eslint/no-explicit-any': ['off'],
4242
'react-hooks/exhaustive-deps': ['off'],
43+
// FIXME to fix, but how???
44+
'react-hooks/set-state-in-effect': ['off'], // or 'warn'
45+
'react-hooks/refs': ['off'],
4346
},
4447
}
4548
);

package-lock.json

Lines changed: 24 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"@types/react-dom": "^19.2.3",
6262
"artillery": "^2.0.32",
6363
"eslint": "^10.4.1",
64-
"eslint-plugin-react-hooks": "^6.1.1",
64+
"eslint-plugin-react-hooks": "^7.1.1",
6565
"eslint-plugin-react-refresh": "^0.5.2",
6666
"globals": "^17.6.0",
6767
"husky": "^9.1.7",

src/components/Gene/GeneExpressionTable.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ const GeneExpressionTable = ({ geneId, speciesId, exprData = undefined, notExpre
179179
const [cFields, setCFields]: any = React.useState({ anat: true });
180180
const [dataType, setDataTypes] = React.useState(DATA_TYPES.map((d) => d.key));
181181

182+
// FIXME
183+
// eslint-disable-next-line react-hooks/use-memo
182184
const columns = React.useMemo(columnsGenerator(cFields, data), [cFields, data]);
183185

184186
// In order to disable the search button in the search has already been made

src/components/Gene/GeneHomologs.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ const GenesCell = ({ genes }) => {
6767
{pos < genes.length && <br />}
6868
</span>
6969
);
70+
// FIXME
71+
// eslint-disable-next-line react-hooks/immutability
7072
prevSpecies = a.species.id;
7173

7274
return r;

src/components/Layout/Footer/Footer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ const NAVBAR_RIGHT = [
5959
const Footer = () => {
6060
const { addNotification } = React.useContext(NotificationContext);
6161
const loc = useLocation();
62-
loc.pathname = `${config.archive ? loc.pathname.replace(/[\\/][^\\/]*/, '') : loc.pathname}`;
63-
const permanentLink = React.useMemo(() => config.permanentVersionedDomain + loc.pathname, [loc]);
62+
const pathname = `${config.archive ? loc.pathname.replace(/[\\/][^\\/]*/, '') : loc.pathname}`;
63+
const permanentLink = React.useMemo(() => config.permanentVersionedDomain + pathname, [loc]);
6464

6565
return (
6666
<Bulma.Footer>

src/pages/analysis/TopAnat.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ const TopAnat = () => {
6363
if (loc.hash !== '' && loc.hash.match(oldResultFragment)) {
6464
// Get result hashtag from loc.hash, and clean the loc.hash value
6565
const resultId = loc.hash.replace(oldResultFragment, '');
66-
loc.hash = '';
6766
// Rewrite the loc with the current pathname + resultId
68-
navigate(`${resultId}`);
67+
navigate(`${resultId}`, { replace: true });
6968
}
7069

7170
const getJobStatus = React.useCallback((ID, jobID, requestParams = true) => {
@@ -86,6 +85,8 @@ const TopAnat = () => {
8685
});
8786
}
8887
} else if (res.data.jobResponse.jobStatus === 'RUNNING') {
88+
// FIXME
89+
// eslint-disable-next-line react-hooks/immutability
8990
getJobStatusTimeOut = setTimeout(() => getJobStatus(ID, jobID, false), 7000);
9091
setResults({ jobId: res.data.jobResponse.jobId });
9192
if (requestParams) {

src/pages/search/expressionmatrix/useLogic.jsx

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,37 @@ const useLogic = (isExprCalls) => {
212212
// filters
213213
const [filters, setFilters] = useState({});
214214

215+
const resetForm = (isSpeciesChange = false, preserveGenes = false) => {
216+
// console.log(`[useLogic.resetForm] resetForm called with:`, {isSpeciesChange, preserveGenes});
217+
if (!preserveGenes) {
218+
// console.log(`[useLogic.resetForm] Clearing genes in resetForm`);
219+
setSelectedGene([]);
220+
}
221+
setSelectedCellTypes([]);
222+
setSelectedStrain([]);
223+
setSelectedTissue([]);
224+
setSelectedSexes([]);
225+
setSelectedDevStages([]);
226+
setHasCellTypeSubStructure(true);
227+
setHasTissueSubStructure(true);
228+
setDevStageSubStructure(true);
229+
if (!isSpeciesChange) {
230+
setSelectedSpecies(EMPTY_SPECIES_VALUE);
231+
setSelectedExpOrAssay([]);
232+
}
233+
};
234+
235+
const getSexesAndDevStageForSpecies = () => {
236+
api.search.species.speciesDevelopmentSexe(selectedSpecies.value).then((resp) => {
237+
if (resp.code === 200) {
238+
setSpeciesSexes(resp.data?.requestDetails?.requestedSpeciesSexes);
239+
setDevStages(resp.data?.requestDetails?.requestedSpeciesDevStageOntology);
240+
} else {
241+
setSpeciesSexes([]);
242+
}
243+
});
244+
};
245+
215246
const updateSelectedSpecies = (newSpecies, preserveGenes = false) => {
216247
setSelectedSpecies(newSpecies);
217248
if (newSpecies.value !== EMPTY_SPECIES_VALUE.value) {
@@ -933,17 +964,6 @@ const useLogic = (isExprCalls) => {
933964
});
934965
};
935966

936-
const getSexesAndDevStageForSpecies = () => {
937-
api.search.species.speciesDevelopmentSexe(selectedSpecies.value).then((resp) => {
938-
if (resp.code === 200) {
939-
setSpeciesSexes(resp.data?.requestDetails?.requestedSpeciesSexes);
940-
setDevStages(resp.data?.requestDetails?.requestedSpeciesDevStageOntology);
941-
} else {
942-
setSpeciesSexes([]);
943-
}
944-
});
945-
};
946-
947967
const AutoCompleteByType = (type, mappingFn) =>
948968
useCallback(
949969
async (query) => {
@@ -1120,6 +1140,49 @@ const useLogic = (isExprCalls) => {
11201140
useEffect(() => {
11211141
// console.log(`[useLogic.js] loc.search CHANGED:`, loc.search);
11221142

1143+
// Add function to process gene list
1144+
const processGeneList = async (geneListParam) => {
1145+
if (!geneListParam) return;
1146+
1147+
setIsProcessingGeneList(true);
1148+
const geneIds = geneListParam.split(/[\r\n]+/);
1149+
1150+
try {
1151+
// Get search results for all genes
1152+
const searchResults = await Promise.all(geneIds.map((geneId) => api.search.genes.geneSearchResult(geneId)));
1153+
1154+
// Process results
1155+
const validResults = searchResults.filter(
1156+
(result) => result.code === 200 && result.data.result.totalMatchCount === 1
1157+
);
1158+
1159+
// Set species
1160+
const firstSpecies = validResults[0].data.result.geneMatches[0].gene.species;
1161+
const speciesValue = {
1162+
label: getSpeciesLabel(firstSpecies),
1163+
value: firstSpecies.id,
1164+
};
1165+
1166+
// Set genes
1167+
const genes = validResults.map((result) => {
1168+
const { gene } = result.data.result.geneMatches[0];
1169+
return {
1170+
label: getGeneLabel(gene),
1171+
value: gene.geneId,
1172+
};
1173+
});
1174+
1175+
// Update state with species and genes
1176+
setIsInitializingFromUrl(true);
1177+
setSelectedSpeciesFromUrl(speciesValue);
1178+
setSelectedGene(genes);
1179+
} catch (error) {
1180+
console.error('Error processing gene list:', error);
1181+
} finally {
1182+
setIsProcessingGeneList(false);
1183+
}
1184+
};
1185+
11231186
const searchParams = new URLSearchParams(loc.search);
11241187
const geneList = searchParams.get('gene_list');
11251188
if (geneList) {
@@ -1133,26 +1196,6 @@ const useLogic = (isExprCalls) => {
11331196
}
11341197
}, [loc.search]);
11351198

1136-
const resetForm = (isSpeciesChange = false, preserveGenes = false) => {
1137-
// console.log(`[useLogic.resetForm] resetForm called with:`, {isSpeciesChange, preserveGenes});
1138-
if (!preserveGenes) {
1139-
// console.log(`[useLogic.resetForm] Clearing genes in resetForm`);
1140-
setSelectedGene([]);
1141-
}
1142-
setSelectedCellTypes([]);
1143-
setSelectedStrain([]);
1144-
setSelectedTissue([]);
1145-
setSelectedSexes([]);
1146-
setSelectedDevStages([]);
1147-
setHasCellTypeSubStructure(true);
1148-
setHasTissueSubStructure(true);
1149-
setDevStageSubStructure(true);
1150-
if (!isSpeciesChange) {
1151-
setSelectedSpecies(EMPTY_SPECIES_VALUE);
1152-
setSelectedExpOrAssay([]);
1153-
}
1154-
};
1155-
11561199
// Expand or collapse a term
11571200
const onToggleExpandCollapse = (term) => {
11581201
// console.log(`[useLogic] onToggleExpandCollapse:\n${JSON.stringify(term)}`);
@@ -1215,49 +1258,6 @@ const useLogic = (isExprCalls) => {
12151258
// console.log(`[useLogic] DONE onToggleExpandCollapse.`);
12161259
};
12171260

1218-
// Add function to process gene list
1219-
const processGeneList = async (geneListParam) => {
1220-
if (!geneListParam) return;
1221-
1222-
setIsProcessingGeneList(true);
1223-
const geneIds = geneListParam.split(/[\r\n]+/);
1224-
1225-
try {
1226-
// Get search results for all genes
1227-
const searchResults = await Promise.all(geneIds.map((geneId) => api.search.genes.geneSearchResult(geneId)));
1228-
1229-
// Process results
1230-
const validResults = searchResults.filter(
1231-
(result) => result.code === 200 && result.data.result.totalMatchCount === 1
1232-
);
1233-
1234-
// Set species
1235-
const firstSpecies = validResults[0].data.result.geneMatches[0].gene.species;
1236-
const speciesValue = {
1237-
label: getSpeciesLabel(firstSpecies),
1238-
value: firstSpecies.id,
1239-
};
1240-
1241-
// Set genes
1242-
const genes = validResults.map((result) => {
1243-
const { gene } = result.data.result.geneMatches[0];
1244-
return {
1245-
label: getGeneLabel(gene),
1246-
value: gene.geneId,
1247-
};
1248-
});
1249-
1250-
// Update state with species and genes
1251-
setIsInitializingFromUrl(true);
1252-
setSelectedSpeciesFromUrl(speciesValue);
1253-
setSelectedGene(genes);
1254-
} catch (error) {
1255-
console.error('Error processing gene list:', error);
1256-
} finally {
1257-
setIsProcessingGeneList(false);
1258-
}
1259-
};
1260-
12611261
return {
12621262
searchResult,
12631263
maxExpScore,

0 commit comments

Comments
 (0)