Skip to content

Commit

Permalink
Added rules for jsdoc plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
LuomaJuha committed Sep 12, 2024
1 parent 95a4077 commit 3ad47f1
Show file tree
Hide file tree
Showing 81 changed files with 2,142 additions and 78 deletions.
56 changes: 54 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
plugins: ["no-jquery"],
plugins: ["no-jquery", "jsdoc"],
ignorePatterns: [
"themes/**/vendor/**",
"themes/**/node_modules/**"
Expand Down Expand Up @@ -39,6 +39,58 @@ module.exports = {
"space-infix-ops": "warn",

// the following is required for Bootstrap 3 collapse:
"no-jquery/no-support": "off"
"no-jquery/no-support": "off",

"jsdoc/check-access": 1, // Recommended
"jsdoc/check-alignment": 1, // Recommended
//"jsdoc/check-examples": 1,
//"jsdoc/check-indentation": 1,
//"jsdoc/check-line-alignment": 1,
"jsdoc/check-param-names": 1, // Recommended
//"jsdoc/check-template-names": 1,
"jsdoc/check-property-names": 1, // Recommended
//"jsdoc/check-syntax": 1,
"jsdoc/check-tag-names": 1, // Recommended
"jsdoc/check-types": 1, // Recommended
"jsdoc/check-values": 1, // Recommended
"jsdoc/empty-tags": 1, // Recommended
"jsdoc/implements-on-classes": 1, // Recommended
//"jsdoc/informative-docs": 1,
//"jsdoc/match-description": 1,
"jsdoc/multiline-blocks": 1, // Recommended
//"jsdoc/no-bad-blocks": 1,
//"jsdoc/no-blank-block-descriptions": 1,
//"jsdoc/no-defaults": 1,
//"jsdoc/no-missing-syntax": 1,
"jsdoc/no-multi-asterisks": 1, // Recommended
//"jsdoc/no-restricted-syntax": 1,
//"jsdoc/no-types": 1,
"jsdoc/no-undefined-types": 1, // Recommended
//"jsdoc/require-asterisk-prefix": 1,
//"jsdoc/require-description": 1,
//"jsdoc/require-description-complete-sentence": 1,
//"jsdoc/require-example": 1,
//"jsdoc/require-file-overview": 1,
//"jsdoc/require-hyphen-before-param-description": 1,
"jsdoc/require-jsdoc": 1, // Recommended
"jsdoc/require-param": 1, // Recommended
"jsdoc/require-param-description": 1, // Recommended
"jsdoc/require-param-name": 1, // Recommended
"jsdoc/require-param-type": 1, // Recommended
"jsdoc/require-property": 1, // Recommended
"jsdoc/require-property-description": 1, // Recommended
"jsdoc/require-property-name": 1, // Recommended
"jsdoc/require-property-type": 1, // Recommended
"jsdoc/require-returns": 1, // Recommended
"jsdoc/require-returns-check": 1, // Recommended
"jsdoc/require-returns-description": 1, // Recommended
"jsdoc/require-returns-type": 1, // Recommended
//"jsdoc/require-template": 1,
//"jsdoc/require-throws": 1,
"jsdoc/require-yields": 1, // Recommended
"jsdoc/require-yields-check": 1, // Recommended
//"jsdoc/sort-tags": 1,
"jsdoc/tag-lines": 1, // Recommended
"jsdoc/valid-types": 1 // Recommended
}
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"all-iso-language-codes": "^1.0.13",
"eslint": "^8.15.0",
"eslint-plugin-no-jquery": "^2.7.0",
"eslint-plugin-jsdoc": "50.2.2",
"grunt-contrib-watch": "^1.1.0",
"jshint": "^2.13.4"
}
Expand Down
18 changes: 18 additions & 0 deletions themes/bootstrap3/js/advanced_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ var nextGroup = 0;
var groupLength = [];
var deleteGroup, deleteSearch;

