From 1e9e4ac86da5c373e2962faee254371d8b6a93e9 Mon Sep 17 00:00:00 2001
From: Valentin Perrelle <valentin.perrelle@cea.fr>
Date: Thu, 3 Feb 2022 18:49:16 +0100
Subject: [PATCH] [ivette] lint: conform to react/display-name rule

---
 ivette/src/dome/renderer/controls/labels.tsx  |  47 +++----
 ivette/src/dome/renderer/table/views.tsx      |   4 +-
 ivette/src/frama-c/kernel/Globals.tsx         |   4 +-
 .../src/frama-c/plugins/eva/CoverageMeter.tsx |   2 +-
 ivette/src/renderer/Application.tsx           |   4 +-
 ivette/src/renderer/Laboratory.tsx            | 130 +++++++++---------
 ivette/src/renderer/Preferences.tsx           |  48 +++----
 7 files changed, 124 insertions(+), 115 deletions(-)

diff --git a/ivette/src/dome/renderer/controls/labels.tsx b/ivette/src/dome/renderer/controls/labels.tsx
index 57b820409dc..630d9bfd0a0 100644
--- a/ivette/src/dome/renderer/controls/labels.tsx
+++ b/ivette/src/dome/renderer/controls/labels.tsx
@@ -62,29 +62,30 @@ export interface LabelProps {
   onContextMenu?: (evt: React.MouseEvent) => void;
 }
 
-const makeLabel = (className: string) => (props: LabelProps, ref: any) => {
-  const { display = true } = props;
-  const allClasses = classes(
-    className,
-    !display && 'dome-control-erased',
-    props.className,
-  );
-  return (
-    <label
-      ref={ref}
-      className={allClasses}
-      title={props.title}
-      style={props.style}
-      onClick={props.onClick}
-      onDoubleClick={props.onDoubleClick}
-      onContextMenu={props.onContextMenu}
-    >
-      {props.icon && <Icon title={props.title} id={props.icon} />}
-      {props.label}
-      {props.children}
-    </label>
-  );
-};
+const makeLabel = (className: string) =>
+  function Label(props: LabelProps, ref: any) {
+    const { display = true } = props;
+    const allClasses = classes(
+      className,
+      !display && 'dome-control-erased',
+      props.className,
+    );
+    return (
+      <label
+        ref={ref}
+        className={allClasses}
+        title={props.title}
+        style={props.style}
+        onClick={props.onClick}
+        onDoubleClick={props.onDoubleClick}
+        onContextMenu={props.onContextMenu}
+      >
+        {props.icon && <Icon title={props.title} id={props.icon} />}
+        {props.label}
+        {props.children}
+      </label>
+    );
+  };
 
 // --------------------------------------------------------------------------
 // --- CSS Classes
diff --git a/ivette/src/dome/renderer/table/views.tsx b/ivette/src/dome/renderer/table/views.tsx
index ca3e2111296..54cae79cb42 100644
--- a/ivette/src/dome/renderer/table/views.tsx
+++ b/ivette/src/dome/renderer/table/views.tsx
@@ -262,7 +262,7 @@ function makeDataRenderer(
   render: ((data: any) => ReactNode) = defaultRenderer,
   onContextMenu?: (row: any, index: number, dataKey: string) => void,
 ): TableCellRenderer {
-  return ((props : TableCellProps) => {
+  return function TableCell(props: TableCellProps) {
     const { cellData } = props;
     try {
       const contents = cellData ? render(cellData) : null;
@@ -283,7 +283,7 @@ function makeDataRenderer(
       );
       return null;
     }
-  });
+  };
 }
 
 // --------------------------------------------------------------------------
