Our coding standards

MEDomicsLab coding standards

Table of contents

Project Repository Structure

FolderDescription

/app

Electron files

/baseFiles

Empty base files

/build

Contains distribution relative files

/go_server

Contains Go code acting as a server

/main

Electron related contents

/node_modules

Contains saved libraries (created from npm install)

/pythonCode

Python code

/pythonEnv

Python virtual environment utils

/renderer

NextJs related content

/resources

NextJs ressources (icons, etc.)

/utilScripts

NextJs ressources (icons, etc.)

Style

import  'bootstrap/dist/css/bootstrap.min.css';
import <all  other  global  css  libraries>

Naming Conventions

Javascript/react

  • Component : PascalCase

  • Component file name : camelCase

  • Each file name should be the same as the component defined inside

  • Component creation : prioritize function implementation over class

export  default  const  myComponent = (someProps) =Β­> {
return (<></>)
}
  • Function creation: prioritize arrow implementation

const  myFct = (someParams) =Β­> {}

See react naming convention

Components Structure

Directory tree of the application components
components
β”œβ”€β”€β”€dataTypeVisualisation
β”‚       dataTablePopoverBPClass.jsx
β”‚       dataTableWrapper.jsx
β”‚       dataTableWrapperBPClass.tsx
β”‚
β”œβ”€β”€β”€evaluation
β”‚       dashboard.jsx
β”‚       evaluationPageContent.jsx
β”‚       pageConfig.jsx
β”‚       pageEval.jsx
β”‚       predictPanel.jsx
β”‚
β”œβ”€β”€β”€extractionImage
β”‚   β”‚   extractionJPG.jsx
β”‚   β”‚
β”‚   └───extractionTypes
β”‚           extractionDenseNet.jsx
β”‚
β”œβ”€β”€β”€extractionMEDimage
β”‚   β”‚   docLink.jsx
β”‚   β”‚   flowCanvas.jsx
β”‚   β”‚
β”‚   β”œβ”€β”€β”€buttonsTypes
β”‚   β”‚       resultsButton.jsx
β”‚   β”‚       viewButton.jsx
β”‚   β”‚
β”‚   └───nodesTypes
β”‚       β”‚   extractionNode.jsx
β”‚       β”‚   featuresNode.jsx
β”‚       β”‚   filterNode.jsx
β”‚       β”‚   segmentationNode.jsx
β”‚       β”‚   standardNode.jsx
β”‚       β”‚
β”‚       β”œβ”€β”€β”€filterTypes
β”‚       β”‚       gaborFilter.jsx
β”‚       β”‚       lawsFilter.jsx
β”‚       β”‚       logFilter.jsx
β”‚       β”‚       meanFilter.jsx
β”‚       β”‚       waveletFilter.jsx
β”‚       β”‚
β”‚       └───standardNodeForms
β”‚               discretizationForm.jsx
β”‚               inputForm.jsx
β”‚               interpolationForm.jsx
β”‚               reSegmentationForm.jsx
β”‚
β”œβ”€β”€β”€extractionTabular
β”‚   β”‚   extractionTabularData.jsx
β”‚   β”‚
β”‚   └───extractionTypes
β”‚           extractionBioBERT.jsx
β”‚           extractionTSfresh.jsx
β”‚
β”œβ”€β”€β”€flow
β”‚   β”‚   btnDiv.jsx
β”‚   β”‚   codeEditor.jsx
β”‚   β”‚   errorRequestDialog.jsx
β”‚   β”‚   flowPageBase.jsx
β”‚   β”‚   groupNode.jsx
β”‚   β”‚   handlers.jsx
β”‚   β”‚   node.jsx
β”‚   β”‚   nodeWrapperResults.jsx
β”‚   β”‚   sidebarAvailableNodes.jsx
β”‚   β”‚   workflowBase.jsx
β”‚   β”‚
β”‚   β”œβ”€β”€β”€context
β”‚   β”‚       flowFunctionsContext.jsx
β”‚   β”‚       flowInfosContext.jsx
β”‚   β”‚       flowResultsContext.jsx
β”‚   β”‚
β”‚   └───results
β”‚           pipelinesResults.jsx
β”‚           resultsPane.jsx
β”‚
β”œβ”€β”€β”€generalPurpose
β”‚       errorRequestContext.jsx
β”‚       loaderContext.jsx
β”‚       progressBarRequests.jsx
β”‚
β”œβ”€β”€β”€input
β”‚       groupingTool.jsx
β”‚       holdOutSetCreationTool.jsx
β”‚       mergeTool.jsx
β”‚       simpleCleaningTool.jsx
β”‚       subsetCreationTool.jsx
β”‚
β”œβ”€β”€β”€layout
β”‚   β”‚   actionContext.jsx
β”‚   β”‚   iconSidebar.jsx
β”‚   β”‚   layoutContext.jsx
β”‚   β”‚   layoutManager.jsx
β”‚   β”‚
β”‚   β”œβ”€β”€β”€flexlayout
β”‚   β”‚       mainContainerClass.tsx
β”‚   β”‚       popout.html
β”‚   β”‚       popupMenu.tsx
β”‚   β”‚       simple.layout
β”‚   β”‚       tabStorage.tsx
β”‚   β”‚       utils.tsx
β”‚   β”‚       zoomPanPinchComponent.jsx
β”‚   β”‚
β”‚   └───sidebarTools
β”‚       β”‚   components.jsx
β”‚       β”‚   fileCreationBtn.jsx
β”‚       β”‚   recursiveChildrenTest.js
β”‚       β”‚
β”‚       β”œβ”€β”€β”€directoryTree
β”‚       β”‚       renderItem.js
β”‚       β”‚       sidebarDirectoryTreeControlled.jsx
β”‚       β”‚       workspaceDirectoryTree.jsx
β”‚       β”‚
β”‚       └───pageSidebar
β”‚               evaluationSidebar.jsx
β”‚               explorerSidebar.jsx
β”‚               extractionSidebar.jsx
β”‚               flowSceneSidebar.jsx
β”‚               homeSidebar.jsx
β”‚               inputSidebar.jsx
β”‚               layoutTestSidebar.jsx
β”‚               searchSidebar.jsx
β”‚
β”œβ”€β”€β”€learning
β”‚   β”‚   checkOption.jsx
β”‚   β”‚   input.jsx
β”‚   β”‚   modalSettingsChooser.jsx
β”‚   β”‚   workflow.jsx
β”‚   β”‚
β”‚   β”œβ”€β”€β”€nodesTypes
β”‚   β”‚       datasetNode.jsx
β”‚   β”‚       loadModelNode.jsx
β”‚   β”‚       optimizeIO.jsx
β”‚   β”‚       selectionNode.jsx
β”‚   β”‚       standardNode.jsx
β”‚   β”‚
β”‚   └───results
β”‚       β”œβ”€β”€β”€node
β”‚       β”‚       analyseResults.jsx
β”‚       β”‚       dataParamResults.jsx
β”‚       β”‚       modelsResults.jsx
β”‚       β”‚       saveModelResults.jsx
β”‚       β”‚
β”‚       └───utilities
β”‚               dataTablePath.jsx
β”‚               parameters.jsx
β”‚
β”œβ”€β”€β”€mainPages
β”‚   β”‚   application.jsx
β”‚   β”‚   evaluation.jsx
β”‚   β”‚   exploratory.jsx
β”‚   β”‚   extractionImage.jsx
β”‚   β”‚   extractionMEDimage.jsx
β”‚   β”‚   extractionText.jsx
β”‚   β”‚   extractionTS.jsx
β”‚   β”‚   home.jsx
β”‚   β”‚   htmlViewer.jsx
β”‚   β”‚   input.jsx
β”‚   β”‚   learning.jsx
β”‚   β”‚   modelViewer.jsx
β”‚   β”‚   output.jsx
β”‚   β”‚   results.jsx
β”‚   β”‚   terminal.jsx
β”‚   β”‚   test.jsx
β”‚   β”‚
β”‚   β”œβ”€β”€β”€dataComponents
β”‚   β”‚       datasetSelector.jsx
β”‚   β”‚       dataTableFromContext.jsx
β”‚   β”‚       dataTableFromContextBP.jsx
β”‚   β”‚       dropzoneComponent.jsx
β”‚   β”‚       dropzoneComponent2.jsx
β”‚   β”‚       listBoxSelector.jsx
β”‚   β”‚       wsSelect.jsx
β”‚   β”‚
β”‚   └───moduleBasics
β”‚           modulePage.jsx
β”‚           pageInfosContext.jsx
β”‚
└───workspace
        dataContext.jsx
        medDataObject.js
        workspaceContext.jsx

