Chore: Enable `no-constant-condition` eslint rule (#104298)

pull/104453/head
Tom Ratcliffe 2 months ago committed by GitHub
parent 067d7b4146
commit 356c979328
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      eslint.config.js
  2. 22
      public/app/features/browse-dashboards/api/browseDashboardsAPI.ts
  3. 2
      public/app/plugins/datasource/grafana-testdata-datasource/runStreams.ts
  4. 46
      public/app/plugins/panel/geomap/layers/data/dayNightLayer.tsx
  5. 4
      public/app/plugins/panel/geomap/layers/data/geojsonDynamic.ts
  6. 3
      public/app/plugins/panel/geomap/layers/data/geojsonLayer.ts
  7. 3
      public/locales/en-US/grafana.json

@ -132,6 +132,7 @@ module.exports = [
'no-redeclare': 'off',
'@typescript-eslint/no-redeclare': ['error'],
'unicorn/no-empty-file': 'error',
'no-constant-condition': 'error',
},
},
{

@ -289,29 +289,11 @@ export const browseDashboardsAPI = createApi({
// Delete all the dashboards sequentially
// TODO error handling here
for (const dashboardUID of selectedDashboards) {
const response = await getDashboardAPI().deleteDashboard(dashboardUID, true);
await getDashboardAPI().deleteDashboard(dashboardUID, true);
// handling success alerts for these feature toggles
// for legacy response, the success alert will be triggered by showSuccessAlert function in public/app/core/services/backend_srv.ts
if (false) {
// TODO: change this to a feature flag when dashboard restore is reworked
const name = response?.title;
if (name) {
const payload = config.featureToggles.kubernetesDashboards
? ['Dashboard moved to Recently deleted']
: [
t('browse-dashboards.soft-delete.success', 'Dashboard {{name}} moved to Recently deleted', {
name,
}),
];
appEvents.publish({
type: AppEvents.alertSuccess.name,
payload,
});
}
} else if (config.featureToggles.kubernetesDashboards) {
if (config.featureToggles.kubernetesDashboards) {
appEvents.publish({
type: AppEvents.alertSuccess.name,
payload: ['Dashboard deleted'],

@ -104,13 +104,11 @@ export function runSignalStream(
};
// Fill the buffer on init
if (true) {
let time = Date.now() - maxDataPoints * speed;
for (let i = 0; i < maxDataPoints; i++) {
addNextRow(time);
time += speed;
}
}
const pushNextEvent = () => {
lastSent = Date.now();

@ -1,7 +1,5 @@
import Feature from 'ol/Feature';
import Map from 'ol/Map';
import { Coordinate } from 'ol/coordinate';
import { MultiLineString } from 'ol/geom';
import Point from 'ol/geom/Point';
import { Group as LayerGroup } from 'ol/layer';
import VectorImage from 'ol/layer/VectorImage';
@ -16,9 +14,7 @@ import {
MapLayerOptions,
PanelData,
GrafanaTheme2,
EventBus,
DataHoverEvent,
DataHoverClearEvent,
EventBus
} from '@grafana/data';
export enum ShowTime {
@ -74,8 +70,6 @@ export const dayNightLayer: MapLayerRegistryItem<DayNightConfig> = {
// DayNight source
const source = new DayNight({});
const sourceMethods = Object.getPrototypeOf(source);
const sourceLine = new DayNight({});
const sourceLineMethods = Object.getPrototypeOf(sourceLine);
// Night polygon
const vectorLayer = new VectorImage({
@ -160,44 +154,6 @@ export const dayNightLayer: MapLayerRegistryItem<DayNightConfig> = {
// Crosshair sharing subscriptions
const subscriptions = new Subscription();
if (false) {
subscriptions.add(
eventBus.subscribe(DataHoverEvent, (event) => {
const time = event.payload?.point?.time;
if (time) {
const lineTime = new Date(time);
const nightLinePoints = sourceLine.getCoordinates(lineTime.toString(), 'line');
nightLineLayer.getSource()?.clear();
const lineStringArray: Coordinate[][] = [];
for (let l = 0; l < nightLinePoints.length - 1; l++) {
const x1: number = Object.values(nightLinePoints[l])[0];
const y1: number = Object.values(nightLinePoints[l])[1];
const x2: number = Object.values(nightLinePoints[l + 1])[0];
const y2: number = Object.values(nightLinePoints[l + 1])[1];
const lineString = [fromLonLat([x1, y1]), fromLonLat([x2, y2])];
lineStringArray.push(lineString);
}
nightLineLayer.getSource()?.addFeature(
new Feature({
geometry: new MultiLineString(lineStringArray),
})
);
let sunLinePos: number[] = [];
sunLinePos = sourceLineMethods.getSunPosition(lineTime);
sunLineFeature.getGeometry()?.setCoordinates(fromLonLat(sunLinePos));
sunLineFeature.setStyle([sunLineStyle, sunLineStyleDash]);
}
})
);
subscriptions.add(
eventBus.subscribe(DataHoverClearEvent, (event) => {
nightLineLayer.getSource()?.clear();
sunLineFeature.setStyle(new Style({}));
})
);
}
return {
init: () => layer,

@ -108,12 +108,12 @@ export const dynamicGeoJSONLayer: MapLayerRegistryItem<DynamicGeoJSONMapperConfi
}
}
}
if (true) {
const s = await getStyleConfigState(config.style);
styles.push({
state: s,
});
}
const style = await getStyleConfigState(config.style);
const idToIdx = new Map<string, number>();

@ -102,12 +102,11 @@ export const geojsonLayer: MapLayerRegistryItem<GeoJSONMapperConfig> = {
}
}
}
if (true) {
const s = await getStyleConfigState(config.style);
styles.push({
state: s,
});
}
const polyStyleStrings: string[] = Object.values(GeoJSONPolyStyles);
const pointStyleStrings: string[] = Object.values(GeoJSONPointStyles);

@ -2680,9 +2680,6 @@
"clear": "Clear search and filters",
"text": "No results found for your query"
},
"soft-delete": {
"success": "Dashboard {{name}} moved to Recently deleted"
},
"text-this-repository-is-read-only": "If you have direct access to the target, copy the JSON and paste it there."
},
"canvas": {

Loading…
Cancel
Save