Skip to content

Commit 5d2b760

Browse files
Merge pull request prometheus#16279 from prometheus/dependabot/npm_and_yarn/web/ui/eslint-9.23.0
chore(deps-dev): bump eslint from 9.18.0 to 9.23.0 in /web/ui
2 parents b99c542 + 6e6ea34 commit 5d2b760

File tree

9 files changed

+141
-383
lines changed

9 files changed

+141
-383
lines changed

web/ui/mantine-ui/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"@typescript-eslint/eslint-plugin": "^8.20.0",
6060
"@typescript-eslint/parser": "^8.25.0",
6161
"@vitejs/plugin-react": "^4.3.4",
62-
"eslint": "^9.18.0",
62+
"eslint": "^9.23.0",
6363
"eslint-plugin-react-hooks": "^5.1.0",
6464
"eslint-plugin-react-refresh": "^0.4.19",
6565
"globals": "^16.0.0",

web/ui/module/codemirror-promql/.eslintrc.json

-34
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { fixupConfigRules } from '@eslint/compat';
2+
import tsParser from '@typescript-eslint/parser';
3+
import path from 'node:path';
4+
import { fileURLToPath } from 'node:url';
5+
import js from '@eslint/js';
6+
import { FlatCompat } from '@eslint/eslintrc';
7+
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = path.dirname(__filename);
10+
const compat = new FlatCompat({
11+
baseDirectory: __dirname,
12+
recommendedConfig: js.configs.recommended,
13+
allConfig: js.configs.all
14+
});
15+
16+
export default [{
17+
ignores: ['**/dist', '**/.eslintrc.cjs', 'node_modules/**'],
18+
}, ...fixupConfigRules(compat.extends(
19+
'eslint:recommended',
20+
'plugin:@typescript-eslint/recommended',
21+
'plugin:prettier/recommended',
22+
)), {
23+
languageOptions: {
24+
parser: tsParser,
25+
},
26+
rules: {
27+
'@typescript-eslint/explicit-function-return-type': ['off'],
28+
'eol-last': [
29+
'error',
30+
'always',
31+
],
32+
'object-curly-spacing': [
33+
'error',
34+
'always',
35+
],
36+
'prefer-const': 'warn',
37+
'comma-dangle': [
38+
'error',
39+
{
40+
'arrays': 'always-multiline',
41+
'objects': 'always-multiline',
42+
'imports': 'always-multiline',
43+
},
44+
],
45+
},
46+
},
47+
];

