Skip to content

Linting: enforce no useless escape #13618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ module.exports = [
// also see: reality. These are here to stay.

eqeqeq: 'off',
'no-useless-escape': 'off',
'jsdoc/check-types': 'off',
'jsdoc/no-defaults': 'off',
'jsdoc/newline-after-description': 'off',
Expand Down Expand Up @@ -241,6 +240,7 @@ module.exports = [
'no-unused-expressions': 'off',
'no-undef': 'off',
'no-unused-vars': 'off',
'no-useless-escape': 'off',
'no-return-assign': 'off',
'camelcase': 'off'
}
Expand Down
3 changes: 2 additions & 1 deletion libraries/dspxUtils/bidderUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export function fillUsersIds(bidRequest, payload) {
did_pubcid: 'pubcid.org',
did_cruid: 'criteo.com',
did_tdid: 'adserver.org',
did_pbmid: 'regexp:[esp\.]*pubmatic\.com',
// eslint-disable-next-line no-useless-escape
did_pbmid: 'regexp:^(?:esp\.)?pubmatic\.com$',
did_id5: 'id5-sync.com',
did_uqid: 'utiq.com',
did_id5_linktype: ['id5-sync.com', function (e) {
Expand Down
2 changes: 1 addition & 1 deletion modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ function _parseNativeBidResponse(bid) {
native.impressionTrackers.push(tracker.url);
break;
case 2:
const script = `<script async src=\"${tracker.url}\"></script>`;
const script = `<script async src="${tracker.url}"></script>`;
if (!native.javascriptTrackers) {
native.javascriptTrackers = script;
} else {
Expand Down
2 changes: 1 addition & 1 deletion modules/adhashBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function brandSafety(badWords, maxScore) {
let score = 0;
const decodedUrl = decodeURI(window.top.location.href.substring(window.top.location.origin.length));
const wordsAndNumbersInUrl = decodedUrl
.replaceAll(/[-,\._/\?=&#%]/g, ' ')
.replaceAll(/[-,._/?=&#%]/g, ' ')
.replaceAll(/\s\s+/g, ' ')
.toLowerCase()
.trim();
Expand Down
12 changes: 6 additions & 6 deletions modules/adkernelAdnAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,12 @@ export function getUmtSource(pageUrl, referrer) {

function getSearchEngine(pageUrl) {
const engines = {
'google': /^https?\:\/\/(?:www\.)?(?:google\.(?:com?\.)?(?:com|cat|[a-z]{2})|g.cn)\//i,
'yandex': /^https?\:\/\/(?:www\.)?ya(?:ndex\.(?:com|net)?\.?(?:asia|mobi|org|[a-z]{2})?|\.ru)\//i,
'bing': /^https?\:\/\/(?:www\.)?bing\.com\//i,
'duckduckgo': /^https?\:\/\/(?:www\.)?duckduckgo\.com\//i,
'ask': /^https?\:\/\/(?:www\.)?ask\.com\//i,
'yahoo': /^https?\:\/\/(?:[-a-z]+\.)?(?:search\.)?yahoo\.com\//i
'google': /^https?:\/\/(?:www\.)?(?:google\.(?:com?\.)?(?:com|cat|[a-z]{2})|g.cn)\//i,
'yandex': /^https?:\/\/(?:www\.)?ya(?:ndex\.(?:com|net)?\.?(?:asia|mobi|org|[a-z]{2})?|\.ru)\//i,
'bing': /^https?:\/\/(?:www\.)?bing\.com\//i,
'duckduckgo': /^https?:\/\/(?:www\.)?duckduckgo\.com\//i,
'ask': /^https?:\/\/(?:www\.)?ask\.com\//i,
'yahoo': /^https?:\/\/(?:[-a-z]+\.)?(?:search\.)?yahoo\.com\//i
};

for (const engine in engines) {
Expand Down
2 changes: 1 addition & 1 deletion modules/beopBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function buildTrackingParams(data, info, value) {
const params = Array.isArray(data.params) ? data.params[0] : data.params;
const pageUrl = getPageUrl(null, window);
return {
pid: params.accountId ?? (data.ad?.match(/account: \“([a-f\d]{24})\“/)?.[1] ?? ''),
pid: params.accountId ?? (data.ad?.match(/account: “([a-f\d]{24})“/)?.[1] ?? ''),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curly quotes are surprising

nid: params.networkId,
nptnid: params.networkPartnerId,
bid: data.bidId || data.requestId,
Expand Down
2 changes: 1 addition & 1 deletion modules/debugging/responses.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function mapDefaultNativeOrtbAsset(asset) {
return {
...asset,
video: {
vasttag: '<?xml version=\"1.0\" encoding=\"UTF-8\"?><VAST version=\"3.0\"><Ad><InLine><AdSystem>GDFP</AdSystem><AdTitle>Demo</AdTitle><Description><![CDATA[Demo]]></Description><Creatives><Creative><Linear ><Duration>00:00:11</Duration><VideoClicks><ClickThrough><![CDATA[https://prebid.org/]]></ClickThrough></VideoClicks><MediaFiles><MediaFile delivery=\"progressive\" width=\"640\" height=\"360\" type=\"video/mp4\" scalable=\"true\" maintainAspectRatio=\"true\"><![CDATA[https://s3.amazonaws.com/files.prebid.org/creatives/PrebidLogo.mp4]]></MediaFile></MediaFiles></Linear></Creative></Creatives></InLine></Ad></VAST>'
vasttag: '<?xml version="1.0" encoding="UTF-8"?><VAST version="3.0"><Ad><InLine><AdSystem>GDFP</AdSystem><AdTitle>Demo</AdTitle><Description><![CDATA[Demo]]></Description><Creatives><Creative><Linear ><Duration>00:00:11</Duration><VideoClicks><ClickThrough><![CDATA[https://prebid.org/]]></ClickThrough></VideoClicks><MediaFiles><MediaFile delivery="progressive" width="640" height="360" type="video/mp4" scalable="true" maintainAspectRatio="true"><![CDATA[https://s3.amazonaws.com/files.prebid.org/creatives/PrebidLogo.mp4]]></MediaFile></MediaFiles></Linear></Creative></Creatives></InLine></Ad></VAST>'
}
}
case 'data': {
Expand Down
6 changes: 3 additions & 3 deletions modules/fintezaAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ function getAntiCacheParam() {

function replaceBidder(str, bidder) {
let _str = str;
_str = _str.replace(/\%bidder\%/, bidder.toLowerCase());
_str = _str.replace(/\%BIDDER\%/, bidder.toUpperCase());
_str = _str.replace(/\%Bidder\%/, bidder.charAt(0).toUpperCase() + bidder.slice(1).toLowerCase());
_str = _str.replace(/%bidder%/, bidder.toLowerCase());
_str = _str.replace(/%BIDDER%/, bidder.toUpperCase());
_str = _str.replace(/%Bidder%/, bidder.charAt(0).toUpperCase() + bidder.slice(1).toLowerCase());

return _str;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/mediafuseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const NATIVE_MAPPING = {
const SOURCE = 'pbjs';
const MAX_IMPS_PER_REQUEST = 15;
const SCRIPT_TAG_START = '<script';
const VIEWABILITY_URL_START = /\/\/cdn\.adnxs\.com\/v|\/\/cdn\.adnxs\-simple\.com\/v/;
const VIEWABILITY_URL_START = /\/\/cdn\.adnxs\.com\/v|\/\/cdn\.adnxs-simple\.com\/v/;
const VIEWABILITY_FILE_NAME = 'trk.js';
const GVLID = 32;
const storage = getStorageManager({bidderCode: BIDDER_CODE});
Expand Down
2 changes: 1 addition & 1 deletion modules/mediakeysBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ function nativeBidResponseHandler(bid) {
native.impressionTrackers.push(tracker.url);
break;
case 2:
const script = `<script async src=\"${tracker.url}\"></script>`;
const script = `<script async src="${tracker.url}"></script>`;
if (!native.javascriptTrackers) {
native.javascriptTrackers = script;
} else {
Expand Down
2 changes: 1 addition & 1 deletion modules/nativoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ export function getPageUrlFromBidRequest(bidRequest) {
}

export function hasProtocol(url) {
const protocolRegexp = /^http[s]?\:/
const protocolRegexp = /^http[s]?:/
return protocolRegexp.test(url)
}

Expand Down
4 changes: 2 additions & 2 deletions modules/nobidBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function nobidBuildRequests(bids, bidderRequest) {
// TODO: does this fallback make sense here?
ret = (window.context && window.context.location && window.context.location.href) ? window.context.location.href : document.location.href;
}
return encodeURIComponent(ret.replace(/\%/g, ''));
return encodeURIComponent(ret.replace(/%/g, ''));
}
var timestamp = function() {
var date = new Date();
Expand Down Expand Up @@ -153,7 +153,7 @@ function nobidBuildRequests(bids, bidderRequest) {
state['sid'] = siteId;
state['l'] = topLocation(bidderRequest);
state['tt'] = encodeURIComponent(document.title);
state['tt'] = state['tt'].replace(/'|;|quot;|39;|&amp;|&|#|\r\n|\r|\n|\t|\f|\%0A|\"|\%22|\%5C|\%23|\%26|\%26|\%09/gm, '');
state['tt'] = state['tt'].replace(/'|;|quot;|39;|&amp;|&|#|\r\n|\r|\n|\t|\f|%0A|"|%22|%5C|%23|%26|%26|%09/gm, '');
state['a'] = filterAdUnitsByIds(divIds, adunits || []);
state['t'] = timestamp();
state['tz'] = Math.round(new Date().getTimezoneOffset());
Expand Down
2 changes: 1 addition & 1 deletion modules/outbrainBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ function parseNative(bid) {
result.impressionTrackers.push(tracker.url);
break;
case 2: // js
result.javascriptTrackers = `<script src=\"${tracker.url}\"></script>`;
result.javascriptTrackers = `<script src="${tracker.url}"></script>`;
break;
}
});
Expand Down
2 changes: 1 addition & 1 deletion modules/ozoneBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const spec = {
logError(err1.replace('{param}', 'publisherId'), adUnitCode);
return false;
}
if (!(bid.params.publisherId).toString().match(/^[a-zA-Z0-9\-]{12}$/)) {
if (!(bid.params.publisherId).toString().match(/^[a-zA-Z0-9-]{12}$/)) {
logError(`${vf} : publisherId must be /^[a-zA-Z0-9\\-]{12}$/`, adUnitCode);
return false;
}
Expand Down
24 changes: 12 additions & 12 deletions modules/pubmaticAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@ const MEDIATYPE = {

// TODO : Remove - Once BM calculation moves to Server Side
const BROWSER_MAP = [
{ value: /(firefox)\/([\w\.]+)/i, key: 12 }, // Firefox
{ value: /\b(?:crios)\/([\w\.]+)/i, key: 1 }, // Chrome for iOS
{ value: /edg(?:e|ios|a)?\/([\w\.]+)/i, key: 2 }, // Edge
{ value: /(opera|opr)(?:.+version\/|[\/ ]+)([\w\.]+)/i, key: 3 }, // Opera
{ value: /(?:ms|\()(ie) ([\w\.]+)|(?:trident\/[\w\.]+)/i, key: 4 }, // Internet Explorer
{ value: /fxios\/([-\w\.]+)/i, key: 5 }, // Firefox for iOS
{ value: /((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i, key: 6 }, // Facebook In-App Browser
{ value: / wv\).+(chrome)\/([\w\.]+)/i, key: 7 }, // Chrome WebView
{ value: /droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i, key: 8 }, // Android Browser
{ value: /(chrome|chromium|crios)\/v?([\w\.]+)/i, key: 9 }, // Chrome
{ value: /version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i, key: 10 }, // Safari Mobile
{ value: /version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i, key: 11 }, // Safari
{ value: /(firefox)\/([\w.]+)/i, key: 12 }, // Firefox
{ value: /\b(?:crios)\/([\w.]+)/i, key: 1 }, // Chrome for iOS
{ value: /edg(?:e|ios|a)?\/([\w.]+)/i, key: 2 }, // Edge
{ value: /(opera|opr)(?:.+version\/|[/ ]+)([\w.]+)/i, key: 3 }, // Opera
{ value: /(?:ms|\()(ie) ([\w.]+)|(?:trident\/[\w.]+)/i, key: 4 }, // Internet Explorer
{ value: /fxios\/([-\w.]+)/i, key: 5 }, // Firefox for iOS
{ value: /((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w.]+);)/i, key: 6 }, // Facebook In-App Browser
{ value: / wv\).+(chrome)\/([\w.]+)/i, key: 7 }, // Chrome WebView
{ value: /droid.+ version\/([\w.]+)\b.+(?:mobile safari|safari)/i, key: 8 }, // Android Browser
{ value: /(chrome|chromium|crios)\/v?([\w.]+)/i, key: 9 }, // Chrome
{ value: /version\/([\w.,]+) .*mobile\/\w+ (safari)/i, key: 10 }, // Safari Mobile
{ value: /version\/([\w(.|,]+) .*(mobile ?safari|safari)/i, key: 11 }, // Safari
];

/// /////////// VARIABLES //////////////
Expand Down
24 changes: 12 additions & 12 deletions modules/pubmaticRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ export const CONSTANTS = Object.freeze({
});

const BROWSER_REGEX_MAP = [
{ regex: /\b(?:crios)\/([\w\.]+)/i, id: 1 }, // Chrome for iOS
{ regex: /(edg|edge)(?:e|ios|a)?(?:\/([\w\.]+))?/i, id: 2 }, // Edge
{ regex: /(opera|opr)(?:.+version\/|[\/ ]+)([\w\.]+)/i, id: 3 }, // Opera
{ regex: /(?:ms|\()(ie) ([\w\.]+)|(?:trident\/[\w\.]+)/i, id: 4 }, // Internet Explorer
{ regex: /fxios\/([-\w\.]+)/i, id: 5 }, // Firefox for iOS
{ regex: /((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i, id: 6 }, // Facebook In-App Browser
{ regex: / wv\).+(chrome)\/([\w\.]+)/i, id: 7 }, // Chrome WebView
{ regex: /droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i, id: 8 }, // Android Browser
{ regex: /(chrome|crios)(?:\/v?([\w\.]+))?\b/i, id: 9 }, // Chrome
{ regex: /version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i, id: 10 }, // Safari Mobile
{ regex: /version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i, id: 11 }, // Safari
{ regex: /(firefox)\/([\w\.]+)/i, id: 12 } // Firefox
{ regex: /\b(?:crios)\/([\w.]+)/i, id: 1 }, // Chrome for iOS
{ regex: /(edg|edge)(?:e|ios|a)?(?:\/([\w.]+))?/i, id: 2 }, // Edge
{ regex: /(opera|opr)(?:.+version\/|[/ ]+)([\w.]+)/i, id: 3 }, // Opera
{ regex: /(?:ms|\()(ie) ([\w.]+)|(?:trident\/[\w.]+)/i, id: 4 }, // Internet Explorer
{ regex: /fxios\/([-\w.]+)/i, id: 5 }, // Firefox for iOS
{ regex: /((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w.]+);)/i, id: 6 }, // Facebook In-App Browser
{ regex: / wv\).+(chrome)\/([\w.]+)/i, id: 7 }, // Chrome WebView
{ regex: /droid.+ version\/([\w.]+)\b.+(?:mobile safari|safari)/i, id: 8 }, // Android Browser
{ regex: /(chrome|crios)(?:\/v?([\w.]+))?\b/i, id: 9 }, // Chrome
{ regex: /version\/([\w.,]+) .*mobile\/\w+ (safari)/i, id: 10 }, // Safari Mobile
{ regex: /version\/([\w(.|,]+) .*(mobile ?safari|safari)/i, id: 11 }, // Safari
{ regex: /(firefox)\/([\w.]+)/i, id: 12 } // Firefox
];

export const defaultValueTemplate = {
Expand Down
2 changes: 1 addition & 1 deletion modules/readpeakBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function impression(slot) {
const floorInfo = slot.getFloor({
currency: 'USD',
mediaType: 'native',
size: '\*'
size: '*'
});
bidFloorFromModule = floorInfo?.currency === 'USD' ? floorInfo?.floor : undefined;
}
Expand Down
4 changes: 2 additions & 2 deletions modules/relaidoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ function onBidWon(bid) {
ad_id: deepAccess(bid, 'adId'),
ad_unit_code: deepAccess(bid, 'adUnitCode'),
ref: window.location.href,
}).replace(/\&$/, '');
}).replace(/&$/, '');
const bidDomain = deepAccess(bid, 'params.0.domain') || BIDDER_DOMAIN;
const burl = `https://${bidDomain}/tr/v1/prebid/win.gif?${query}`;
triggerPixel(burl);
Expand All @@ -219,7 +219,7 @@ function onTimeout(data) {
ad_unit_code: deepAccess(data, '0.adUnitCode'),
version: ADAPTER_VERSION,
ref: window.location.href,
}).replace(/\&$/, '');
}).replace(/&$/, '');
const bidDomain = deepAccess(data, '0.params.0.domain') || BIDDER_DOMAIN;
const timeoutUrl = `https://${bidDomain}/tr/v1/prebid/timeout.gif?${query}`;
triggerPixel(timeoutUrl);
Expand Down
2 changes: 1 addition & 1 deletion modules/smarticoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const spec = {

url = SMARTICO_CONFIG.widgetUrl + '?token=' + encodeURIComponent(token) + '&auction-id=' + encodeURIComponent(bid.auctionId) + '&from-auction-buffer=1&own_session=1&ad=' + encodeURIComponent(ad.id) + '&scriptid=' + scriptId + (ad.bannerFormatAlias ? '&banner-format=' + encodeURIComponent(ad.bannerFormatAlias) : '') + (language ? '&language=' + encodeURIComponent(language) : '')

html = '<script id="' + scriptId + '" async defer type="text/javascript" src="' + url + '"><\/script>'
html = '<script id="' + scriptId + '" async defer type="text/javascript" src="' + url + '"></script>'

bidObject = {
requestId: bid.bidId,
Expand Down
2 changes: 1 addition & 1 deletion modules/sonobiBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const spec = {
buildRequests: (validBidRequests, bidderRequest) => {
const bids = validBidRequests.map(bid => {
let slotIdentifier = _validateSlot(bid);
if (/^[\/]?[\d]+[[\/].+[\/]?]?$/.test(slotIdentifier)) {
if (/^\/?\d+\/.+\/?$/.test(slotIdentifier)) {
slotIdentifier = slotIdentifier.charAt(0) === '/' ? slotIdentifier : '/' + slotIdentifier;
return {
[`${slotIdentifier}|${bid.bidId}`]: `${_validateSize(bid)}|${_validateFloor(bid)}${_validateGPID(bid)}${_validateMediaType(bid)}`
Expand Down
4 changes: 2 additions & 2 deletions modules/tappxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,8 @@ export function _getHostInfo(validBidRequests) {

domainInfo.domain = hostParam.split('/', 1)[0];

const regexHostParamHttps = new RegExp(`^https:\/\/`);
const regexHostParamHttp = new RegExp(`^http:\/\/`);
const regexHostParamHttps = new RegExp('^https://');
const regexHostParamHttp = new RegExp('^http://');

const regexNewEndpoints = new RegExp(`^(vz.*|zz.*)\\.[a-z]{3}\\.tappx\\.com$`, 'i');
const regexClassicEndpoints = new RegExp(`^([a-z]{3}|testing)\\.[a-z]{3}\\.tappx\\.com$`, 'i');
Expand Down
Loading