diff --git a/ivette/src/frama-c/kernel/Globals.tsx b/ivette/src/frama-c/kernel/Globals.tsx
index 49799d3ef0f..6c9714d287b 100644
--- a/ivette/src/frama-c/kernel/Globals.tsx
+++ b/ivette/src/frama-c/kernel/Globals.tsx
@@ -95,7 +95,7 @@ function FctItem(props: FctItemProps) {
 // --- Globals Section(s)
 // --------------------------------------------------------------------------
 
-export default () => {
+export default function Globals() {
 
   // Hooks
   const [selection, updateSelection] = States.useSelection();
@@ -198,6 +198,6 @@ export default () => {
     </Section>
   );
 
-};
+}
 
 // --------------------------------------------------------------------------
diff --git a/ivette/src/frama-c/plugins/eva/CoverageMeter.tsx b/ivette/src/frama-c/plugins/eva/CoverageMeter.tsx
index fe709dea8cd..7248e4c0ea0 100644
--- a/ivette/src/frama-c/plugins/eva/CoverageMeter.tsx
+++ b/ivette/src/frama-c/plugins/eva/CoverageMeter.tsx
@@ -33,7 +33,7 @@ export function percent(coverage: CoverageProps): string {
   return `${(q * 100).toFixed(1)}%`;
 }
 
-export default function(props: { coverage: CoverageProps }) {
+export default function CoverageMeter(props: { coverage: CoverageProps }) {
   const { reachable, dead } = props.coverage;
   const total = reachable + dead;
 
diff --git a/ivette/src/renderer/Application.tsx b/ivette/src/renderer/Application.tsx
index e3ba66cbb85..ec11b9c6bda 100644
--- a/ivette/src/renderer/Application.tsx
+++ b/ivette/src/renderer/Application.tsx
@@ -41,7 +41,7 @@ import './loader';
 // --- Main View
 // --------------------------------------------------------------------------
 
-export default (() => {
+export default function Application() {
   const [sidebar, flipSidebar] =
     Dome.useFlipSettings('frama-c.sidebar.unfold', true);
   const [viewbar, flipViewbar] =
@@ -95,6 +95,6 @@ export default (() => {
       </Toolbar.ToolBar>
     </Vfill>
   );
-});
+}
 
 // --------------------------------------------------------------------------
diff --git a/ivette/src/renderer/Laboratory.tsx b/ivette/src/renderer/Laboratory.tsx
index cf3ce8cd5ce..edeffafa311 100644
--- a/ivette/src/renderer/Laboratory.tsx
+++ b/ivette/src/renderer/Laboratory.tsx
@@ -141,70 +141,76 @@ const GRIDITEM_PLAIN = { fill: 'both' };
 const GRIDITEM_HPANE = { fill: 'horizontal' };
 const GRIDITEM_VPANE = { fill: 'vertical' };
 
-const makeGridItem = (customize: any, onClose: any) => (comp: any) => {
-  const { id: libId, label, title, layout = 'PLAIN', children } = comp;
-  const id = getItemId('components', libId);
-  let properties: any = { ...GRIDITEM };
-  switch (layout) {
-    case 'PLAIN':
-      properties = { ...properties, ...GRIDITEM_PLAIN };
-      break;
-    case 'HPANE':
-      properties = { ...properties, GRIDITEM_HPANE };
-      break;
-    case 'VPANE':
-      properties = { ...properties, GRIDITEM_VPANE };
-      break;
-    default:
-      console.warn(`[labviews] unexpected layout for ${id} component`, layout);
-      break;
-  }
-  Object.keys(properties).forEach((key) => {
-    const prop = comp[key];
-    if (prop) properties[key] = prop;
-  });
-  let CLOSING;
-  if (customize) {
-    CLOSING = (
-      <IconButton
-        className="labview-close"
-        offset={-1}
-        icon="CROSS"
-        onClick={() => onClose(id)}
-      />
+const makeGridItem = (customize: any, onClose: any) =>
+  function GridItem(comp: any) {
+    const { id: libId, label, title, layout = 'PLAIN', children } = comp;
+    const id = getItemId('components', libId);
+    let properties: any = { ...GRIDITEM };
+    switch (layout) {
+      case 'PLAIN':
+        properties = { ...properties, ...GRIDITEM_PLAIN };
+        break;
+      case 'HPANE':
+        properties = { ...properties, GRIDITEM_HPANE };
+        break;
+      case 'VPANE':
+        properties = { ...properties, GRIDITEM_VPANE };
+        break;
+      default:
+        console.warn(
+          `[labviews] unexpected layout for ${id} component`,
+          layout);
+        break;
+    }
+    Object.keys(properties).forEach((key) => {
+      const prop = comp[key];
+      if (prop) properties[key] = prop;
+    });
+    let CLOSING;
+    if (customize) {
+      CLOSING = (
+        <IconButton
+          className="labview-close"
+          offset={-1}
+          icon="CROSS"
+          onClick={() => onClose(id)}
+        />
+      );
+    }
+    return (
+      <Grids.GridItem
+        id={id}
+        className={properties.className}
+        handle={properties.handle}
+        resize={properties.resize}
+        fill={properties.fill}
+        shrink={properties.shrink}
+        minWidth={properties.minWidth}
+        minHeight={properties.minHeight}
+        width={properties.width}
+        height={properties.height}
+      >
+        <Vfill className="labview-content">
+          <Hbox className="labview-titlebar">
+            <Hfill>
+              <Catch label={id}>
+                <RenderElement id={`labview.title.${id}`}>
+                  <Label
+                    className="labview-handle"
+                    label={label}
+                    title={title} />
+                </RenderElement>
+              </Catch>
+            </Hfill>
+            {CLOSING}
+          </Hbox>
+          <TITLE.Provider value={{ id, label, title }}>
+            <Catch label={id}>{children}</Catch>
+          </TITLE.Provider>
+        </Vfill>
+      </Grids.GridItem>
     );
   }
-  return (
-    <Grids.GridItem
-      id={id}
-      className={properties.className}
-      handle={properties.handle}
-      resize={properties.resize}
-      fill={properties.fill}
-      shrink={properties.shrink}
-      minWidth={properties.minWidth}
-      minHeight={properties.minHeight}
-      width={properties.width}
-      height={properties.height}
-    >
-      <Vfill className="labview-content">
-        <Hbox className="labview-titlebar">
-          <Hfill>
-            <Catch label={id}>
-              <RenderElement id={`labview.title.${id}`}>
-                <Label className="labview-handle" label={label} title={title} />
-              </RenderElement>
-            </Catch>
-          </Hfill>
-          {CLOSING}
-        </Hbox>
-        <TITLE.Provider value={{ id, label, title }}>
-          <Catch label={id}>{children}</Catch>
-        </TITLE.Provider>
-      </Vfill>
-    </Grids.GridItem>
-  );
-};
 
 // --------------------------------------------------------------------------
 // --- Customization Views
diff --git a/ivette/src/renderer/Preferences.tsx b/ivette/src/renderer/Preferences.tsx
index 023d17b672a..654b661afd2 100644
--- a/ivette/src/renderer/Preferences.tsx
+++ b/ivette/src/renderer/Preferences.tsx
@@ -101,28 +101,30 @@ function EditorCommandFields(props: P.EditorCommandProps) {
 // --- Export Components
 // --------------------------------------------------------------------------
 
-export default (() => (
-  <Forms.Page>
-    <Forms.Section label="AST View" unfold>
-      <ThemeFields
-        target="Internal AST"
-        theme={P.AstTheme}
-        fontSize={P.AstFontSize}
-        wrapText={P.AstWrapText}
-      />
-    </Forms.Section>
-    <Forms.Section label="Source View" unfold>
-      <ThemeFields
-        target="Source Code"
-        theme={P.SourceTheme}
-        fontSize={P.SourceFontSize}
-        wrapText={P.SourceWrapText}
-      />
-    </Forms.Section>
-    <Forms.Section label="Editor Command" unfold>
-      <EditorCommandFields command={P.EditorCommand} />
-    </Forms.Section>
-  </Forms.Page>
-));
+export default function Preferences() {
+  return (
+    <Forms.Page>
+      <Forms.Section label="AST View" unfold>
+        <ThemeFields
+          target="Internal AST"
+          theme={P.AstTheme}
+          fontSize={P.AstFontSize}
+          wrapText={P.AstWrapText}
+        />
+      </Forms.Section>
+      <Forms.Section label="Source View" unfold>
+        <ThemeFields
+          target="Source Code"
+          theme={P.SourceTheme}
+          fontSize={P.SourceFontSize}
+          wrapText={P.SourceWrapText}
+        />
+      </Forms.Section>
+      <Forms.Section label="Editor Command" unfold>
+        <EditorCommandFields command={P.EditorCommand} />
+      </Forms.Section>
+    </Forms.Page>
+  )
+}
 
 // --------------------------------------------------------------------------
-- 
GitLab