Skip to content

Commit

Permalink
No issue - added jsdoc linters
Browse files Browse the repository at this point in the history
  • Loading branch information
Manvel committed Dec 27, 2023
1 parent 23894ef commit 9775e7b
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 67 deletions.
9 changes: 7 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@
"node": true,
"es2021": true
},
"extends": "eslint:recommended",
"extends": ["eslint:recommended", "plugin:jsdoc/recommended-error"],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["jsdoc"],
"rules": {
"global-require": "off",
"no-cond-assign": "off",
"no-empty": "off"
"no-empty": "off",
"jsdoc/require-jsdoc": "off",
"jsdoc/require-returns": "off",
"jsdoc/require-returns-description": "off",
"jsdoc/require-param-description": "off",
},
"globals": {
"cba": true,
Expand Down
18 changes: 17 additions & 1 deletion src/js/background/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@
* <http://www.gnu.org/licenses/>.
*/

/**
* @typedef {import("../db/projects").ActionType} ActionType
*/

/**
* Projects containing actions.
* @typedef {object} RecordedEventMsg
* @property {"RecordedEvent"} msgType - Message ID.
* @property {ActionType} type - One of [injectable action types](https://chrome-automation.com/actions).
* @property {string[]} inputs - action's arguments/inputs.
*/

/**
* @typedef {RecordedEventMsg} RpcMessages
*/

const browser = require("webextension-polyfill");
require("../analytics");
const {CBA} = require("./CBA");
Expand Down Expand Up @@ -84,7 +100,7 @@ isFirstLoad();

/**
* Function for storing records in Local Storage
* @param {RecordedEventMsg} msg
* @param {import("../types/messagePassing").RecordedEventMsg} msg
*/
function storeRecord(msg) {
if(msg.type == "redirect") {
Expand Down
5 changes: 4 additions & 1 deletion src/js/cs/record.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
* <http://www.gnu.org/licenses/>.
*/

/**
* @typedef {import("../db/projects").ActionType} ActionType
*/

const port = browser.runtime.connect({name: "recordPort"});

function findClosest(query)
Expand Down Expand Up @@ -136,7 +140,6 @@ function getPath(element) {
* Data: the path to the object (selector) or redirectionURL
* evType: Type of the event (click, change, redirect)
* newValue: newValue as example for changed value
*
* @param {ActionType} type
* @param {string[]} inputs
*/
Expand Down
9 changes: 6 additions & 3 deletions src/js/db/customActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@
*/

/**
* @typedef {Object} CustomActionInfo
* @typedef {import("./projects").Action} Action
*/

/**
* @typedef {object} CustomActionInfo
* @property {string} description - Custom action description.
*/

/**
* Custom and predefined actions:
* - Used by [Functions datagrid](https://chrome-automation.com/functions-grid).
* - Editable in [Functions tab](https://chrome-automation.com/functions-management).
*
* @typedef {Object} CustomAction
* @typedef {object} CustomAction
* @property {Action} data - Action.
* @property {CustomActionInfo} info - More information.
* @property {string} text - Name.
Expand Down
3 changes: 1 addition & 2 deletions src/js/db/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/**
* @typedef {Object} Prefs
* @typedef {object} Prefs
* @property {boolean} hidePowerfulActionWarning - Hide tooltip for powerful actions.
*/

Expand Down Expand Up @@ -65,7 +65,6 @@ async function get(pref)
* Set preference.
* @param {keyof Prefs} pref
* @param {Prefs[pref]} value
* @returns
*/
async function set(pref, value)
{
Expand Down
32 changes: 5 additions & 27 deletions src/js/db/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,13 @@
// Keep types in [sync with Wiki](https://github.com/browser-automation/cba/wiki/Storage-%7C-projects).

/**
* @typedef {(
* |"Inject"
* |"inject-cs"
* |"bg-inject"
* |"bg-function"
* |"change"
* |"check"
* |"click"
* |"click-update"
* |"update"
* |"timer"
* |"redirect"
* |"copy-html"
* |"copy"
* |"pause"
* )} ActionType
* @typedef {"Inject"|"inject-cs"|"bg-inject"|"bg-function"|"change"|"check"|"click"|"click-update"|"update"|"timer"|"redirect"|"copy-html"|"copy"|"pause"} ActionType
*/

/**
* Injectable actions as seen in [Actions table](https://chrome-automation.com/actions-grid).
* Learn more about [Various actions](https://chrome-automation.com/actions).
* @typedef {Object} Action
* @typedef {object} Action
* @property {string} id - Unique Identifier.
* @property {ActionType} type - One of [injectable action types](https://chrome-automation.com/actions).
* @property {string[]} inputs - action's arguments/inputs:
Expand All @@ -51,7 +36,7 @@

/**
* Projects containing actions.
* @typedef {Object} Project
* @typedef {object} Project
* @property {Action[]} actions - Injectable actions.
* @property {string} id - Unique Identifier.
* @property {string} text - Name of the project.
Expand All @@ -61,7 +46,7 @@
/**
* [Groups, containing project](https://chrome-automation.com/project) which
* contain [actions](https://chrome-automation.com/actions-grid).
* @typedef {Object} Group
* @typedef {object} Group
* @property {boolean} expanded - expands/collapse group.
* @property {string} id - Unique Identifier.
* @property {Project[]} subItems - Sub projects.
Expand Down Expand Up @@ -120,9 +105,8 @@ async function addAction(groupId, subItemId, action) {

/**
* Import project into a Group with group name.
* @param {Group["subItems"]} subItems
* @param {Group["subItems"]} subItems
* @param {Group["text"]} groupText
* @returns
*/
async function importProjects(subItems, groupText)
{
Expand Down Expand Up @@ -177,10 +161,8 @@ function createGroupObj(groupText, groupId) {

/**
* Check if project with specific name exists in Projects.
*
* @param {Project[]} items
* @param {string} value
* @returns
*/
function hasTextWithValue(items, value)
{
Expand All @@ -189,10 +171,8 @@ function hasTextWithValue(items, value)

/**
* Get unique text for a new project.
*
* @param {Project[]} items
* @param {string} prefix
* @returns
*/
function getNextText(items, prefix) {
if (!items || !items.length)
Expand All @@ -206,10 +186,8 @@ function getNextText(items, prefix) {

/**
* Check if id exists in the groups.
*
* @param {Group[]} groups
* @param {string} currentId
* @returns
*/
function hasId(groups, currentId)
{
Expand Down
31 changes: 0 additions & 31 deletions src/js/types/messagePassing.js

This file was deleted.

0 comments on commit 9775e7b

Please sign in to comment.