Skip to content

Commit

Permalink
enable jsdoc/newline-after-description
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-atr committed Dec 28, 2022
1 parent 034db74 commit f5d898e
Show file tree
Hide file tree
Showing 43 changed files with 138 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ module.exports = {
'no-restricted-syntax': 0,
// jsdoc rules
'jsdoc/check-tag-names': ['error', { definedTags: ['scriptlet', 'trustedScriptlet', 'redirect'] }],
'jsdoc/require-returns-description': 0,
'jsdoc/newline-after-description': 0,
'jsdoc/require-param': 0,
'jsdoc/tag-lines': 0,
'jsdoc/require-jsdoc': 0,
Expand All @@ -42,6 +40,8 @@ module.exports = {
// jsdoc problematics
'jsdoc/valid-types': 0,
'jsdoc/no-undefined-types': 0,
// jsdoc questionable
'jsdoc/require-returns-description': 0,
},
overrides: [
{
Expand Down
1 change: 1 addition & 0 deletions scripts/build-compatibility-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const getTableHeader = () => {

/**
* Builds markdown string of scriptlets/redirect compatibility table
*
* @param {string} title title for scriptlets or redirects
* @param {CompatibilityItem[]} data array of scriptlets or redirects compatibility data items
* @param {'scriptlets'|'redirects'} id
Expand Down
1 change: 1 addition & 0 deletions scripts/build-redirects.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ const getJsRedirects = async (options = {}) => {
// TODO: seems like duplicate of already existed code
/**
* Returns first line of describing comment from redirect resource file
*
* @param {string} rrName redirect resource name
*/
const getComment = (rrName) => {
Expand Down
1 change: 1 addition & 0 deletions scripts/build-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const TEST_FILE_NAME_MARKER = '.test.js';

/**
* Prepares rollup config for test file
*
* @param {string} fileName test file name
* @param {string} dirPath resolved directory path
* @param {string} subDir subdirectory with test files
Expand Down
5 changes: 5 additions & 0 deletions scripts/check-sources-updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const {

/**
* Checks if arrays contain the same strings
*
* @param {Array} arr1
* @param {Array} arr2
*/
Expand All @@ -39,6 +40,7 @@ const getCompatibilityTable = () => {

/**
* Returns list of scriptlets listed in table for specified platform
*
* @param {"ubo"|"abp"} platform
*/
const getScriptletsFromTable = (platform) => {
Expand All @@ -48,6 +50,7 @@ const getScriptletsFromTable = (platform) => {

/**
* Returns list of redirects listed in table for specified platform
*
* @param {"ubo"|"abp"} platform
*/
const getRedirectsFromTable = (platform) => {
Expand All @@ -57,6 +60,7 @@ const getRedirectsFromTable = (platform) => {

/**
* Finds a difference between old and new array
*
* @param {Array} oldList
* @param {Array} newList
*/
Expand All @@ -77,6 +81,7 @@ const getDiff = (oldList, newList) => {

/**
* Marks removed rules with (removed) and adds new rules to the end of the table
*
* @param {{removed: Array, added: Array}} diff Object with diffs for certain type and platform
* @param {"scriptlets"|"redirects"} ruleType
* @param {"ubo"|"abp"} platform
Expand Down
2 changes: 2 additions & 0 deletions scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const writeFile = async (filePath, content) => {

/**
* Gets list of `.js` files in directory
*
* @param {string} relativeDirPath relative path to directory
* @returns {string[]} array of file names
*/
Expand Down Expand Up @@ -108,6 +109,7 @@ const prepareCommentsData = (commentTags, source) => {

/**
* Gets data objects which describe every required comment in one directory
*
* @param {string[]} filesList list of files in directory
* @param {string} relativeDirPath relative path to directory
*
Expand Down
2 changes: 2 additions & 0 deletions scripts/rollup-runners.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { log } = console;

/**
* Builds scriptlets
*
* @param {object|object[]} config config may be list of configs or one config
*/
export const rollupStandard = async (config) => {
Expand All @@ -26,6 +27,7 @@ export const rollupStandard = async (config) => {

/**
* Builds scriptlets in the watch mode
*
* @param {object|object[]} config - config may be list of configs or one config
*/
export const rollupWatch = (config) => {
Expand Down
3 changes: 3 additions & 0 deletions src/helpers/add-event-listener-utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Validates event type
*
* @param {*} type
* @returns {boolean}
*/
Expand All @@ -10,6 +11,7 @@ export const validateType = (type) => {

/**
* Validates event listener
*
* @param {*} listener
* @returns {boolean}
*/
Expand All @@ -26,6 +28,7 @@ export const validateListener = (listener) => {
/**
* Serialize valid event listener
* https://developer.mozilla.org/en-US/docs/Web/API/EventListener
*
* @param {EventListener} listener valid listener
* @returns {string}
*/
Expand Down
3 changes: 3 additions & 0 deletions src/helpers/adjust-set-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const shouldMatchAnyDelay = (delay) => delay === '*';

/**
* Handles input delay value
*
* @param {*} delay
* @returns {number} proper number delay value
*/
Expand All @@ -18,6 +19,7 @@ export const getMatchDelay = (delay) => {

/**
* Checks delay match condition
*
* @param {*} inputDelay
* @param {number} realDelay
* @returns {boolean}
Expand All @@ -29,6 +31,7 @@ export const isDelayMatched = (inputDelay, realDelay) => {

/**
* Handles input boost value
*
* @param {*} boost
* @returns {number} proper number boost multiplier value
*/
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/array-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Some browsers do not support Array.prototype.flat()
* for example, Opera 42 which is used for browserstack tests
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat
*
* @param {Array} input
*/
export const flatten = (input) => {
Expand All @@ -24,6 +25,7 @@ export const flatten = (input) => {

/**
* Predicate method to check if the array item exists
*
* @param {any} item
* @returns {boolean}
*/
Expand Down
13 changes: 13 additions & 0 deletions src/helpers/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const REMOVE_ATTR_CLASS_APPLYING = ['asap', 'stay', 'complete'];

/**
* Returns array of strings separated by space which not in quotes
*
* @param {string} str
*/
const getSentences = (str) => {
Expand All @@ -75,6 +76,7 @@ const getSentences = (str) => {

/**
* Replaces string with data by placeholders
*
* @param {string} str
* @param {object} data - where keys are placeholders names
*/
Expand Down Expand Up @@ -104,6 +106,7 @@ const splitArgs = (str) => {

/**
* Validates remove-attr/class scriptlet args
*
* @param {string[]} parsedArgs
* @returns {string[]|Error} valid args OR error for invalid selector
*/
Expand Down Expand Up @@ -147,6 +150,7 @@ const validateRemoveAttrClassArgs = (parsedArgs) => {

/**
* Converts string of UBO scriptlet rule to AdGuard scriptlet rule
*
* @param {string} rule - UBO scriptlet rule
* @returns {string[]} - array with one AdGuard scriptlet rule
*/
Expand Down Expand Up @@ -193,6 +197,7 @@ export const convertUboScriptletToAdg = (rule) => {

/**
* Convert string of ABP snippet rule to AdGuard scriptlet rule
*
* @param {string} rule - ABP snippet rule
* @returns {Array} - array of AdGuard scriptlet rules -
* one or few items depends on Abp-rule
Expand Down Expand Up @@ -221,6 +226,7 @@ export const convertAbpSnippetToAdg = (rule) => {

/**
* Converts scriptlet rule to AdGuard one
*
* @param {string} rule
* @returns {Array} - array of AdGuard scriptlet rules -
* one item for Adg and Ubo or few items for Abp
Expand All @@ -240,6 +246,7 @@ export const convertScriptletToAdg = (rule) => {

/**
* Converts UBO scriptlet rule to AdGuard one
*
* @param {string} rule - AdGuard scriptlet rule
* @returns {string} - UBO scriptlet rule
*/
Expand Down Expand Up @@ -328,6 +335,7 @@ export const convertAdgScriptletToUbo = (rule) => {

/**
* Checks whether the ADG scriptlet exists or UBO/ABP scriptlet is compatible to ADG
*
* @param {string} input - can be ADG or UBO or ABP scriptlet rule
* @returns {boolean}
*/
Expand All @@ -350,6 +358,7 @@ 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 {string} rule
Expand All @@ -373,6 +382,7 @@ const getMarkerData = (modifiers, redirectsData, rule) => {

/**
* Converts Ubo redirect rule to Adg one
*
* @param {string} rule
* @returns {string}
*/
Expand Down Expand Up @@ -403,6 +413,7 @@ export const convertUboRedirectToAdg = (rule) => {

/**
* Converts Abp redirect rule to Adg one
*
* @param {string} rule
* @returns {string}
*/
Expand All @@ -428,6 +439,7 @@ export const convertAbpRedirectToAdg = (rule) => {

/**
* Converts redirect rule to AdGuard one
*
* @param {string} rule
* @returns {string}
*/
Expand All @@ -452,6 +464,7 @@ export const convertRedirectToAdg = (rule) => {
* Source types are chosen according to redirect name
* e.g. ||ad.com^$redirect=<name>,important ->> ||ad.com^$redirect=<name>,important,script
* 3. Replaces Adg redirect name by Ubo analog
*
* @param {string} rule
* @returns {string}
*/
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/cookie-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,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
*/
Expand Down Expand Up @@ -124,6 +125,7 @@ export const parseCookieString = (cookieString) => {

/**
* Check if cookie with specified name and value is present in a cookie string
*
* @param {string} cookieString
* @param {string} name
* @param {string} value
Expand Down
1 change: 1 addition & 0 deletions src/helpers/create-on-error-handler.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Generates function which silents global errors on page generated by scriptlet
* If error doesn't belong to our error we transfer it to the native onError handler
*
* @param {string} rid - unique identifier of scriptlet
* @returns {onError}
*/
Expand Down
1 change: 1 addition & 0 deletions src/helpers/hit.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable no-console, no-underscore-dangle */
/**
* Hit used only for debug purposes now
*
* @param {Source} source
* use LOG_MARKER = 'log: ' at the start of a message
* for logging scriptlets
Expand Down
3 changes: 3 additions & 0 deletions src/helpers/injector.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Concat dependencies to scriptlet code
*
* @param {string} scriptlet string view of scriptlet
*/
export function attachDependencies(scriptlet) {
Expand All @@ -11,6 +12,7 @@ export function attachDependencies(scriptlet) {

/**
* Add scriptlet call to existing code
*
* @param {Function} scriptlet
* @param {string} code
*/
Expand Down Expand Up @@ -64,6 +66,7 @@ export function passSourceAndProps(source, code, redirect = false) {

/**
* Wrap code in no name function
*
* @param {string} code which must be wrapped
*/
export function wrapInNonameFunc(code) {
Expand Down
1 change: 1 addition & 0 deletions src/helpers/log-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Convention is to log messages by source.verbose if such log
* is not a part of scriptlet's functionality, eg on invalid input,
* and use 'forced' argument otherwise.
*
* @param {Source} source required
* @param {string} message required, message to log
* @param {boolean} [forced=false] to log message unconditionally
Expand Down
1 change: 1 addition & 0 deletions src/helpers/match-request-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { logMessage } from './log-message';
* Checks if given propsToMatch string matches with given request data
* This is used by prevent-xhr, prevent-fetch, trusted-replace-xhr-response
* 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
Expand Down
1 change: 1 addition & 0 deletions src/helpers/match-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getNativeRegexpTest } from './regexp-utils';
/**
* Checks if the stackTrace contains stackRegexp
* https://github.com/AdguardTeam/Scriptlets/issues/82
*
* @param {string|undefined} stackMatch - input stack value to match
* @param {string} stackTrace - script error stack trace
* @returns {boolean}
Expand Down
Loading

0 comments on commit f5d898e

Please sign in to comment.