chore: add eslint rules for no-console (#10071)
Some checks failed
build-staging / prepare (push) Has been cancelled
build-staging / js-build (push) Has been cancelled
build-staging / go-build (push) Has been cancelled
build-staging / staging (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled

This commit is contained in:
Ashwin Bhatkal
2026-01-24 00:36:05 +05:30
committed by GitHub
parent 1c4dfc931f
commit dd0738ac70
14 changed files with 16 additions and 54 deletions

View File

@@ -38,7 +38,7 @@ module.exports = {
'import', // Import/export linting 'import', // Import/export linting
'sonarjs', // Code quality/complexity 'sonarjs', // Code quality/complexity
// TODO: Uncomment after running: yarn add -D eslint-plugin-spellcheck // TODO: Uncomment after running: yarn add -D eslint-plugin-spellcheck
// 'spellcheck', // 'spellcheck', // Correct spellings
], ],
settings: { settings: {
react: { react: {
@@ -60,8 +60,7 @@ module.exports = {
'no-debugger': 'error', // Disallows debugger statements in production code 'no-debugger': 'error', // Disallows debugger statements in production code
curly: 'error', // Requires curly braces for all control statements curly: 'error', // Requires curly braces for all control statements
eqeqeq: ['error', 'always', { null: 'ignore' }], // Enforces === and !== (allows == null for null/undefined check) eqeqeq: ['error', 'always', { null: 'ignore' }], // Enforces === and !== (allows == null for null/undefined check)
// TODO: Enable after fixing ~15 console.log statements 'no-console': ['error', { allow: ['warn', 'error'] }], // Warns on console.log, allows console.warn/error
// 'no-console': ['error', { allow: ['warn', 'error'] }], // Warns on console.log, allows console.warn/error
// TypeScript rules // TypeScript rules
'@typescript-eslint/explicit-function-return-type': 'error', // Requires explicit return types on functions '@typescript-eslint/explicit-function-return-type': 'error', // Requires explicit return types on functions

View File

@@ -1,14 +1,5 @@
import './Slider.styles.scss'; import './Slider.styles.scss';
import { IQuickFiltersConfig } from 'components/QuickFilters/types'; export default function Slider(): JSX.Element {
interface ISliderProps {
filter: IQuickFiltersConfig;
}
// not needed for now build when required
export default function Slider(props: ISliderProps): JSX.Element {
const { filter } = props;
console.log(filter);
return <div>Slider</div>; return <div>Slider</div>;
} }

View File

@@ -311,7 +311,7 @@ export default function QuickFilters(props: IQuickFiltersProps): JSX.Element {
/> />
); );
case FiltersType.SLIDER: case FiltersType.SLIDER:
return <Slider filter={filter} />; return <Slider />;
// eslint-disable-next-line sonarjs/no-duplicated-branches // eslint-disable-next-line sonarjs/no-duplicated-branches
default: default:
return ( return (

View File

@@ -166,7 +166,7 @@ function UpdateContextLinks({
onSave(newContextLink); onSave(newContextLink);
} catch (error) { } catch (error) {
// Form validation failed, don't call onSave // Form validation failed, don't call onSave
console.log('Form validation failed:', error); console.error('Form validation failed:', error);
} }
}; };

View File

@@ -129,7 +129,6 @@ const useBaseAggregateOptions = ({
const handleBaseDrilldown = useCallback( const handleBaseDrilldown = useCallback(
(key: string): void => { (key: string): void => {
console.log('Base drilldown:', { key, aggregateData });
const route = getRoute(key); const route = getRoute(key);
const timeRange = aggregateData?.timeRange; const timeRange = aggregateData?.timeRange;
const filtersToAdd = aggregateData?.filters || []; const filtersToAdd = aggregateData?.filters || [];

View File

@@ -83,11 +83,6 @@ const useDashboardVarConfig = ({
dashboardVar: [string, IDashboardVariable], dashboardVar: [string, IDashboardVariable],
fieldValue: any, fieldValue: any,
) => { ) => {
console.log('Setting variable:', {
fieldName,
dashboardVarId: dashboardVar[0],
fieldValue,
});
onValueUpdate(fieldName, dashboardVar[1]?.id, fieldValue, false); onValueUpdate(fieldName, dashboardVar[1]?.id, fieldValue, false);
onClose(); onClose();
}, },
@@ -96,10 +91,6 @@ const useDashboardVarConfig = ({
const handleUnsetVariable = useCallback( const handleUnsetVariable = useCallback(
(fieldName: string, dashboardVar: [string, IDashboardVariable]) => { (fieldName: string, dashboardVar: [string, IDashboardVariable]) => {
console.log('Unsetting variable:', {
fieldName,
dashboardVarId: dashboardVar[0],
});
onValueUpdate(fieldName, dashboardVar[0], null, false); onValueUpdate(fieldName, dashboardVar[0], null, false);
onClose(); onClose();
}, },
@@ -109,12 +100,6 @@ const useDashboardVarConfig = ({
const handleCreateVariable = useCallback( const handleCreateVariable = useCallback(
(fieldName: string, fieldValue: string | number | boolean) => { (fieldName: string, fieldValue: string | number | boolean) => {
const source = getSourceFromQuery(); const source = getSourceFromQuery();
console.log('Creating variable from drilldown:', {
fieldName,
fieldValue,
source,
widgetId,
});
createVariable( createVariable(
fieldName, fieldName,
fieldValue, fieldValue,
@@ -125,7 +110,7 @@ const useDashboardVarConfig = ({
); );
onClose(); onClose();
}, },
[createVariable, getSourceFromQuery, widgetId, onClose], [createVariable, getSourceFromQuery, onClose],
); );
const contextItems = useMemo( const contextItems = useMemo(

View File

@@ -55,7 +55,7 @@ const useDragColumns = <T>(storageKey: LOCALSTORAGE): UseDragColumns<T> => {
const parsedDraggedColumns = await JSON.parse(localStorageColumns); const parsedDraggedColumns = await JSON.parse(localStorageColumns);
nextDraggedColumns = parsedDraggedColumns; nextDraggedColumns = parsedDraggedColumns;
} catch (e) { } catch (e) {
console.log('error while parsing json'); console.error('error while parsing json: ', e);
} finally { } finally {
redirectWithDraggedColumns(nextDraggedColumns); redirectWithDraggedColumns(nextDraggedColumns);
} }

View File

@@ -4,11 +4,6 @@ import parser from 'lib/logql/parser';
describe('lib/logql/parser', () => { describe('lib/logql/parser', () => {
test('parse valid queries', () => { test('parse valid queries', () => {
logqlQueries.forEach((queryObject) => { logqlQueries.forEach((queryObject) => {
try {
parser(queryObject.query);
} catch (e) {
console.log(e);
}
expect(parser(queryObject.query)).toEqual(queryObject.parsedQuery); expect(parser(queryObject.query)).toEqual(queryObject.parsedQuery);
}); });
}); });

View File

@@ -4,11 +4,7 @@ import { reverseParser } from 'lib/logql/reverseParser';
describe('lib/logql/reverseParser', () => { describe('lib/logql/reverseParser', () => {
test('reverse parse valid queries', () => { test('reverse parse valid queries', () => {
logqlQueries.forEach((queryObject) => { logqlQueries.forEach((queryObject) => {
try { expect(reverseParser(queryObject.parsedQuery)).toEqual(queryObject.query);
expect(reverseParser(queryObject.parsedQuery)).toEqual(queryObject.query);
} catch (e) {
console.log(e);
}
}); });
}); });
}); });

View File

@@ -11,8 +11,8 @@ describe('getYAxisScale', () => {
keyIndex: 1, keyIndex: 1,
thresholdValue: 10, thresholdValue: 10,
thresholdUnit: 'percentunit', thresholdUnit: 'percentunit',
moveThreshold(dragIndex, hoverIndex): void { moveThreshold(): void {
console.log(dragIndex, hoverIndex); // no-op
}, },
selectedGraph: PANEL_TYPES.TIME_SERIES, selectedGraph: PANEL_TYPES.TIME_SERIES,
}, },
@@ -21,8 +21,8 @@ describe('getYAxisScale', () => {
keyIndex: 2, keyIndex: 2,
thresholdValue: 20, thresholdValue: 20,
thresholdUnit: 'percentunit', thresholdUnit: 'percentunit',
moveThreshold(dragIndex, hoverIndex): void { moveThreshold(): void {
console.log(dragIndex, hoverIndex); // no-op
}, },
selectedGraph: PANEL_TYPES.TIME_SERIES, selectedGraph: PANEL_TYPES.TIME_SERIES,
}, },

View File

@@ -20,8 +20,7 @@ export const parseQueryIntoSpanKind = (
current = parsedValue; current = parsedValue;
} }
} catch (error) { } catch (error) {
console.log(error); console.error('error while parsing json: ', error);
console.log('error while parsing json');
} }
} }

View File

@@ -19,7 +19,7 @@ export const parseQueryIntoCurrent = (
current = parseInt(parsedValue, 10); current = parseInt(parsedValue, 10);
} }
} catch (error) { } catch (error) {
console.log('error while parsing json'); console.error('error while parsing json: ', error);
} }
} }

View File

@@ -20,8 +20,7 @@ export const parseQueryIntoOrder = (
current = parsedValue; current = parsedValue;
} }
} catch (error) { } catch (error) {
console.log(error); console.error('error while parsing json: ', error);
console.log('error while parsing json');
} }
} }

View File

@@ -20,8 +20,7 @@ export const parseAggregateOrderParams = (
current = parsedValue; current = parsedValue;
} }
} catch (error) { } catch (error) {
console.log(error); console.error('error while parsing json: ', error);
console.log('error while parsing json');
} }
} }