Skip to content

Commit

Permalink
fix: Adds noconsole rule to guard against casual console.log msgs #625
Browse files Browse the repository at this point in the history
* Uses eslint-disable-next-line to keep those instances where it makes
  sense to use console.[log|error]

issue #625
  • Loading branch information
phantomjinx committed Oct 24, 2023
1 parent fd12d90 commit 87a3688
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'import'],
rules: {
'no-console': 'error',
semi: ['error', 'never'],
'@typescript-eslint/explicit-member-accessibility': [
'warn',
Expand Down
1 change: 1 addition & 0 deletions packages/hawtio/scripts/generate-camel-svg-index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable no-console */
/* jshint node: true */
const fs = require('fs')
const path = require('path')
Expand Down
1 change: 1 addition & 0 deletions packages/hawtio/src/core/logging.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
import { stringSorter } from '@hawtiosrc/util/strings'
import jsLogger, { GlobalLogger, ILogger, ILogLevel } from 'js-logger'
import { is, object, type } from 'superstruct'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ export function createEndpointFromData(
endPointPath: string,
parameters: Record<string, string>,
) {
if (!componentName) console.error('createEndpointFromData: component name must be defined')
if (!componentName) log.error('createEndpointFromData: component name must be defined')

if (!endPointPath) console.error('createEndpointFromData: endpoint path must be defined')
if (!endPointPath) log.error('createEndpointFromData: endpoint path must be defined')

log.debug('Have endpoint data ' + JSON.stringify(parameters))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ let canDisplayInflightExchanges = false
jest.mock('./exchanges-service', () => {
return {
getInflightExchanges: jest.fn(async () => {
console.log('using mocked getInflightExchanges()')
return Promise.resolve(xchgs)
}),
canBrowseInflightExchanges: jest.fn(async (node: MBeanNode): Promise<boolean> => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Connection, ConnectionTestResult, Connections, IConnectService } from '

class MockConnectService implements IConnectService {
constructor() {
// eslint-disable-next-line no-console
console.log('Using mock connect service')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import jmxCamelResponse from './jmx-camel-tree.json'

class MockJolokiaService implements IJolokiaService {
constructor() {
// eslint-disable-next-line no-console
console.log('Using mock jolokia service')
}

Expand Down
1 change: 1 addition & 0 deletions packages/hawtio/src/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ fetchMock.enableMocks()

// Default mock response for every usage of fetch
fetchMock.mockResponse(req => {
// eslint-disable-next-line no-console
console.log('Mock fetch:', req.url)
let res = '{}'
switch (req.url) {
Expand Down

0 comments on commit 87a3688

Please sign in to comment.