Skip to content

Commit

Permalink
fix: fix eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-nguyen-cs committed Feb 9, 2024
1 parent e4a927a commit 7d8945e
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 28 deletions.
2 changes: 1 addition & 1 deletion taxonomy-editor-frontend/src/backend-types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type ProjectType = {
_Time__minute: number;
_Time__second: number;
_Time__nanosecond: number;
_Time__tzinfo: {};
_Time__tzinfo: any;
};
};
description: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ const CreateNodeDialogContent = ({
}}
>
{[...ISO6391.getAllNames()].sort().map((languageNameItem) => (
<MenuItem value={languageNameItem}>{languageNameItem}</MenuItem>
<MenuItem key={languageNameItem} value={languageNameItem}>
{languageNameItem}
</MenuItem>
))}
</Select>
</FormControl>
Expand Down
5 changes: 2 additions & 3 deletions taxonomy-editor-frontend/src/components/ResponsiveAppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import ListSubheader from "@mui/material/ListSubheader";
import MuiLink from "@mui/material/Link";
import SettingsIcon from "@mui/icons-material/Settings";
import { useTranslation } from "react-i18next";

const logo = require("../assets/logosmall.jpg");
import logoUrl from "../assets/logosmall.jpg";

type ResponsiveAppBarProps = {
displayedPages: Array<{ translationKey: string; url: string }>;
Expand Down Expand Up @@ -130,7 +129,7 @@ const ResponsiveAppBar = ({ displayedPages }: ResponsiveAppBarProps) => {
target="_blank"
>
<img
src={logo}
src={logoUrl}
width="50px"
height="50px"
alt="OpenFoodFacts logo"
Expand Down
2 changes: 1 addition & 1 deletion taxonomy-editor-frontend/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @returns string
*/
function taxonomyApiUrlFromUi(location) {
let components = location.host.split(".");
const components = location.host.split(".");
if (components[0] === "ui") {
// we build api url by just replacing ui by api
components[0] = "api";
Expand Down
2 changes: 2 additions & 0 deletions taxonomy-editor-frontend/src/declaration.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare module "*.jpg";
declare module "*.png";
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface RenderedProperties {

const ListAllEntryProperties = ({ nodeObject, setNodeObject }) => {
const collectProperties = () => {
let renderedProperties: RenderedProperties[] = [];
const renderedProperties: RenderedProperties[] = [];
Object.keys(nodeObject).forEach((key) => {
// Collecting uuids of properties
// UUID of properties will have a "_uuid" suffix
Expand Down Expand Up @@ -53,8 +53,8 @@ const ListAllEntryProperties = ({ nodeObject, setNodeObject }) => {
// Helper function used for deleting properties of node
const deletePropertyData = (key) => {
setNodeObject((prevState) => {
const toRemove = "prop_" + key;
const { [toRemove]: _, ...newNodeObject } = prevState;
const keyToRemove = "prop_" + key;
const { [keyToRemove]: _propToRemove, ...newNodeObject } = prevState;
return newNodeObject;
});
};
Expand All @@ -71,7 +71,7 @@ const ListAllEntryProperties = ({ nodeObject, setNodeObject }) => {
]}
editable={{
onRowAdd: (newRow) =>
new Promise((resolve, reject) => {
new Promise((resolve) => {
// Add new property to rendered rows
const updatedRows = [
...data,
Expand All @@ -81,11 +81,12 @@ const ListAllEntryProperties = ({ nodeObject, setNodeObject }) => {

// Add new key-value pair of a property in nodeObject
changePropertyData(newRow.propertyName, newRow.propertyValue);
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
resolve();
}),
onRowDelete: (selectedRow) =>
new Promise((resolve, reject) => {
new Promise((resolve) => {
// Delete property from rendered rows
const updatedRows = [...data];
const index = parseInt(selectedRow.id);
Expand All @@ -94,29 +95,34 @@ const ListAllEntryProperties = ({ nodeObject, setNodeObject }) => {

// Delete key-value pair of a property from nodeObject
deletePropertyData(selectedRow.propertyName);
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
resolve();
}),
onRowUpdate: (updatedRow, oldRow) =>
new Promise((resolve, reject) => {
new Promise((resolve) => {
// Update row in rendered rows
const updatedRows = data.map((el) =>
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
el.id === oldRow.id ? updatedRow : el
);
setData(updatedRows);
// Updation takes place by deletion + addition
// If property name has been changed, previous key should be removed from nodeObject
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
updatedRow.propertyName !== oldRow.propertyName &&
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
deletePropertyData(oldRow.propertyName);
// Add new property to nodeObject
changePropertyData(
updatedRow.propertyName,
updatedRow.propertyValue
);
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
resolve();
}),
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ const ListEntryChildren = ({ url, urlPrefix, setUpdateNodeChildren }) => {

useEffect(() => {
if (incomingData) {
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
setUpdateNodeChildren(incomingData.map((el) => el?.[0]));
const arrayData: Relations[] = [];
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
incomingData.map((el) =>
arrayData.push({ index: Math.random().toString(), child: el?.[0] })
);
Expand Down Expand Up @@ -161,7 +163,8 @@ const ListEntryChildren = ({ url, urlPrefix, setUpdateNodeChildren }) => {
<DialogTitle>Add a child</DialogTitle>
<DialogContent>
<DialogContentText>
Enter the name of the child in the format "LC:child_tag_id"
Enter the name of the child in the format
&quot;LC:child_tag_id&quot;
</DialogContentText>
<DialogContentText>Example - en:yogurts</DialogContentText>
<Stack sx={{ mt: 2 }} direction="row" alignItems="center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const ListTranslations = ({
useEffect(() => {
// get shown languages from local storage if it exists else use main language
try {
let rawLocalStorageShownLanguages =
const rawLocalStorageShownLanguages =
localStorage.getItem(SHOWN_LANGUAGES_KEY);
let localStorageShownLanguages: string[] | null =
rawLocalStorageShownLanguages
Expand Down
2 changes: 1 addition & 1 deletion taxonomy-editor-frontend/src/pages/editentry/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const EditEntry = ({
<Box>
<Stack direction="row" alignItems="center">
<Typography sx={{ mb: 2, mt: 2, ml: 2 }} variant="h4">
You are now editing "{id}"
You are now editing &quot;{id}&quot;
</Typography>
<IconButton
sx={{ ml: 1, color: greyHexCode }}
Expand Down
6 changes: 4 additions & 2 deletions taxonomy-editor-frontend/src/pages/errors/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import { useState, useEffect } from "react";

const Errors = ({ addNavLinks }) => {
const { taxonomyName, branchName } = useParams();
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
const baseUrl = createBaseURL(taxonomyName, branchName);
const [errors, setErrors] = useState([]);
const {
Expand All @@ -29,7 +30,8 @@ const Errors = ({ addNavLinks }) => {

useEffect(() => {
if (!errorData) return;
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
const newErrors = errorData.errors.map((error, index) => ({
id: index + 1,
error: error,
Expand Down
6 changes: 4 additions & 2 deletions taxonomy-editor-frontend/src/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import Stack from "@mui/material/Stack";
import Container from "@mui/material/Container";
import logoUrl from "../../assets/logo.png";
import classificationImgUrl from "../../assets/classification.png";

type Props = {
clearNavBarLinks: () => void;
Expand Down Expand Up @@ -34,15 +36,15 @@ const Home = ({ clearNavBarLinks }: Props) => {
component="img"
height={140}
width={700}
src={require("../../assets/logo.png")}
src={logoUrl}
alt="Open Food Facts Logo"
/>
<Box sx={{ mt: 1 }} />
<Box
component="img"
width={128}
height={128}
src={require("../../assets/classification.png")}
src={classificationImgUrl}
alt="Classification Logo"
/>
<Typography sx={{ mt: 4, mb: 6 }} variant="h2">
Expand Down
3 changes: 2 additions & 1 deletion taxonomy-editor-frontend/src/pages/search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import SearchResults from "./SearchResults";
import { ENTER_KEYCODE } from "../../constants";
import WarningParsingErrors from "../../components/WarningParsingErrors";
import { createBaseURL } from "../../utils";
import classificationImgUrl from "../../assets/classification.png";

type SearchNodeProps = {
addNavLinks: ({
Expand Down Expand Up @@ -62,7 +63,7 @@ const SearchNode = ({
component="img"
width={100}
height={100}
src={require("../../assets/classification.png")}
src={classificationImgUrl}
alt="Classification Logo"
/>
<form
Expand Down

0 comments on commit 7d8945e

Please sign in to comment.