Skip to content

Commit

Permalink
enable no-console eslint rule for project (prebid#4802)
Browse files Browse the repository at this point in the history
* add no-console eslint rule for tests directory

* remove console logs from onetag tests

* update scope of rule to include src files
  • Loading branch information
jsnellbaker authored and rjvelicaria committed Apr 9, 2020
1 parent 92c0b12 commit 5b6f579
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 21 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module.exports = {
"no-throw-literal": "off",
"no-undef": 2,
"no-useless-escape": "off",
"no-console": "error"
},
"overrides": Object.keys(allowedModules).map((key) => ({
"files": key + "/**/*.js",
Expand Down
8 changes: 4 additions & 4 deletions modules/adxpremiumAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ let googletag = window.googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function() {
googletag.pubads().addEventListener('slotRenderEnded', args => {
console.log(Date.now() + ' GOOGLE SLOT: ' + JSON.stringify(args));
utils.logInfo(Date.now() + ' GOOGLE SLOT: ' + JSON.stringify(args));
});
});

Expand All @@ -72,7 +72,7 @@ let bidResponsesMapper = {};
function auctionInit(args) {
completeObject.auction_id = args.auctionId;
completeObject.publisher_id = adxpremiumAnalyticsAdapter.initOptions.pubId;
try { completeObject.referer = args.bidderRequests[0].refererInfo.referer.split('?')[0]; } catch (e) { console.log(e.message); }
try { completeObject.referer = args.bidderRequests[0].refererInfo.referer.split('?')[0]; } catch (e) { utils.logWarn('Could not parse referer, error details:', e.message); }
completeObject.device_type = deviceType();
}
function bidRequested(args) {
Expand Down Expand Up @@ -130,11 +130,11 @@ function sendEvent(completeObject) {
let responseEvents = btoa(JSON.stringify(completeObject));
let mutation = `mutation {createEvent(input: {event: {eventData: "${responseEvents}"}}) {event {createTime } } }`;
let dataToSend = JSON.stringify({ query: mutation });
ajax(url, function () { console.log(Date.now() + ' Sending event to adxpremium server.') }, dataToSend, {
ajax(url, function () { utils.logInfo(Date.now() + ' Sending event to adxpremium server.') }, dataToSend, {
contentType: 'application/json',
method: 'POST'
});
} catch (err) { console.log(err) }
} catch (err) { utils.logError('Could not send event, error details:', err) }
}

// save the base class function
Expand Down
2 changes: 1 addition & 1 deletion modules/nobidBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function nobidBuildRequests(bids, bidderRequest) {
var height = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
return `${width}x${height}`;
} catch (e) {
console.error(e);
utils.logWarn('Could not parse screen dimensions, error details:', e);
}
}
var state = {};
Expand Down
5 changes: 3 additions & 2 deletions modules/sharethroughBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { registerBidder } from '../src/adapters/bidderFactory.js';
import * as utils from '../src/utils.js';

const VERSION = '3.2.1';
const BIDDER_CODE = 'sharethrough';
Expand Down Expand Up @@ -181,7 +182,7 @@ function handleIframe () {
window.document.getElementsByTagName('body')[0].appendChild(sfpIframeBusterJs);
iframeBusterLoaded = true;
} catch (e) {
console.error(e);
utils.logError('Trouble writing frame buster script, error details:', e);
}
}

Expand All @@ -199,7 +200,7 @@ function handleIframe () {
window.document.getElementsByTagName('body')[0].appendChild(sfpJs);
}
} catch (e) {
console.error(e);
utils.logError('Trouble writing sfp script, error details:', e);
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions modules/sovrnBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ export const spec = {
options: {contentType: 'text/plain'}
}
} catch (e) {
console.log('error in build:')
console.log(e)
utils.logError('Could not build bidrequest, error deatils:', e);
}
},

Expand Down Expand Up @@ -143,8 +142,7 @@ export const spec = {
}
return sovrnBidResponses
} catch (e) {
console.log('error in interpret:')
console.log(e)
utils.logError('Could not intrepret bidresponse, error deatils:', e);
}
},

Expand Down
1 change: 1 addition & 0 deletions src/adapters/analytics/example2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
import { ajax } from '../../../src/ajax.js';

/**
Expand Down
1 change: 1 addition & 0 deletions src/adapters/analytics/libraries/example.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
/** @module example */

window.ExampleAnalyticsGlobalObject = function(hander, type, data) {
Expand Down
1 change: 1 addition & 0 deletions src/adapters/analytics/libraries/example2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
/** @module example */

window.ExampleAnalyticsGlobalObject2 = function(hander, type, data) {
Expand Down
1 change: 1 addition & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
import { config } from './config.js';
import clone from 'just-clone';
import find from 'core-js/library/fn/array/find.js';
Expand Down
2 changes: 1 addition & 1 deletion test/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ module.exports = {
"no-unused-vars": "off",
"no-use-before-define": "off",
"no-useless-escape": "off",
"one-var": "off",
"one-var": "off"
}
};
1 change: 1 addition & 0 deletions test/mock-server/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
const express = require('express');
const argv = require('yargs').argv;
const app = module.exports = express();
Expand Down
8 changes: 2 additions & 6 deletions test/spec/modules/onetagBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,14 @@ describe('onetag', function () {
expect(bid.pubId).to.be.a('string');
}
});
} catch (e) {
console.log('Error while parsing');
}
} catch (e) {}
it('Returns empty data if no valid requests are passed', function () {
serverRequest = spec.buildRequests([]);
let dataString = serverRequest.data;
try {
let dataObj = JSON.parse(dataString);
expect(dataObj.bids).to.be.an('array').that.is.empty;
} catch (e) {
console.log('Error while parsing');
}
} catch (e) {}
});
it('should send GDPR consent data', function () {
let consentString = 'consentString';
Expand Down
2 changes: 0 additions & 2 deletions test/spec/modules/tribeosBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ describe('tribeosBidAdapter', function() {
expect(bids).to.have.lengthOf(1);
let bid = bids[0];

console.error(JSON.stringify(bid));

expect(bid.cpm).to.equal(1.1);
expect(bid.currency).to.equal('USD');
expect(bid.width).to.equal(300);
Expand Down
2 changes: 1 addition & 1 deletion test/spec/unit/pbjs_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ describe('Unit: Prebid Module', function () {
try {
$$PREBID_GLOBAL$$.requestBids({});
} catch (e) {
console.log(e);
console.log(e); // eslint-disable-line
}
assert.ok(logMessageSpy.calledWith('No adUnits configured. No bids requested.'), 'expected message was logged');
});
Expand Down

0 comments on commit 5b6f579

Please sign in to comment.