Skip to content

Commit

Permalink
enable jsdoc/check-types
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-atr committed Dec 27, 2022
1 parent 4908c90 commit fe20657
Show file tree
Hide file tree
Showing 27 changed files with 52 additions and 53 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ module.exports = {
'jsdoc/tag-lines': 0,
'jsdoc/require-jsdoc': 0,
'jsdoc/require-param-description': 0,
'jsdoc/check-types': 0,
'jsdoc/check-alignment': 0,
'jsdoc/require-returns': 0,
'jsdoc/require-property-description': 0,
Expand Down
4 changes: 2 additions & 2 deletions scripts/build-compatibility-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ const WIKI_COMPATIBILITY_TABLE_PATH = path.resolve(
);

/**
* @typedef {Object} CompatibilityItem
* @typedef {object} CompatibilityItem
* @property {string} adg
* @property {string} abp
* @property {string} ubo
*/

/**
* @typedef {Object} CompatibilityData
* @typedef {object} CompatibilityData
* @property {CompatibilityItem[]} scriptlets
* @property {CompatibilityItem[]} redirects
*/
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const manageDataFromFiles = () => {
*/

/**
* @typedef {Object} MarkdownData
* @typedef {object} MarkdownData
* @property {string} list table of content
* @property {string} body main content which
*/
Expand Down
4 changes: 2 additions & 2 deletions scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const getFilesList = (relativeDirPath) => {
};

/**
* @typedef {Object} CommentTag
* @typedef {object} CommentTag
* @property {string} type tag name
* @property {string} string text following the tag
*/
Expand Down Expand Up @@ -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.
*
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const getSentences = (str) => {
/**
* Replaces string with data by placeholders
* @param {string} str
* @param {Object} data - where keys are placeholders names
* @param {object} data - where keys are placeholders names
*/
const replacePlaceholders = (str, data) => {
return Object.keys(data).reduce((acc, key) => {
Expand Down Expand Up @@ -351,9 +351,9 @@ export const isValidScriptletRule = (input) => {
/**
* Gets index and redirect resource marker from UBO/ADG modifiers array
* @param {string[]} modifiers
* @param {Object} redirectsData validator.REDIRECT_RULE_TYPES.(UBO|ADG)
* @param {object} redirectsData validator.REDIRECT_RULE_TYPES.(UBO|ADG)
* @param {string} rule
* @returns {Object} { index, marker }
* @returns {object} { index, marker }
*/
const getMarkerData = (modifiers, redirectsData, rule) => {
let marker;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/cookie-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,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 = '=';
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/get-descriptor-addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { randomId } from './random-id';
* https://github.com/AdguardTeam/Scriptlets/issues/226
* https://github.com/AdguardTeam/Scriptlets/issues/232
*
* @return {Object}
* @return {object}
*/
export function getDescriptorAddon() {
return {
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/get-property-in-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { isEmptyObject } from './object-utils';

/**
* @typedef Chain
* @property {Object} base
* @property {object} base
* @property {string} prop
* @property {string} [chain]
*/
Expand All @@ -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
* @param {object} base
* @param {string} chain
* @returns {Chain}
*/
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/get-wildcard-property-in-chain.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @typedef Chain
* @property {Object} base
* @property {object} base
* @property {string} prop
* @property {string} [chain]
*/
Expand All @@ -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
* @param {object} base
* @param {string} chain
* @param {boolean} [lookThrough=false]
* should the method look through it's props in order to wildcard
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/match-request-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { logMessage } from './log-message';
* and trusted-replace-fetch-response scriptlets
* @param {Source} source
* @param {string} propsToMatch
* @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}
*/
export const matchRequestProps = (source, propsToMatch, requestData) => {
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/noop-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const noopArray = () => [];

/**
* Function returns empty object
* @return {Object} empty object
* @return {object} empty object
*/
export const noopObject = () => ({});

Expand Down
12 changes: 6 additions & 6 deletions src/helpers/object-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Converts object to array of pairs.
* Object.entries() polyfill because it is not supported by IE
* https://caniuse.com/?search=Object.entries
* @param {Object} object
* @param {object} object
* @returns {Array} array of pairs
*/
export const getObjectEntries = (object) => {
Expand All @@ -17,7 +17,7 @@ export const getObjectEntries = (object) => {
* Object.fromEntries() polyfill because it is not supported by IE
* https://caniuse.com/?search=Object.fromEntries
* @param {Array} entries - array of pairs
* @returns {Object}
* @returns {object}
*/
export const getObjectFromEntries = (entries) => {
const output = entries
Expand All @@ -32,16 +32,16 @@ export const getObjectFromEntries = (entries) => {

/**
* Checks whether the obj is an empty object
* @param {Object} obj
* @param {object} obj
* @returns {boolean}
*/
export const isEmptyObject = (obj) => Object.keys(obj).length === 0 && !obj.prototype;

/**
* Checks whether the obj is an empty object
* @param {Object} obj
* @param {object} obj
* @param {string} prop
* @returns {Object|null}
* @returns {object | null}
*/
export const safeGetDescriptor = (obj, prop) => {
const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
Expand All @@ -53,7 +53,7 @@ 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 {PropertyDescriptor} descriptor contains getter and setter functions
* @returns {boolean} is operation successful
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/open-shadow-dom-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,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
*/
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/parse-flags.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Behaviour flags string parser
* @param {string} flags required, 'applying' argument string
* @return {Object}
* @return {object}
*/
export const parseFlags = (flags) => {
const FLAGS_DIVIDER = ' ';
Expand Down
12 changes: 6 additions & 6 deletions src/helpers/parse-rule.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Iterate over iterable argument and evaluate current state with transitions
* @param {Array|Collection|string} iterable
* @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
*/
Expand Down Expand Up @@ -65,8 +65,8 @@ export const parseRule = (ruleText) => {
* Transition function: the current index position in start, end or between params
* @param {string} rule
* @param {number} index
* @param {Object} Object
* @param {Object} Object.sep contains prop symb with current separator char
* @param {object} Object
* @param {object} Object.sep contains prop symb with current separator char
*/
const opened = (rule, index, { sep }) => {
const char = rule[index];
Expand Down Expand Up @@ -101,9 +101,9 @@ export const parseRule = (ruleText) => {
* Transition function: the current index position inside param
* @param {string} rule
* @param {number} index
* @param {Object} 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
* @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
*/
const param = (rule, index, { saver, sep }) => {
const char = rule[index];
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/prevent-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const isValidCallback = (callback) => {
* Checks whether 'callback' and 'delay' are matching
* by given parameters 'matchCallback' and 'matchDelay'.
* Used for prevent-setTimeout and prevent-setInterval.
* @param {Object} preventData
* @param {object} preventData
* @param {Function} preventData.callback
* @param {any} preventData.delay
* @param {string} preventData.matchCallback
Expand Down
14 changes: 7 additions & 7 deletions src/helpers/request-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const getRequestProps = () => [
/**
* Collects Request options to object
* @param {Request} request
* @returns {Object} data object
* @returns {object} data object
*/
export const getRequestData = (request) => {
const requestInitOptions = getRequestProps();
Expand All @@ -41,7 +41,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 = {};
Expand Down Expand Up @@ -75,7 +75,7 @@ export const getFetchData = (args) => {
* @param {string} async
* @param {string} user
* @param {string} password
* @returns {Object}
* @returns {object}
*/
export const getXhrData = (method, url, async, user, password) => {
return {
Expand All @@ -91,7 +91,7 @@ export const getXhrData = (method, url, async, user, password) => {
* Parse propsToMatch input string into object;
* used for prevent-fetch and prevent-xhr
* @param {string} propsToMatchStr
* @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 = ' ';
Expand Down Expand Up @@ -123,7 +123,7 @@ export const parseMatchProps = (propsToMatchStr) => {

/**
* Validates parsed data values
* @param {Object} data
* @param {object} data
* @returns {boolean}
*/
export const validateParsedData = (data) => {
Expand All @@ -133,8 +133,8 @@ export const validateParsedData = (data) => {

/**
* Converts valid parsed data to data obj for further matching
* @param {Object} data
* @returns {Object}
* @param {object} data
* @returns {object}
*/
export const getMatchPropsData = (data) => {
const matchData = {};
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/string-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export const isValidMatchNumber = (match) => {
};

/**
* @typedef {Object} MatchData
* @typedef {object} MatchData
* @property {boolean} isInvertedMatch
* @property {RegExp} matchRegexp
*/
Expand All @@ -228,7 +228,7 @@ export const parseMatchArg = (match) => {
};

/**
* @typedef {Object} DelayData
* @typedef {object} DelayData
* @property {boolean} isInvertedDelayMatch
* @property {number|null} delayMatch
*/
Expand All @@ -252,7 +252,7 @@ export const parseDelayArg = (delay) => {

/**
* Converts object to string for logging
* @param {Object} obj data object
* @param {object} obj data object
* @returns {string}
*/
export const objectToString = (obj) => {
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/throttle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Returns a wrapper, passing the call to 'method' at maximum once per 'delay' milliseconds.
* Those calls that fall into the "cooldown" period, are ignored
* @param {Function} cb
* @param {Number} delay - milliseconds
* @param {number} delay - milliseconds
*/
export const throttle = (cb, delay) => {
let wait = false;
Expand Down
4 changes: 2 additions & 2 deletions src/redirects/blocking-redirects/click2load.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function clickToLoad() {
* but we need script run with no error
* 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 = {};
Expand Down Expand Up @@ -123,7 +123,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;
Expand Down
2 changes: 1 addition & 1 deletion src/redirects/google-analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function GoogleAnalytics(source) {

/**
* checks data object and delays callback
* @param {Object|Array} dataObj gtag payload
* @param {object|Array} dataObj gtag payload
* @param {string} funcName callback prop name
*/
const handleCallback = (dataObj, funcName) => {
Expand Down
2 changes: 1 addition & 1 deletion src/redirects/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const getRedirectByName = (name) => {
};

/**
* @typedef {Object} Source - redirect properties
* @typedef {object} Source - redirect properties
* @property {string} name redirect name
* @property {Array<string>} args Arguments for redirect function
* @property {'extension'|'test'} [engine] -
Expand Down
2 changes: 1 addition & 1 deletion src/redirects/metrika-yandex-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function metrikaYandexTag(source) {
* https://yandex.ru/support/metrica/objects/reachgoal.html
* @param {string} id
* @param {string} target
* @param {Object} params
* @param {object} params
* @param {Function} callback
* @param {any} ctx
*/
Expand Down
2 changes: 1 addition & 1 deletion src/redirects/metrika-yandex-watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit fe20657

Please sign in to comment.