From c3360533981fb35c5038e201e5d8dbefb2f49cc4 Mon Sep 17 00:00:00 2001 From: Matt Fisher Date: Fri, 25 Jul 2025 12:01:28 -0600 Subject: [PATCH 1/3] Forbid console.log and console.info Console calls, IMO, should be for debugging only. They're useful for users facing bugs to share information about any unexpected events. Instead of using `console.log` as a catch-all, I'd like to think more carefully about the purpose of each message, and either omit or log it as an error, warning, or debug message. --- .eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.js b/.eslintrc.js index 62776d2df..4c4f8e7b1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -51,6 +51,7 @@ module.exports = { } ], "prefer-arrow-callback": "error", + "no-console": ["error", {"allow": ["error", "warn", "debug"]}], "no-duplicate-imports": "error", }, }; From e337d4a7fc9dfa002ad5fc05a631347b50d9c94f Mon Sep 17 00:00:00 2001 From: Matt Fisher Date: Fri, 25 Jul 2025 12:05:21 -0600 Subject: [PATCH 2/3] Clean up console calls Remove log and info calls or convert them to other calls. Clean up some messages. --- packages/base/src/commands/index.ts | 3 +-- .../src/dialogs/symbology/vector_layer/types/Categorized.tsx | 2 -- packages/base/src/mainview/mainView.tsx | 2 +- packages/base/src/stacBrowser/hooks/useStacSearch.ts | 4 ++-- packages/base/src/tools.ts | 5 ++++- packages/schema/src/model.ts | 3 +-- python/jupytergis_core/src/jgisplugin/plugins.ts | 1 - python/jupytergis_core/src/plugin.ts | 3 --- python/jupytergis_lab/src/index.ts | 1 - python/jupytergis_qgis/src/plugins.ts | 2 -- 10 files changed, 9 insertions(+), 17 deletions(-) diff --git a/packages/base/src/commands/index.ts b/packages/base/src/commands/index.ts index d702984cf..858a085ae 100644 --- a/packages/base/src/commands/index.ts +++ b/packages/base/src/commands/index.ts @@ -740,7 +740,6 @@ export function addCommands( if (!currentWidget || !completionProviderManager) { return; } - console.log('zooming'); const model = tracker.currentWidget.model; const selectedItems = model.localState?.selected.value; @@ -961,7 +960,7 @@ namespace Private { const selected = model?.localState?.selected?.value; if (!selected) { - console.info('Nothing selected'); + console.error('Failed to remove selected item -- nothing selected'); return; } diff --git a/packages/base/src/dialogs/symbology/vector_layer/types/Categorized.tsx b/packages/base/src/dialogs/symbology/vector_layer/types/Categorized.tsx index fc7fcf002..5a1fa15b2 100644 --- a/packages/base/src/dialogs/symbology/vector_layer/types/Categorized.tsx +++ b/packages/base/src/dialogs/symbology/vector_layer/types/Categorized.tsx @@ -203,8 +203,6 @@ const Categorized: React.FC = ({ const newStyle = { ...layer.parameters.color }; if (method === 'color') { - console.log('delecol'); - delete newStyle['fill-color']; delete newStyle['stroke-color']; delete newStyle['circle-fill-color']; diff --git a/packages/base/src/mainview/mainView.tsx b/packages/base/src/mainview/mainView.tsx index 8b0a1ece8..8f4c0ca4a 100644 --- a/packages/base/src/mainview/mainView.tsx +++ b/packages/base/src/mainview/mainView.tsx @@ -2110,7 +2110,7 @@ export class MainView extends React.Component { const olLayer = this.getLayer(layerId); if (!jgisLayer || !olLayer) { - console.log('Layer not found'); + console.error('Failed to update layer -- layer not found'); return; } diff --git a/packages/base/src/stacBrowser/hooks/useStacSearch.ts b/packages/base/src/stacBrowser/hooks/useStacSearch.ts index 5d07ace63..6decadc4a 100644 --- a/packages/base/src/stacBrowser/hooks/useStacSearch.ts +++ b/packages/base/src/stacBrowser/hooks/useStacSearch.ts @@ -209,7 +209,7 @@ function useStacSearch({ model }: IUseStacSearchProps): IUseStacSearchReturn { )) as IStacSearchResult; if (!data) { - console.log('No Results found'); + console.debug('STAC search failed -- no results found'); setResults([]); setTotalPages(1); setTotalResults(0); @@ -221,7 +221,7 @@ function useStacSearch({ model }: IUseStacSearchProps): IUseStacSearchReturn { setTotalPages(Math.ceil(pages)); setTotalResults(data.context.matched); } catch (error) { - console.error('Error fetching data:', error); + console.error('STAC search failed -- error fetching data:', error); setResults([]); setTotalPages(1); setTotalResults(0); diff --git a/packages/base/src/tools.ts b/packages/base/src/tools.ts index 855d98374..0fb3693d3 100644 --- a/packages/base/src/tools.ts +++ b/packages/base/src/tools.ts @@ -111,7 +111,10 @@ export async function requestAPI( try { data = JSON.parse(data); } catch (error) { - console.log('Not a JSON response body.', response); + console.error( + 'Jupyter API request failed -- not a JSON response body:', + response, + ); } } diff --git a/packages/schema/src/model.ts b/packages/schema/src/model.ts index 27622a0d9..a80f6562f 100644 --- a/packages/schema/src/model.ts +++ b/packages/schema/src/model.ts @@ -69,7 +69,6 @@ export class JupyterGISModel implements IJupyterGISModel { setting.changed.connect(() => { this._settings = setting.composite as any; - console.log('JupyterGIS Settings updated:', this._settings); }); } } @@ -628,7 +627,7 @@ export class JupyterGISModel implements IJupyterGISModel { layerTreeInfo.mainGroup, ); } else { - console.log('Something went wrong when renaming layer'); + console.error('Layer group rename failed -- could not get layer tree.'); } } diff --git a/python/jupytergis_core/src/jgisplugin/plugins.ts b/python/jupytergis_core/src/jgisplugin/plugins.ts index d3c390680..afd4b44a9 100644 --- a/python/jupytergis_core/src/jgisplugin/plugins.ts +++ b/python/jupytergis_core/src/jgisplugin/plugins.ts @@ -65,7 +65,6 @@ const activate = async ( try { settings = await settingRegistry.load(SETTINGS_ID); - console.log(`Loaded settings for ${SETTINGS_ID}`, settings); } catch (error) { console.warn(`Failed to load settings for ${SETTINGS_ID}`, error); } diff --git a/python/jupytergis_core/src/plugin.ts b/python/jupytergis_core/src/plugin.ts index 2dfec7bc2..951cb3fdc 100644 --- a/python/jupytergis_core/src/plugin.ts +++ b/python/jupytergis_core/src/plugin.ts @@ -41,7 +41,6 @@ export const trackerPlugin: JupyterFrontEndPlugin = { const tracker = new WidgetTracker({ namespace: NAME_SPACE, }); - console.log('jupytergis:core:tracker is activated!'); return tracker; }, }; @@ -80,8 +79,6 @@ export const layerBrowserRegistryPlugin: JupyterFrontEndPlugin { - console.log('jupytergis:core:layer-browser-registry is activated'); - const registry = new JupyterGISLayerBrowserRegistry(); return registry; }, diff --git a/python/jupytergis_lab/src/index.ts b/python/jupytergis_lab/src/index.ts index 205f4b7c3..49e092765 100644 --- a/python/jupytergis_lab/src/index.ts +++ b/python/jupytergis_lab/src/index.ts @@ -59,7 +59,6 @@ const plugin: JupyterFrontEndPlugin = { translator?: ITranslator, completionProviderManager?: ICompletionProviderManager, ): void => { - console.log('jupytergis:lab:main-menu is activated!'); translator = translator ?? nullTranslator; const isEnabled = (): boolean => { return ( diff --git a/python/jupytergis_qgis/src/plugins.ts b/python/jupytergis_qgis/src/plugins.ts index 00008cdec..4ab2444b2 100644 --- a/python/jupytergis_qgis/src/plugins.ts +++ b/python/jupytergis_qgis/src/plugins.ts @@ -302,8 +302,6 @@ const activate = async ( }); } } - - console.log('@jupytergis/jupytergis-qgis:qgisplugin is activated!'); }; export const qgisplugin: JupyterFrontEndPlugin = { From af6807f40618d754b4919ea75ef9f21743e34cf3 Mon Sep 17 00:00:00 2001 From: Matt Fisher Date: Fri, 25 Jul 2025 12:12:11 -0600 Subject: [PATCH 3/3] Cleanup unused variable --- python/jupytergis_core/src/jgisplugin/plugins.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/python/jupytergis_core/src/jgisplugin/plugins.ts b/python/jupytergis_core/src/jgisplugin/plugins.ts index afd4b44a9..df3146ad9 100644 --- a/python/jupytergis_core/src/jgisplugin/plugins.ts +++ b/python/jupytergis_core/src/jgisplugin/plugins.ts @@ -61,10 +61,8 @@ const activate = async ( window.jupytergisMaps = {}; } - let settings: ISettingRegistry.ISettings | null = null; - try { - settings = await settingRegistry.load(SETTINGS_ID); + await settingRegistry.load(SETTINGS_ID); } catch (error) { console.warn(`Failed to load settings for ${SETTINGS_ID}`, error); }