Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jsdoc update #8266

Merged
merged 2 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/**
50 changes: 44 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,25 @@
"parser": "@babel/eslint-parser",
"plugins": [
"react",
"no-jquery"
"no-jquery",
"jsdoc"
Copy link
Member

@maltheism maltheism Dec 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@driusan jsdoc has been added to the plugins. When "valid-jsdoc": "off" is set to "error" then we will get errors when running npm run compile such as if comments are missing @return or correct @param value. Also the comments now have a standardized structure requirement similar to php. I believe @laemtl has the rule currently set to off because she's cleaning up the comments in parts by separate PRs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oups I forgot to add a description. Thanks @maltheism for the clarifications!


],
"settings": {
"react": {
"version": "detect"
},
"jsdoc": {
"tagNamePreference": {
"return": "return",
"tag constructor": "constructor"
},
"preferredTypes": {
"Function": "function",
"function": "Function",
"Array": "array",
"array": "Array"
}
}
},
"env": {
Expand All @@ -22,7 +36,12 @@
"globalReturn": false
}
},
"extends": ["eslint:recommended", "plugin:react/recommended", "google"],
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:jsdoc/recommended",
"google"
],
"rules": {
"max-len": ["error", {
"code": 80,
Expand Down Expand Up @@ -53,7 +72,8 @@
"react/jsx-uses-vars": "error",
"prefer-rest-params": "error",
"array-callback-return": "off",
"require-jsdoc": "error",
"require-jsdoc": "off",
"valid-jsdoc": "off",
"no-implicit-globals": "off",
"no-invalid-this": "off",
"no-alert": "off",
Expand All @@ -62,14 +82,31 @@
}],
"no-console": ["warn", {
"allow": ["info", "warn", "error"]
}]
}],
"jsdoc/require-param-description": "off",
"jsdoc/require-returns": "off",
"jsdoc/require-returns-description": "off"
},
"overrides": [
{
"files": "**/*.+(ts|tsx)",
"plugins": ["@typescript-eslint"],
"extends": ["plugin:@typescript-eslint/recommended", "eslint:recommended", "plugin:react/recommended", "google"],
"extends": [
"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 Expand Up @@ -246,6 +283,7 @@
"loris": true,
"QueryString": true,
"swal": true,
"schema_urls": true
"schema_urls": true,
"JSX": true
}
}
2 changes: 1 addition & 1 deletion htdocs/js/advancedMenu.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Is element set
*
* @return {int} - returns 0|1
* @return {number} - returns 0|1
*/
function isElementSet() {
'use strict';
Expand Down
4 changes: 2 additions & 2 deletions htdocs/js/instrument_form_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ function notAnswered() {
* Appends a hidden empty value, if a multiselect dropdown has nothing selected
* Required to trigger validation on the backend
*
* @param {JQuery} form <form> element
* @param {JQuery} element <select> element
* @param {HTMLElement} form <form> element
* @param {HTMLElement} element <select> element
*/
function addEmptyOption(form, element) {
let selectedOptions = element.find(':selected');
Expand Down
6 changes: 3 additions & 3 deletions htdocs/js/passwordVisibility.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* exported passwordVisibility */

/**
* @author Laetitia Fesselier
* @version 1.0.0
*
* Display a password input
* with a toggle option to display it in plain text
*
* For React integration, see React version (jsx/Password.js)
*
* @author Laetitia Fesselier
* @version 1.0.0
*/

/**
Expand Down
6 changes: 3 additions & 3 deletions htdocs/js/util/queryString.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
*
* @author Alex Ilea
* @version 0.0.2
* @since 2016-11-22
*
*/

/**
* @constructor
* @return {{}} - QueryString helper object
*
*/
let QueryString = {
/**
Expand Down
3 changes: 1 addition & 2 deletions jslib/fetchDataStream.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* Process as many rows as possible from a data stream.
*
* @param {binary} data - a chunk of data read from the data stream
* @param {array} data - a chunk of data read from the data stream
* @param {function} rowcb - The row callback function
* @param {function} endstreamcb - The stream termination callback
* function
*
* @return {object} An object containing keys "remainder" which is
* a slice of any unprocessed data, and a key "eos" which is a boolean
* indicating whether the end of the stream has been reached.
Expand Down
1 change: 0 additions & 1 deletion jsx/Breadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* @author Alex Ilea
* @author Jake Penny
* @version 2.0.0
*
*/

import React, {Component} from 'react';
Expand Down
1 change: 0 additions & 1 deletion jsx/CSSGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import React, {useState, useEffect, useRef} from 'react';
* may also be optionally specified for each card.
*
* @param {array} props - Cards to add to the grid.
*
* @return {object} - A React component for a CSS grid of cards
*/
function CSSGrid(props) {
Expand Down
1 change: 0 additions & 1 deletion jsx/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*
* @author Zaliqa Rosli
* @version 1.0.0
*
*/
import React, {Component} from 'react';
import PropTypes from 'prop-types';
Expand Down
18 changes: 8 additions & 10 deletions jsx/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class DataTable extends Component {
* Set the component page variable
* to a new value
*
* @param {int} i - Page index
* @param {number} i - Page index
*/
changePage(i) {
const page = this.state.page;
Expand All @@ -55,7 +55,7 @@ class DataTable extends Component {
* If component sort.column is already set to column
* Toggle sort.ascending
*
* @param {int} column - The column index
* @param {number} column - The column index
*/
setSortColumn(column) {
if (this.state.sort.column === column) {
Expand All @@ -68,7 +68,7 @@ class DataTable extends Component {
/**
* Update the sort column
*
* @param {int} column - The column index
* @param {number} column - The column index
*/
updateSortColumn(column) {
const sort = this.state.sort;
Expand All @@ -88,7 +88,7 @@ class DataTable extends Component {
/**
* Updates page state
*
* @param {int} number - Number of page
* @param {number} number - Number of page
*/
updatePageNumber(number) {
const page = this.state.page;
Expand All @@ -111,7 +111,7 @@ class DataTable extends Component {
/**
* Export the filtered rows and columns into a csv
*
* @param {int[]} filteredRowIndexes - The filtered Row Indexes
* @param {number[]} filteredRowIndexes - The filtered Row Indexes
*/
downloadCSV(filteredRowIndexes) {
let csvData = filteredRowIndexes.map((id) => this.props.data[id]);
Expand Down Expand Up @@ -152,8 +152,6 @@ class DataTable extends Component {

/**
* Get the Filtered Row Indexes
*
* @return {int[]}
*/
getFilteredRowIndexes() {
let useKeyword = false;
Expand Down Expand Up @@ -208,8 +206,8 @@ class DataTable extends Component {
/**
* Sort the given rows according to the sort configuration
*
* @param {int[]} rowIndexes - The row indexes
* @return {Object[]}
* @param {number[]} rowIndexes - The row indexes
* @return {object[]}
*/
sortRows(rowIndexes) {
const index = [];
Expand Down Expand Up @@ -391,7 +389,7 @@ class DataTable extends Component {
/**
* Renders the Actions buttons.
*
* @return {string[]} - Array of React Elements
* @return {string[]|void} - Array of React Elements
*/
renderActions() {
if (this.props.actions) {
Expand Down
2 changes: 1 addition & 1 deletion jsx/DynamicDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class DynamicDataTable extends Component {
/**
* Ajax failure callback
*
* @param {jqXHR} data
* @param {object} data
* @param {string} errorCode
* @param {string} errorMsg
*/
Expand Down
3 changes: 1 addition & 2 deletions jsx/Filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import PropTypes from 'prop-types';
* Alters the filter object and sends it to parent on every update.
*
* @param {props} props
* @return {jsx}
*
* @return {JSX}
*/
function Filter(props) {
/**
Expand Down
2 changes: 0 additions & 2 deletions jsx/FilterForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*
* @author Loris Team
* @version 1.1.0
*
*/
import React, {Component} from 'react';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -126,7 +125,6 @@ class FilterForm extends Component {
* @param {string} type - form element type (i.e component name)
* @param {string} key - the name of the form element
* @param {string} value - the value of the form element
*
* @return {{}} filter - filterData
*/
setFilter(type, key, value) {
Expand Down
2 changes: 1 addition & 1 deletion jsx/FilterableDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class FilterableDataTable extends Component {
*
* @param {string} name
* @param {*} value
* @param {bool} exactMatch
* @param {boolean} exactMatch
*/
addFilter(name, value, exactMatch) {
const filters = this.state.filters;
Expand Down
13 changes: 7 additions & 6 deletions jsx/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ CheckboxElement, ButtonElement, LorisElement
*
* @author Loris Team
* @version 1.0.0
*
*/

import React, {Component} from 'react';
Expand Down Expand Up @@ -38,6 +37,7 @@ class FormElement extends Component {

/**
* Get form elements
*
* @return {JSX[]} - An array of element React markup
*/
getFormElements() {
Expand Down Expand Up @@ -184,6 +184,7 @@ class FieldsetElement extends Component {

/**
* Get form elements
*
* @return {JSX[]} - An array of element React markup
*/
getFormElements() {
Expand Down Expand Up @@ -2224,7 +2225,6 @@ LinkElement.defaultProps = {
class CheckboxElement extends React.Component {
/**
* @constructor
* @param {object} props - React Component properties
*/
constructor() {
super();
Expand Down Expand Up @@ -2334,6 +2334,7 @@ class ButtonElement extends Component {

/**
* Handle click
*
* @param {object} e - Event
*/
handleClick(e) {
Expand Down Expand Up @@ -2388,10 +2389,10 @@ ButtonElement.defaultProps = {
};

/**
* Call To Action (CTA) component
* React wrapper for <button> element that is used for Call to Actions, usually
* outside the context of forms.
*/
* Call To Action (CTA) component
* React wrapper for <button> element that is used for Call to Actions, usually
* outside the context of forms.
*/
class CTA extends Component {
/**
* Renders the React component.
Expand Down
1 change: 0 additions & 1 deletion jsx/InfoPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Display a message in an information panel.
*
* @param {object} props - React props
*
* @return {JSX}
*/
function InfoPanel(props) {
Expand Down
4 changes: 1 addition & 3 deletions jsx/Loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*
* @author Henri Rabalais
* @version 1.0.0
*
*/
import PropTypes from 'prop-types';

Expand All @@ -12,8 +11,7 @@ import PropTypes from 'prop-types';
* something is loading.
*
* @param {array} props - The React props
*
* @return {DOMObject} - Loader React component
* @return {HTMLElement} - Loader React component
*/
function Loader(props) {
return (
Expand Down
1 change: 0 additions & 1 deletion jsx/Markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const ReactMarkdown = require('react-markdown');
*
* @author Dave MacFarlane
* @version 0.0.1
*
*/
class Markdown extends Component {
/**
Expand Down
Loading