web/ui/module/codemirror-promql/src/complete/hybrid.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ function isAggregatorWithParam(functionCallBody: SyntaxNode): boolean {
232232
export function analyzeCompletion(state: EditorState, node: SyntaxNode, pos: number): Context[] {
233233
const result: Context[] = [];
234234
switch (node.type.id) {
235-
case 0: // 0 is the id of the error node
235+
case 0: {
236+
// 0 is the id of the error node
236237
if (node.parent?.type.id === OffsetExpr) {
237238
// we are likely in the given situation:
238239
// `metric_name offset 5` that leads to this tree:
@@ -270,7 +271,8 @@ export function analyzeCompletion(state: EditorState, node: SyntaxNode, pos: num
270271
result.push({ kind: ContextKind.BinOp });
271272
}
272273
break;
273-
case Identifier:
274+
}
275+
case Identifier: {
274276
// sometimes an Identifier has an error has parent. This should be treated in priority
275277
if (node.parent?.type.id === 0) {
276278
const errorNodeParent = node.parent.parent;
@@ -380,6 +382,7 @@ export function analyzeCompletion(state: EditorState, node: SyntaxNode, pos: num
380382
}
381383
}
382384
break;
385+
}
383386
case PromQL:
384387
if (node.firstChild !== null && node.firstChild.type.id === 0) {
385388
// this situation can happen when there is nothing in the text area and the user is explicitly triggering the autocompletion (with ctrl + space)

web/ui/module/codemirror-promql/src/parser/matcher.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@ function createMatcher(labelMatcher: SyntaxNode, state: EditorState): Matcher {
4141
case QuotedLabelName:
4242
matcher.name = state.sliceDoc(cursor.from, cursor.to).slice(1, -1);
4343
break;
44-
case MatchOp:
44+
case MatchOp: {
4545
const ope = cursor.node.firstChild;
4646
if (ope) {
4747
matcher.type = ope.type.id;
4848
}
4949
break;
50+
}
5051
case StringLiteral:
5152
matcher.value = state.sliceDoc(cursor.from, cursor.to).slice(1, -1);
5253
break;
@@ -63,12 +64,13 @@ function createMatcher(labelMatcher: SyntaxNode, state: EditorState): Matcher {
6364
case LabelName:
6465
matcher.name = state.sliceDoc(cursor.from, cursor.to);
6566
break;
66-
case MatchOp:
67+
case MatchOp: {
6768
const ope = cursor.node.firstChild;
6869
if (ope) {
6970
matcher.type = ope.type.id;
7071
}
7172
break;
73+
}
7274
case StringLiteral:
7375
matcher.value = state.sliceDoc(cursor.from, cursor.to).slice(1, -1);
7476
break;

web/ui/module/codemirror-promql/src/parser/parser.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ describe('promql operations', () => {
959959
],
960960
},
961961
{
962-
expr: `{'foo\`metric':'bar'}`, // eslint-disable-line
962+
expr: `{'foo\`metric':'bar'}`,
963963
expectedValueType: ValueType.vector,
964964
expectedDiag: [],
965965
},

web/ui/module/codemirror-promql/src/parser/parser.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -116,25 +116,27 @@ export class Parser {
116116
case ParenExpr:
117117
this.checkAST(node.getChild('Expr'));
118118
break;
119-
case UnaryExpr:
119+
case UnaryExpr: {
120120
const unaryExprType = this.checkAST(node.getChild('Expr'));
121121
if (unaryExprType !== ValueType.scalar && unaryExprType !== ValueType.vector) {
122122
this.addDiagnostic(node, `unary expression only allowed on expressions of type scalar or instant vector, got ${unaryExprType}`);
123123
}
124124
break;
125-
case SubqueryExpr:
125+
}
126+
case SubqueryExpr: {
126127
const subQueryExprType = this.checkAST(node.getChild('Expr'));
127128
if (subQueryExprType !== ValueType.vector) {
128129
this.addDiagnostic(node, `subquery is only allowed on instant vector, got ${subQueryExprType} in ${node.name} instead`);
129130
}
130131
break;
132+
}
131133
case MatrixSelector:
132134
this.checkAST(node.getChild('Expr'));
133135
break;
134136
case VectorSelector:
135137
this.checkVectorSelector(node);
136138
break;
137-
case StepInvariantExpr:
139+
case StepInvariantExpr: {
138140
const exprValue = this.checkAST(node.getChild('Expr'));
139141
if (exprValue !== ValueType.vector && exprValue !== ValueType.matrix) {
140142
this.addDiagnostic(node, `@ modifier must be preceded by an instant selector vector or range vector selector or a subquery`);
@@ -148,6 +150,7 @@ export class Parser {
148150
// So far I didn't find the way to fix it. I think it's likely due to the fact we are building an ESM package which is now something stable in nodeJS/javascript but still experimental in typescript.
149151
// For the above reason, we decided to drop these checks.
150152
break;
153+
}
151154
}
152155

153156
return getType(node);

web/ui/module/codemirror-promql/src/parser/type.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,21 @@ export function getType(node: SyntaxNode | null): ValueType {
5252
return getType(node.getChild('Expr'));
5353
case UnaryExpr:
5454
return getType(node.getChild('Expr'));
55-
case BinaryExpr:
55+
case BinaryExpr: {
5656
const lt = getType(node.firstChild);
5757
const rt = getType(node.lastChild);
5858
if (lt === ValueType.scalar && rt === ValueType.scalar) {
5959
return ValueType.scalar;
6060
}
6161
return ValueType.vector;
62-
case FunctionCall:
62+
}
63+
case FunctionCall: {
6364
const funcNode = node.firstChild?.firstChild;
6465
if (!funcNode) {
6566
return ValueType.none;
6667
}
6768
return getFunction(funcNode.type.id).returnType;
69+
}
6870
case StepInvariantExpr:
6971
return getType(node.getChild('Expr'));
7072
default:

0 commit comments

Comments
 (0)