From e41d475725276e8546d4754e83e0a13f943f4e7e Mon Sep 17 00:00:00 2001 From: Devarasetty Praneeth <89689768+praneeth622@users.noreply.github.com> Date: Fri, 4 Jul 2025 09:58:48 +0000 Subject: [PATCH] Remove development debug code from production builds (#10521) --- src/core/components/debug.jsx | 5 ++++- src/core/components/examples-select.jsx | 10 +++------- src/core/config/sources/query.js | 7 ++++++- src/core/plugins/spec/actions.js | 15 +++++++++++---- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/core/components/debug.jsx b/src/core/components/debug.jsx index a8b2d6c70bf..f7427cd8501 100644 --- a/src/core/components/debug.jsx +++ b/src/core/components/debug.jsx @@ -23,7 +23,10 @@ export default class Debug extends React.Component { let { getState, getComponent } = this.props - window.props = this.props + // Only expose props to window in development mode + if (process.env.NODE_ENV === "development") { + window.props = this.props + } const Collapse = getComponent("Collapse") diff --git a/src/core/components/examples-select.jsx b/src/core/components/examples-select.jsx index 4bdede4c13b..872bb1ee0ae 100644 --- a/src/core/components/examples-select.jsx +++ b/src/core/components/examples-select.jsx @@ -19,13 +19,9 @@ export default class ExamplesSelect extends React.PureComponent { static defaultProps = { examples: Map({}), - onSelect: (...args) => - // eslint-disable-next-line no-console - console.log( - // FIXME: remove before merging to master... - `DEBUG: ExamplesSelect was not given an onSelect callback`, - ...args - ), + onSelect: () => { + // No-op default callback + }, currentExampleKey: null, showLabels: true, } diff --git a/src/core/config/sources/query.js b/src/core/config/sources/query.js index 6ed14ba3d69..52d55908456 100644 --- a/src/core/config/sources/query.js +++ b/src/core/config/sources/query.js @@ -13,8 +13,13 @@ const optionsFromQuery = () => (options) => { const urlSearchParams = options.queryConfigEnabled ? parseSearch() : {} return Object.entries(urlSearchParams).reduce((acc, [key, value]) => { - // TODO(oliwia.rogala@smartbear.com): drop support for `config` in the next major release + // Legacy support for 'config' parameter (deprecated, will be removed in next major release) if (key === "config") { + if (process.env.NODE_ENV === "development") { + console.warn( + "The 'config' query parameter is deprecated and will be removed in the next major release. Use 'configUrl' instead." + ) + } acc["configUrl"] = value } else if (key === "urls.primaryName") { acc[key] = value diff --git a/src/core/plugins/spec/actions.js b/src/core/plugins/spec/actions.js index 8ea0c5801b2..db3b6f4649e 100644 --- a/src/core/plugins/spec/actions.js +++ b/src/core/plugins/spec/actions.js @@ -66,13 +66,20 @@ export const parseToJson = (str) => ({specActions, specSelectors, errActions}) = errActions.clear({ source: "parser" }) json = YAML.load(str, { schema: JSON_SCHEMA }) } catch(e) { - // TODO: push error to state - console.error(e) + // Handle parsing errors by creating proper error state + const errorMessage = e.reason || e.message || "Failed to parse specification" + const errorLine = e.mark && e.mark.line ? e.mark.line + 1 : undefined + + // Only log to console in development + if (process.env.NODE_ENV === "development") { + console.error("Spec parsing error:", e) + } + return errActions.newSpecErr({ source: "parser", level: "error", - message: e.reason, - line: e.mark && e.mark.line ? e.mark.line + 1 : undefined + message: errorMessage, + line: errorLine }) } if(json && typeof json === "object") {