diff --git a/.eslintrc.js b/.eslintrc.js index 1167273a..de4697c8 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -38,4 +38,11 @@ module.exports = { 'jsdoc/require-param-description': 0, 'jsdoc/require-returns-description': 0, }, + settings: { + jsdoc: { + preferredTypes: { + object: 'Object', + }, + }, + }, }; diff --git a/scripts/build-compatibility-table.js b/scripts/build-compatibility-table.js index 4fb62ba6..9fb98825 100644 --- a/scripts/build-compatibility-table.js +++ b/scripts/build-compatibility-table.js @@ -20,14 +20,14 @@ const WIKI_COMPATIBILITY_TABLE_PATH = path.resolve( ); /** - * @typedef {object} CompatibilityItem + * @typedef {Object} CompatibilityItem * @property {string} adg AdGuard name * @property {string} abp Adblock Plus name * @property {string} ubo uBlock name */ /** - * @typedef {object} CompatibilityData + * @typedef {Object} CompatibilityData * @property {CompatibilityItem[]} scriptlets list of scriptlets compatibility items * @property {CompatibilityItem[]} redirects list of redirects compatibility items */ diff --git a/scripts/build-docs.js b/scripts/build-docs.js index e2f28e85..c785c858 100644 --- a/scripts/build-docs.js +++ b/scripts/build-docs.js @@ -48,7 +48,7 @@ const aboutTrustedScriptletsPath = path.resolve( /** * Collects required comments from files * - * @returns {object} describing object for scriptlets and redirects + * @returns {Object} describing object for scriptlets and redirects */ const manageDataFromFiles = () => { const dataFromScriptletsFiles = getDataFromFiles( @@ -87,7 +87,7 @@ const manageDataFromFiles = () => { */ /** - * @typedef {object} MarkdownData + * @typedef {Object} MarkdownData * @property {string} list table of content * @property {string} body main content which */ diff --git a/scripts/build-tests.js b/scripts/build-tests.js index 685aa0c5..090eb9cb 100644 --- a/scripts/build-tests.js +++ b/scripts/build-tests.js @@ -18,7 +18,7 @@ const TEST_FILE_NAME_MARKER = '.test.js'; * @param {string} fileName test file name * @param {string} dirPath resolved directory path * @param {string} subDir subdirectory with test files - * @returns {object} rollup config + * @returns {Object} rollup config */ const getTestConfig = (fileName, dirPath, subDir) => { if (!fs.existsSync(TESTS_DIST)) { diff --git a/scripts/check-sources-updates.js b/scripts/check-sources-updates.js index 47e10768..f548d3e3 100644 --- a/scripts/check-sources-updates.js +++ b/scripts/check-sources-updates.js @@ -33,7 +33,7 @@ const areArraysOfStringsEqual = (arr1, arr2) => { /** * Returns parsed compatibility table * - * @returns {object} + * @returns {Object} */ const getCompatibilityTable = () => { const rawData = fs.readFileSync(COMPATIBILITY_TABLE_DATA_PATH); @@ -64,7 +64,7 @@ const getRedirectsFromTable = (platform) => { }; /** - * @typedef {object} Diff + * @typedef {Object} Diff * @property {string[]} added added content * @property {string[]} removed removed content */ diff --git a/scripts/helpers.js b/scripts/helpers.js index 83cd4b38..8dcec4ef 100644 --- a/scripts/helpers.js +++ b/scripts/helpers.js @@ -31,7 +31,7 @@ const getFilesList = (relativeDirPath) => { }; /** - * @typedef {object} CommentTag + * @typedef {Object} CommentTag * @property {string} type tag name * @property {string} string text following the tag */ @@ -77,7 +77,7 @@ Please add one OR edit the list of NON_SCRIPTLETS_FILES / NON_REDIRECTS_FILES.`) }; /** - * @typedef {object} DescribingCommentData + * @typedef {Object} DescribingCommentData * * Collected data from jsdoc-type comment for every scriptlet or redirect. * @property {string} type parsed instance tag: diff --git a/src/helpers/converter.js b/src/helpers/converter.js index 4755e4b3..51856c27 100644 --- a/src/helpers/converter.js +++ b/src/helpers/converter.js @@ -79,7 +79,7 @@ const getSentences = (str) => { * Replaces string with data by placeholders * * @param {string} str string with placeholders - * @param {object} data - where keys are placeholders names + * @param {Object} data - where keys are placeholders names * @returns {string} string filled with data */ const replacePlaceholders = (str, data) => { @@ -362,9 +362,9 @@ export const isValidScriptletRule = (input) => { * Gets index and redirect resource marker from UBO/ADG modifiers array * * @param {string[]} modifiers rule modifiers - * @param {object} redirectsData validator.REDIRECT_RULE_TYPES.(UBO|ADG) + * @param {Object} redirectsData validator.REDIRECT_RULE_TYPES.(UBO|ADG) * @param {string} rule rule string - * @returns {object} { index, marker } + * @returns {Object} { index, marker } */ const getMarkerData = (modifiers, redirectsData, rule) => { let marker; diff --git a/src/helpers/cookie-utils.js b/src/helpers/cookie-utils.js index 39d27f56..7bebf680 100644 --- a/src/helpers/cookie-utils.js +++ b/src/helpers/cookie-utils.js @@ -88,7 +88,7 @@ export const getLimitedCookieValue = (value) => { * Parses cookie string into object * * @param {string} cookieString string that conforms to document.cookie format - * @returns {object} key:value object that corresponds with incoming cookies keys and values + * @returns {Object} key:value object that corresponds with incoming cookies keys and values */ export const parseCookieString = (cookieString) => { const COOKIE_DELIMITER = '='; diff --git a/src/helpers/get-descriptor-addon.js b/src/helpers/get-descriptor-addon.js index 6e7a3c1a..1acb3909 100644 --- a/src/helpers/get-descriptor-addon.js +++ b/src/helpers/get-descriptor-addon.js @@ -7,7 +7,7 @@ import { randomId } from './random-id'; * https://github.com/AdguardTeam/Scriptlets/issues/226 * https://github.com/AdguardTeam/Scriptlets/issues/232 * - * @returns {object} descriptor addon + * @returns {Object} descriptor addon */ export function getDescriptorAddon() { return { diff --git a/src/helpers/get-property-in-chain.js b/src/helpers/get-property-in-chain.js index e27f34f6..dd1f413b 100644 --- a/src/helpers/get-property-in-chain.js +++ b/src/helpers/get-property-in-chain.js @@ -2,7 +2,7 @@ import { isEmptyObject } from './object-utils'; /** * @typedef ChainInfo - * @property {object} base current chain base + * @property {Object} base current chain base * @property {string} prop current chain prop * @property {string} [chain] string representation */ @@ -14,7 +14,7 @@ import { isEmptyObject } from './object-utils'; * defines this property as 'undefined' * and returns base, property name and remaining part of property chain * - * @param {object} base object that owns chain + * @param {Object} base object that owns chain * @param {string} chain chain of owner properties * @returns {ChainInfo} chain info object */ diff --git a/src/helpers/get-wildcard-property-in-chain.js b/src/helpers/get-wildcard-property-in-chain.js index 1782db98..0b139c8d 100644 --- a/src/helpers/get-wildcard-property-in-chain.js +++ b/src/helpers/get-wildcard-property-in-chain.js @@ -1,6 +1,6 @@ /** * @typedef ChainInfo - * @property {object} base current chain base + * @property {Object} base current chain base * @property {string} prop current chain prop * @property {string} [chain] string representation */ @@ -10,7 +10,7 @@ * Similar to getPropertyInChain but upgraded for json-prune: * handle wildcard properties and does not define nonexistent base property as 'undefined' * - * @param {object} base object that owns chain + * @param {Object} base object that owns chain * @param {string} chain chain of owner properties * @param {boolean} [lookThrough=false] * should the method look through it's props in order to wildcard diff --git a/src/helpers/hit.js b/src/helpers/hit.js index ac88b531..8d5c685d 100644 --- a/src/helpers/hit.js +++ b/src/helpers/hit.js @@ -3,7 +3,7 @@ /** * Hit used only for debug purposes now * - * @param {object} source scriptlet properties + * @param {Object} source scriptlet properties * use LOG_MARKER = 'log: ' at the start of a message * for logging scriptlets */ diff --git a/src/helpers/injector.js b/src/helpers/injector.js index b67f0649..74a1958e 100644 --- a/src/helpers/injector.js +++ b/src/helpers/injector.js @@ -44,7 +44,7 @@ export function addCall(scriptlet, code) { * function noeval(source) { alert(source); } * noeval.apply(this, args); * )({"args": ["aaa", "bbb"], "name":"noeval"}, ["aaa", "bbb"])` - * @param {object} source - object with scriptlet properties + * @param {Object} source - object with scriptlet properties * @param {string} code - scriptlet source code with dependencies * @param {boolean} redirect if function is redirect * @returns {string} full scriptlet code diff --git a/src/helpers/log-message.js b/src/helpers/log-message.js index ceb038ea..1a87bf5e 100644 --- a/src/helpers/log-message.js +++ b/src/helpers/log-message.js @@ -4,7 +4,7 @@ * is not a part of scriptlet's functionality, eg on invalid input, * and use 'forced' argument otherwise. * - * @param {object} source required, scriptlet properties + * @param {Object} source required, scriptlet properties * @param {string} message required, message to log * @param {boolean} [forced=false] to log message unconditionally */ diff --git a/src/helpers/match-request-props.js b/src/helpers/match-request-props.js index be868a49..2c4f52bd 100644 --- a/src/helpers/match-request-props.js +++ b/src/helpers/match-request-props.js @@ -10,9 +10,9 @@ import { logMessage } from './log-message'; * This is used by prevent-xhr, prevent-fetch, trusted-replace-xhr-response * and trusted-replace-fetch-response scriptlets * - * @param {object} source scriptlet properties + * @param {Object} source scriptlet properties * @param {string} propsToMatch string of space-separated request properties to match - * @param {object} requestData object with standard properties of fetch/xhr like url, method etc + * @param {Object} requestData object with standard properties of fetch/xhr like url, method etc * @returns {boolean} if request properties match */ export const matchRequestProps = (source, propsToMatch, requestData) => { diff --git a/src/helpers/noop-utils.js b/src/helpers/noop-utils.js index 900c7728..5e106b34 100644 --- a/src/helpers/noop-utils.js +++ b/src/helpers/noop-utils.js @@ -59,7 +59,7 @@ export const noopArray = () => []; /** * Function returns empty object * - * @returns {object} empty object + * @returns {Object} empty object */ export const noopObject = () => ({}); diff --git a/src/helpers/object-utils.js b/src/helpers/object-utils.js index 9b05e875..d8aa5973 100644 --- a/src/helpers/object-utils.js +++ b/src/helpers/object-utils.js @@ -3,7 +3,7 @@ * Object.entries() polyfill because it is not supported by IE * https://caniuse.com/?search=Object.entries * - * @param {object} object arbitrary object + * @param {Object} object arbitrary object * @returns {Array} array of pairs */ export const getObjectEntries = (object) => { @@ -19,7 +19,7 @@ export const getObjectEntries = (object) => { * https://caniuse.com/?search=Object.fromEntries * * @param {Array} entries - array of pairs - * @returns {object} result object + * @returns {Object} result object */ export const getObjectFromEntries = (entries) => { const output = entries @@ -35,7 +35,7 @@ export const getObjectFromEntries = (entries) => { /** * Checks whether the obj is an empty object * - * @param {object} obj arbitrary object + * @param {Object} obj arbitrary object * @returns {boolean} if object is empty */ export const isEmptyObject = (obj) => Object.keys(obj).length === 0 && !obj.prototype; @@ -43,7 +43,7 @@ export const isEmptyObject = (obj) => Object.keys(obj).length === 0 && !obj.prot /** * Safely retrieve property descriptor * - * @param {object} obj target object + * @param {Object} obj target object * @param {string} prop target property * @returns {object|null} descriptor or null if it's not available or non-configurable */ @@ -58,9 +58,9 @@ export const safeGetDescriptor = (obj, prop) => { /** * Set getter and setter to property if it's configurable * - * @param {object} object target object with property + * @param {Object} object target object with property * @param {string} property property name - * @param {object} descriptor contains getter and setter functions + * @param {Object} descriptor contains getter and setter functions * @returns {boolean} is operation successful */ export function setPropertyAccess(object, property, descriptor) { diff --git a/src/helpers/open-shadow-dom-utils.js b/src/helpers/open-shadow-dom-utils.js index aa05e622..83797a9a 100644 --- a/src/helpers/open-shadow-dom-utils.js +++ b/src/helpers/open-shadow-dom-utils.js @@ -29,7 +29,7 @@ export const findHostElements = (rootElement) => { */ /** - * @typedef {object} PierceData + * @typedef {Object} PierceData * @property {HTMLElement[]} targets found elements that match the specified selector * @property {HTMLElement[]} innerHosts inner shadow-dom hosts */ diff --git a/src/helpers/parse-flags.js b/src/helpers/parse-flags.js index e5d20c10..5c679f1a 100644 --- a/src/helpers/parse-flags.js +++ b/src/helpers/parse-flags.js @@ -1,5 +1,5 @@ /** - * @typedef {object} FlagsData object that holds info about valid flags + * @typedef {Object} FlagsData object that holds info about valid flags * and provides method for easy access * @property {string} ASAP asap flag string * @property {string} COMPLETE complete flag string diff --git a/src/helpers/parse-rule.js b/src/helpers/parse-rule.js index 254bc52c..809a8810 100644 --- a/src/helpers/parse-rule.js +++ b/src/helpers/parse-rule.js @@ -2,7 +2,7 @@ * Iterate over iterable argument and evaluate current state with transitions * * @param {Array|string} iterable rule or list or rules - * @param {object} transitions transtion functions + * @param {Object} transitions transtion functions * @param {string} init first transition name * @param {any} args arguments which should be passed to transition functions * @returns {string} state @@ -23,7 +23,7 @@ export const ADG_SCRIPTLET_MASK = '#//scriptlet'; /** * Helper to accumulate an array of strings char by char * - * @returns {object} object with helper methods + * @returns {Object} object with helper methods */ const wordSaver = () => { let str = ''; @@ -72,8 +72,8 @@ export const parseRule = (ruleText) => { * * @param {string} rule rule string * @param {number} index index - * @param {object} Object helper object - * @param {object} Object.sep contains prop symb with current separator char + * @param {Object} Object helper object + * @param {Object} Object.sep contains prop symb with current separator char * @throws {string} throws if given rule is not a scriptlet * @returns {string} transition */ @@ -111,9 +111,9 @@ export const parseRule = (ruleText) => { * * @param {string} rule rule string * @param {number} index index - * @param {object} Object helper object - * @param {object} Object.sep contains prop `symb` with current separator char - * @param {object} Object.saver helper which allow to save strings by car by char + * @param {Object} Object helper object + * @param {Object} Object.sep contains prop `symb` with current separator char + * @param {Object} Object.saver helper which allow to save strings by car by char * @returns {void} */ const param = (rule, index, { saver, sep }) => { diff --git a/src/helpers/prevent-utils.js b/src/helpers/prevent-utils.js index 3df656f4..e7534f1b 100644 --- a/src/helpers/prevent-utils.js +++ b/src/helpers/prevent-utils.js @@ -38,7 +38,7 @@ export const parseRawDelay = (delay) => { * by given parameters 'matchCallback' and 'matchDelay'. * Used for prevent-setTimeout and prevent-setInterval. * - * @param {object} preventData set of data to determine if scriptlet should match + * @param {Object} preventData set of data to determine if scriptlet should match * @param {Function} preventData.callback method's callback arg * @param {any} preventData.delay method's delay arg * @param {string} preventData.matchCallback scriptlets's callback arg diff --git a/src/helpers/request-utils.js b/src/helpers/request-utils.js index 1d68792f..33c39e9a 100644 --- a/src/helpers/request-utils.js +++ b/src/helpers/request-utils.js @@ -27,7 +27,7 @@ export const getRequestProps = () => [ * Collects Request options to object * * @param {Request} request Request instance to collect properties from - * @returns {object} data object + * @returns {Object} data object */ export const getRequestData = (request) => { const requestInitOptions = getRequestProps(); @@ -44,7 +44,7 @@ export const getRequestData = (request) => { * Collects fetch args to object * * @param {*} args fetch args - * @returns {object} data object + * @returns {Object} data object */ export const getFetchData = (args) => { const fetchPropsObj = {}; @@ -79,7 +79,7 @@ export const getFetchData = (args) => { * @param {string} async request async prop * @param {string} user request user prop * @param {string} password request password prop - * @returns {object} aggregated request data + * @returns {Object} aggregated request data */ export const getXhrData = (method, url, async, user, password) => { return { @@ -96,7 +96,7 @@ export const getXhrData = (method, url, async, user, password) => { * used for prevent-fetch and prevent-xhr * * @param {string} propsToMatchStr string of space-separated request properties to match - * @returns {object} object where 'key' is prop name and 'value' is prop value + * @returns {Object} object where 'key' is prop name and 'value' is prop value */ export const parseMatchProps = (propsToMatchStr) => { const PROPS_DIVIDER = ' '; @@ -129,7 +129,7 @@ export const parseMatchProps = (propsToMatchStr) => { /** * Validates parsed data values * - * @param {object} data request data + * @param {Object} data request data * @returns {boolean} if data is valid */ export const validateParsedData = (data) => { @@ -140,8 +140,8 @@ export const validateParsedData = (data) => { /** * Converts valid parsed data to data obj for further matching * - * @param {object} data parsed request data - * @returns {object} data obj ready for matching + * @param {Object} data parsed request data + * @returns {Object} data obj ready for matching */ export const getMatchPropsData = (data) => { const matchData = {}; diff --git a/src/helpers/storage-utils.js b/src/helpers/storage-utils.js index ff7e35e2..acdb3e36 100644 --- a/src/helpers/storage-utils.js +++ b/src/helpers/storage-utils.js @@ -4,7 +4,7 @@ import { logMessage } from './log-message'; /** * Sets item to a specified storage, if storage isn't full. * - * @param {object} source scriptlet's configuration + * @param {Object} source scriptlet's configuration * @param {Storage} storage storage instance to set item into * @param {string} key storage key * @param {string} value staroge value diff --git a/src/helpers/string-utils.js b/src/helpers/string-utils.js index 45fcc5e6..09f94770 100644 --- a/src/helpers/string-utils.js +++ b/src/helpers/string-utils.js @@ -223,7 +223,7 @@ export const isValidMatchNumber = (match) => { }; /** - * @typedef {object} MatchData + * @typedef {Object} MatchData * @property {boolean} isInvertedMatch if matching should be inverted * @property {RegExp} matchRegexp match value parsed into regex */ @@ -245,7 +245,7 @@ export const parseMatchArg = (match) => { }; /** - * @typedef {object} DelayData + * @typedef {Object} DelayData * @property {boolean} isInvertedDelayMatch if matching should be inverted * @property {number|null} delayMatch parsed delay or null if delay is invalid */ @@ -269,7 +269,7 @@ export const parseDelayArg = (delay) => { /** * Converts object to string for logging * - * @param {object} obj data object + * @param {Object} obj data object * @returns {string} object's string representation */ export const objectToString = (obj) => { diff --git a/src/redirects/blocking-redirects/click2load.js b/src/redirects/blocking-redirects/click2load.js index ee5545b4..e0f19f7b 100644 --- a/src/redirects/blocking-redirects/click2load.js +++ b/src/redirects/blocking-redirects/click2load.js @@ -29,7 +29,7 @@ function clickToLoad() { * because frame will be shown anyway if click2load redirect rule used * * @param {string} rawQueryStr - * @returns {object} key is parameter name and value is parameter value + * @returns {Object} key is parameter name and value is parameter value */ const parseSearchParam = (rawQueryStr) => { const res = {}; @@ -125,7 +125,7 @@ function clickToLoad() { * Returns translations data for navigator.language * or 'en' if navigator.language is not supported * - * @returns {object} data for one locale with 'title' and 'button' keys + * @returns {Object} data for one locale with 'title' and 'button' keys */ const getTranslations = () => { const baseLocaleData = translationsData.en; diff --git a/src/redirects/index.js b/src/redirects/index.js index ba2efe96..6b9b8244 100644 --- a/src/redirects/index.js +++ b/src/redirects/index.js @@ -32,7 +32,7 @@ const getRedirectByName = (name) => { }; /** - * @typedef {object} Source - redirect properties + * @typedef {Object} Source - redirect properties * @property {string} name redirect name * @property {Array} args Arguments for redirect function * @property {'extension'|'test'} [engine] - diff --git a/src/redirects/metrika-yandex-tag.js b/src/redirects/metrika-yandex-tag.js index 0a5f9762..a432926b 100644 --- a/src/redirects/metrika-yandex-tag.js +++ b/src/redirects/metrika-yandex-tag.js @@ -69,7 +69,7 @@ export function metrikaYandexTag(source) { * * @param {string} id * @param {string} target - * @param {object} params + * @param {Object} params * @param {Function} callback * @param {any} ctx */ diff --git a/src/redirects/metrika-yandex-watch.js b/src/redirects/metrika-yandex-watch.js index 03f5a57d..f2646de7 100644 --- a/src/redirects/metrika-yandex-watch.js +++ b/src/redirects/metrika-yandex-watch.js @@ -17,7 +17,7 @@ export function metrikaYandexWatch(source) { /** * Gets callback and its context from options and call it in async way * - * @param {object} options Yandex Metrika API options + * @param {Object} options Yandex Metrika API options */ const asyncCallbackFromOptions = (options = {}) => { let { callback } = options; diff --git a/src/redirects/redirects.js b/src/redirects/redirects.js index 8e2fa182..5d90c806 100644 --- a/src/redirects/redirects.js +++ b/src/redirects/redirects.js @@ -10,7 +10,7 @@ import jsYaml from 'js-yaml'; * content: R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== * } * - * @typedef {object} Redirect + * @typedef {Object} Redirect * @property {string} title resource name * @property {string} comment resource description * @property {string} content encoded resource content diff --git a/src/scriptlets/index.js b/src/scriptlets/index.js index 300c6b8b..bf9e9242 100644 --- a/src/scriptlets/index.js +++ b/src/scriptlets/index.js @@ -14,7 +14,7 @@ import { import { getScriptletFunction } from '../../tmp/scriptlets-func'; /** - * @typedef {object} Source - scriptlet properties + * @typedef {Object} Source - scriptlet properties * @property {string} name Scriptlet name * @property {Array} args Arguments for scriptlet function * @property {'extension'|'corelibs'|'test'} engine - @@ -28,7 +28,7 @@ import { getScriptletFunction } from '../../tmp/scriptlets-func'; /** * Returns scriptlet code by param * - * @param {Source} source + * @param {Object} source scriptlet properties * @returns {string|null} scriptlet code * @throws on unknown scriptlet name */ @@ -54,7 +54,7 @@ function getScriptletCode(source) { /** * Scriptlets variable * - * @returns {object} object with methods: + * @returns {Object} object with methods: * `invoke` method receives one argument with `Source` type * `validate` method receives one argument with `String` type */ diff --git a/src/scriptlets/json-prune.js b/src/scriptlets/json-prune.js index a1457e4f..d0bb1480 100644 --- a/src/scriptlets/json-prune.js +++ b/src/scriptlets/json-prune.js @@ -156,8 +156,8 @@ export function jsonPrune(source, propsToRemove, requiredInitialProps, stack) { /** * Prunes properties of 'root' object * - * @param {object} root - * @returns {object} pruned root + * @param {Object} root + * @returns {Object} pruned root */ const jsonPruner = (root) => { if (prunePaths.length === 0 && requiredPaths.length === 0) {