From 7b3411185d7a1754cc450633423a554139b3792d Mon Sep 17 00:00:00 2001 From: liangling Date: Mon, 25 Nov 2024 17:11:53 +0800 Subject: [PATCH] feat: add biomejs feature --- biome.json | 74 +++++++++++++++ package.json | 1 + pnpm-lock.yaml | 91 +++++++++++++++++++ src/alert/.config/jest-setup.js | 2 +- src/alert/.config/jest.config.js | 2 +- .../.config/jest/mocks/react-inlinesvg.tsx | 8 +- src/alert/.config/jest/utils.js | 2 +- src/alert/.config/webpack/utils.ts | 10 +- src/alert/.config/webpack/webpack.config.ts | 20 ++-- .../src/components/alert-condition-input.tsx | 4 +- .../src/components/alert-dimension-input.tsx | 3 +- src/alert/src/components/editor-form.tsx | 2 +- src/alert/src/components/query-editor.tsx | 24 ++--- src/alert/src/configuration/config-editor.tsx | 4 +- src/alert/src/datasource/datasource.ts | 24 ++--- src/alert/src/lang/en.json | 14 +-- src/alert/src/typings/config.ts | 2 +- src/alert/src/typings/datasource.ts | 4 +- src/alert/src/typings/metric.ts | 6 +- src/alert/src/typings/variable.ts | 2 +- src/alert/src/utils/common.ts | 8 +- src/alert/src/utils/utils.ts | 2 +- src/event/.config/jest-setup.js | 2 +- .../.config/jest/mocks/react-inlinesvg.tsx | 8 +- src/event/.config/jest/utils.js | 2 +- src/event/.config/webpack/utils.ts | 10 +- src/event/.config/webpack/webpack.config.ts | 18 ++-- src/event/src/components/condition-input.tsx | 4 +- src/event/src/components/data-input.tsx | 2 +- src/event/src/components/dimension-input.tsx | 2 +- src/event/src/components/event-editor.tsx | 12 +-- src/event/src/components/type-iput.tsx | 2 +- src/event/src/components/variable-editor.tsx | 20 ++-- src/event/src/components/variable-line.tsx | 2 +- src/event/src/configuration/config-editor.tsx | 4 +- src/event/src/datasource/datasource.ts | 24 ++--- src/event/src/typings/config.ts | 2 +- src/event/src/typings/datasource.ts | 4 +- src/event/src/typings/variable.ts | 2 +- src/event/src/utils/utils.ts | 2 +- src/profiling/.config/jest-setup.js | 2 +- .../.config/jest/mocks/react-inlinesvg.tsx | 8 +- src/profiling/.config/jest/utils.js | 2 +- src/profiling/.config/webpack/utils.ts | 10 +- .../.config/webpack/webpack.config.ts | 20 ++-- .../src/components/condition-input.tsx | 6 +- src/profiling/src/components/query-editor.tsx | 6 +- .../src/configuration/config-editor.tsx | 4 +- src/profiling/src/datasource/datasource.ts | 26 +++--- src/profiling/src/typings/config.ts | 2 +- src/profiling/src/typings/datasource.ts | 4 +- src/profiling/src/utils/utils.ts | 2 +- src/timeseries/.config/jest-setup.js | 2 +- .../.config/jest/mocks/react-inlinesvg.tsx | 8 +- src/timeseries/.config/jest/utils.js | 2 +- src/timeseries/.config/webpack/utils.ts | 2 +- .../.config/webpack/webpack.config.ts | 18 ++-- .../src/components/addvance-setting.tsx | 2 +- src/timeseries/src/components/alias-input.tsx | 2 +- .../src/components/condition-input.tsx | 4 +- .../src/components/dimension-input.tsx | 2 +- src/timeseries/src/components/editor-form.tsx | 2 +- .../src/components/function-menu.tsx | 16 ++-- .../src/components/funtion-input.tsx | 4 +- .../src/components/interval-input.tsx | 2 +- .../src/components/metirc-input.tsx | 31 +++---- .../src/components/promql-editor.tsx | 8 +- .../src/components/query-editor.tsx | 80 ++++++++-------- .../src/components/query-formula.tsx | 2 +- .../src/components/target-input.tsx | 4 +- .../src/components/variable-editor.tsx | 22 ++--- .../src/components/variable-line.tsx | 2 +- .../src/configuration/config-editor.tsx | 4 +- src/timeseries/src/datasource/datasource.ts | 32 +++---- src/timeseries/src/types.ts | 4 +- src/timeseries/src/typings/config.ts | 2 +- src/timeseries/src/typings/datasource.ts | 11 +-- src/timeseries/src/typings/metric.ts | 8 +- src/timeseries/src/typings/variable.ts | 2 +- src/timeseries/src/utils/common.ts | 12 +-- src/timeseries/src/utils/utils.ts | 2 +- src/trace/.config/jest-setup.js | 2 +- .../.config/jest/mocks/react-inlinesvg.tsx | 8 +- src/trace/.config/jest/utils.js | 2 +- src/trace/.config/webpack/utils.ts | 10 +- src/trace/.config/webpack/webpack.config.ts | 16 ++-- src/trace/src/CheatSheet.tsx | 2 +- src/trace/src/components/QueryEditor.tsx | 6 +- src/trace/src/components/SearchForm.tsx | 12 +-- src/trace/src/configuration/ConfigEditor.tsx | 2 +- src/trace/src/datasource.ts | 26 +++--- src/trace/src/dependencyGraphTransform.ts | 2 +- src/trace/src/graphTransform.ts | 4 +- src/trace/src/responseTransform.ts | 8 +- src/trace/src/transform-trace-data.tsx | 8 +- src/trace/src/types.ts | 2 +- src/trace/src/utils/get-config.tsx | 2 +- src/trace/src/utils/trace-viewer.ts | 4 +- src/trace/src/utils/trace.ts | 2 +- 99 files changed, 558 insertions(+), 375 deletions(-) create mode 100644 biome.json diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..d23db7d --- /dev/null +++ b/biome.json @@ -0,0 +1,74 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", + "organizeImports": { + "enabled": false + }, + "vcs": { + "enabled": true, + "clientKind": "git" + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "suspicious": { + "noExplicitAny": { + "level": "off" + }, + "noAssignInExpressions": "warn", + "noArrayIndexKey": "warn" + }, + "style": { + "useSelfClosingElements": { + "fix": "safe", + "level": "warn" + }, + "noUnusedTemplateLiteral": { + "fix": "safe", + "level": "error" + }, + "noNonNullAssertion": "warn" + }, + "complexity": { + "noBannedTypes": { + "fix": "safe", + "level": "error" + }, + "noForEach": { + "level": "warn" + }, + "useArrowFunction": { + "fix": "none", + "level": "warn" + } + }, + "a11y": { + "useKeyWithMouseEvents": "off", + "useKeyWithClickEvents": "off", + "noSvgWithoutTitle": "off", + "useValidAnchor": "off" + } + } + }, + "formatter": { + "indentStyle": "space", + "indentWidth": 2, + "lineEnding": "lf", + "lineWidth": 120, + "attributePosition": "multiline" + }, + "javascript": { + "jsxRuntime": "reactClassic", + "formatter": { + "quoteStyle": "single", + "jsxQuoteStyle": "single", + "quoteProperties": "asNeeded", + "trailingCommas": "es5", + "semicolons": "always", + "arrowParentheses": "asNeeded", + "bracketSpacing": true, + "bracketSameLine": false, + "attributePosition": "multiline" + } + } +} diff --git a/package.json b/package.json index 212098f..b5133d4 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "packageManager": "pnpm@8.10.2", "devDependencies": { "@babel/core": "^7.24.5", + "@biomejs/biome": "^1.9.4", "@blueking/bkui-lint": "^0.0.3", "@grafana/tsconfig": "1.3.0-rc1", "@swc/core": "^1.4.17", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 99fe5fb..e312c4f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@babel/core': specifier: ^7.24.5 version: 7.24.5 + '@biomejs/biome': + specifier: ^1.9.4 + version: 1.9.4 '@blueking/bkui-lint': specifier: ^0.0.3 version: 0.0.3(@babel/core@7.24.5)(@types/eslint@8.56.5)(postcss@8.4.35)(typescript@5.4.5) @@ -604,6 +607,59 @@ packages: '@bcoe/v8-coverage@0.2.3': resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} + '@biomejs/biome@1.9.4': + resolution: {integrity: sha512-1rkd7G70+o9KkTn5KLmDYXihGoTaIGO9PIIN2ZB7UJxFrWw04CZHPYiMRjYsaDvVV7hP1dYNRLxSANLaBFGpog==} + engines: {node: '>=14.21.3'} + hasBin: true + + '@biomejs/cli-darwin-arm64@1.9.4': + resolution: {integrity: sha512-bFBsPWrNvkdKrNCYeAp+xo2HecOGPAy9WyNyB/jKnnedgzl4W4Hb9ZMzYNbf8dMCGmUdSavlYHiR01QaYR58cw==} + engines: {node: '>=14.21.3'} + cpu: [arm64] + os: [darwin] + + '@biomejs/cli-darwin-x64@1.9.4': + resolution: {integrity: sha512-ngYBh/+bEedqkSevPVhLP4QfVPCpb+4BBe2p7Xs32dBgs7rh9nY2AIYUL6BgLw1JVXV8GlpKmb/hNiuIxfPfZg==} + engines: {node: '>=14.21.3'} + cpu: [x64] + os: [darwin] + + '@biomejs/cli-linux-arm64-musl@1.9.4': + resolution: {integrity: sha512-v665Ct9WCRjGa8+kTr0CzApU0+XXtRgwmzIf1SeKSGAv+2scAlW6JR5PMFo6FzqqZ64Po79cKODKf3/AAmECqA==} + engines: {node: '>=14.21.3'} + cpu: [arm64] + os: [linux] + + '@biomejs/cli-linux-arm64@1.9.4': + resolution: {integrity: sha512-fJIW0+LYujdjUgJJuwesP4EjIBl/N/TcOX3IvIHJQNsAqvV2CHIogsmA94BPG6jZATS4Hi+xv4SkBBQSt1N4/g==} + engines: {node: '>=14.21.3'} + cpu: [arm64] + os: [linux] + + '@biomejs/cli-linux-x64-musl@1.9.4': + resolution: {integrity: sha512-gEhi/jSBhZ2m6wjV530Yy8+fNqG8PAinM3oV7CyO+6c3CEh16Eizm21uHVsyVBEB6RIM8JHIl6AGYCv6Q6Q9Tg==} + engines: {node: '>=14.21.3'} + cpu: [x64] + os: [linux] + + '@biomejs/cli-linux-x64@1.9.4': + resolution: {integrity: sha512-lRCJv/Vi3Vlwmbd6K+oQ0KhLHMAysN8lXoCI7XeHlxaajk06u7G+UsFSO01NAs5iYuWKmVZjmiOzJ0OJmGsMwg==} + engines: {node: '>=14.21.3'} + cpu: [x64] + os: [linux] + + '@biomejs/cli-win32-arm64@1.9.4': + resolution: {integrity: sha512-tlbhLk+WXZmgwoIKwHIHEBZUwxml7bRJgk0X2sPyNR3S93cdRq6XulAZRQJ17FYGGzWne0fgrXBKpl7l4M87Hg==} + engines: {node: '>=14.21.3'} + cpu: [arm64] + os: [win32] + + '@biomejs/cli-win32-x64@1.9.4': + resolution: {integrity: sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA==} + engines: {node: '>=14.21.3'} + cpu: [x64] + os: [win32] + '@blueking/bkui-lint@0.0.3': resolution: {integrity: sha512-rK2g22R5nxpL2/94sxrn1n7YN+iqdcL5evIEo2vr9mihLTWJUDfXURTRtEjU3ukQyk1mUTDGeGZV43yw6Da2gw==} @@ -5989,6 +6045,41 @@ snapshots: '@bcoe/v8-coverage@0.2.3': {} + '@biomejs/biome@1.9.4': + optionalDependencies: + '@biomejs/cli-darwin-arm64': 1.9.4 + '@biomejs/cli-darwin-x64': 1.9.4 + '@biomejs/cli-linux-arm64': 1.9.4 + '@biomejs/cli-linux-arm64-musl': 1.9.4 + '@biomejs/cli-linux-x64': 1.9.4 + '@biomejs/cli-linux-x64-musl': 1.9.4 + '@biomejs/cli-win32-arm64': 1.9.4 + '@biomejs/cli-win32-x64': 1.9.4 + + '@biomejs/cli-darwin-arm64@1.9.4': + optional: true + + '@biomejs/cli-darwin-x64@1.9.4': + optional: true + + '@biomejs/cli-linux-arm64-musl@1.9.4': + optional: true + + '@biomejs/cli-linux-arm64@1.9.4': + optional: true + + '@biomejs/cli-linux-x64-musl@1.9.4': + optional: true + + '@biomejs/cli-linux-x64@1.9.4': + optional: true + + '@biomejs/cli-win32-arm64@1.9.4': + optional: true + + '@biomejs/cli-win32-x64@1.9.4': + optional: true + '@blueking/bkui-lint@0.0.3(@babel/core@7.24.5)(@types/eslint@8.56.5)(postcss@8.4.35)(typescript@5.4.5)': dependencies: '@typescript-eslint/eslint-plugin': 7.8.0(@typescript-eslint/parser@7.8.0(eslint@9.2.0)(typescript@5.4.5))(eslint@9.2.0)(typescript@5.4.5) diff --git a/src/alert/.config/jest-setup.js b/src/alert/.config/jest-setup.js index 1b9fc2f..b437976 100644 --- a/src/alert/.config/jest-setup.js +++ b/src/alert/.config/jest-setup.js @@ -10,7 +10,7 @@ import '@testing-library/jest-dom'; // https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom Object.defineProperty(global, 'matchMedia', { writable: true, - value: jest.fn().mockImplementation((query) => ({ + value: jest.fn().mockImplementation(query => ({ matches: false, media: query, onchange: null, diff --git a/src/alert/.config/jest.config.js b/src/alert/.config/jest.config.js index 94489cb..5716bb6 100644 --- a/src/alert/.config/jest.config.js +++ b/src/alert/.config/jest.config.js @@ -5,7 +5,7 @@ * https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-jest-config */ -const path = require('path'); +const path = require('node:path'); const { grafanaESModules, nodeModulesToTransform } = require('./jest/utils'); module.exports = { diff --git a/src/alert/.config/jest/mocks/react-inlinesvg.tsx b/src/alert/.config/jest/mocks/react-inlinesvg.tsx index d540f3a..bac103d 100644 --- a/src/alert/.config/jest/mocks/react-inlinesvg.tsx +++ b/src/alert/.config/jest/mocks/react-inlinesvg.tsx @@ -19,7 +19,13 @@ const SVG_FILE_NAME_REGEX = /(.+)\/(.+)\.svg$/; const InlineSVG = ({ src }: { src: string }) => { // testId will be the file name without extension (e.g. `public/img/icons/angle-double-down.svg` -> `angle-double-down`) const testId = src.replace(SVG_FILE_NAME_REGEX, '$2'); - return ; + return ( + + ); }; export default InlineSVG; diff --git a/src/alert/.config/jest/utils.js b/src/alert/.config/jest/utils.js index fdca0de..3654e98 100644 --- a/src/alert/.config/jest/utils.js +++ b/src/alert/.config/jest/utils.js @@ -8,7 +8,7 @@ * This utility function is useful in combination with jest `transformIgnorePatterns` config * to transform specific packages (e.g.ES modules) in a projects node_modules folder. */ -const nodeModulesToTransform = (moduleNames) => `node_modules\/(?!.*(${moduleNames.join('|')})\/.*)`; +const nodeModulesToTransform = moduleNames => `node_modules\/(?!.*(${moduleNames.join('|')})\/.*)`; // Array of known nested grafana package dependencies that only bundle an ESM version const grafanaESModules = [ diff --git a/src/alert/.config/webpack/utils.ts b/src/alert/.config/webpack/utils.ts index 07eea6e..7673f57 100644 --- a/src/alert/.config/webpack/utils.ts +++ b/src/alert/.config/webpack/utils.ts @@ -1,7 +1,7 @@ -import fs from 'fs'; -import process from 'process'; -import os from 'os'; -import path from 'path'; +import fs from 'node:fs'; +import process from 'node:process'; +import os from 'node:os'; +import path from 'node:path'; import { glob } from 'glob'; import { SOURCE_DIR } from './constants'; @@ -39,7 +39,7 @@ export async function getEntries(): Promise> { const pluginsJson = await glob('**/src/**/plugin.json', { absolute: true }); const plugins = await Promise.all( - pluginsJson.map((pluginJson) => { + pluginsJson.map(pluginJson => { const folder = path.dirname(pluginJson); return glob(`${folder}/module.{ts,tsx,js,jsx}`, { absolute: true }); }) diff --git a/src/alert/.config/webpack/webpack.config.ts b/src/alert/.config/webpack/webpack.config.ts index 23e28b5..1f04cf0 100644 --- a/src/alert/.config/webpack/webpack.config.ts +++ b/src/alert/.config/webpack/webpack.config.ts @@ -1,9 +1,9 @@ import CopyWebpackPlugin from 'copy-webpack-plugin'; import LiveReloadPlugin from 'webpack-livereload-plugin'; -import path from 'path'; +import path from 'node:path'; import ReplaceInFileWebpackPlugin from 'replace-in-file-webpack-plugin'; import MiniCssExtractPlugin from 'mini-css-extract-plugin'; -import { Configuration } from 'webpack'; +import type { Configuration } from 'webpack'; import { getPackageJson, getPluginJson, hasReadme, getEntries, isWSL } from './utils'; import { SOURCE_DIR, DIST_DIR } from './constants'; @@ -58,8 +58,8 @@ const config = async (env): Promise => { // Mark legacy SDK imports as external if their name starts with the "grafana/" prefix ({ request }, callback) => { const prefix = 'grafana/'; - const hasPrefix = (request) => request.indexOf(prefix) === 0; - const stripPrefix = (request) => request.substr(prefix.length); + const hasPrefix = request => request.indexOf(prefix) === 0; + const stripPrefix = request => request.substr(prefix.length); if (hasPrefix(request)) { return callback(undefined, stripPrefix(request)); @@ -101,7 +101,7 @@ const config = async (env): Promise => { { loader: 'sass-loader', options: { - additionalData: `$plugin-name: monitor-grafana-alert;`, + additionalData: '$plugin-name: monitor-grafana-alert;', }, }, ], @@ -152,7 +152,7 @@ const config = async (env): Promise => { generator: { publicPath: `public/plugins/${pluginJson.id}/img/`, outputPath: 'img/', - filename: Boolean(env.production) ? '[hash][ext]' : '[file]', + filename: env.production ? '[hash][ext]' : '[file]', }, }, { @@ -161,7 +161,7 @@ const config = async (env): Promise => { generator: { publicPath: `public/plugins/${pluginJson.id}/fonts/`, outputPath: 'fonts/', - filename: Boolean(env.production) ? '[hash][ext]' : '[name][ext]', + filename: env.production ? '[hash][ext]' : '[name][ext]', }, }, ], @@ -169,9 +169,9 @@ const config = async (env): Promise => { output: { clean: { - keep: new RegExp(`(.*?_(amd64|arm(64)?)(.exe)?|go_plugin_build_manifest)`), + keep: /(.*?_(amd64|arm(64)?)(.exe)?|go_plugin_build_manifest)/, }, - filename: `[name].js`, + filename: '[name].js', path: path.resolve(process.cwd(), DIST_DIR), publicPath: `public/plugins/${pluginJson.id}/`, libraryTarget: 'amd', @@ -215,7 +215,7 @@ const config = async (env): Promise => { }, ]), new MiniCssExtractPlugin({ - filename: `[name].css`, + filename: '[name].css', chunkFilename: '[id].css', }), ...(env.development diff --git a/src/alert/src/components/alert-condition-input.tsx b/src/alert/src/components/alert-condition-input.tsx index 3275e7e..8e13a5c 100644 --- a/src/alert/src/components/alert-condition-input.tsx +++ b/src/alert/src/components/alert-condition-input.tsx @@ -123,7 +123,7 @@ export default class AlertConditionInput extends React.PureComponent = { -readonly [P in keyof T]: T[P] }; export type IQueryEditorProps = QueryEditorProps; export enum SearcState { - 'auto' = 'auto', - 'deafult' = 'deafult', - 'loading' = 'loading', + auto = 'auto', + deafult = 'deafult', + loading = 'loading', } interface IQueryEditorState { agg_method: string; @@ -90,7 +90,7 @@ export default class MonitorQueryEditor extends React.PureComponent { @@ -112,7 +112,7 @@ export default class MonitorQueryEditor extends React.PureComponent needQuery !== false && this.handleQuery(), + () => needQuery !== false && this.handleQuery() ); }; handleDimensionChange = async (v: string[]) => { @@ -120,7 +120,7 @@ export default class MonitorQueryEditor extends React.PureComponent { @@ -128,7 +128,7 @@ export default class MonitorQueryEditor extends React.PureComponent { @@ -136,7 +136,7 @@ export default class MonitorQueryEditor extends React.PureComponent { @@ -144,7 +144,7 @@ export default class MonitorQueryEditor extends React.PureComponent { diff --git a/src/alert/src/configuration/config-editor.tsx b/src/alert/src/configuration/config-editor.tsx index 07e9aae..451803f 100644 --- a/src/alert/src/configuration/config-editor.tsx +++ b/src/alert/src/configuration/config-editor.tsx @@ -23,11 +23,11 @@ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ -import { type DataSourcePluginOptionsEditorProps } from '@grafana/data'; +import type { DataSourcePluginOptionsEditorProps } from '@grafana/data'; import { LegacyForms, TagsInput } from '@grafana/ui'; import React from 'react'; -import { type QueryOption, type SecureOption } from '../typings/config'; +import type { QueryOption, SecureOption } from '../typings/config'; import { t } from '../utils/utils'; const { Input, FormField, Switch } = LegacyForms; export default class ConfigEditor extends React.PureComponent< diff --git a/src/alert/src/datasource/datasource.ts b/src/alert/src/datasource/datasource.ts index 7b5f1c8..3e296f9 100644 --- a/src/alert/src/datasource/datasource.ts +++ b/src/alert/src/datasource/datasource.ts @@ -44,9 +44,9 @@ import { import { getBackendSrv, type BackendSrvRequest, getTemplateSrv } from '@grafana/runtime'; import apiCacheInstance from 'common/utils/api-cache'; -import { type QueryOption } from '../typings/config'; +import type { QueryOption } from '../typings/config'; import { DIM_NULL_ID, type IQueryConfig, type QueryData } from '../typings/datasource'; -import { type IMetric, type ITargetData, type EditMode, type IntervalType } from '../typings/metric'; +import type { IMetric, ITargetData, EditMode, IntervalType } from '../typings/metric'; import { type K8sVariableQueryType, ScenarioType, type VariableQuery, VariableQueryType } from '../typings/variable'; import { handleTransformOldVariableQuery } from '../utils/common'; import { random } from '../utils/utils'; @@ -129,7 +129,7 @@ export default class DashboardDatasource extends DataSourceApi, + dimensions: Record ) { const regex = /\$([\w]+)|\[\[([\s\S]+?)\]\]/g; const tagRegx = /(\$(tag_|dim_)\$[\w.]+)/gm; @@ -180,7 +180,7 @@ export default class DashboardDatasource extends DataSourceApi item.metric_field === config.metric_field && item.result_table_id === config.result_table_id, + item => item.metric_field === config.metric_field && item.result_table_id === config.result_table_id ); aliasData = { metric_id: metric?.metric_field, @@ -574,7 +574,7 @@ export default class DashboardDatasource extends DataSourceApi []), + this.request(params).catch(() => []) ); const data = await apiCacheInstance.getCache(cacheKey); return data; @@ -597,7 +597,7 @@ export default class DashboardDatasource extends DataSourceApi []), + this.request(params).catch(() => []) ); const res = await apiCacheInstance.getCache(cacheKey); return res; @@ -747,13 +747,13 @@ export default class DashboardDatasource extends DataSourceApi - this.buildFetchSeries(data, options.scopedVars, config.alias, config, item), + this.buildFetchSeries(data, options.scopedVars, config.alias, config, item) ) .catch(e => { console.error(e); errorMsg += e.data?.message || 'query error'; return []; - }), + }) ); } }); @@ -761,7 +761,7 @@ export default class DashboardDatasource extends DataSourceApi - list.reduce((pre, cur) => (cur?.length ? ((pre.data = [...pre.data, ...cur]), pre) : pre), { data: [] }), + list.reduce((pre, cur) => (cur?.length ? ((pre.data = [...pre.data, ...cur]), pre) : pre), { data: [] }) ) .catch(e => { console.error(e); @@ -779,7 +779,7 @@ export default class DashboardDatasource extends DataSourceApi 1) { const tableRefId = options.targets.filter(item => item.format === 'table').map(item => item.refId); @@ -897,7 +897,7 @@ export default class DashboardDatasource extends DataSourceApi { let metricConfig: any = {}; if (data.dimensionData) { const { metric, conditions, dimensions, monitorObject } = data.dimensionData; - const [dataSourceTypeLabel, , resultTableId, metricField] = metric?.id; + const [dataSourceTypeLabel, , resultTableId, metricField] = metric.id; const dataSourceLabel = dataSourceTypeLabel?.replace(/(_|\.)(log|event|time_series)$/, '') || ''; metricConfig = { data_source_label: dataSourceLabel, @@ -50,7 +50,7 @@ export const handleTransformOldVariableQuery = (data: any) => { item.reduce((pre, cur) => { pre[cur.type] = cur.value; return pre; - }, {}), + }, {}) ), group_by: typeof dimensions === 'string' ? [dimensions] : dimensions, }; @@ -64,7 +64,7 @@ export const handleTransformOldVariableQuery = (data: any) => { item.reduce((pre, cur) => { pre[cur.type] = cur.value; return pre; - }, {}), + }, {}) ) || [], variables: data.variables, metricConfig, diff --git a/src/alert/src/utils/utils.ts b/src/alert/src/utils/utils.ts index 7474647..197b55e 100644 --- a/src/alert/src/utils/utils.ts +++ b/src/alert/src/utils/utils.ts @@ -35,7 +35,7 @@ export const random = (n: number, str = 'abcdefghijklmnopqrstuvwxyz0123456789'): // 生成n位长度的字符串 let result = ''; for (let i = 0; i < n; i++) { - result += str[parseInt(String(Math.random() * str.length))]; + result += str[Number.parseInt(String(Math.random() * str.length))]; } return result; }; diff --git a/src/event/.config/jest-setup.js b/src/event/.config/jest-setup.js index 1b9fc2f..b437976 100644 --- a/src/event/.config/jest-setup.js +++ b/src/event/.config/jest-setup.js @@ -10,7 +10,7 @@ import '@testing-library/jest-dom'; // https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom Object.defineProperty(global, 'matchMedia', { writable: true, - value: jest.fn().mockImplementation((query) => ({ + value: jest.fn().mockImplementation(query => ({ matches: false, media: query, onchange: null, diff --git a/src/event/.config/jest/mocks/react-inlinesvg.tsx b/src/event/.config/jest/mocks/react-inlinesvg.tsx index d540f3a..bac103d 100644 --- a/src/event/.config/jest/mocks/react-inlinesvg.tsx +++ b/src/event/.config/jest/mocks/react-inlinesvg.tsx @@ -19,7 +19,13 @@ const SVG_FILE_NAME_REGEX = /(.+)\/(.+)\.svg$/; const InlineSVG = ({ src }: { src: string }) => { // testId will be the file name without extension (e.g. `public/img/icons/angle-double-down.svg` -> `angle-double-down`) const testId = src.replace(SVG_FILE_NAME_REGEX, '$2'); - return ; + return ( + + ); }; export default InlineSVG; diff --git a/src/event/.config/jest/utils.js b/src/event/.config/jest/utils.js index fdca0de..3654e98 100644 --- a/src/event/.config/jest/utils.js +++ b/src/event/.config/jest/utils.js @@ -8,7 +8,7 @@ * This utility function is useful in combination with jest `transformIgnorePatterns` config * to transform specific packages (e.g.ES modules) in a projects node_modules folder. */ -const nodeModulesToTransform = (moduleNames) => `node_modules\/(?!.*(${moduleNames.join('|')})\/.*)`; +const nodeModulesToTransform = moduleNames => `node_modules\/(?!.*(${moduleNames.join('|')})\/.*)`; // Array of known nested grafana package dependencies that only bundle an ESM version const grafanaESModules = [ diff --git a/src/event/.config/webpack/utils.ts b/src/event/.config/webpack/utils.ts index 07eea6e..7673f57 100644 --- a/src/event/.config/webpack/utils.ts +++ b/src/event/.config/webpack/utils.ts @@ -1,7 +1,7 @@ -import fs from 'fs'; -import process from 'process'; -import os from 'os'; -import path from 'path'; +import fs from 'node:fs'; +import process from 'node:process'; +import os from 'node:os'; +import path from 'node:path'; import { glob } from 'glob'; import { SOURCE_DIR } from './constants'; @@ -39,7 +39,7 @@ export async function getEntries(): Promise> { const pluginsJson = await glob('**/src/**/plugin.json', { absolute: true }); const plugins = await Promise.all( - pluginsJson.map((pluginJson) => { + pluginsJson.map(pluginJson => { const folder = path.dirname(pluginJson); return glob(`${folder}/module.{ts,tsx,js,jsx}`, { absolute: true }); }) diff --git a/src/event/.config/webpack/webpack.config.ts b/src/event/.config/webpack/webpack.config.ts index 9403f19..1cb9801 100644 --- a/src/event/.config/webpack/webpack.config.ts +++ b/src/event/.config/webpack/webpack.config.ts @@ -1,9 +1,9 @@ import CopyWebpackPlugin from 'copy-webpack-plugin'; import LiveReloadPlugin from 'webpack-livereload-plugin'; -import path from 'path'; +import path from 'node:path'; import ReplaceInFileWebpackPlugin from 'replace-in-file-webpack-plugin'; import MiniCssExtractPlugin from 'mini-css-extract-plugin'; -import { Configuration } from 'webpack'; +import type { Configuration } from 'webpack'; import { getPackageJson, getPluginJson, hasReadme, getEntries, isWSL } from './utils'; import { SOURCE_DIR, DIST_DIR } from './constants'; @@ -58,8 +58,8 @@ const config = async (env): Promise => { // Mark legacy SDK imports as external if their name starts with the "grafana/" prefix ({ request }, callback) => { const prefix = 'grafana/'; - const hasPrefix = (request) => request.indexOf(prefix) === 0; - const stripPrefix = (request) => request.substr(prefix.length); + const hasPrefix = request => request.indexOf(prefix) === 0; + const stripPrefix = request => request.substr(prefix.length); if (hasPrefix(request)) { return callback(undefined, stripPrefix(request)); @@ -155,7 +155,7 @@ const config = async (env): Promise => { generator: { publicPath: `public/plugins/${pluginJson.id}/img/`, outputPath: 'img/', - filename: Boolean(env.production) ? '[hash][ext]' : '[file]', + filename: env.production ? '[hash][ext]' : '[file]', }, }, { @@ -164,7 +164,7 @@ const config = async (env): Promise => { generator: { publicPath: `public/plugins/${pluginJson.id}/fonts/`, outputPath: 'fonts/', - filename: Boolean(env.production) ? '[hash][ext]' : '[name][ext]', + filename: env.production ? '[hash][ext]' : '[name][ext]', }, }, ], @@ -172,9 +172,9 @@ const config = async (env): Promise => { output: { clean: { - keep: new RegExp(`(.*?_(amd64|arm(64)?)(.exe)?|go_plugin_build_manifest)`), + keep: /(.*?_(amd64|arm(64)?)(.exe)?|go_plugin_build_manifest)/, }, - filename: `[name].js`, + filename: '[name].js', path: path.resolve(process.cwd(), DIST_DIR), publicPath: `public/plugins/${pluginJson.id}/`, libraryTarget: 'amd', @@ -218,7 +218,7 @@ const config = async (env): Promise => { }, ]), new MiniCssExtractPlugin({ - filename: `[name].css`, + filename: '[name].css', chunkFilename: '[id].css', }), ...(env.development diff --git a/src/event/src/components/condition-input.tsx b/src/event/src/components/condition-input.tsx index ecc7d6e..ee9a965 100644 --- a/src/event/src/components/condition-input.tsx +++ b/src/event/src/components/condition-input.tsx @@ -89,7 +89,7 @@ export default class ConditionInput extends React.PureComponent }; } return item; - }), + }) ); } handleKeyChange = async (v: string, index: number) => { @@ -111,7 +111,7 @@ export default class ConditionInput extends React.PureComponent }; } return item; - }), + }) ); if (this.state.dimensionValueMap[v] || !v || !this.props.getDimensionValue) return; const data = await this.props.getDimensionValue(v); diff --git a/src/event/src/components/data-input.tsx b/src/event/src/components/data-input.tsx index e17d276..ea68b4c 100644 --- a/src/event/src/components/data-input.tsx +++ b/src/event/src/components/data-input.tsx @@ -25,7 +25,7 @@ */ import Select from 'antd/es/select'; import React from 'react'; -import { type ICommonItem } from 'typings/metric'; +import type { ICommonItem } from 'typings/metric'; const { Option } = Select; export interface IDataInputProps { onChange?: (v: string) => void; diff --git a/src/event/src/components/dimension-input.tsx b/src/event/src/components/dimension-input.tsx index 6b52380..f4b7fdc 100644 --- a/src/event/src/components/dimension-input.tsx +++ b/src/event/src/components/dimension-input.tsx @@ -29,7 +29,7 @@ import Select from 'antd/es/select'; import Tooltip from 'antd/es/tooltip'; import React from 'react'; -import { type ICommonItem } from '../typings/metric'; +import type { ICommonItem } from '../typings/metric'; import { LanguageContext } from '../utils/context'; import { t } from '../utils/utils'; const { Option } = Select; diff --git a/src/event/src/components/event-editor.tsx b/src/event/src/components/event-editor.tsx index 8a417eb..919ed07 100644 --- a/src/event/src/components/event-editor.tsx +++ b/src/event/src/components/event-editor.tsx @@ -25,13 +25,13 @@ * IN THE SOFTWARE. */ -import { type QueryEditorProps } from '@grafana/data'; +import type { QueryEditorProps } from '@grafana/data'; import Spin from 'antd/es/spin'; import React from 'react'; -import { type QueryOption } from '../typings/config'; -import { type QueryData } from '../typings/datasource'; -import { type ICommonItem, type IConditionItem, type MetricType, type IDataItem } from '../typings/metric'; +import type { QueryOption } from '../typings/config'; +import type { QueryData } from '../typings/datasource'; +import type { ICommonItem, IConditionItem, MetricType, IDataItem } from '../typings/metric'; import { getCookie, t } from '../utils/utils'; import AliasInput from './alias-input'; import ConditionInput from './condition-input'; @@ -201,9 +201,9 @@ export default class MonitorQueryEditor extends React.PureComponent { diff --git a/src/event/src/components/type-iput.tsx b/src/event/src/components/type-iput.tsx index cdbc2b8..74218df 100644 --- a/src/event/src/components/type-iput.tsx +++ b/src/event/src/components/type-iput.tsx @@ -26,7 +26,7 @@ import Select from 'antd/es/select'; import React from 'react'; -import { type MetricType } from '../typings/metric'; +import type { MetricType } from '../typings/metric'; const { Option } = Select; const metaList: { id: MetricType; name: string }[] = [ { diff --git a/src/event/src/components/variable-editor.tsx b/src/event/src/components/variable-editor.tsx index 515f818..32c99c7 100644 --- a/src/event/src/components/variable-editor.tsx +++ b/src/event/src/components/variable-editor.tsx @@ -29,7 +29,7 @@ import Select from 'antd/es/select'; import Spin from 'antd/es/spin'; import React from 'react'; -import { type ICommonItem, type IConditionItem, type MetricType, type IDataItem } from '../typings/metric'; +import type { ICommonItem, IConditionItem, MetricType, IDataItem } from '../typings/metric'; import { VariableQueryType, type VariableQuery } from '../typings/variable'; import { LanguageContext } from '../utils/context'; // import { CascaderOptionType } from 'antd/es/cascader'; @@ -164,7 +164,7 @@ export default class VariableQueryEditor extends React.PureComponent { @@ -239,7 +239,7 @@ export default class VariableQueryEditor extends React.PureComponent { @@ -247,7 +247,7 @@ export default class VariableQueryEditor extends React.PureComponent { @@ -293,9 +293,9 @@ export default class VariableQueryEditor extends React.PureComponent { needQuery && this.handleQuery(); resolve(undefined); - }, + } ); - }, + } ); }); }; diff --git a/src/event/src/components/variable-line.tsx b/src/event/src/components/variable-line.tsx index 681bc36..ba4f2e1 100644 --- a/src/event/src/components/variable-line.tsx +++ b/src/event/src/components/variable-line.tsx @@ -34,7 +34,7 @@ export default class VariableLine extends React.PureComponent {this.props.title}
{this.props?.children}
-
+
); } diff --git a/src/event/src/configuration/config-editor.tsx b/src/event/src/configuration/config-editor.tsx index 8736292..41f92c6 100644 --- a/src/event/src/configuration/config-editor.tsx +++ b/src/event/src/configuration/config-editor.tsx @@ -23,11 +23,11 @@ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ -import { type DataSourcePluginOptionsEditorProps } from '@grafana/data'; +import type { DataSourcePluginOptionsEditorProps } from '@grafana/data'; import { LegacyForms, TagsInput } from '@grafana/ui'; import React from 'react'; -import { type QueryOption, type SecureOption } from '../typings/config'; +import type { QueryOption, SecureOption } from '../typings/config'; import { t } from '../utils/utils'; const { FormField, Input, Switch } = LegacyForms; export default class ConfigEditor extends React.PureComponent< diff --git a/src/event/src/datasource/datasource.ts b/src/event/src/datasource/datasource.ts index 7e8a51a..b6e0746 100644 --- a/src/event/src/datasource/datasource.ts +++ b/src/event/src/datasource/datasource.ts @@ -36,9 +36,9 @@ import { import { type BackendSrvRequest, getBackendSrv, getTemplateSrv } from '@grafana/runtime'; import apiCacheInstance from 'common/utils/api-cache'; -import { type QueryOption } from '../typings/config'; -import { type IQueryConfig, type QueryData } from '../typings/datasource'; -import { type IMetric } from '../typings/metric'; +import type { QueryOption } from '../typings/config'; +import type { IQueryConfig, QueryData } from '../typings/datasource'; +import type { IMetric } from '../typings/metric'; import { type VariableQuery, VariableQueryType } from '../typings/variable'; import { random } from '../utils/utils'; interface QueryFetchData { @@ -104,7 +104,7 @@ export default class DashboardDatasource extends DataSourceApi, + dimensions: Record ) { const regex = /\$(\w+)|\[\[([\s\S]+?)\]\]/g; const aliasName = alias.replace(regex, (match: any, g1: any, g2: any) => { @@ -138,7 +138,7 @@ export default class DashboardDatasource extends DataSourceApi item.metric_field === config.metric_field && item.result_table_id === config.result_table_id, + item => item.metric_field === config.metric_field && item.result_table_id === config.result_table_id ); aliasData = { formula: config.method, @@ -290,7 +290,7 @@ export default class DashboardDatasource extends DataSourceApi []), + this.request(params).catch(() => []) ); const data = await apiCacheInstance.getCache(cacheKey); return data; @@ -313,7 +313,7 @@ export default class DashboardDatasource extends DataSourceApi []), + this.request(params).catch(() => []) ); const res = await apiCacheInstance.getCache(cacheKey); return res; @@ -402,9 +402,9 @@ export default class DashboardDatasource extends DataSourceApi - isTableQuery ? data : this.buildFetchSeries(data, options.scopedVars, config.alias, config), + isTableQuery ? data : this.buildFetchSeries(data, options.scopedVars, config.alias, config) ) - .catch(() => []), + .catch(() => []) ); configList.push(queryConfig); }); @@ -412,7 +412,7 @@ export default class DashboardDatasource extends DataSourceApi - list.reduce((pre, cur) => (cur?.length ? ((pre.data = [...pre.data, ...cur]), pre) : pre), { data: [] }), + list.reduce((pre, cur) => (cur?.length ? ((pre.data = [...pre.data, ...cur]), pre) : pre), { data: [] }) ) .catch(e => { console.error(e); @@ -449,7 +449,7 @@ export default class DashboardDatasource extends DataSourceApi ({ + value: jest.fn().mockImplementation(query => ({ matches: false, media: query, onchange: null, diff --git a/src/profiling/.config/jest/mocks/react-inlinesvg.tsx b/src/profiling/.config/jest/mocks/react-inlinesvg.tsx index d540f3a..bac103d 100644 --- a/src/profiling/.config/jest/mocks/react-inlinesvg.tsx +++ b/src/profiling/.config/jest/mocks/react-inlinesvg.tsx @@ -19,7 +19,13 @@ const SVG_FILE_NAME_REGEX = /(.+)\/(.+)\.svg$/; const InlineSVG = ({ src }: { src: string }) => { // testId will be the file name without extension (e.g. `public/img/icons/angle-double-down.svg` -> `angle-double-down`) const testId = src.replace(SVG_FILE_NAME_REGEX, '$2'); - return ; + return ( + + ); }; export default InlineSVG; diff --git a/src/profiling/.config/jest/utils.js b/src/profiling/.config/jest/utils.js index fdca0de..3654e98 100644 --- a/src/profiling/.config/jest/utils.js +++ b/src/profiling/.config/jest/utils.js @@ -8,7 +8,7 @@ * This utility function is useful in combination with jest `transformIgnorePatterns` config * to transform specific packages (e.g.ES modules) in a projects node_modules folder. */ -const nodeModulesToTransform = (moduleNames) => `node_modules\/(?!.*(${moduleNames.join('|')})\/.*)`; +const nodeModulesToTransform = moduleNames => `node_modules\/(?!.*(${moduleNames.join('|')})\/.*)`; // Array of known nested grafana package dependencies that only bundle an ESM version const grafanaESModules = [ diff --git a/src/profiling/.config/webpack/utils.ts b/src/profiling/.config/webpack/utils.ts index 07eea6e..7673f57 100644 --- a/src/profiling/.config/webpack/utils.ts +++ b/src/profiling/.config/webpack/utils.ts @@ -1,7 +1,7 @@ -import fs from 'fs'; -import process from 'process'; -import os from 'os'; -import path from 'path'; +import fs from 'node:fs'; +import process from 'node:process'; +import os from 'node:os'; +import path from 'node:path'; import { glob } from 'glob'; import { SOURCE_DIR } from './constants'; @@ -39,7 +39,7 @@ export async function getEntries(): Promise> { const pluginsJson = await glob('**/src/**/plugin.json', { absolute: true }); const plugins = await Promise.all( - pluginsJson.map((pluginJson) => { + pluginsJson.map(pluginJson => { const folder = path.dirname(pluginJson); return glob(`${folder}/module.{ts,tsx,js,jsx}`, { absolute: true }); }) diff --git a/src/profiling/.config/webpack/webpack.config.ts b/src/profiling/.config/webpack/webpack.config.ts index 8bd851d..35a643e 100644 --- a/src/profiling/.config/webpack/webpack.config.ts +++ b/src/profiling/.config/webpack/webpack.config.ts @@ -1,9 +1,9 @@ import CopyWebpackPlugin from 'copy-webpack-plugin'; import LiveReloadPlugin from 'webpack-livereload-plugin'; -import path from 'path'; +import path from 'node:path'; import ReplaceInFileWebpackPlugin from 'replace-in-file-webpack-plugin'; import MiniCssExtractPlugin from 'mini-css-extract-plugin'; -import { Configuration } from 'webpack'; +import type { Configuration } from 'webpack'; import { getPackageJson, getPluginJson, hasReadme, getEntries, isWSL } from './utils'; import { SOURCE_DIR, DIST_DIR } from './constants'; @@ -58,8 +58,8 @@ const config = async (env): Promise => { // Mark legacy SDK imports as external if their name starts with the "grafana/" prefix ({ request }, callback) => { const prefix = 'grafana/'; - const hasPrefix = (request) => request.indexOf(prefix) === 0; - const stripPrefix = (request) => request.substr(prefix.length); + const hasPrefix = request => request.indexOf(prefix) === 0; + const stripPrefix = request => request.substr(prefix.length); if (hasPrefix(request)) { return callback(undefined, stripPrefix(request)); @@ -101,7 +101,7 @@ const config = async (env): Promise => { { loader: 'sass-loader', options: { - additionalData: `$plugin-name: monitor-profiling;`, + additionalData: '$plugin-name: monitor-profiling;', }, }, ], @@ -151,7 +151,7 @@ const config = async (env): Promise => { generator: { publicPath: `public/plugins/${pluginJson.id}/img/`, outputPath: 'img/', - filename: Boolean(env.production) ? '[hash][ext]' : '[file]', + filename: env.production ? '[hash][ext]' : '[file]', }, }, { @@ -160,7 +160,7 @@ const config = async (env): Promise => { generator: { publicPath: `public/plugins/${pluginJson.id}/fonts/`, outputPath: 'fonts/', - filename: Boolean(env.production) ? '[hash][ext]' : '[name][ext]', + filename: env.production ? '[hash][ext]' : '[name][ext]', }, }, ], @@ -168,9 +168,9 @@ const config = async (env): Promise => { output: { clean: { - keep: new RegExp(`(.*?_(amd64|arm(64)?)(.exe)?|go_plugin_build_manifest)`), + keep: /(.*?_(amd64|arm(64)?)(.exe)?|go_plugin_build_manifest)/, }, - filename: `[name].js`, + filename: '[name].js', path: path.resolve(process.cwd(), DIST_DIR), publicPath: `public/plugins/${pluginJson.id}/`, libraryTarget: 'amd', @@ -214,7 +214,7 @@ const config = async (env): Promise => { }, ]), new MiniCssExtractPlugin({ - filename: `[name].css`, + filename: '[name].css', chunkFilename: '[id].css', }), ...(env.development diff --git a/src/profiling/src/components/condition-input.tsx b/src/profiling/src/components/condition-input.tsx index 5dd8c04..914760e 100644 --- a/src/profiling/src/components/condition-input.tsx +++ b/src/profiling/src/components/condition-input.tsx @@ -32,7 +32,7 @@ import Tooltip from 'antd/es/tooltip'; import React, { useState, useEffect } from 'react'; import { map, merge, type Observable } from 'rxjs'; -import { type ProfilingQuery } from '../typings/datasource'; +import type { ProfilingQuery } from '../typings/datasource'; import { CONDITION, type ICommonItem, type IConditionItem, STRING_CONDITION_METHOD_LIST } from '../typings/metric'; import { DIM_NULL_ID } from '../typings/profile'; import { t } from '../utils/utils'; @@ -63,7 +63,7 @@ const ConditionInput: React.FC = ({ datasource, filterList, keyList, onC service_name: serviceName, label_key: key, }) - .pipe(map(data => ({ [key]: data || [] }))), + .pipe(map(data => ({ [key]: data || [] }))) ); } } @@ -170,7 +170,7 @@ const ConditionInput: React.FC = ({ datasource, filterList, keyList, onC }; } return item; - }), + }) ); }; diff --git a/src/profiling/src/components/query-editor.tsx b/src/profiling/src/components/query-editor.tsx index 5433d42..7c112b2 100644 --- a/src/profiling/src/components/query-editor.tsx +++ b/src/profiling/src/components/query-editor.tsx @@ -23,20 +23,20 @@ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ -import { type QueryEditorProps } from '@grafana/data'; import Cascader, { type BaseOptionType } from 'antd/es/cascader'; import Select from 'antd/es/select'; import Tooltip from 'antd/es/tooltip'; import React, { useEffect, useState } from 'react'; -import { type ProfilingQuery } from '../typings/datasource'; -import { type ICommonItem } from '../typings/metric'; import { LanguageContext } from '../utils/context'; import { t, language } from '../utils/utils'; import ConditionInput from './condition-input'; import EditorForm from './editor-form'; import type ProfilingDatasource from '../datasource/datasource'; +import type { ProfilingQuery } from '../typings/datasource'; +import type { ICommonItem } from '../typings/metric'; +import type { QueryEditorProps } from '@grafana/data'; type Props = QueryEditorProps; diff --git a/src/profiling/src/configuration/config-editor.tsx b/src/profiling/src/configuration/config-editor.tsx index 7e62557..d1cada8 100644 --- a/src/profiling/src/configuration/config-editor.tsx +++ b/src/profiling/src/configuration/config-editor.tsx @@ -24,11 +24,11 @@ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ -import { type DataSourcePluginOptionsEditorProps } from '@grafana/data'; +import type { DataSourcePluginOptionsEditorProps } from '@grafana/data'; import { LegacyForms, TagsInput } from '@grafana/ui'; import React, { useState } from 'react'; -import { type QueryOption, type SecureOption } from '../typings/config'; +import type { QueryOption, SecureOption } from '../typings/config'; import { t } from '../utils/utils'; const { FormField, Input, Switch } = LegacyForms; diff --git a/src/profiling/src/datasource/datasource.ts b/src/profiling/src/datasource/datasource.ts index 3a5edf4..6b6c20a 100644 --- a/src/profiling/src/datasource/datasource.ts +++ b/src/profiling/src/datasource/datasource.ts @@ -41,10 +41,10 @@ import { } from '@grafana/runtime'; import { catchError, lastValueFrom, map, merge, Observable, of } from 'rxjs'; -import { type QueryOption } from '../typings/config'; -import { type ProfilingQuery } from '../typings/datasource'; -import { type ICommonItem } from '../typings/metric'; -import { type IApplication } from '../typings/profile'; +import type { QueryOption } from '../typings/config'; +import type { ProfilingQuery } from '../typings/datasource'; +import type { ICommonItem } from '../typings/metric'; +import type { IApplication } from '../typings/profile'; import { random } from '../utils/utils'; export enum QueryUrl { get_profile_application_service = 'get_profile_application_service/', @@ -91,7 +91,7 @@ export default class DashboardDatasource extends DataSourceApi subscriber.next({ data: [toDataFrame(events)] })) .catch(err => subscriber.error(err)) .finally(() => subscriber.complete()); - }), + }) ); } return merge(...streams); @@ -127,7 +127,7 @@ export default class DashboardDatasource extends DataSourceApi ({ label: item.name, value: item.key, - })), + })) ), catchError(() => { return of([]); - }), + }) ); } getProfileApplicationService() { @@ -185,7 +185,7 @@ export default class DashboardDatasource extends DataSourceApi { return of([] as IApplication[]); - }), + }) ); } getProfileLabels(params: Pick) { @@ -202,7 +202,7 @@ export default class DashboardDatasource extends DataSourceApi (data?.label_keys || []).map(key => ({ id: key, name: key }))), catchError(() => { return of([] as ICommonItem[]); - }), + }) ); } getProfileValues(params: Pick & { label_key: string }) { @@ -219,7 +219,7 @@ export default class DashboardDatasource extends DataSourceApi (data?.label_values || []).map(key => ({ id: key, name: key }))), catchError(() => { return of([] as ICommonItem[]); - }), + }) ); } async testDatasource() { @@ -240,7 +240,7 @@ export default class DashboardDatasource extends DataSourceApi ({ message: 'Successfully queried the Blueking Monitor service.', @@ -277,7 +277,7 @@ export default class DashboardDatasource extends DataSourceApi ({ + value: jest.fn().mockImplementation(query => ({ matches: false, media: query, onchange: null, diff --git a/src/timeseries/.config/jest/mocks/react-inlinesvg.tsx b/src/timeseries/.config/jest/mocks/react-inlinesvg.tsx index d540f3a..bac103d 100644 --- a/src/timeseries/.config/jest/mocks/react-inlinesvg.tsx +++ b/src/timeseries/.config/jest/mocks/react-inlinesvg.tsx @@ -19,7 +19,13 @@ const SVG_FILE_NAME_REGEX = /(.+)\/(.+)\.svg$/; const InlineSVG = ({ src }: { src: string }) => { // testId will be the file name without extension (e.g. `public/img/icons/angle-double-down.svg` -> `angle-double-down`) const testId = src.replace(SVG_FILE_NAME_REGEX, '$2'); - return ; + return ( + + ); }; export default InlineSVG; diff --git a/src/timeseries/.config/jest/utils.js b/src/timeseries/.config/jest/utils.js index fdca0de..3654e98 100644 --- a/src/timeseries/.config/jest/utils.js +++ b/src/timeseries/.config/jest/utils.js @@ -8,7 +8,7 @@ * This utility function is useful in combination with jest `transformIgnorePatterns` config * to transform specific packages (e.g.ES modules) in a projects node_modules folder. */ -const nodeModulesToTransform = (moduleNames) => `node_modules\/(?!.*(${moduleNames.join('|')})\/.*)`; +const nodeModulesToTransform = moduleNames => `node_modules\/(?!.*(${moduleNames.join('|')})\/.*)`; // Array of known nested grafana package dependencies that only bundle an ESM version const grafanaESModules = [ diff --git a/src/timeseries/.config/webpack/utils.ts b/src/timeseries/.config/webpack/utils.ts index 07eea6e..de1bc6d 100644 --- a/src/timeseries/.config/webpack/utils.ts +++ b/src/timeseries/.config/webpack/utils.ts @@ -39,7 +39,7 @@ export async function getEntries(): Promise> { const pluginsJson = await glob('**/src/**/plugin.json', { absolute: true }); const plugins = await Promise.all( - pluginsJson.map((pluginJson) => { + pluginsJson.map(pluginJson => { const folder = path.dirname(pluginJson); return glob(`${folder}/module.{ts,tsx,js,jsx}`, { absolute: true }); }) diff --git a/src/timeseries/.config/webpack/webpack.config.ts b/src/timeseries/.config/webpack/webpack.config.ts index d449b47..11dda4a 100644 --- a/src/timeseries/.config/webpack/webpack.config.ts +++ b/src/timeseries/.config/webpack/webpack.config.ts @@ -1,9 +1,9 @@ import CopyWebpackPlugin from 'copy-webpack-plugin'; import LiveReloadPlugin from 'webpack-livereload-plugin'; -import path from 'path'; +import path from 'node:path'; import ReplaceInFileWebpackPlugin from 'replace-in-file-webpack-plugin'; import MiniCssExtractPlugin from 'mini-css-extract-plugin'; -import { Configuration } from 'webpack'; +import type { Configuration } from 'webpack'; import { getPackageJson, getPluginJson, hasReadme, getEntries, isWSL } from './utils'; import { SOURCE_DIR, DIST_DIR } from './constants'; @@ -58,8 +58,8 @@ const config = async (env): Promise => { // Mark legacy SDK imports as external if their name starts with the "grafana/" prefix ({ request }, callback) => { const prefix = 'grafana/'; - const hasPrefix = (request) => request.indexOf(prefix) === 0; - const stripPrefix = (request) => request.substr(prefix.length); + const hasPrefix = request => request.indexOf(prefix) === 0; + const stripPrefix = request => request.substr(prefix.length); if (hasPrefix(request)) { return callback(undefined, stripPrefix(request)); @@ -155,7 +155,7 @@ const config = async (env): Promise => { generator: { publicPath: `public/plugins/${pluginJson.id}/img/`, outputPath: 'img/', - filename: Boolean(env.production) ? '[hash][ext]' : '[file]', + filename: env.production ? '[hash][ext]' : '[file]', }, }, { @@ -164,7 +164,7 @@ const config = async (env): Promise => { generator: { publicPath: `public/plugins/${pluginJson.id}/fonts/`, outputPath: 'fonts/', - filename: Boolean(env.production) ? '[hash][ext]' : '[name][ext]', + filename: env.production ? '[hash][ext]' : '[name][ext]', }, }, ], @@ -172,9 +172,9 @@ const config = async (env): Promise => { output: { clean: { - keep: new RegExp(`(.*?_(amd64|arm(64)?)(.exe)?|go_plugin_build_manifest)`), + keep: /(.*?_(amd64|arm(64)?)(.exe)?|go_plugin_build_manifest)/, }, - filename: `[name].js`, + filename: '[name].js', path: path.resolve(process.cwd(), DIST_DIR), publicPath: `public/plugins/${pluginJson.id}/`, libraryTarget: 'amd', @@ -218,7 +218,7 @@ const config = async (env): Promise => { }, ]), new MiniCssExtractPlugin({ - filename: `[name].css`, + filename: '[name].css', chunkFilename: '[id].css', }), ...(env.development diff --git a/src/timeseries/src/components/addvance-setting.tsx b/src/timeseries/src/components/addvance-setting.tsx index d545e56..dfeca50 100644 --- a/src/timeseries/src/components/addvance-setting.tsx +++ b/src/timeseries/src/components/addvance-setting.tsx @@ -27,7 +27,7 @@ import Select from 'antd/es/select'; import Switch from 'antd/es/switch'; import React from 'react'; -import { type EditMode } from '../typings/metric'; +import type { EditMode } from '../typings/metric'; import { t } from '../utils/utils'; import AliasInput from './alias-input'; import EditorForm from './editor-form'; diff --git a/src/timeseries/src/components/alias-input.tsx b/src/timeseries/src/components/alias-input.tsx index e021be4..38c7edb 100644 --- a/src/timeseries/src/components/alias-input.tsx +++ b/src/timeseries/src/components/alias-input.tsx @@ -26,7 +26,7 @@ import Input, { type InputProps } from 'antd/es/input'; import React from 'react'; -import { type MetricDetail } from '../typings/metric'; +import type { MetricDetail } from '../typings/metric'; import { LanguageContext } from '../utils/context'; import { t } from '../utils/utils'; export interface IAliasInputProps { diff --git a/src/timeseries/src/components/condition-input.tsx b/src/timeseries/src/components/condition-input.tsx index c3f54e0..b7b6bae 100644 --- a/src/timeseries/src/components/condition-input.tsx +++ b/src/timeseries/src/components/condition-input.tsx @@ -163,7 +163,7 @@ export default class ConditionInput extends React.PureComponent }; } return item; - }), + }) ); if (this.state.dimensionValueMap[v] || !v) return; const data = await this.getDimensionValue(v); @@ -246,7 +246,7 @@ export default class ConditionInput extends React.PureComponent }; } return item; - }), + }) ); } /** diff --git a/src/timeseries/src/components/dimension-input.tsx b/src/timeseries/src/components/dimension-input.tsx index 6107afb..79d9d32 100644 --- a/src/timeseries/src/components/dimension-input.tsx +++ b/src/timeseries/src/components/dimension-input.tsx @@ -29,7 +29,7 @@ import Select from 'antd/es/select'; import Tooltip from 'antd/es/tooltip'; import React from 'react'; -import { type MetricDetail } from '../typings/metric'; +import type { MetricDetail } from '../typings/metric'; import { LanguageContext } from '../utils/context'; import { t } from '../utils/utils'; const { Option } = Select; diff --git a/src/timeseries/src/components/editor-form.tsx b/src/timeseries/src/components/editor-form.tsx index b12463b..7c71f27 100644 --- a/src/timeseries/src/components/editor-form.tsx +++ b/src/timeseries/src/components/editor-form.tsx @@ -26,7 +26,7 @@ import Tooltip from 'antd/es/tooltip'; import React from 'react'; -import { type MetricDetail } from '../typings/metric'; +import type { MetricDetail } from '../typings/metric'; import { LanguageContext } from '../utils/context'; export interface IEditorFormProps { labelStyle?: React.CSSProperties; diff --git a/src/timeseries/src/components/function-menu.tsx b/src/timeseries/src/components/function-menu.tsx index 497763f..5724e0e 100644 --- a/src/timeseries/src/components/function-menu.tsx +++ b/src/timeseries/src/components/function-menu.tsx @@ -29,7 +29,7 @@ import Input from 'antd/es/input'; import Popover from 'antd/es/popover'; import React from 'react'; -import { type IFunctionItem, type MetricDetail } from '../typings/metric'; +import type { IFunctionItem, MetricDetail } from '../typings/metric'; import { LanguageContext } from '../utils/context'; import { t } from '../utils/utils'; export interface IFunctionMenuProps { @@ -80,7 +80,7 @@ export default class FunctionMenu extends React.PureComponent { this.handleFuncTypeMouseenter(this.filterList[0]); - }, + } ); }; handleSelectFunc = (item: IFunctionItem) => { @@ -118,7 +118,7 @@ export default class FunctionMenu extends React.PureComponent} value={keyword} onChange={this.handleKeywordChange} - > + />
{this.filterList?.length > 0 && (
    @@ -129,7 +129,7 @@ export default class FunctionMenu extends React.PureComponent this.handleFuncTypeMouseenter(item)} > {item.name} - + ))}
@@ -149,15 +149,15 @@ export default class FunctionMenu extends React.PureComponent {item.name.slice( item.name.toLocaleLowerCase().indexOf(keyword.toLocaleLowerCase()), - item.name.toLocaleLowerCase().indexOf(keyword.toLocaleLowerCase()) + keyword.length, + item.name.toLocaleLowerCase().indexOf(keyword.toLocaleLowerCase()) + keyword.length )} {item.name.slice( item.name.toLocaleLowerCase().indexOf(keyword.toLocaleLowerCase()) + keyword.length, - item.name.length, + item.name.length )} - ), + ) )} )} @@ -210,7 +210,7 @@ export default class FunctionMenu extends React.PureComponent - func?.children?.some(item => item.name.toLocaleLowerCase().includes(this.state.keyword.toLocaleLowerCase())), + func?.children?.some(item => item.name.toLocaleLowerCase().includes(this.state.keyword.toLocaleLowerCase())) ); } } diff --git a/src/timeseries/src/components/funtion-input.tsx b/src/timeseries/src/components/funtion-input.tsx index 16d60c5..de1ff92 100644 --- a/src/timeseries/src/components/funtion-input.tsx +++ b/src/timeseries/src/components/funtion-input.tsx @@ -32,7 +32,7 @@ import Menu from 'antd/es/menu'; import Popover from 'antd/es/popover'; import React from 'react'; -import { type IFunctionItem, type IFunctionParam } from '../typings/metric'; +import type { IFunctionItem, IFunctionParam } from '../typings/metric'; import { LanguageContext } from '../utils/context'; import { t } from '../utils/utils'; export const EMPTY_VALUE = '-空-'; @@ -150,7 +150,7 @@ export default class FunctionInput extends React.PureComponent this.handleParamBlur(e, param)} - > + /> ); } diff --git a/src/timeseries/src/components/interval-input.tsx b/src/timeseries/src/components/interval-input.tsx index 6660e49..4f0917b 100644 --- a/src/timeseries/src/components/interval-input.tsx +++ b/src/timeseries/src/components/interval-input.tsx @@ -30,7 +30,7 @@ import Menu from 'antd/es/menu'; import Select from 'antd/es/select'; import React from 'react'; -import { type IntervalType, type MetricDetail } from '../typings/metric'; +import type { IntervalType, MetricDetail } from '../typings/metric'; const { Option } = Select; const { Item } = Menu; export interface IIntervalInputProps { diff --git a/src/timeseries/src/components/metirc-input.tsx b/src/timeseries/src/components/metirc-input.tsx index 6b96f0d..adee18a 100644 --- a/src/timeseries/src/components/metirc-input.tsx +++ b/src/timeseries/src/components/metirc-input.tsx @@ -40,7 +40,7 @@ import Tabs from 'antd/es/tabs'; import Tooltip from 'antd/es/tooltip'; import React from 'react'; -import { type IMetric, type MetricDetail } from '../typings/metric'; +import type { IMetric, MetricDetail } from '../typings/metric'; import { LanguageContext } from '../utils/context'; import { createMetricTitleTooltips, t, random } from '../utils/utils'; @@ -169,8 +169,7 @@ export default class MonitorQueryEditor extends React.PureComponent - item.data_source_label === metric.data_source_label && item.data_type_label === metric.data_type_label, + item => item.data_source_label === metric.data_source_label && item.data_type_label === metric.data_type_label )?.name, metric.related_name, ] @@ -194,7 +193,7 @@ export default class MonitorQueryEditor extends React.PureComponent item.count > 0 || datasourceLabel.some(set => set.id === item.id), + item => item.count > 0 || datasourceLabel.some(set => set.id === item.id) ); } else { datasources = dataSourceList.filter(item => datasourceLabel.some(set => set.id === item.id)); @@ -311,7 +310,7 @@ export default class MonitorQueryEditor extends React.PureComponent this.getMetricList(true), + () => this.getMetricList(true) ); }; /** @@ -408,7 +407,7 @@ export default class MonitorQueryEditor extends React.PureComponent { this.setState({ timer }); }); - }, + } ); }; handleTagChange = (activeKey: string) => { @@ -440,7 +439,7 @@ export default class MonitorQueryEditor extends React.PureComponent item.id === activeKey), }, - () => this.getMetricList(true), + () => this.getMetricList(true) ); }; handleVisibleChange = v => { @@ -467,7 +466,7 @@ export default class MonitorQueryEditor extends React.PureComponent { this.inputRef.current.focus(); }, 300); - }, + } ); } else if (!v) { document.removeEventListener('keydown', this.handleKeyDown); @@ -538,7 +537,7 @@ export default class MonitorQueryEditor extends React.PureComponent - + @@ -584,7 +583,7 @@ export default class MonitorQueryEditor extends React.PureComponent{item.name}} - > + /> ))} )} @@ -625,16 +624,16 @@ export default class MonitorQueryEditor extends React.PureComponent + /> - + + /> @@ -663,7 +662,7 @@ export default class MonitorQueryEditor extends React.PureComponent } className='more-loading' - > + /> )}
@@ -785,7 +784,7 @@ export default class MonitorQueryEditor extends React.PureComponent this.handleCopyMetric(this.props.metric as any, e)} > - + , { this.props.onChange?.(update.state.doc.toString()); @@ -199,7 +199,7 @@ export default class PromqlEditor extends React.PureComponent
+ />
); } diff --git a/src/timeseries/src/components/query-editor.tsx b/src/timeseries/src/components/query-editor.tsx index 67e8a9d..24c3961 100644 --- a/src/timeseries/src/components/query-editor.tsx +++ b/src/timeseries/src/components/query-editor.tsx @@ -33,8 +33,8 @@ import Message from 'antd/es/message'; import Spin from 'antd/es/spin'; import React from 'react'; -import { type QueryOption } from '../typings/config'; -import { type IQueryConfig, type QueryData } from '../typings/datasource'; +import type { QueryOption } from '../typings/config'; +import type { IQueryConfig, QueryData } from '../typings/datasource'; import { type EditMode, type EditorStatus, @@ -70,9 +70,9 @@ const refLetters = 'abcdefghijklmnopqrstuvwxyz'; export type Writeable = { -readonly [P in keyof T]: T[P] }; export type IQueryEditorProps = QueryEditorProps; export enum SearcState { - 'auto' = 'auto', - 'deafult' = 'deafult', - 'loading' = 'loading', + auto = 'auto', + deafult = 'deafult', + loading = 'loading', } interface IQueryEditorState { cluster: ITargetItem[]; @@ -163,7 +163,7 @@ export default class MonitorQueryEditor extends React.PureComponent { this.handleQuery(); this.state.searchState !== SearcState.auto && this.props.onRunQuery(); - }, + } ); }; expressionListComp = language => { @@ -238,9 +238,9 @@ export default class MonitorQueryEditor extends React.PureComponent this.handleExpressionChecked(index)} > {item.active ? ( - + ) : ( - + )} { @@ -316,7 +316,7 @@ export default class MonitorQueryEditor extends React.PureComponent { @@ -329,7 +329,7 @@ export default class MonitorQueryEditor extends React.PureComponent { @@ -348,7 +348,7 @@ export default class MonitorQueryEditor extends React.PureComponent { @@ -364,7 +364,7 @@ export default class MonitorQueryEditor extends React.PureComponent { @@ -388,7 +388,7 @@ export default class MonitorQueryEditor extends React.PureComponent item.active)?.expression; if (!promqlAlias) { promqlAlias = params?.query_configs?.find( - item => item.alias && (item.display || typeof item.display === undefined), + item => item.alias && (item.display || typeof item.display === undefined) )?.alias; } source = await this.props.datasource.queryConfigToPromql(params as QueryData).catch(e => { @@ -406,7 +406,7 @@ export default class MonitorQueryEditor extends React.PureComponent { @@ -516,7 +516,7 @@ export default class MonitorQueryEditor extends React.PureComponent { @@ -562,14 +562,14 @@ export default class MonitorQueryEditor extends React.PureComponent this.handleQuery(list), + () => this.handleQuery(list) ); } } else { @@ -702,7 +702,7 @@ export default class MonitorQueryEditor extends React.PureComponent { this.handleQuery(); immediateQuery && this.state.searchState !== SearcState.auto && this.props.onRunQuery(); - }, + } ); } else { const data = await this.props.datasource.promqlToqueryConfig(v, 'code').catch(() => { @@ -742,7 +742,7 @@ export default class MonitorQueryEditor extends React.PureComponent 1, // expression: list.length < 2 ? '' : this.state.expression, }, - this.handleQuery, + this.handleQuery ); } else { hasError = true; @@ -918,7 +918,7 @@ export default class MonitorQueryEditor extends React.PureComponent { if (index === metricIndex) { @@ -931,7 +931,7 @@ export default class MonitorQueryEditor extends React.PureComponent (cur?.children?.length ? [...pre, ...cur.children] : pre), - [], + [] ) as any; return functions.map(func => { const funcItem = funcList.find(set => set.id === func.id); @@ -1088,7 +1088,7 @@ export default class MonitorQueryEditor extends React.PureComponent (cur?.agg_dimension?.length > pre?.length ? cur.agg_dimension : pre), - [] as any, + [] as any ); return metricList.map((item, index) => { if (item.metricMetaId) { @@ -1317,9 +1317,9 @@ export default class MonitorQueryEditor extends React.PureComponent this.handleSetMetricDisplay(index)} > {item.display ? ( - + ) : ( - + )} this.handleCopyMetric(index)} > - + - + ) : undefined} @@ -369,7 +369,7 @@ export default class TargetInput extends React.PureComponent + /> )} diff --git a/src/timeseries/src/components/variable-editor.tsx b/src/timeseries/src/components/variable-editor.tsx index c7924d5..14de651 100644 --- a/src/timeseries/src/components/variable-editor.tsx +++ b/src/timeseries/src/components/variable-editor.tsx @@ -126,7 +126,7 @@ export default class VariableQueryEditor extends React.PureComponent { @@ -136,7 +136,7 @@ export default class VariableQueryEditor extends React.PureComponent { @@ -146,7 +146,7 @@ export default class VariableQueryEditor extends React.PureComponent { @@ -156,7 +156,7 @@ export default class VariableQueryEditor extends React.PureComponent { @@ -202,7 +202,7 @@ export default class VariableQueryEditor extends React.PureComponent metric_field === metric.metric_field && - ((data_label && data_label === metric.data_label) || result_table_id === metric.result_table_id), + ((data_label && data_label === metric.data_label) || result_table_id === metric.result_table_id) ); this.setState({ loading: false, diff --git a/src/timeseries/src/components/variable-line.tsx b/src/timeseries/src/components/variable-line.tsx index dbcb269..06c649c 100644 --- a/src/timeseries/src/components/variable-line.tsx +++ b/src/timeseries/src/components/variable-line.tsx @@ -33,7 +33,7 @@ export default class VariableLine extends React.PureComponent {this.props.title}
{this.props?.children}
-
+
); } diff --git a/src/timeseries/src/configuration/config-editor.tsx b/src/timeseries/src/configuration/config-editor.tsx index 8736292..41f92c6 100644 --- a/src/timeseries/src/configuration/config-editor.tsx +++ b/src/timeseries/src/configuration/config-editor.tsx @@ -23,11 +23,11 @@ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ -import { type DataSourcePluginOptionsEditorProps } from '@grafana/data'; +import type { DataSourcePluginOptionsEditorProps } from '@grafana/data'; import { LegacyForms, TagsInput } from '@grafana/ui'; import React from 'react'; -import { type QueryOption, type SecureOption } from '../typings/config'; +import type { QueryOption, SecureOption } from '../typings/config'; import { t } from '../utils/utils'; const { FormField, Input, Switch } = LegacyForms; export default class ConfigEditor extends React.PureComponent< diff --git a/src/timeseries/src/datasource/datasource.ts b/src/timeseries/src/datasource/datasource.ts index 105067d..759b4de 100644 --- a/src/timeseries/src/datasource/datasource.ts +++ b/src/timeseries/src/datasource/datasource.ts @@ -44,9 +44,9 @@ import { import { type BackendSrvRequest, getBackendSrv, getTemplateSrv } from '@grafana/runtime'; import apiCacheInstance from 'common/utils/api-cache'; -import { type QueryOption } from '../typings/config'; +import type { QueryOption } from '../typings/config'; import { DIM_NULL_ID, type IQueryConfig, type QueryData } from '../typings/datasource'; -import { type EditMode, type IMetric, type ITargetData, type IntervalType } from '../typings/metric'; +import type { EditMode, IMetric, ITargetData, IntervalType } from '../typings/metric'; import { type K8sVariableQueryType, ScenarioType, type VariableQuery, VariableQueryType } from '../typings/variable'; import { handleTransformOldQuery, handleTransformOldVariableQuery } from '../utils/common'; import { random } from '../utils/utils'; @@ -190,7 +190,7 @@ export default class DashboardDatasource extends DataSourceApi, + sere: Record ) { // const regex = /\$([\w]+)|\[\[([\s\S]+?)\]\]/g; // const tagRegex = /(\$(tag_|dim_)\$[\w._]+)/gm; @@ -256,7 +256,7 @@ export default class DashboardDatasource extends DataSourceApi item.metric_field === config.metric_field && item.result_table_id === config.result_table_id, + item => item.metric_field === config.metric_field && item.result_table_id === config.result_table_id ); aliasData = { formula: config.method, @@ -639,7 +639,7 @@ export default class DashboardDatasource extends DataSourceApi []), + this.request(params).catch(() => []) ); const data = await apiCacheInstance.getCache(cacheKey); return data; @@ -662,7 +662,7 @@ export default class DashboardDatasource extends DataSourceApi []), + this.request(params).catch(() => []) ); const res = await apiCacheInstance.getCache(cacheKey); return res; @@ -871,13 +871,13 @@ export default class DashboardDatasource extends DataSourceApi - this.buildFetchSeries(data, options.scopedVars, config.alias, config, item), + this.buildFetchSeries(data, options.scopedVars, config.alias, config, item) ) .catch(e => { console.error(e); errorMsg += e.data?.message || 'query error'; return []; - }), + }) ); } configList.push(queryConfig); @@ -914,14 +914,14 @@ export default class DashboardDatasource extends DataSourceApi { console.error(e); errorMsg += e.data?.message || 'query error'; return []; - }), + }) ); } else { const { cluster, expressionList, host, module, enableDownSampling } = item; @@ -951,7 +951,7 @@ export default class DashboardDatasource extends DataSourceApi - list.reduce((pre, cur) => (cur?.length ? ((pre.data = [...pre.data, ...cur]), pre) : pre), { data: [] }), + list.reduce((pre, cur) => (cur?.length ? ((pre.data = [...pre.data, ...cur]), pre) : pre), { data: [] }) ) .catch(e => { console.error(e); @@ -979,7 +979,7 @@ export default class DashboardDatasource extends DataSourceApi 1) { const tableRefId = options.targets.filter(item => item.format === 'table').map(item => item.refId); @@ -1102,7 +1102,7 @@ export default class DashboardDatasource extends DataSourceApi item.data_source_label === this.data_source_label && item.data_type_label === this.data_type_label, + item => item.data_source_label === this.data_source_label && item.data_type_label === this.data_type_label )?.name, this.related_name, ] diff --git a/src/timeseries/src/typings/variable.ts b/src/timeseries/src/typings/variable.ts index 73683a5..7199122 100644 --- a/src/timeseries/src/typings/variable.ts +++ b/src/timeseries/src/typings/variable.ts @@ -24,7 +24,7 @@ * IN THE SOFTWARE. */ -import { type IConditionItem } from './metric'; +import type { IConditionItem } from './metric'; // 变量类型 export enum VariableQueryType { Dimension = 'dimension', diff --git a/src/timeseries/src/utils/common.ts b/src/timeseries/src/utils/common.ts index 6d90660..70939df 100644 --- a/src/timeseries/src/utils/common.ts +++ b/src/timeseries/src/utils/common.ts @@ -23,8 +23,8 @@ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ -import { type QueryData } from '../typings/datasource'; -import { type VariableQuery } from '../typings/variable'; +import type { QueryData } from '../typings/datasource'; +import type { VariableQuery } from '../typings/variable'; /** * @description: 转换旧版本查询 * @param {any} data 旧版本数据 @@ -57,10 +57,10 @@ export const handleTransformOldQuery = (data: any) => { item.reduce((pre, cur) => { pre[cur.type] = cur.value; return pre; - }, {}), + }, {}) ), }, - dataSourceLabel === 'bk_log_search' ? { index_set_id } : {}, + dataSourceLabel === 'bk_log_search' ? { index_set_id } : {} ); const newQuery: QueryData = { alias: '', @@ -99,7 +99,7 @@ export const handleTransformOldVariableQuery = (data: any) => { item.reduce((pre, cur) => { pre[cur.type] = cur.value; return pre; - }, {}), + }, {}) ), }; } @@ -114,7 +114,7 @@ export const handleTransformOldVariableQuery = (data: any) => { item.reduce((pre, cur) => { pre[cur.type] = cur.value; return pre; - }, {}), + }, {}) ) || [], }; return newQuery; diff --git a/src/timeseries/src/utils/utils.ts b/src/timeseries/src/utils/utils.ts index b1c5e21..eef2a99 100644 --- a/src/timeseries/src/utils/utils.ts +++ b/src/timeseries/src/utils/utils.ts @@ -35,7 +35,7 @@ export const random = (n: number, str = 'abcdefghijklmnopqrstuvwxyz0123456789'): // 生成n位长度的字符串 let result = ''; for (let i = 0; i < n; i++) { - result += str[parseInt(String(Math.random() * str.length))]; + result += str[Number.parseInt(String(Math.random() * str.length))]; } return result; }; diff --git a/src/trace/.config/jest-setup.js b/src/trace/.config/jest-setup.js index 1b9fc2f..b437976 100644 --- a/src/trace/.config/jest-setup.js +++ b/src/trace/.config/jest-setup.js @@ -10,7 +10,7 @@ import '@testing-library/jest-dom'; // https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom Object.defineProperty(global, 'matchMedia', { writable: true, - value: jest.fn().mockImplementation((query) => ({ + value: jest.fn().mockImplementation(query => ({ matches: false, media: query, onchange: null, diff --git a/src/trace/.config/jest/mocks/react-inlinesvg.tsx b/src/trace/.config/jest/mocks/react-inlinesvg.tsx index d540f3a..bac103d 100644 --- a/src/trace/.config/jest/mocks/react-inlinesvg.tsx +++ b/src/trace/.config/jest/mocks/react-inlinesvg.tsx @@ -19,7 +19,13 @@ const SVG_FILE_NAME_REGEX = /(.+)\/(.+)\.svg$/; const InlineSVG = ({ src }: { src: string }) => { // testId will be the file name without extension (e.g. `public/img/icons/angle-double-down.svg` -> `angle-double-down`) const testId = src.replace(SVG_FILE_NAME_REGEX, '$2'); - return ; + return ( + + ); }; export default InlineSVG; diff --git a/src/trace/.config/jest/utils.js b/src/trace/.config/jest/utils.js index fdca0de..3654e98 100644 --- a/src/trace/.config/jest/utils.js +++ b/src/trace/.config/jest/utils.js @@ -8,7 +8,7 @@ * This utility function is useful in combination with jest `transformIgnorePatterns` config * to transform specific packages (e.g.ES modules) in a projects node_modules folder. */ -const nodeModulesToTransform = (moduleNames) => `node_modules\/(?!.*(${moduleNames.join('|')})\/.*)`; +const nodeModulesToTransform = moduleNames => `node_modules\/(?!.*(${moduleNames.join('|')})\/.*)`; // Array of known nested grafana package dependencies that only bundle an ESM version const grafanaESModules = [ diff --git a/src/trace/.config/webpack/utils.ts b/src/trace/.config/webpack/utils.ts index 07eea6e..7673f57 100644 --- a/src/trace/.config/webpack/utils.ts +++ b/src/trace/.config/webpack/utils.ts @@ -1,7 +1,7 @@ -import fs from 'fs'; -import process from 'process'; -import os from 'os'; -import path from 'path'; +import fs from 'node:fs'; +import process from 'node:process'; +import os from 'node:os'; +import path from 'node:path'; import { glob } from 'glob'; import { SOURCE_DIR } from './constants'; @@ -39,7 +39,7 @@ export async function getEntries(): Promise> { const pluginsJson = await glob('**/src/**/plugin.json', { absolute: true }); const plugins = await Promise.all( - pluginsJson.map((pluginJson) => { + pluginsJson.map(pluginJson => { const folder = path.dirname(pluginJson); return glob(`${folder}/module.{ts,tsx,js,jsx}`, { absolute: true }); }) diff --git a/src/trace/.config/webpack/webpack.config.ts b/src/trace/.config/webpack/webpack.config.ts index 4a495f1..d775dad 100644 --- a/src/trace/.config/webpack/webpack.config.ts +++ b/src/trace/.config/webpack/webpack.config.ts @@ -7,9 +7,9 @@ import CopyWebpackPlugin from 'copy-webpack-plugin'; import LiveReloadPlugin from 'webpack-livereload-plugin'; -import path from 'path'; +import path from 'node:path'; import ReplaceInFileWebpackPlugin from 'replace-in-file-webpack-plugin'; -import { Configuration } from 'webpack'; +import type { Configuration } from 'webpack'; import { getPackageJson, getPluginJson, hasReadme, getEntries, isWSL } from './utils'; import { SOURCE_DIR, DIST_DIR } from './constants'; @@ -59,8 +59,8 @@ const config = async (env): Promise => { // Mark legacy SDK imports as external if their name starts with the "grafana/" prefix ({ request }, callback) => { const prefix = 'grafana/'; - const hasPrefix = (request) => request.indexOf(prefix) === 0; - const stripPrefix = (request) => request.substr(prefix.length); + const hasPrefix = request => request.indexOf(prefix) === 0; + const stripPrefix = request => request.substr(prefix.length); if (hasPrefix(request)) { return callback(undefined, stripPrefix(request)); @@ -101,7 +101,7 @@ const config = async (env): Promise => { // Keep publicPath relative for host.com/grafana/ deployments publicPath: `public/plugins/${pluginJson.id}/img/`, outputPath: 'img/', - filename: Boolean(env.production) ? '[hash][ext]' : '[file]', + filename: env.production ? '[hash][ext]' : '[file]', }, }, { @@ -111,7 +111,7 @@ const config = async (env): Promise => { // Keep publicPath relative for host.com/grafana/ deployments publicPath: `public/plugins/${pluginJson.id}/fonts/`, outputPath: 'fonts/', - filename: Boolean(env.production) ? '[hash][ext]' : '[name][ext]', + filename: env.production ? '[hash][ext]' : '[name][ext]', }, }, ], @@ -119,9 +119,9 @@ const config = async (env): Promise => { output: { clean: { - keep: new RegExp(`(.*?_(amd64|arm(64)?)(.exe)?|go_plugin_build_manifest)`), + keep: /(.*?_(amd64|arm(64)?)(.exe)?|go_plugin_build_manifest)/, }, - filename: `[name].js`, + filename: '[name].js', path: path.resolve(process.cwd(), DIST_DIR), publicPath: `public/plugins/${pluginJson.id}/`, libraryTarget: 'amd', diff --git a/src/trace/src/CheatSheet.tsx b/src/trace/src/CheatSheet.tsx index b12eedd..7aab8f9 100644 --- a/src/trace/src/CheatSheet.tsx +++ b/src/trace/src/CheatSheet.tsx @@ -1,5 +1,5 @@ import { css } from '@emotion/css'; -import { type GrafanaTheme2 } from '@grafana/data'; +import type { GrafanaTheme2 } from '@grafana/data'; import { useStyles2 } from '@grafana/ui'; import React from 'react'; diff --git a/src/trace/src/components/QueryEditor.tsx b/src/trace/src/components/QueryEditor.tsx index 5261e85..cfbc1ce 100644 --- a/src/trace/src/components/QueryEditor.tsx +++ b/src/trace/src/components/QueryEditor.tsx @@ -1,5 +1,5 @@ import { css } from '@emotion/css'; -import { type QueryEditorProps } from '@grafana/data'; +import type { QueryEditorProps } from '@grafana/data'; import { Button, FileDropzone, @@ -14,8 +14,8 @@ import { } from '@grafana/ui'; import React, { useState } from 'react'; -import { type JaegerDatasource } from '../datasource'; -import { type JaegerQuery, type JaegerQueryType } from '../types'; +import type { JaegerDatasource } from '../datasource'; +import type { JaegerQuery, JaegerQueryType } from '../types'; import { SearchForm } from './SearchForm'; type Props = QueryEditorProps; diff --git a/src/trace/src/components/SearchForm.tsx b/src/trace/src/components/SearchForm.tsx index f5fe734..978da6a 100644 --- a/src/trace/src/components/SearchForm.tsx +++ b/src/trace/src/components/SearchForm.tsx @@ -7,8 +7,8 @@ import { fuzzyMatch, InlineField, InlineFieldRow, Input, Select } from '@grafana // import { dispatch } from 'grafana/app/store/store'; import React, { useCallback, useEffect, useState } from 'react'; -import { type JaegerDatasource } from '../datasource'; -import { type JaegerQuery } from '../types'; +import type { JaegerDatasource } from '../datasource'; +import type { JaegerQuery } from '../types'; import { transformToLogfmt } from '../util'; const durationPlaceholder = 'e.g. 1.2s, 100ms, 500us'; @@ -65,7 +65,7 @@ export function SearchForm({ datasource, query, onChange }: Props) { setIsLoading(prevValue => ({ ...prevValue, [loaderOfType]: false })); } }, - [datasource], + [datasource] ); useEffect(() => { @@ -83,7 +83,7 @@ export function SearchForm({ datasource, query, onChange }: Props) { const getOperations = async () => { const operations = await loadOptions( `/api/services/${encodeURIComponent(getTemplateSrv().replace(query.service!))}/operations`, - 'operations', + 'operations' ); if (query.operation && getTemplateSrv().containsTemplate(query.operation)) { operations.push(toOption(query.operation)); @@ -178,7 +178,7 @@ export function SearchForm({ datasource, query, onChange }: Props) { onOpenMenu={() => loadOptions( `/api/services/${encodeURIComponent(getTemplateSrv().replace(query.service!))}/operations`, - 'operations', + 'operations' ) } /> @@ -259,7 +259,7 @@ export function SearchForm({ datasource, query, onChange }: Props) { onChange={v => onChange({ ...query, - limit: v.currentTarget.value ? parseInt(v.currentTarget.value, 10) : undefined, + limit: v.currentTarget.value ? Number.parseInt(v.currentTarget.value, 10) : undefined, }) } /> diff --git a/src/trace/src/configuration/ConfigEditor.tsx b/src/trace/src/configuration/ConfigEditor.tsx index 2d1467c..0295271 100644 --- a/src/trace/src/configuration/ConfigEditor.tsx +++ b/src/trace/src/configuration/ConfigEditor.tsx @@ -1,5 +1,5 @@ import { css } from '@emotion/css'; -import { type DataSourcePluginOptionsEditorProps, type GrafanaTheme2 } from '@grafana/data'; +import type { DataSourcePluginOptionsEditorProps, GrafanaTheme2 } from '@grafana/data'; import { ConfigSection, DataSourceDescription } from '@grafana/experimental'; import { NodeGraphSection, SpanBarSection, TraceToLogsSection, TraceToMetricsSection } from '@grafana/o11y-ds-frontend'; import { config } from '@grafana/runtime'; diff --git a/src/trace/src/datasource.ts b/src/trace/src/datasource.ts index ef17477..d21143e 100644 --- a/src/trace/src/datasource.ts +++ b/src/trace/src/datasource.ts @@ -13,18 +13,18 @@ import { type ScopedVars, urlUtil, } from '@grafana/data'; -import { type NodeGraphOptions, type SpanBarOptions } from '@grafana/o11y-ds-frontend'; +import type { NodeGraphOptions, SpanBarOptions } from '@grafana/o11y-ds-frontend'; import { type BackendSrvRequest, getBackendSrv, getTemplateSrv } from '@grafana/runtime'; import { identity, omit, pick, pickBy } from 'lodash'; import { lastValueFrom, type Observable, of } from 'rxjs'; import { catchError, map } from 'rxjs/operators'; import { ALL_OPERATIONS_KEY } from './components/SearchForm'; -import { type TraceIdTimeParamsOptions } from './configuration/TraceIdTimeParams'; +import type { TraceIdTimeParamsOptions } from './configuration/TraceIdTimeParams'; import { mapJaegerDependenciesResponse } from './dependencyGraphTransform'; import { createGraphFrames } from './graphTransform'; import { createTableFrame, createTraceFrame } from './responseTransform'; -import { type JaegerQuery } from './types'; +import type { JaegerQuery } from './types'; import { convertTagsLogfmt } from './util'; export interface JaegerJsonData extends DataSourceJsonData { @@ -73,7 +73,7 @@ export class JaegerDatasource extends DataSourceApi return of({ error: { message: 'You must select a service.' }, data: [] }); } - let { start, end } = this.getTimeRange(); + const { start, end } = this.getTimeRange(); if (target.queryType !== 'search' && target.query) { let url = `/api/traces/${encodeURIComponent(getTemplateSrv().replace(target.query, options.scopedVars))}`; @@ -87,14 +87,14 @@ export class JaegerDatasource extends DataSourceApi if (!traceData) { return { data: [emptyTraceDataFrame] }; } - let data = [createTraceFrame(traceData)]; + const data = [createTraceFrame(traceData)]; if (this.nodeGraph?.enabled) { data.push(...createGraphFrames(traceData)); } return { data, }; - }), + }) ); } @@ -105,7 +105,7 @@ export class JaegerDatasource extends DataSourceApi try { const traceData = JSON.parse(this.uploadedJson as string).data[0]; - let data = [createTraceFrame(traceData)]; + const data = [createTraceFrame(traceData)]; if (this.nodeGraph?.enabled) { data.push(...createGraphFrames(traceData)); } @@ -115,7 +115,7 @@ export class JaegerDatasource extends DataSourceApi } } - let jaegerInterpolated = pick(this.applyVariables(target, options.scopedVars), [ + const jaegerInterpolated = pick(this.applyVariables(target, options.scopedVars), [ 'service', 'operation', 'tags', @@ -138,7 +138,7 @@ export class JaegerDatasource extends DataSourceApi } // TODO: this api is internal, used in jaeger ui. Officially they have gRPC api that should be used. - return this._request(`/api/traces`, { + return this._request('/api/traces', { ...jaegerQuery, ...this.getTimeRange(), lookback: 'custom', @@ -147,7 +147,7 @@ export class JaegerDatasource extends DataSourceApi return { data: [createTableFrame(response.data.data, this.instanceSettings)], }; - }), + }) ); } @@ -216,8 +216,8 @@ export class JaegerDatasource extends DataSourceApi message += `. ${JSON.stringify(err.data)}`; } return of({ status: 'error', message: message }); - }), - ), + }) + ) ); } @@ -236,7 +236,7 @@ export class JaegerDatasource extends DataSourceApi private _request( apiUrl: string, data?: Record, - options?: Partial, + options?: Partial ): Observable> { const params = data ? urlUtil.serializeParams(data) : ''; const url = `${this.instanceSettings.url}${apiUrl}${params.length ? `?${params}` : ''}`; diff --git a/src/trace/src/dependencyGraphTransform.ts b/src/trace/src/dependencyGraphTransform.ts index 892d661..07c4112 100644 --- a/src/trace/src/dependencyGraphTransform.ts +++ b/src/trace/src/dependencyGraphTransform.ts @@ -7,7 +7,7 @@ import { NodeGraphDataFrameFieldNames as Fields, } from '@grafana/data'; -import { type JaegerServiceDependency } from './types'; +import type { JaegerServiceDependency } from './types'; interface Node { [Fields.id]: string; diff --git a/src/trace/src/graphTransform.ts b/src/trace/src/graphTransform.ts index 1dac054..d592c79 100644 --- a/src/trace/src/graphTransform.ts +++ b/src/trace/src/graphTransform.ts @@ -1,7 +1,7 @@ import { type DataFrame, NodeGraphDataFrameFieldNames as Fields } from '@grafana/data'; import { getNonOverlappingDuration, getStats, makeFrames, makeSpanMap } from '@grafana/o11y-ds-frontend'; -import { type Span, type TraceResponse } from './types'; +import type { Span, TraceResponse } from './types'; interface Node { [Fields.id]: string; @@ -91,7 +91,7 @@ function convertTraceToGraph(data: TraceResponse): { nodes: Node[]; edges: Edge[ */ function findTraceDuration(spans: Span[]): number { let traceEndTime = 0; - let traceStartTime = Infinity; + let traceStartTime = Number.POSITIVE_INFINITY; for (const span of spans) { if (span.startTime < traceStartTime) { diff --git a/src/trace/src/responseTransform.ts b/src/trace/src/responseTransform.ts index a02989f..6130caf 100644 --- a/src/trace/src/responseTransform.ts +++ b/src/trace/src/responseTransform.ts @@ -9,7 +9,7 @@ import { // import { transformTraceData } from 'grafana/app/features/explore/TraceView/components'; import transformTraceData from './transform-trace-data'; -import { type JaegerResponse, type Span, type TraceProcess, type TraceResponse } from './types'; +import type { JaegerResponse, Span, TraceProcess, TraceResponse } from './types'; export function createTraceFrame(data: TraceResponse): DataFrame { const spans = data.spans.map(s => toSpanRow(s, data.processes)); @@ -121,13 +121,13 @@ function transformToTraceData(data: TraceResponse) { } export function transformToJaeger(data: MutableDataFrame): JaegerResponse { - let traceResponse: TraceResponse = { + const traceResponse: TraceResponse = { traceID: '', spans: [], processes: {}, warnings: null, }; - let processes: string[] = []; + const processes: string[] = []; for (let i = 0; i < data.length; i++) { const span = data.get(i); @@ -168,7 +168,7 @@ export function transformToJaeger(data: MutableDataFrame): JaegerResponse { operationName: span.operationName, processID: Object.keys(traceResponse.processes).find( - key => traceResponse.processes[key].serviceName === span.serviceName, + key => traceResponse.processes[key].serviceName === span.serviceName ) || '', startTime: span.startTime * 1000, tags: span.tags, diff --git a/src/trace/src/transform-trace-data.tsx b/src/trace/src/transform-trace-data.tsx index 436af93..c84ec54 100644 --- a/src/trace/src/transform-trace-data.tsx +++ b/src/trace/src/transform-trace-data.tsx @@ -14,13 +14,7 @@ import { isEqual as _isEqual } from 'lodash'; -import { - type TraceKeyValuePair, - type TraceSpan, - type Trace, - type TraceResponse, - type TraceProcess, -} from './types/trace'; +import type { TraceKeyValuePair, TraceSpan, Trace, TraceResponse, TraceProcess } from './types/trace'; import { getConfigValue } from './utils/get-config'; import { getTraceSpanIdsAsTree } from './utils/trace'; import { getTraceName } from './utils/trace-viewer'; diff --git a/src/trace/src/types.ts b/src/trace/src/types.ts index cfcbdd7..082d9c9 100644 --- a/src/trace/src/types.ts +++ b/src/trace/src/types.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import { type DataQuery } from '@grafana/data'; +import type { DataQuery } from '@grafana/data'; export type TraceKeyValuePair = { key: string; type?: string; diff --git a/src/trace/src/utils/get-config.tsx b/src/trace/src/utils/get-config.tsx index 648a5fa..814e2ce 100644 --- a/src/trace/src/utils/get-config.tsx +++ b/src/trace/src/utils/get-config.tsx @@ -37,7 +37,7 @@ export const defaultConfig = Object.defineProperty( }, // fields that should be individually merged vs wholesale replaced '__mergeFields', - { value: ['dependencies', 'search', 'tracking'] }, + { value: ['dependencies', 'search', 'tracking'] } ); /** * Merge the embedded config from the query service (if present) with the diff --git a/src/trace/src/utils/trace-viewer.ts b/src/trace/src/utils/trace-viewer.ts index da56259..d0e82aa 100644 --- a/src/trace/src/utils/trace-viewer.ts +++ b/src/trace/src/utils/trace-viewer.ts @@ -14,7 +14,7 @@ import { memoize } from 'lodash'; -import { type TraceSpan } from '../types/trace'; +import type { TraceSpan } from '../types/trace'; export function _getTraceNameImpl(spans: TraceSpan[]) { // Use a span with no references to another span in given array @@ -25,7 +25,7 @@ export function _getTraceNameImpl(spans: TraceSpan[]) { for (let i = 0; i < spans.length; i++) { const hasInternalRef = spans[i].references?.some( - ({ traceID, spanID }) => traceID === spans[i].traceID && allIDs.has(spanID), + ({ traceID, spanID }) => traceID === spans[i].traceID && allIDs.has(spanID) ); if (hasInternalRef) { continue; diff --git a/src/trace/src/utils/trace.ts b/src/trace/src/utils/trace.ts index 2d68a3f..6c9e3d5 100644 --- a/src/trace/src/utils/trace.ts +++ b/src/trace/src/utils/trace.ts @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { type TraceResponse, type TraceSpanData } from '../types/trace'; +import type { TraceResponse, TraceSpanData } from '../types/trace'; import TreeNode from './TreeNode'; export const getTraceSpans = (trace: TraceResponse) => trace.spans;