mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-11 05:47:27 -08:00
Make linter run by upgrading the ESLint config
Signed-off-by: Julius Volz <julius.volz@gmail.com>
This commit is contained in:
parent
c1c2e32137
commit
07856b4bb9
|
@ -1,21 +0,0 @@
|
|||
module.exports = {
|
||||
root: true,
|
||||
env: { browser: true, es2020: true },
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'plugin:react-hooks/recommended',
|
||||
],
|
||||
ignorePatterns: ['dist', '.eslintrc.cjs'],
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: ['react-refresh'],
|
||||
rules: {
|
||||
'react-refresh/only-export-components': [
|
||||
'warn',
|
||||
{ allowConstantExport: true },
|
||||
],
|
||||
'no-unused-vars': ['error', { 'argsIgnorePattern': '^_' }],
|
||||
'@typescript-eslint/no-unused-vars': ['error', { 'argsIgnorePattern': '^_' }],
|
||||
'prefer-const': ['error', { destructuring: 'all' }],
|
||||
},
|
||||
}
|
71
web/ui/mantine-ui/eslint.config.mjs
Normal file
71
web/ui/mantine-ui/eslint.config.mjs
Normal file
|
@ -0,0 +1,71 @@
|
|||
import { fixupConfigRules } from '@eslint/compat';
|
||||
import reactRefresh from 'eslint-plugin-react-refresh';
|
||||
import globals from 'globals';
|
||||
import tsParser from '@typescript-eslint/parser';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import js from '@eslint/js';
|
||||
import { FlatCompat } from '@eslint/eslintrc';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const compat = new FlatCompat({
|
||||
baseDirectory: __dirname,
|
||||
recommendedConfig: js.configs.recommended,
|
||||
allConfig: js.configs.all
|
||||
});
|
||||
|
||||
export default [{
|
||||
ignores: ['**/dist', '**/.eslintrc.cjs'],
|
||||
}, ...fixupConfigRules(compat.extends(
|
||||
'eslint:recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'plugin:react-hooks/recommended',
|
||||
)), {
|
||||
plugins: {
|
||||
'react-refresh': reactRefresh,
|
||||
},
|
||||
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.browser,
|
||||
},
|
||||
|
||||
parser: tsParser,
|
||||
},
|
||||
|
||||
rules: {
|
||||
'react-refresh/only-export-components': ['warn', {
|
||||
allowConstantExport: true,
|
||||
}],
|
||||
|
||||
// Disable the base rule as it can report incorrect errors
|
||||
'no-unused-vars': 'off',
|
||||
|
||||
// Use the TypeScript-specific rule for unused vars
|
||||
'@typescript-eslint/no-unused-vars': ['warn', {
|
||||
argsIgnorePattern: '^_',
|
||||
varsIgnorePattern: '^_',
|
||||
caughtErrorsIgnorePattern: '^_',
|
||||
}],
|
||||
|
||||
'prefer-const': ['error', {
|
||||
destructuring: 'all',
|
||||
}],
|
||||
},
|
||||
},
|
||||
// Override for Node.js-based config files
|
||||
{
|
||||
files: ['postcss.config.cjs'], // Specify any other config files
|
||||
languageOptions: {
|
||||
ecmaVersion: 2021, // Optional, set ECMAScript version
|
||||
sourceType: 'script', // For CommonJS (non-ESM) modules
|
||||
globals: {
|
||||
module: 'readonly',
|
||||
require: 'readonly',
|
||||
process: 'readonly',
|
||||
__dirname: 'readonly', // Include other Node.js globals if needed
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
|
@ -6,7 +6,8 @@
|
|||
"scripts": {
|
||||
"start": "vite",
|
||||
"build": "tsc && vite build",
|
||||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
||||
"lint": "eslint . --report-unused-disable-directives --max-warnings 0",
|
||||
"lint:fix": "eslint . --report-unused-disable-directives --max-warnings 0 --fix",
|
||||
"preview": "vite preview",
|
||||
"test": "vitest"
|
||||
},
|
||||
|
@ -49,6 +50,9 @@
|
|||
"use-query-params": "^2.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/compat": "^1.1.1",
|
||||
"@eslint/eslintrc": "^3.1.0",
|
||||
"@eslint/js": "^9.9.1",
|
||||
"@types/react": "^18.3.5",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
||||
|
@ -57,6 +61,7 @@
|
|||
"eslint": "^9.9.1",
|
||||
"eslint-plugin-react-hooks": "^5.1.0-rc-e56f4ae3-20240830",
|
||||
"eslint-plugin-react-refresh": "^0.4.11",
|
||||
"globals": "^15.9.0",
|
||||
"jsdom": "^25.0.0",
|
||||
"postcss": "^8.4.35",
|
||||
"postcss-preset-mantine": "^1.17.0",
|
||||
|
|
|
@ -196,7 +196,7 @@ function App() {
|
|||
|
||||
useEffect(() => {
|
||||
dispatch(updateSettings({ pathPrefix }));
|
||||
}, [pathPrefix]);
|
||||
}, [pathPrefix, dispatch]);
|
||||
|
||||
const { agentMode, consolesLink } = useSettings();
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ export const bucketRangeString = ([
|
|||
boundaryRule,
|
||||
leftBoundary,
|
||||
rightBoundary,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
|
||||
_,
|
||||
]: [number, string, string, string]): string => {
|
||||
return `${leftDelim(boundaryRule)}${leftBoundary} -> ${rightBoundary}${rightDelim(boundaryRule)}`;
|
||||
|
|
|
@ -131,13 +131,13 @@ const TreeNode: FC<{
|
|||
if (error) {
|
||||
reportNodeState && reportNodeState("error");
|
||||
}
|
||||
}, [error]);
|
||||
}, [error, reportNodeState]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isFetching) {
|
||||
reportNodeState && reportNodeState("running");
|
||||
}
|
||||
}, [isFetching]);
|
||||
}, [isFetching, reportNodeState]);
|
||||
|
||||
// Update the size and position of tree connector lines based on the node's and its parent's position.
|
||||
useLayoutEffect(() => {
|
||||
|
@ -221,7 +221,7 @@ const TreeNode: FC<{
|
|||
),
|
||||
labelExamples,
|
||||
});
|
||||
}, [data]);
|
||||
}, [data, reportNodeState]);
|
||||
|
||||
const innerNode = (
|
||||
<Group
|
||||
|
|
|
@ -1,51 +1,51 @@
|
|||
export enum nodeType {
|
||||
aggregation = 'aggregation',
|
||||
binaryExpr = 'binaryExpr',
|
||||
call = 'call',
|
||||
matrixSelector = 'matrixSelector',
|
||||
subquery = 'subquery',
|
||||
numberLiteral = 'numberLiteral',
|
||||
parenExpr = 'parenExpr',
|
||||
stringLiteral = 'stringLiteral',
|
||||
unaryExpr = 'unaryExpr',
|
||||
vectorSelector = 'vectorSelector',
|
||||
placeholder = 'placeholder',
|
||||
aggregation = "aggregation",
|
||||
binaryExpr = "binaryExpr",
|
||||
call = "call",
|
||||
matrixSelector = "matrixSelector",
|
||||
subquery = "subquery",
|
||||
numberLiteral = "numberLiteral",
|
||||
parenExpr = "parenExpr",
|
||||
stringLiteral = "stringLiteral",
|
||||
unaryExpr = "unaryExpr",
|
||||
vectorSelector = "vectorSelector",
|
||||
placeholder = "placeholder",
|
||||
}
|
||||
|
||||
export enum aggregationType {
|
||||
sum = 'sum',
|
||||
min = 'min',
|
||||
max = 'max',
|
||||
avg = 'avg',
|
||||
stddev = 'stddev',
|
||||
stdvar = 'stdvar',
|
||||
count = 'count',
|
||||
group = 'group',
|
||||
countValues = 'count_values',
|
||||
bottomk = 'bottomk',
|
||||
topk = 'topk',
|
||||
quantile = 'quantile',
|
||||
limitK = 'limitk',
|
||||
limitRatio = 'limit_ratio',
|
||||
sum = "sum",
|
||||
min = "min",
|
||||
max = "max",
|
||||
avg = "avg",
|
||||
stddev = "stddev",
|
||||
stdvar = "stdvar",
|
||||
count = "count",
|
||||
group = "group",
|
||||
countValues = "count_values",
|
||||
bottomk = "bottomk",
|
||||
topk = "topk",
|
||||
quantile = "quantile",
|
||||
limitK = "limitk",
|
||||
limitRatio = "limit_ratio",
|
||||
}
|
||||
|
||||
export enum binaryOperatorType {
|
||||
add = '+',
|
||||
sub = '-',
|
||||
mul = '*',
|
||||
div = '/',
|
||||
mod = '%',
|
||||
pow = '^',
|
||||
eql = '==',
|
||||
neq = '!=',
|
||||
gtr = '>',
|
||||
lss = '<',
|
||||
gte = '>=',
|
||||
lte = '<=',
|
||||
and = 'and',
|
||||
or = 'or',
|
||||
unless = 'unless',
|
||||
atan2 = 'atan2',
|
||||
add = "+",
|
||||
sub = "-",
|
||||
mul = "*",
|
||||
div = "/",
|
||||
mod = "%",
|
||||
pow = "^",
|
||||
eql = "==",
|
||||
neq = "!=",
|
||||
gtr = ">",
|
||||
lss = "<",
|
||||
gte = ">=",
|
||||
lte = "<=",
|
||||
and = "and",
|
||||
or = "or",
|
||||
unless = "unless",
|
||||
atan2 = "atan2",
|
||||
}
|
||||
|
||||
export const compOperatorTypes: binaryOperatorType[] = [
|
||||
|
@ -64,31 +64,31 @@ export const setOperatorTypes: binaryOperatorType[] = [
|
|||
];
|
||||
|
||||
export enum unaryOperatorType {
|
||||
plus = '+',
|
||||
minus = '-',
|
||||
plus = "+",
|
||||
minus = "-",
|
||||
}
|
||||
|
||||
export enum vectorMatchCardinality {
|
||||
oneToOne = 'one-to-one',
|
||||
manyToOne = 'many-to-one',
|
||||
oneToMany = 'one-to-many',
|
||||
manyToMany = 'many-to-many',
|
||||
oneToOne = "one-to-one",
|
||||
manyToOne = "many-to-one",
|
||||
oneToMany = "one-to-many",
|
||||
manyToMany = "many-to-many",
|
||||
}
|
||||
|
||||
export enum valueType {
|
||||
// TODO: 'none' should never make it out of Prometheus. Do we need this here?
|
||||
none = 'none',
|
||||
vector = 'vector',
|
||||
scalar = 'scalar',
|
||||
matrix = 'matrix',
|
||||
string = 'string',
|
||||
none = "none",
|
||||
vector = "vector",
|
||||
scalar = "scalar",
|
||||
matrix = "matrix",
|
||||
string = "string",
|
||||
}
|
||||
|
||||
export enum matchType {
|
||||
equal = '=',
|
||||
notEqual = '!=',
|
||||
matchRegexp = '=~',
|
||||
matchNotRegexp = '!~',
|
||||
equal = "=",
|
||||
notEqual = "!=",
|
||||
matchRegexp = "=~",
|
||||
matchNotRegexp = "!~",
|
||||
}
|
||||
|
||||
export interface Func {
|
||||
|
@ -111,7 +111,7 @@ export interface VectorMatching {
|
|||
include: string[];
|
||||
}
|
||||
|
||||
export type StartOrEnd = 'start' | 'end' | null;
|
||||
export type StartOrEnd = "start" | "end" | null;
|
||||
|
||||
// AST Node Types.
|
||||
|
||||
|
|
26
web/ui/mantine-ui/src/promql/tools/go.mod
Normal file
26
web/ui/mantine-ui/src/promql/tools/go.mod
Normal file
|
@ -0,0 +1,26 @@
|
|||
module github.com/prometheus/prometheus/web/ui/mantine-ui/src/promql/tools
|
||||
|
||||
go 1.23.0
|
||||
|
||||
require (
|
||||
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc
|
||||
github.com/prometheus/prometheus v0.54.1
|
||||
github.com/russross/blackfriday/v2 v2.1.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/dennwc/varint v1.0.0 // indirect
|
||||
github.com/go-kit/log v0.2.1 // indirect
|
||||
github.com/go-logfmt/logfmt v0.6.0 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/prometheus/client_golang v1.19.1 // indirect
|
||||
github.com/prometheus/client_model v0.6.1 // indirect
|
||||
github.com/prometheus/common v0.55.0 // indirect
|
||||
github.com/prometheus/procfs v0.15.1 // indirect
|
||||
go.uber.org/atomic v1.11.0 // indirect
|
||||
golang.org/x/sys v0.22.0 // indirect
|
||||
golang.org/x/text v0.16.0 // indirect
|
||||
google.golang.org/protobuf v1.34.2 // indirect
|
||||
)
|
107
web/ui/mantine-ui/src/promql/tools/go.sum
Normal file
107
web/ui/mantine-ui/src/promql/tools/go.sum
Normal file
|
@ -0,0 +1,107 @@
|
|||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 h1:GJHeeA2N7xrG3q30L2UXDyuWRzDM900/65j70wcM4Ww=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI=
|
||||
github.com/alecthomas/units v0.0.0-20240626203959-61d1e3462e30 h1:t3eaIm0rUkzbrIewtiFmMK5RXHej2XnoXNhxVsAYUfg=
|
||||
github.com/alecthomas/units v0.0.0-20240626203959-61d1e3462e30/go.mod h1:fvzegU4vN3H1qMT+8wDmzjAcDONcgo2/SZ/TyfdUOFs=
|
||||
github.com/aws/aws-sdk-go v1.54.19 h1:tyWV+07jagrNiCcGRzRhdtVjQs7Vy41NwsuOcl0IbVI=
|
||||
github.com/aws/aws-sdk-go v1.54.19/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU=
|
||||
github.com/bboreham/go-loser v0.0.0-20230920113527-fcc2c21820a3 h1:6df1vn4bBlDDo4tARvBm7l6KA9iVMnE3NWizDeWSrps=
|
||||
github.com/bboreham/go-loser v0.0.0-20230920113527-fcc2c21820a3/go.mod h1:CIWtjkly68+yqLPbvwwR/fjNJA/idrtULjZWh2v1ys0=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dennwc/varint v1.0.0 h1:kGNFFSSw8ToIy3obO/kKr8U9GZYUAxQEVuix4zfDWzE=
|
||||
github.com/dennwc/varint v1.0.0/go.mod h1:hnItb35rvZvJrbTALZtY/iQfDs48JKRG1RPpgziApxA=
|
||||
github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU=
|
||||
github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
|
||||
github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4=
|
||||
github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
|
||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
|
||||
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc h1:GN2Lv3MGO7AS6PrRoT6yV5+wkrOpcszoIsO4+4ds248=
|
||||
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc/go.mod h1:+JKpmjMGhpgPL+rXZ5nsZieVzvarn86asRlBg4uNGnk=
|
||||
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
||||
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
||||
github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA=
|
||||
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
|
||||
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
||||
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
|
||||
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
|
||||
github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
|
||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||
github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc=
|
||||
github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
|
||||
github.com/prometheus/common/sigv4 v0.1.0 h1:qoVebwtwwEhS85Czm2dSROY5fTo2PAPEVdDeppTwGX4=
|
||||
github.com/prometheus/common/sigv4 v0.1.0/go.mod h1:2Jkxxk9yYvCkE5G1sQT7GuEXm57JrvHu9k5YwTjsNtI=
|
||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||
github.com/prometheus/prometheus v0.54.1 h1:vKuwQNjnYN2/mDoWfHXDhAsz/68q/dQDb+YbcEqU7MQ=
|
||||
github.com/prometheus/prometheus v0.54.1/go.mod h1:xlLByHhk2g3ycakQGrMaU8K7OySZx98BzeCR99991NY=
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
|
||||
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
|
||||
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
|
||||
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA=
|
||||
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
|
||||
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
|
||||
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
|
||||
golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs=
|
||||
golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
||||
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
||||
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
||||
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
k8s.io/apimachinery v0.29.3 h1:2tbx+5L7RNvqJjn7RIuIKu9XTsIZ9Z5wX2G22XAa5EU=
|
||||
k8s.io/apimachinery v0.29.3/go.mod h1:hx/S4V2PNW4OMg3WizRrHutyB5la0iCUbZym+W0EQIU=
|
||||
k8s.io/client-go v0.29.3 h1:R/zaZbEAxqComZ9FHeQwOh3Y1ZUs7FaHKZdQtIc2WZg=
|
||||
k8s.io/client-go v0.29.3/go.mod h1:tkDisCvgPfiRpxGnOORfkljmS+UrW+WtXAy2fTvXJB0=
|
||||
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
|
||||
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
|
||||
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
|
||||
k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI=
|
||||
k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
|
|
@ -1,9 +1,18 @@
|
|||
import ASTNode, { binaryOperatorType, nodeType, valueType, Call, compOperatorTypes, setOperatorTypes } from './ast';
|
||||
import { functionArgNames } from './functionMeta';
|
||||
import ASTNode, {
|
||||
binaryOperatorType,
|
||||
nodeType,
|
||||
valueType,
|
||||
Call,
|
||||
compOperatorTypes,
|
||||
setOperatorTypes,
|
||||
} from "./ast";
|
||||
import { functionArgNames } from "./functionMeta";
|
||||
|
||||
export const getNonParenNodeType = (n: ASTNode) => {
|
||||
let cur: ASTNode;
|
||||
for (cur = n; cur.type === 'parenExpr'; cur = cur.expr) {}
|
||||
for (cur = n; cur.type === "parenExpr"; cur = cur.expr) {
|
||||
// Continue traversing until a non-parenthesis expression is found
|
||||
}
|
||||
return cur.type;
|
||||
};
|
||||
|
||||
|
@ -34,7 +43,10 @@ const binOpPrecedence = {
|
|||
[binaryOperatorType.atan2]: 2,
|
||||
};
|
||||
|
||||
export const maybeParenthesizeBinopChild = (op: binaryOperatorType, child: ASTNode): ASTNode => {
|
||||
export const maybeParenthesizeBinopChild = (
|
||||
op: binaryOperatorType,
|
||||
child: ASTNode
|
||||
): ASTNode => {
|
||||
if (child.type !== nodeType.binaryExpr) {
|
||||
return child;
|
||||
}
|
||||
|
@ -73,7 +85,7 @@ export const getNodeChildren = (node: ASTNode): ASTNode[] => {
|
|||
case nodeType.binaryExpr:
|
||||
return [node.lhs, node.rhs];
|
||||
default:
|
||||
throw new Error('unsupported node type');
|
||||
throw new Error("unsupported node type");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -92,18 +104,19 @@ export const getNodeChild = (node: ASTNode, idx: number) => {
|
|||
case nodeType.binaryExpr:
|
||||
return idx === 0 ? node.lhs : node.rhs;
|
||||
default:
|
||||
throw new Error('unsupported node type');
|
||||
throw new Error("unsupported node type");
|
||||
}
|
||||
};
|
||||
|
||||
export const containsPlaceholders = (node: ASTNode): boolean =>
|
||||
node.type === nodeType.placeholder || getNodeChildren(node).some((n) => containsPlaceholders(n));
|
||||
node.type === nodeType.placeholder ||
|
||||
getNodeChildren(node).some((n) => containsPlaceholders(n));
|
||||
|
||||
export const nodeValueType = (node: ASTNode): valueType | null => {
|
||||
switch (node.type) {
|
||||
case nodeType.aggregation:
|
||||
return valueType.vector;
|
||||
case nodeType.binaryExpr:
|
||||
case nodeType.binaryExpr: {
|
||||
const childTypes = [nodeValueType(node.lhs), nodeValueType(node.rhs)];
|
||||
|
||||
if (childTypes.includes(null)) {
|
||||
|
@ -116,6 +129,7 @@ export const nodeValueType = (node: ASTNode): valueType | null => {
|
|||
}
|
||||
|
||||
return valueType.scalar;
|
||||
}
|
||||
case nodeType.call:
|
||||
return node.func.returnType;
|
||||
case nodeType.matrixSelector:
|
||||
|
@ -135,7 +149,7 @@ export const nodeValueType = (node: ASTNode): valueType | null => {
|
|||
case nodeType.vectorSelector:
|
||||
return valueType.vector;
|
||||
default:
|
||||
throw new Error('invalid node type');
|
||||
throw new Error("invalid node type");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -144,50 +158,65 @@ export const childDescription = (node: ASTNode, idx: number): string => {
|
|||
case nodeType.aggregation:
|
||||
if (aggregatorsWithParam.includes(node.op) && idx === 0) {
|
||||
switch (node.op) {
|
||||
case 'topk':
|
||||
case 'bottomk':
|
||||
case 'limitk':
|
||||
return 'k';
|
||||
case 'quantile':
|
||||
return 'quantile';
|
||||
case 'count_values':
|
||||
return 'target label name';
|
||||
case 'limit_ratio':
|
||||
return 'ratio';
|
||||
case "topk":
|
||||
case "bottomk":
|
||||
case "limitk":
|
||||
return "k";
|
||||
case "quantile":
|
||||
return "quantile";
|
||||
case "count_values":
|
||||
return "target label name";
|
||||
case "limit_ratio":
|
||||
return "ratio";
|
||||
}
|
||||
}
|
||||
|
||||
return 'vector to aggregate';
|
||||
return "vector to aggregate";
|
||||
case nodeType.binaryExpr:
|
||||
return idx === 0 ? 'left-hand side' : 'right-hand side';
|
||||
return idx === 0 ? "left-hand side" : "right-hand side";
|
||||
case nodeType.call:
|
||||
if (functionArgNames.hasOwnProperty(node.func.name)) {
|
||||
if (node.func.name in functionArgNames) {
|
||||
const argNames = functionArgNames[node.func.name];
|
||||
return argNames[Math.min(functionArgNames[node.func.name].length - 1, idx)];
|
||||
return argNames[Math.min(argNames.length - 1, idx)];
|
||||
}
|
||||
return 'argument';
|
||||
return "argument";
|
||||
case nodeType.parenExpr:
|
||||
return 'expression';
|
||||
return "expression";
|
||||
case nodeType.placeholder:
|
||||
return 'argument';
|
||||
return "argument";
|
||||
case nodeType.subquery:
|
||||
return 'subquery to execute';
|
||||
return "subquery to execute";
|
||||
case nodeType.unaryExpr:
|
||||
return 'expression';
|
||||
return "expression";
|
||||
default:
|
||||
throw new Error('invalid node type');
|
||||
throw new Error("invalid node type");
|
||||
}
|
||||
};
|
||||
|
||||
export const aggregatorsWithParam = ['topk', 'bottomk', 'quantile', 'count_values', 'limitk', 'limit_ratio'];
|
||||
export const aggregatorsWithParam = [
|
||||
"topk",
|
||||
"bottomk",
|
||||
"quantile",
|
||||
"count_values",
|
||||
"limitk",
|
||||
"limit_ratio",
|
||||
];
|
||||
|
||||
export const anyValueType = [valueType.scalar, valueType.string, valueType.matrix, valueType.vector];
|
||||
export const anyValueType = [
|
||||
valueType.scalar,
|
||||
valueType.string,
|
||||
valueType.matrix,
|
||||
valueType.vector,
|
||||
];
|
||||
|
||||
export const allowedChildValueTypes = (node: ASTNode, idx: number): valueType[] => {
|
||||
export const allowedChildValueTypes = (
|
||||
node: ASTNode,
|
||||
idx: number
|
||||
): valueType[] => {
|
||||
switch (node.type) {
|
||||
case nodeType.aggregation:
|
||||
if (aggregatorsWithParam.includes(node.op) && idx === 0) {
|
||||
if (node.op === 'count_values') {
|
||||
if (node.op === "count_values") {
|
||||
return [valueType.string];
|
||||
}
|
||||
return [valueType.scalar];
|
||||
|
@ -211,7 +240,7 @@ export const allowedChildValueTypes = (node: ASTNode, idx: number): valueType[]
|
|||
case nodeType.unaryExpr:
|
||||
return anyValueType;
|
||||
default:
|
||||
throw new Error('invalid node type');
|
||||
throw new Error("invalid node type");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -225,17 +254,19 @@ export const canAddVarArg = (node: Call): boolean => {
|
|||
};
|
||||
|
||||
export const canRemoveVarArg = (node: Call): boolean => {
|
||||
return node.func.variadic !== 0 && node.args.length >= node.func.argTypes.length;
|
||||
return (
|
||||
node.func.variadic !== 0 && node.args.length >= node.func.argTypes.length
|
||||
);
|
||||
};
|
||||
|
||||
export const humanizedValueType: Record<valueType, string> = {
|
||||
[valueType.none]: 'none',
|
||||
[valueType.string]: 'string',
|
||||
[valueType.scalar]: 'number (scalar)',
|
||||
[valueType.vector]: 'instant vector',
|
||||
[valueType.matrix]: 'range vector',
|
||||
[valueType.none]: "none",
|
||||
[valueType.string]: "string",
|
||||
[valueType.scalar]: "number (scalar)",
|
||||
[valueType.vector]: "instant vector",
|
||||
[valueType.matrix]: "range vector",
|
||||
};
|
||||
|
||||
export const escapeString = (str: string) => {
|
||||
return str.replace(/([\\"])/g, '\\$1');
|
||||
return str.replace(/([\\"])/g, "\\$1");
|
||||
};
|
||||
|
|
27
web/ui/package-lock.json
generated
27
web/ui/package-lock.json
generated
|
@ -62,6 +62,9 @@
|
|||
"use-query-params": "^2.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/compat": "^1.1.1",
|
||||
"@eslint/eslintrc": "^3.1.0",
|
||||
"@eslint/js": "^9.9.1",
|
||||
"@types/react": "^18.3.5",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
||||
|
@ -70,6 +73,7 @@
|
|||
"eslint": "^9.9.1",
|
||||
"eslint-plugin-react-hooks": "^5.1.0-rc-e56f4ae3-20240830",
|
||||
"eslint-plugin-react-refresh": "^0.4.11",
|
||||
"globals": "^15.9.0",
|
||||
"jsdom": "^25.0.0",
|
||||
"postcss": "^8.4.35",
|
||||
"postcss-preset-mantine": "^1.17.0",
|
||||
|
@ -169,6 +173,19 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"mantine-ui/node_modules/globals": {
|
||||
"version": "15.9.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-15.9.0.tgz",
|
||||
"integrity": "sha512-SmSKyLLKFbSr6rptvP8izbyxJL4ILwqO9Jg23UA0sDlGlu58V59D1//I3vlc0KJphVdUR7vMjHIplYnzBxorQA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"module/codemirror-promql": {
|
||||
"name": "@prometheus-io/codemirror-promql",
|
||||
"version": "0.54.1",
|
||||
|
@ -1448,6 +1465,16 @@
|
|||
"node": "^12.0.0 || ^14.0.0 || >=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/compat": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/compat/-/compat-1.1.1.tgz",
|
||||
"integrity": "sha512-lpHyRyplhGPL5mGEh6M9O5nnKk0Gz4bFI+Zu6tKlPpDUN7XshWvH9C/px4UVm87IAANE0W81CEsNGbS1KlzXpA==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/config-array": {
|
||||
"version": "0.18.0",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.18.0.tgz",
|
||||
|
|
Loading…
Reference in a new issue