/**
* Add a search template for search group
* @param {string} group Key for the group for search
* @param {object} _fieldValues Object containing field values
* @param {boolean} isUser Is user logged in
* @returns {false} To terminate eventHandler properly
*/
function addSearch(group, _fieldValues, isUser = false) {
var fieldValues = _fieldValues || {};
// Build the new search
Expand Down Expand Up @@ -87,6 +94,9 @@ deleteSearch = function _deleteSearch(group, sindex) {
return false;
};

/**
* Function to loop through group link labels and renumber the links
*/
function _renumberGroupLinkLabels() {
$('.adv-group-close').each(function deleteGroupLinkLabel(i, link) {
$(link).attr(
Expand All @@ -96,6 +106,14 @@ function _renumberGroupLinkLabels() {
});
}

/**
* Add a group for advanced search
* @param {string} _firstTerm First term identifier
* @param {string} _firstField First field
* @param {string} _join Join and|or|not
* @param {boolean} isUser Is user logged in?
* @returns {number} Index for the next group
*/
function addGroup(_firstTerm, _firstField, _join, isUser = false) {
var firstTerm = _firstTerm || '';
var firstField = _firstField || '';
Expand Down
69 changes: 69 additions & 0 deletions themes/bootstrap3/js/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,41 @@ VuFind.register('cart', function Cart() {
var _COOKIE_PATH = '/';
var _COOKIE_SAMESITE = 'Lax';

/**
*
* @param domain

Check warning on line 14 in themes/bootstrap3/js/cart.js

View workflow job for this annotation

GitHub Actions / Tests with PHP 8.2

Missing JSDoc @param "domain" description

Check warning on line 14 in themes/bootstrap3/js/cart.js

View workflow job for this annotation

GitHub Actions / Tests with PHP 8.2

Missing JSDoc @param "domain" type
*/
function setDomain(domain) {
_COOKIE_DOMAIN = domain;
}

/**
*
* @param path

Check warning on line 22 in themes/bootstrap3/js/cart.js

View workflow job for this annotation

GitHub Actions / Tests with PHP 8.2

Missing JSDoc @param "path" description

Check warning on line 22 in themes/bootstrap3/js/cart.js

View workflow job for this annotation

GitHub Actions / Tests with PHP 8.2

Missing JSDoc @param "path" type
*/
function setCookiePath(path) {
_COOKIE_PATH = path;
}

/**
*
* @param sameSite

Check warning on line 30 in themes/bootstrap3/js/cart.js

View workflow job for this annotation

GitHub Actions / Tests with PHP 8.2

Missing JSDoc @param "sameSite" description

Check warning on line 30 in themes/bootstrap3/js/cart.js

View workflow job for this annotation

GitHub Actions / Tests with PHP 8.2

Missing JSDoc @param "sameSite" type
*/
function setCookieSameSite(sameSite) {
_COOKIE_SAMESITE = sameSite;
}

/**

Check warning on line 36 in themes/bootstrap3/js/cart.js

View workflow job for this annotation

GitHub Actions / Tests with PHP 8.2

Missing JSDoc @returns declaration
*
*/
function _getCookieParams() {
return { path: _COOKIE_PATH, domain: _COOKIE_DOMAIN, SameSite: _COOKIE_SAMESITE };
}

/**

Check warning on line 43 in themes/bootstrap3/js/cart.js

View workflow job for this annotation

GitHub Actions / Tests with PHP 8.2

Missing JSDoc @returns declaration
*
* @param op

Check warning on line 45 in themes/bootstrap3/js/cart.js

View workflow job for this annotation

GitHub Actions / Tests with PHP 8.2

Missing JSDoc @param "op" description

Check warning on line 45 in themes/bootstrap3/js/cart.js

View workflow job for this annotation

GitHub Actions / Tests with PHP 8.2

Missing JSDoc @param "op" type
*/
function _uniqueArray(op) {
var ret = [];
for (var i = 0; i < op.length; i++) {
Expand All @@ -35,20 +54,29 @@ VuFind.register('cart', function Cart() {
return ret;
}

/**
*
*/
function _getItems() {
var items = window.Cookies.get(_COOKIE);
if (items) {
return items.split(_COOKIE_DELIM);
}
return [];
}
/**
*
*/
function _getSources() {
var items = window.Cookies.get(_COOKIE_SOURCES);
if (items) {
return items.split(_COOKIE_DELIM);
}
return [];
}
/**
*
*/
function getFullItems() {
var items = _getItems();
var sources = _getSources();
Expand All @@ -62,11 +90,19 @@ VuFind.register('cart', function Cart() {
return full;
}

/**
*
* @param id
* @param _source
*/
function hasItem(id, _source) {
var source = _source || VuFind.defaultSearchBackend;
return _getItems().indexOf(String.fromCharCode(65 + _getSources().indexOf(source)) + id) > -1;
}

/**
*
*/
function _refreshToggles() {
var $toggleBtns = $('.btn-bookbag-toggle');
if ($toggleBtns.length > 0) {
Expand All @@ -82,6 +118,9 @@ VuFind.register('cart', function Cart() {
}
}

/**
*
*/
function updateCount() {
var items = VuFind.cart.getFullItems();
$('#cartItems strong').html(items.length);
Expand All @@ -93,6 +132,11 @@ VuFind.register('cart', function Cart() {
_refreshToggles();
}

/**
*
* @param id
* @param _source
*/
function addItem(id, _source) {
var source = _source || VuFind.defaultSearchBackend;
var cartItems = _getItems();
Expand All @@ -113,6 +157,11 @@ VuFind.register('cart', function Cart() {
updateCount();
return true;
}
/**
*
* @param id
* @param source
*/
function removeItem(id, source) {
var cartItems = _getItems();
var cartSources = _getSources();
Expand Down Expand Up @@ -157,6 +206,10 @@ VuFind.register('cart', function Cart() {
}

var _cartNotificationTimeout = false;
/**
*
* @param _form
*/
function _registerUpdate(_form) {
var $form = typeof _form === 'undefined'
? $('form[name="bulkActionForm"]')
Expand Down Expand Up @@ -210,6 +263,10 @@ VuFind.register('cart', function Cart() {
});
}

/**
*
* @param _container
*/
function registerToggles(_container) {
var container = typeof _container !== 'undefined' ? $(_container) : $(document);
var $toggleBtns = container.find('.btn-bookbag-toggle');
Expand Down Expand Up @@ -244,10 +301,17 @@ VuFind.register('cart', function Cart() {
}
}

/**
*
* @param params
*/
function updateContainer(params) {
registerToggles(params.container);
}

/**
*
*/
function init() {
// Record buttons
registerToggles();
Expand Down Expand Up @@ -283,6 +347,11 @@ VuFind.register('cart', function Cart() {

// Building an array and checking indexes prevents a race situation
// We want to prioritize empty over printing
/**
*
* @param event
* @param data
*/
function cartFormHandler(event, data) {
let numberOfItems = 0;
let isPrint = false;
Expand Down
28 changes: 28 additions & 0 deletions themes/bootstrap3/js/channels.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/*global getUrlRoot, VuFind */
VuFind.register('channels', function Channels() {
/**
*
* @param elem
*/
function addLinkButtons(elem) {
var links;
try {
Expand Down Expand Up @@ -35,12 +39,20 @@ VuFind.register('channels', function Channels() {
}

var currentPopoverRecord = false;
/**
*
* @param record
*/
function isCurrentPopoverRecord(record) {
return record && currentPopoverRecord
&& record.data('record-id') === currentPopoverRecord.data('record-id')
&& record.data('record-source') === currentPopoverRecord.data('record-source')
&& record.data('channel-id') === currentPopoverRecord.data('channel-id');
}
/**
*
* @param record
*/
function switchPopover(record) {
// Hide the old popover:
if (currentPopoverRecord) {
Expand All @@ -61,6 +73,10 @@ VuFind.register('channels', function Channels() {
}

// Truncate lines to height with ellipses
/**
*
* @param el
*/
function clampLines(el) {
var words = el.innerHTML.split(" ");
while (el.scrollHeight > el.offsetHeight) {
Expand All @@ -69,6 +85,11 @@ VuFind.register('channels', function Channels() {
}
}

/**
*
* @param i
* @param op
*/
function setupChannelSlider(i, op) {
$(op).find(".slide").removeClass("hidden");
$(op).slick({
Expand Down Expand Up @@ -150,6 +171,10 @@ VuFind.register('channels', function Channels() {

var bindChannelAddMenu; // circular dependency fix for jshint

/**
*
* @param e
*/
function selectAddedChannel(e) {
$.ajax(e.target.href).done(function addChannelAjaxDone(data) {
var list = $(e.target).closest('.dropdown-menu');
Expand Down Expand Up @@ -194,6 +219,9 @@ VuFind.register('channels', function Channels() {
});
};

/**
*
*/
function init () {
$('.channel').each(setupChannelSlider);
$('.channel').each(bindChannelAddMenu);
Expand Down
Loading

0 comments on commit 3ad47f1

Please sign in to comment.