mirror of https://github.com/prometheus/prometheus
Merge pull request #9344 from prometheus/fix-eslint-warning-cmp
fix eslint warning for codemirror-promqlpull/9364/head
commit
6c9ded2854
|
@ -55,6 +55,7 @@ export interface CacheConfig {
|
||||||
export interface PrometheusConfig {
|
export interface PrometheusConfig {
|
||||||
url: string;
|
url: string;
|
||||||
lookbackInterval?: number;
|
lookbackInterval?: number;
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
httpErrorHandler?: (error: any) => void;
|
httpErrorHandler?: (error: any) => void;
|
||||||
fetchFn?: FetchFn;
|
fetchFn?: FetchFn;
|
||||||
// cache will allow user to change the configuration of the cached Prometheus client (which is used by default)
|
// cache will allow user to change the configuration of the cached Prometheus client (which is used by default)
|
||||||
|
@ -79,6 +80,7 @@ const serviceUnavailable = 503;
|
||||||
export class HTTPPrometheusClient implements PrometheusClient {
|
export class HTTPPrometheusClient implements PrometheusClient {
|
||||||
private readonly lookbackInterval = 60 * 60 * 1000 * 12; //12 hours
|
private readonly lookbackInterval = 60 * 60 * 1000 * 12; //12 hours
|
||||||
private readonly url: string;
|
private readonly url: string;
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
private readonly errorHandler?: (error: any) => void;
|
private readonly errorHandler?: (error: any) => void;
|
||||||
private readonly httpMethod: 'POST' | 'GET' = 'POST';
|
private readonly httpMethod: 'POST' | 'GET' = 'POST';
|
||||||
// For some reason, just assigning via "= fetch" here does not end up executing fetch correctly
|
// For some reason, just assigning via "= fetch" here does not end up executing fetch correctly
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
import { EditorView } from '@codemirror/view';
|
import { EditorView } from '@codemirror/view';
|
||||||
import { Diagnostic, linter } from '@codemirror/lint';
|
import { Diagnostic, linter } from '@codemirror/lint';
|
||||||
import { HybridLint } from './hybrid';
|
import { HybridLint } from './hybrid';
|
||||||
|
import { Extension } from '@codemirror/state';
|
||||||
|
|
||||||
type lintFunc = (view: EditorView) => readonly Diagnostic[] | Promise<readonly Diagnostic[]>;
|
type lintFunc = (view: EditorView) => readonly Diagnostic[] | Promise<readonly Diagnostic[]>;
|
||||||
|
|
||||||
|
@ -27,6 +28,6 @@ export function newLintStrategy(): LintStrategy {
|
||||||
return new HybridLint();
|
return new HybridLint();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function promQLLinter(callbackFunc: (this: LintStrategy) => lintFunc, thisArg: LintStrategy) {
|
export function promQLLinter(callbackFunc: (this: LintStrategy) => lintFunc, thisArg: LintStrategy): Extension {
|
||||||
return linter(callbackFunc.call(thisArg));
|
return linter(callbackFunc.call(thisArg));
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ export class Parser {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
analyze() {
|
analyze(): void {
|
||||||
// when you are at the root of the tree, the first node is not `Expr` but a node with no name.
|
// when you are at the root of the tree, the first node is not `Expr` but a node with no name.
|
||||||
// So to be able to iterate other the node relative to the promql node, we have to get the first child at the beginning
|
// So to be able to iterate other the node relative to the promql node, we have to get the first child at the beginning
|
||||||
this.checkAST(this.tree.topNode.firstChild);
|
this.checkAST(this.tree.topNode.firstChild);
|
||||||
|
|
|
@ -30,7 +30,7 @@ import {
|
||||||
import { VectorMatchCardinality, VectorMatching } from '../types';
|
import { VectorMatchCardinality, VectorMatching } from '../types';
|
||||||
import { containsAtLeastOneChild, retrieveAllRecursiveNodes } from './path-finder';
|
import { containsAtLeastOneChild, retrieveAllRecursiveNodes } from './path-finder';
|
||||||
|
|
||||||
export function buildVectorMatching(state: EditorState, binaryNode: SyntaxNode) {
|
export function buildVectorMatching(state: EditorState, binaryNode: SyntaxNode): VectorMatching | null {
|
||||||
if (!binaryNode || binaryNode.type.id !== BinaryExpr) {
|
if (!binaryNode || binaryNode.type.id !== BinaryExpr) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ export enum LanguageType {
|
||||||
MetricName = 'MetricName',
|
MetricName = 'MetricName',
|
||||||
}
|
}
|
||||||
|
|
||||||
export function promQLLanguage(top: LanguageType) {
|
export function promQLLanguage(top: LanguageType): LezerLanguage {
|
||||||
return LezerLanguage.define({
|
return LezerLanguage.define({
|
||||||
parser: parser.configure({
|
parser: parser.configure({
|
||||||
top: top,
|
top: top,
|
||||||
|
|
|
@ -28,7 +28,7 @@ export function createEditorState(expr: string): EditorState {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mockPrometheusServer() {
|
export function mockPrometheusServer(): void {
|
||||||
nock('http://localhost:8080')
|
nock('http://localhost:8080')
|
||||||
.get('/api/v1/label/__name__/values')
|
.get('/api/v1/label/__name__/values')
|
||||||
.query(true)
|
.query(true)
|
||||||
|
|
Loading…
Reference in New Issue