From 6e117be43642e17a207d56dd1308d0a8d8e19cea Mon Sep 17 00:00:00 2001 From: Zalmoxisus Date: Wed, 12 Dec 2018 22:45:37 +0200 Subject: [PATCH] Remove console logs in production --- .../redux-devtools-trace-monitor/.eslintrc | 2 +- .../src/StackTraceTab.js | 38 ++++++++++--------- .../utils/generateAnsiHTML.js | 2 +- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/packages/redux-devtools-trace-monitor/.eslintrc b/packages/redux-devtools-trace-monitor/.eslintrc index 6a079582..e5be8efc 100644 --- a/packages/redux-devtools-trace-monitor/.eslintrc +++ b/packages/redux-devtools-trace-monitor/.eslintrc @@ -24,7 +24,7 @@ "react/jsx-quotes": 0, "eol-last": 0, "no-unused-vars": 0, - "no-console": 0, + "no-console": 1, "comma-dangle": 0 }, "plugins": [ diff --git a/packages/redux-devtools-trace-monitor/src/StackTraceTab.js b/packages/redux-devtools-trace-monitor/src/StackTraceTab.js index 121a966f..7653d923 100644 --- a/packages/redux-devtools-trace-monitor/src/StackTraceTab.js +++ b/packages/redux-devtools-trace-monitor/src/StackTraceTab.js @@ -12,7 +12,7 @@ export default class StackTraceTab extends Component { }; } componentDidMount() { - //console.log("StackTraceTab mounted"); + // console.log("StackTraceTab mounted"); this.checkForStackTrace(); } @@ -38,10 +38,12 @@ export default class StackTraceTab extends Component { const deserializedError = Object.assign(new Error(), {stack: liftedAction.stack}); getStackFrames(deserializedError) - .then(stackFrames => { - console.log('Stack frames: ', stackFrames); - this.setState({stackFrames, currentError: deserializedError}); - }); + .then(stackFrames => { + /* eslint-disable no-console */ + if (process.env.NODE_ENV === 'development') console.log('Stack frames: ', stackFrames); + /* eslint-enable no-console */ + this.setState({stackFrames, currentError: deserializedError}); + }); } else { this.setState({stackFrames: []}); @@ -49,38 +51,38 @@ export default class StackTraceTab extends Component { } onStackLocationClicked = (fileLocation = {}) => { - //console.log("Stack location args: ", ...args); + // console.log("Stack location args: ", ...args); const {fileName, lineNumber} = fileLocation; if(fileName && lineNumber) { const matchingStackFrame = this.state.stackFrames.find(stackFrame => { const matches = ( - (stackFrame._originalFileName === fileName && stackFrame._originalLineNumber === lineNumber) || - (stackFrame.fileName === fileName && stackFrame.lineNumber === lineNumber) - ); + (stackFrame._originalFileName === fileName && stackFrame._originalLineNumber === lineNumber) || + (stackFrame.fileName === fileName && stackFrame.lineNumber === lineNumber) + ); return matches; }); - //console.log("Matching stack frame: ", matchingStackFrame); + // console.log("Matching stack frame: ", matchingStackFrame); if(matchingStackFrame) { - /* - const frameIndex = this.state.stackFrames.indexOf(matchingStackFrame); - const originalStackFrame = parsedFramesNoSourcemaps[frameIndex]; - console.log("Original stack frame: ", originalStackFrame); - */ + /* + const frameIndex = this.state.stackFrames.indexOf(matchingStackFrame); + const originalStackFrame = parsedFramesNoSourcemaps[frameIndex]; + console.log("Original stack frame: ", originalStackFrame); + */ const adjustedLineNumber = Math.max(lineNumber - 1, 0); chrome.devtools.panels.openResource(fileName, adjustedLineNumber, (result) => { - //console.log("openResource callback args: ", callbackArgs); - //console.log("Testing"); + //console.log("openResource callback args: ", callbackArgs); + //console.log("Testing"); if(result.isError) { const {fileName: finalFileName, lineNumber: finalLineNumber} = matchingStackFrame; const adjustedLineNumber = Math.max(finalLineNumber - 1, 0); chrome.devtools.panels.openResource(finalFileName, adjustedLineNumber, (result) => { - //console.log("openResource result: ", result); + // console.log("openResource result: ", result); }); } }); diff --git a/packages/redux-devtools-trace-monitor/src/react-error-overlay/utils/generateAnsiHTML.js b/packages/redux-devtools-trace-monitor/src/react-error-overlay/utils/generateAnsiHTML.js index 01248d76..79cc058e 100644 --- a/packages/redux-devtools-trace-monitor/src/react-error-overlay/utils/generateAnsiHTML.js +++ b/packages/redux-devtools-trace-monitor/src/react-error-overlay/utils/generateAnsiHTML.js @@ -86,7 +86,7 @@ function generateAnsiHTML(txt: string): string { result += '' + part + ''; } else { if (fg != null) { - console.log('Missing color mapping: ', fg); + console.log('Missing color mapping:', fg); // eslint-disable-line no-console } result += '' + part + ''; }