Merge pull request #9344 from prometheus/fix-eslint-warning-cmp

fix eslint warning for codemirror-promql
This commit is contained in:
Julius Volz 2021-09-16 12:05:39 +02:00 committed by GitHub
commit 6c9ded2854
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 5 deletions

View File

@ -55,6 +55,7 @@ export interface CacheConfig {
export interface PrometheusConfig {
url: string;
lookbackInterval?: number;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
httpErrorHandler?: (error: any) => void;
fetchFn?: FetchFn;
// 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 {
private readonly lookbackInterval = 60 * 60 * 1000 * 12; //12 hours
private readonly url: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private readonly errorHandler?: (error: any) => void;
private readonly httpMethod: 'POST' | 'GET' = 'POST';
// 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 { Diagnostic, linter } from '@codemirror/lint';
import { HybridLint } from './hybrid';
import { Extension } from '@codemirror/state';
type lintFunc = (view: EditorView) => readonly Diagnostic[] | Promise<readonly Diagnostic[]>;
@ -27,6 +28,6 @@ export function newLintStrategy(): LintStrategy {
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));
}

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.
// 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);

View File

@ -30,7 +30,7 @@ import {
import { VectorMatchCardinality, VectorMatching } from '../types';
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) {
return null;
}

View File

@ -24,7 +24,7 @@ export enum LanguageType {
MetricName = 'MetricName',
}
export function promQLLanguage(top: LanguageType) {
export function promQLLanguage(top: LanguageType): LezerLanguage {
return LezerLanguage.define({
parser: parser.configure({
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')
.get('/api/v1/label/__name__/values')
.query(true)