To generate this : tree .\renderer\components\ /f

Setup of eslint and prettier

Syntax

(ES6 for JS as mentioned by Electron, for Python Electron follows Chromium's Coding Style)

Installation

  • Install prettier and plugin (should be included in package.json so a npm install should do it) npm install prettier eslint-plugin-prettier eslint-config-prettier

  • Install eslint and prettier extensions

  • Open workspace settings

    • Can be accessed directly from this path: .vscode/settings.json

    • Or press CTRL+SHIFT+P and type Preferences: Open Workspace Settings (JSON)

  • Add these lines

{
  "eslint.options": {
    "overrideConfigFile": ".eslintrc.js"
  },
  "editor.formatOnSave": true,
  "eslint.validate": ["javascript"],
  "editor.defaultFormatter": "esbenp.prettier-vscode"
}

Usage

There are 2 config files:

  • eslint -Β­> .eslintrc.js

  • prettier -> .prettierrc.js

A higher priority is placed on Prettier wich handles basic formatting

see config file for more information on what it rules

then, all standards rules are placed in eslint config file. So if you need to add specific rules, it should be in .eslintrc.js file

Use CTRL+S to save and format files. Eslint may triggered error displayed as a red underline so you can hover these conventions error, then click on 'quick fix' and click on 'fix all/the problem(s)'

Documentation

Docstring

/**
* @param  {type}  someParams description
* @return  {type} description
* @description
* functionnal description of the function/React object
*/
const  myfct = (someParams) =Β­> {}

Comments

  • Do not over detailed the code for readability

  • Comments are meant to help understand important or critical actions in code

Documentation generation

Not tested : https://www.npmjs.com/package/react-doc-generator

(Comments, docstrings, documentation generator...)

Python Coding Standard

(see MEDomicsTools for Python)

Last updated