From 9775e7bfb23006866e7f302ed9092953a7030465 Mon Sep 17 00:00:00 2001 From: Manvel Saroyan Date: Wed, 27 Dec 2023 17:01:56 +0400 Subject: [PATCH] No issue - added jsdoc linters --- .eslintrc | 9 +++++++-- src/js/background/main.js | 18 +++++++++++++++++- src/js/cs/record.js | 5 ++++- src/js/db/customActions.js | 9 ++++++--- src/js/db/prefs.js | 3 +-- src/js/db/projects.js | 32 +++++--------------------------- src/js/types/messagePassing.js | 31 ------------------------------- 7 files changed, 40 insertions(+), 67 deletions(-) delete mode 100644 src/js/types/messagePassing.js diff --git a/.eslintrc b/.eslintrc index c3e3ffb..7440279 100644 --- a/.eslintrc +++ b/.eslintrc @@ -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, diff --git a/src/js/background/main.js b/src/js/background/main.js index 8071832..ee060a6 100644 --- a/src/js/background/main.js +++ b/src/js/background/main.js @@ -17,6 +17,22 @@ * . */ +/** + * @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"); @@ -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") { diff --git a/src/js/cs/record.js b/src/js/cs/record.js index 9cd2f6f..e4f4378 100644 --- a/src/js/cs/record.js +++ b/src/js/cs/record.js @@ -17,6 +17,10 @@ * . */ +/** + * @typedef {import("../db/projects").ActionType} ActionType + */ + const port = browser.runtime.connect({name: "recordPort"}); function findClosest(query) @@ -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 */ diff --git a/src/js/db/customActions.js b/src/js/db/customActions.js index 8ad675a..e05140f 100644 --- a/src/js/db/customActions.js +++ b/src/js/db/customActions.js @@ -18,7 +18,11 @@ */ /** - * @typedef {Object} CustomActionInfo + * @typedef {import("./projects").Action} Action + */ + +/** + * @typedef {object} CustomActionInfo * @property {string} description - Custom action description. */ @@ -26,8 +30,7 @@ * 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. diff --git a/src/js/db/prefs.js b/src/js/db/prefs.js index 87e44b9..dddf9f5 100644 --- a/src/js/db/prefs.js +++ b/src/js/db/prefs.js @@ -18,7 +18,7 @@ */ /** - * @typedef {Object} Prefs + * @typedef {object} Prefs * @property {boolean} hidePowerfulActionWarning - Hide tooltip for powerful actions. */ @@ -65,7 +65,6 @@ async function get(pref) * Set preference. * @param {keyof Prefs} pref * @param {Prefs[pref]} value - * @returns */ async function set(pref, value) { diff --git a/src/js/db/projects.js b/src/js/db/projects.js index 4737385..abec329 100644 --- a/src/js/db/projects.js +++ b/src/js/db/projects.js @@ -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: @@ -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. @@ -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. @@ -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) { @@ -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) { @@ -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) @@ -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) { diff --git a/src/js/types/messagePassing.js b/src/js/types/messagePassing.js deleted file mode 100644 index 7f41063..0000000 --- a/src/js/types/messagePassing.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file is part of Chromium Browser Automation. - * Copyright (C) 2020-present Manvel Saroyan - * - * Chromium Browser Automation is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Chromium Browser Automation is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Chromium Browser Automation. If not, see - * . - */ - -/** - * 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 - */ -