From 0d0a06c491060819f7868e9e5cba13414f8d5da9 Mon Sep 17 00:00:00 2001 From: Vault Automation Date: Fri, 23 Jan 2026 13:26:41 -0800 Subject: [PATCH] Update eslint console rule (#11883) (#11948) Allow for console error and warn and fail for everything else. Remove disable rules for console. Co-authored-by: Angelo Cordon --- ui/.eslintrc.js | 8 ++++- ui/app/forms/open-api.ts | 1 - ui/app/routes/vault/cluster.js | 3 +- ui/app/services/analytics.ts | 3 +- ui/app/services/api.ts | 2 +- ui/app/services/flags.ts | 4 +-- ui/app/utils/forms/validate.ts | 2 -- .../addon/components/replication-dashboard.js | 2 +- .../addon/components/secrets/page/overview.ts | 2 +- ui/tests/unit/services/analytics-test.js | 36 ++++++++++++------- ui/tests/unit/services/api-test.js | 2 +- 11 files changed, 39 insertions(+), 26 deletions(-) diff --git a/ui/.eslintrc.js b/ui/.eslintrc.js index af44c06ee8..9227b5bcb1 100644 --- a/ui/.eslintrc.js +++ b/ui/.eslintrc.js @@ -29,7 +29,7 @@ module.exports = { browser: true, }, rules: { - 'no-console': 'error', + 'no-console': ['error', { allow: ['warn', 'error', 'info'] }], 'prefer-const': ['error', { destructuring: 'all' }], 'ember/no-mixins': 'warn', 'ember/no-new-mixins': 'off', // should be warn but then every line of the mixin is green @@ -42,6 +42,12 @@ module.exports = { '@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }], }, overrides: [ + { + files: ['scripts/generate-form-config.js'], + rules: { + 'no-console': 'off', + }, + }, // node files { files: [ diff --git a/ui/app/forms/open-api.ts b/ui/app/forms/open-api.ts index 8c24406688..4abfd85001 100644 --- a/ui/app/forms/open-api.ts +++ b/ui/app/forms/open-api.ts @@ -66,7 +66,6 @@ export default class OpenApiForm extends Form { ); } else { // to aide in development log out an error to the console if the schema is not found - // eslint-disable-next-line no-console console.error(`OpenApiForm: Schema '${schemaKey}' not found in OpenAPI spec.`); } diff --git a/ui/app/routes/vault/cluster.js b/ui/app/routes/vault/cluster.js index c2a481f680..b4800af72d 100644 --- a/ui/app/routes/vault/cluster.js +++ b/ui/app/routes/vault/cluster.js @@ -184,8 +184,7 @@ export default Route.extend(ModelBoundaryRoute, ClusterRoute, { isEnterprise: Boolean(model.license), }); } catch (e) { - // eslint-disable-next-line no-console - console.log('unable to start analytics', e); + console.error('unable to start analytics', e); } } }, diff --git a/ui/app/services/analytics.ts b/ui/app/services/analytics.ts index 2ceb42450a..8e1e9e841a 100644 --- a/ui/app/services/analytics.ts +++ b/ui/app/services/analytics.ts @@ -27,8 +27,7 @@ export default class AnalyticsService extends Service { private log(...args: unknown[]) { if (this.debug) { - // eslint-disable-next-line no-console - console.log(`[Analytics - ${this.provider.name}]`, ...args); + console.info(`[Analytics - ${this.provider.name}]`, ...args); } } diff --git a/ui/app/services/api.ts b/ui/app/services/api.ts index 7bb887232f..b6de21fdea 100644 --- a/ui/app/services/api.ts +++ b/ui/app/services/api.ts @@ -210,7 +210,7 @@ export default class ApiService extends Service { // log out generic error for ease of debugging in dev env if (config.environment === 'development') { - console.log('API Error:', e); // eslint-disable-line no-console + console.error('API Error:', e); } return { diff --git a/ui/app/services/flags.ts b/ui/app/services/flags.ts index bdaf0ed24d..44f6c4a4b8 100644 --- a/ui/app/services/flags.ts +++ b/ui/app/services/flags.ts @@ -49,7 +49,7 @@ export default class FlagsService extends Service { } } catch (error) { if (macroCondition(isDevelopingApp())) { - console.error(error); // eslint-disable-line no-console + console.error(error); } } }); @@ -74,7 +74,7 @@ export default class FlagsService extends Service { return; } catch (error) { if (macroCondition(isDevelopingApp())) { - console.error(error); // eslint-disable-line no-console + console.error(error); } } }); diff --git a/ui/app/utils/forms/validate.ts b/ui/app/utils/forms/validate.ts index 4b4d086434..cb4dd344be 100644 --- a/ui/app/utils/forms/validate.ts +++ b/ui/app/utils/forms/validate.ts @@ -3,8 +3,6 @@ * SPDX-License-Identifier: BUSL-1.1 */ -/* eslint-disable no-console */ - import validators from 'vault/utils/forms/validators'; import { get } from '@ember/object'; diff --git a/ui/lib/core/addon/components/replication-dashboard.js b/ui/lib/core/addon/components/replication-dashboard.js index 6c0c35526c..840fd9e650 100644 --- a/ui/lib/core/addon/components/replication-dashboard.js +++ b/ui/lib/core/addon/components/replication-dashboard.js @@ -73,7 +73,7 @@ export default class ReplicationDashboard extends Component { // when DR and Performance is enabled on the same cluster, // the states should always be the same // we are leaving this console log statement to be sure - console.log('DR State: ', drState, 'Performance State: ', performanceState); // eslint-disable-line + console.warn('DR State: ', drState, 'Performance State: ', performanceState); } return drState; diff --git a/ui/lib/sync/addon/components/secrets/page/overview.ts b/ui/lib/sync/addon/components/secrets/page/overview.ts index d493858e40..83d7fbd61a 100644 --- a/ui/lib/sync/addon/components/secrets/page/overview.ts +++ b/ui/lib/sync/addon/components/secrets/page/overview.ts @@ -108,7 +108,7 @@ export default class SyncSecretsDestinationsPageComponent extends Component