Skip to content

Commit

Permalink
Require JSDOC for .tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
laemtl committed Dec 14, 2022
1 parent b8b50dd commit c736924
Show file tree
Hide file tree
Showing 34 changed files with 533 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ htdocs/js/FileSaver.min.js
htdocs/vendor/
htdocs/fontawesome/
htdocs/bootstrap/

# ignore until eslint errors are fixed
modules/electrophysiology_browser/jsx/react-series-data-viewer/src/series/components/**
12 changes: 12 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@
"plugin:@typescript-eslint/recommended"
],
"rules": {
"jsdoc/require-jsdoc": [
"error",
{"require": {
"ArrowFunctionExpression": true,
"FunctionExpression": true,
"ClassDeclaration": true,
"MethodDefinition": true
}}
],
"jsdoc/require-param-description": "error",
"jsdoc/require-returns": "error",
"jsdoc/require-returns-description": "error",
"no-undef": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-explicit-any": "off"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* fetchBlob
*
* @param {string} url - The url to fetch
* @param {object} params - The request params
* @returns {Promise} - The blob data
*/
export const fetchBlob = (url: string, params?: RequestInit) : Promise<Blob> =>
fetch(url, params).then((response) => {
if (!response.ok) {
Expand All @@ -6,6 +13,13 @@ export const fetchBlob = (url: string, params?: RequestInit) : Promise<Blob> =>
return response.blob().then((data) => data);
});

/**
* fetchJSON
*
* @param {string} url - The url to fetch
* @param {object} params - The request params
* @returns {Promise} - The json data
*/
export const fetchJSON = (url: string, params?: RequestInit) =>
fetch(url, params).then((response) => {
if (!response.ok) {
Expand All @@ -14,6 +28,13 @@ export const fetchJSON = (url: string, params?: RequestInit) =>
return response.json().then((data) => data);
});

/**
* fetchText
*
* @param {string} url - The url to fetch
* @param {object} params - The request params
* @returns {Promise} - The text data
*/
export const fetchText = (url: string, params?: RequestInit) =>
fetch(url, params).then((response) => {
if (!response.ok) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
import {FloatChunk} from '../protocol-buffers/chunk_pb';
import {fetchBlob} from '../ajax';

/**
* fetchChunk
*
* @param {string} url - The url to fetch
* @returns {Promise} - The chunk data
*/
export const fetchChunk = (url: string): Promise<typeof FloatChunk> => {
return fetchBlob(url).then((blob) => {
const reader = new FileReader();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ import {scaleOrdinal} from 'd3-scale';

export const colorOrder = scaleOrdinal();

/**
* hex2rgba
*
* @param {object} root - An object
* @param {string} root.color - An hexadecimal color
* @param {number} root.alpha - Opacity
* @returns {string} - An rgba expression
*/
export const hex2rgba = ({color = '#000000', alpha = 1} : {
color: string,
alpha: number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ class EEGLabSeriesProvider extends Component<CProps> {

this.store.dispatch(setPhysioFileID(physioFileID));

/**
*
* @param {Function} fetcher The fn to collect the type of data
* @param {string} url - The url
* @param {string} route - The route
* @returns {Promise} - The data
*/
const racers = (fetcher, url, route = '') => {
if (url) {
return [fetcher(`${url}${route}`)
Expand Down Expand Up @@ -196,7 +203,7 @@ class EEGLabSeriesProvider extends Component<CProps> {
/**
* Renders the React component.
*
* @return {JSX} - React markup for the component
* @returns {JSX} - React markup for the component
*/
render() {
const [signalViewer, ...rest] = React.Children.toArray(this.props.children);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ type CProps = {
interval: [number, number],
};

/**
*
* @param root0
* @param root0.timeSelection
* @param root0.epochs
* @param root0.setTimeSelection
* @param root0.setRightPanel
* @param root0.setEpochs
* @param root0.currentAnnotation
* @param root0.setCurrentAnnotation
* @param root0.physioFileID
* @param root0.annotationMetadata
* @param root0.interval
*/
const AnnotationForm = ({
timeSelection,
epochs,
Expand Down Expand Up @@ -65,6 +79,10 @@ const AnnotationForm = ({
setEvent([startEvent, endEvent]);
}, [timeSelection]);

/**
*
* @param event
*/
const validate = (event) => (
(event[0] || event[0] === 0)
&& (event[1] || event[1] === 0)
Expand All @@ -73,6 +91,11 @@ const AnnotationForm = ({
&& event[1] >= interval[0] && event[1] <= interval[1]
);

/**
*
* @param id
* @param val
*/
const handleStartTimeChange = (id, val) => {
const value = parseInt(val);
setEvent([value, event[1]]);
Expand All @@ -91,6 +114,11 @@ const AnnotationForm = ({
}
};

/**
*
* @param name
* @param val
*/
const handleEndTimeChange = (name, val) => {
const value = parseInt(val);
setEvent([event[0], value]);
Expand All @@ -109,16 +137,32 @@ const AnnotationForm = ({
}
};

/**
*
* @param name
* @param value
*/
const handleLabelChange = (name, value) => {
setLabel(value);
};
/**
*
* @param name
* @param value
*/
const handleCommentChange = (name, value) => {
setComment(value);
};
/**
*
*/
const handleSubmit = () => {
setIsSubmitted(true);
};

/**
*
*/
const handleReset = () => {
// Clear all fields
setEvent(['', '']);
Expand All @@ -127,6 +171,9 @@ const AnnotationForm = ({
setComment('');
};

/**
*
*/
const handleDelete = () => {
setIsDeleted(true);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ type CProps = {
hideLine: boolean,
};

/**
*
* @param root0
* @param root0.orientation
* @param root0.domain
* @param root0.range
* @param root0.ticks
* @param root0.padding
* @param root0.format
* @param root0.hideLine
*/
const Axis = ({
orientation,
domain,
Expand Down Expand Up @@ -45,6 +56,10 @@ Axis.defaultProps = {
ticks: 10,
padding: 0,
hideLine: false,
/**
*
* @param tick
*/
format: (tick) => `${tick}`,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ type CProps = {
physioFileID: number,
};

/**
*
* @param root0
* @param root0.electrodes
* @param root0.physioFileID
*/
const EEGMontage = (
{
electrodes,
Expand Down Expand Up @@ -49,12 +55,20 @@ const EEGMontage = (
.rotateZ( startAngle)
.rotateX(-startAngle);

/**
*
* @param v
*/
const dragStart = (v: any) => {
setDrag(true);
setMx(v[0]);
setMy(v[1]);
};

/**
*
* @param v
*/
const dragged = (v: any) => {
if (!drag) return;
const beta = (v[0] - mx + mouseX) * -2 * Math.PI;
Expand All @@ -67,6 +81,10 @@ const EEGMontage = (
setAngleZ(angleZ);
};

/**
*
* @param v
*/
const dragEnd = (v: any) => {
setDrag(false);
setMouseX(v[0] - mx + mouseX);
Expand Down Expand Up @@ -185,6 +203,9 @@ const EEGMontage = (
scatter2D.push({x: x * scale2D, y: y * scale2D});
});

/**
*
*/
const Montage3D = () => (
<Group>
{point3D.rotateZ(angleZ).rotateX(angleX)(scatter3D).map((point, i) => {
Expand All @@ -205,6 +226,9 @@ const EEGMontage = (
</Group>
);

/**
*
*/
const Montage2D = () => (
<Group>
<line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ type CProps = {
opacity: number,
};

/**
*
* @param root0
* @param root0.parentHeight
* @param root0.onset
* @param root0.duration
* @param root0.scales
* @param root0.color
* @param root0.opacity
*/
const Epoch = (
{
parentHeight,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ type CProps = {
interval: [number, number],
};

/**
*
* @param root0
* @param root0.epochs
* @param root0.filteredEpochs
* @param root0.rightPanel
* @param root0.setCurrentAnnotation
* @param root0.setTimeSelection
* @param root0.setRightPanel
* @param root0.toggleEpoch
* @param root0.updateActiveEpoch
* @param root0.interval
*/
const EventManager = ({
epochs,
filteredEpochs,
Expand Down Expand Up @@ -140,6 +153,9 @@ const EventManager = ({
const epoch = epochs[index];
const visible = filteredEpochs.includes(index);

/**
*
*/
const handleCommentVisibilityChange = () => {
if (!visibleComments.includes(index)) {
setVisibleComments([
Expand All @@ -153,6 +169,9 @@ const EventManager = ({
}
};

/**
*
*/
const handleEditClick = () => {
setCurrentAnnotation(epoch);
setRightPanel('annotationForm');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ type CProps = {
updateFilteredEpochs: (_: void) => void,
};

/**
*
* @param root0
* @param root0.viewerHeight
* @param root0.domain
* @param root0.interval
* @param root0.setInterval
* @param root0.dragStart
* @param root0.dragContinue
* @param root0.dragEnd
* @param root0.updateFilteredEpochs
*/
const IntervalSelect: FunctionComponent<CProps> = ({
viewerHeight,
domain,
Expand Down
Loading

0 comments on commit c736924

Please sign in to comment.