Skip to content

Commit

Permalink
Merge pull request monti-apm#121 from monti-apm/chore/lint-changes
Browse files Browse the repository at this point in the history
chore: enables console rule as error on lint
  • Loading branch information
zodern authored May 15, 2024
2 parents 4e4e74a + 8429c3c commit efa7dda
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ rules:
no-catch-shadow: 2
no-class-assign: 2
no-cond-assign: 2
no-console: 0
no-console: 2
no-const-assign: 2
no-constant-condition: 2
no-continue: 0
Expand Down Expand Up @@ -277,3 +277,7 @@ rules:
prefer-rest-params: 0
symbol-description: 1
callback-return: 0
overrides:
- files: ['**/tests/**/*.{js,cjs,mjs}']
rules:
no-console: 0
3 changes: 2 additions & 1 deletion lib/common/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ Kadira.send = function (payload, path, callback) {
if (retryCount < 5) {
retry.retryLater(retryCount++, send);
} else {
console.warn('Error sending error traces to Monti APM server');
// eslint-disable-next-line no-console
console.warn('Monti APM: Error sending error traces to Monti APM server');
if (callback) {
callback(err);
}
Expand Down
1 change: 1 addition & 0 deletions lib/conflicting_agents.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const conflictingPackages = [
Meteor.startup(() => {
conflictingPackages.forEach(name => {
if (name in Package) {
// eslint-disable-next-line no-console
console.log(
`Monti APM: your app is using the ${name} package. Using more than one APM agent in an app can cause unexpected problems.`
);
Expand Down
3 changes: 3 additions & 0 deletions lib/hijack/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export function TrackUncaughtExceptions () {
// since we are capturing error, we are also on the error message.
// so developers think we are also reponsible for the error.
// But we are not. This will fix that.
// eslint-disable-next-line no-console
console.error(err.stack);
process.exit(7);
}
Expand Down Expand Up @@ -88,7 +89,9 @@ export function TrackUnhandledRejections () {

// We could emit a warning instead like Node does internally
// but it requires Node 8 or newer
// eslint-disable-next-line no-console
console.warn(message);
// eslint-disable-next-line no-console
console.error(reason && reason.stack ? reason.stack : reason);
});
}
Expand Down
1 change: 1 addition & 0 deletions lib/hijack/gc.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default class GCMetrics {
case constants.NODE_PERFORMANCE_GC_WEAKCB:
return 'gcWeakCB';
default:
// eslint-disable-next-line no-console
console.log(`Monti APM: Unrecognized GC Kind: ${gcKind}`);
}
}
Expand Down
1 change: 1 addition & 0 deletions lib/hijack/timeout_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const TimeoutManager = {

Monti.trackError(error, { type, subType: 'server', kadiraInfo });

// eslint-disable-next-line no-console
console.warn(`[Monti APM] ${error.message}`);
}, timeout);
},
Expand Down
1 change: 1 addition & 0 deletions lib/kadira.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
/* global MontiProfiler */

import { Meteor } from 'meteor/meteor';
Expand Down
2 changes: 2 additions & 0 deletions lib/models/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export function SystemModel () {
try {
await this.getFreeMemory();
} catch (e) {
// eslint-disable-next-line no-console
console.log('Monti APM: failed to get memory info', e);
}
}, 2000);
Expand Down Expand Up @@ -123,6 +124,7 @@ SystemModel.prototype.getFreeMemory = async function () {
return true;
}
} catch (e) {
// eslint-disable-next-line no-console
console.error('Monti APM: failed to get native memory info, falling back to default option', e);
}

Expand Down
1 change: 1 addition & 0 deletions lib/ntp.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ function getLogger () {
arguments[0] = message;
}

// eslint-disable-next-line no-console
console.log(...arguments);
};
}
1 change: 1 addition & 0 deletions lib/profiler/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ Kadira.profileCpu = function profileCpu () {
const message =
'Please install montiapm:profiler' +
' to take a CPU profile.';
// eslint-disable-next-line no-console
console.log(message);
};
3 changes: 3 additions & 0 deletions lib/sourcemaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export function handleApiResponse (body = {}) {
handleApiResponse(_body);
})
.catch(function (err) {
// eslint-disable-next-line no-console
console.log('Monti APM: unable to send data', err);
});
}
Expand All @@ -75,6 +76,7 @@ function sendSourcemap (sourcemap, sourcemapPath) {
let stream = fs.createReadStream(sourcemapPath);

stream.on('error', (err) => {
// eslint-disable-next-line no-console
console.log('Monti APM: error while uploading sourcemap', err);
});

Expand All @@ -84,6 +86,7 @@ function sendSourcemap (sourcemap, sourcemapPath) {

Kadira.coreApi.sendStream(`/sourcemap?arch=${arch}&archVersion=${archVersion}&file=${file}`, stream)
.catch(function (err) {
// eslint-disable-next-line no-console
console.log('Monti APM: error uploading sourcemap', err);
});
}
Expand Down
7 changes: 7 additions & 0 deletions lib/tracer/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Tracer.prototype.start = function (name, type, {
}

if (TRACE_TYPES.indexOf(type) === -1) {
// eslint-disable-next-line no-console
console.warn(`Monti APM: unknown trace type "${type}"`);
return null;
}
Expand Down Expand Up @@ -105,8 +106,11 @@ Tracer.prototype.event = function (traceInfo, type, data, metaData) {

if (lastEvent && !lastEvent.endAt) {
if (!lastEvent.nested) {
// eslint-disable-next-line no-console
console.error('Monti: invalid trace. Please share the trace below at');
// eslint-disable-next-line no-console
console.error('Monti: https://github.com/monti-apm/monti-apm-agent/issues/14');
// eslint-disable-next-line no-console
console.dir(traceInfo, { depth: 10 });
}
let lastNested = lastEvent.nested[lastEvent.nested.length - 1];
Expand Down Expand Up @@ -220,10 +224,12 @@ Tracer.prototype.buildTrace = function (traceInfo) {
let processedEvents = [];

if (firstEvent.type !== 'start') {
// eslint-disable-next-line no-console
console.warn('Monti APM: trace has not started yet');
return null;
} else if (lastEvent.type !== 'complete' && lastEvent.type !== 'error') {
// trace is not completed or errored yet
// eslint-disable-next-line no-console
console.warn('Monti APM: trace has not completed or errored yet');
return null;
}
Expand All @@ -250,6 +256,7 @@ Tracer.prototype.buildTrace = function (traceInfo) {
let event = traceInfo.events[lc];

if (!event.endAt) {
// eslint-disable-next-line no-console
console.error('Monti APM: no end event for type: ', event.type);
return null;
}
Expand Down
1 change: 1 addition & 0 deletions tools/mock_engine.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
const http = require('http');
const app = http.createServer((req, res) => {
console.log('AUTH:', req.headers);
Expand Down

0 comments on commit efa7dda

Please sign in to comment.