fix eslint warning for codemirror-promql

Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
pull/9344/head
Augustin Husson 2021-09-15 13:38:48 +02:00
parent 7ff76ed1ab
commit e52204e556
6 changed files with 8 additions and 5 deletions

View File

@ -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

View File

@ -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));
} }

View File

@ -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);

View File

@ -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;
} }

View File

@ -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,

View File

@ -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)