From f6b772cccb5aa77aece657b20d520a75181d764b Mon Sep 17 00:00:00 2001 From: yash singh Date: Fri, 22 Sep 2023 15:08:03 +0530 Subject: [PATCH] fixed eslist issues | updated packages to fix errors with yarn build --- package.json | 94 ++++++++++++++++++++--------------------- src/PartListSection.tsx | 5 ++- src/QueryEditor.tsx | 28 ++++++------ src/datasource.ts | 2 +- src/types.ts | 3 ++ webpack.config.ts | 2 +- 6 files changed, 70 insertions(+), 64 deletions(-) diff --git a/package.json b/package.json index 504f7aa..c00131a 100644 --- a/package.json +++ b/package.json @@ -19,59 +19,59 @@ "author": "Opentext", "license": "Apache-2.0", "devDependencies": { - "@babel/core": "^7.21.4", - "@babel/helper-compilation-targets": "^7.20.7", - "@babel/preset-typescript": "^7.13.0", - "@grafana/e2e": "9.5.3", - "@grafana/e2e-selectors": "9.5.3", - "@grafana/eslint-config": "^6.0.0", - "@grafana/experimental": "^1.1.0", - "@grafana/tsconfig": "^1.2.0-rc1", - "@swc/core": "^1.3.62", - "@swc/helpers": "^0.5.0", - "@swc/jest": "^0.2.26", - "@testing-library/jest-dom": "^5.16.5", - "@testing-library/react": "^12.1.4", - "@types/enzyme": "3.10.5", + "@babel/core": "^7.22.20", + "@babel/helper-compilation-targets": "^7.22.15", + "@babel/preset-typescript": "^7.22.15", + "@grafana/e2e": "10.1.2", + "@grafana/e2e-selectors": "10.1.2", + "@grafana/eslint-config": "^6.0.1", + "@grafana/experimental": "^1.7.2", + "@grafana/tsconfig": "^1.3.0-rc1", + "@swc/core": "^1.3.87", + "@swc/helpers": "^0.5.2", + "@swc/jest": "^0.2.29", + "@testing-library/jest-dom": "^6.1.3", + "@testing-library/react": "^14.0.0", + "@types/enzyme": "3.10.13", "@types/enzyme-adapter-react-16": "^1.0.6", - "@types/jest": "^29.5.0", - "@types/lodash": "^4.14.194", - "@types/node": "^18.15.11", - "@typescript-eslint/eslint-plugin": "^4.22.1", - "@typescript-eslint/parser": "^4.22.1", + "@types/jest": "^29.5.5", + "@types/lodash": "^4.14.198", + "@types/node": "^20.6.3", + "@typescript-eslint/eslint-plugin": "^6.7.2", + "@typescript-eslint/parser": "^6.7.2", "copy-webpack-plugin": "^11.0.0", "css-loader": "^6.7.3", "enzyme": "3.11.0", - "enzyme-adapter-react-16": "^1.15.6", + "enzyme-adapter-react-16": "^1.15.7", "enzyme-to-json": "^3.3.4", - "eslint": "^7.25.0", - "eslint-config-prettier": "^8.3.0", - "eslint-plugin-jsdoc": "^35.0.0", - "eslint-plugin-lodash": "^7.2.0", - "eslint-plugin-no-only-tests": "^2.6.0", - "eslint-plugin-prettier": "^3.4.0", - "eslint-plugin-react": "^7.23.2", - "eslint-plugin-react-hooks": "^4.2.0", + "eslint": "^8.49.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-jsdoc": "^46.8.2", + "eslint-plugin-lodash": "^7.4.0", + "eslint-plugin-no-only-tests": "^3.1.0", + "eslint-plugin-prettier": "^5.0.0", + "eslint-plugin-react": "^7.33.2", + "eslint-plugin-react-hooks": "^4.6.0", "eslint-webpack-plugin": "^4.0.1", "fork-ts-checker-webpack-plugin": "^8.0.0", - "glob": "^10.2.7", + "glob": "^10.3.5", "identity-obj-proxy": "3.0.0", - "jest": "^29.5.0", - "jest-environment-jsdom": "^29.5.0", - "jest-expo": "~27.0.1", + "jest": "^29.7.0", + "jest-environment-jsdom": "^29.7.0", + "jest-expo": "~49.0.0", "jest-serializer-enzyme": "^1.0.0", - "prettier": "^2.8.7", + "prettier": "^3.0.3", "react-autosuggest": "^10.1.0", "replace-in-file-webpack-plugin": "^1.0.6", - "sass": "1.63.2", - "sass-loader": "13.3.1", + "sass": "1.68.0", + "sass-loader": "13.3.2", "style-loader": "3.3.3", "swc-loader": "^0.2.3", - "ts-jest": "26.4.4", + "ts-jest": "29.1.1", "ts-node": "^10.9.1", "tsconfig-paths": "^4.2.0", "tslib": "2.5.3", - "typescript": "4.8.4", + "typescript": "5.2.2", "webpack": "^5.86.0", "webpack-cli": "^5.1.4", "webpack-livereload-plugin": "^3.0.2" @@ -84,23 +84,23 @@ }, "dependencies": { "@emotion/css": "^11.1.3", - "@grafana/data": "9.5.3", - "@grafana/runtime": "7.5.8", - "@grafana/ui": "7.5.8", + "@grafana/data": "10.1.2", + "@grafana/runtime": "10.1.2", + "@grafana/ui": "10.1.2", "@types/react-autosuggest": "^10.1.6", "@types/react-virtualized-auto-sizer": "^1.0.1", - "ace-builds": "^1.15.2", + "ace-builds": "^1.27.0", "brace": "^0.11.1", "grafana-data": "^2.0.1", - "react": "17.0.2", + "react": "18.2.0", "react-ace": "^10.1.0", "react-autosuggest": "^10.1.0", - "react-awesome-query-builder": "^5.4.1", - "react-dom": "17.0.2", - "react-monaco-editor": "^0.51.0", + "react-awesome-query-builder": "^5.4.2", + "react-dom": "18.2.0", + "react-monaco-editor": "^0.54.0", "react-use": "^17.4.0", - "react-virtualized-auto-sizer": "^1.0.7", - "tslib": "2.5.3", + "react-virtualized-auto-sizer": "^1.0.20", + "tslib": "2.6.2", "yarn": "^1.22.19" }, "packageManager": "yarn@1.22.19" diff --git a/src/PartListSection.tsx b/src/PartListSection.tsx index d33dc13..98b4136 100644 --- a/src/PartListSection.tsx +++ b/src/PartListSection.tsx @@ -5,12 +5,15 @@ import { toSelectableValue } from './toSelectableValue'; import { AddButton } from './AddButton'; import { unwrap } from './unwrap'; +// eslint-disable-next-line @typescript-eslint/array-type export type PartParams = Array<{ value: string; options: (() => Promise>) | null; }>; + type Props = { + // eslint-disable-next-line @typescript-eslint/array-type parts: Array<{ name: string; params: PartParams; @@ -133,7 +136,7 @@ const Part = ({ name, params, onChange, onRemove }: PartProps): JSX.Element => { > ( {params.map((p, i) => { - const results = new Promise>>((resolve) => resolve([])); + const results = new Promise[]>((resolve) => resolve([])); const { value, options } = p; const isLast = i === params.length - 1; const loadOptions = diff --git a/src/QueryEditor.tsx b/src/QueryEditor.tsx index 7c55872..6c4ca80 100644 --- a/src/QueryEditor.tsx +++ b/src/QueryEditor.tsx @@ -204,7 +204,7 @@ export const QueryEditor = (props: Props): JSX.Element => { const label = type.split('|')[0]; const value = type.split('|')[1]; const partType = type.split('|')[2]; - let defaultParams: Array = []; + let defaultParams: any[] = []; switch (value) { case 'column': defaultParams = ['value']; @@ -292,7 +292,7 @@ export const QueryEditor = (props: Props): JSX.Element => { // handler when WHERE section part is added const handleWhereParamsAdd = (type: string) => { const clonedQuery = cloneDeep(query); - let defaultParams: Array = []; + let defaultParams: any[] = []; let partName = ''; switch (type) { case 'macro': @@ -338,7 +338,7 @@ export const QueryEditor = (props: Props): JSX.Element => { const handleGroupParamsAdd = (type: string, data: any = { label: '', value: '', type: '' }) => { // const clonedQuery = cloneDeep(query); const clonedQuery = cloneDeep(query); - let defaultParams: Array = []; + let defaultParams: any[] = []; let partName = ''; switch (type) { case 'time': @@ -374,7 +374,7 @@ export const QueryEditor = (props: Props): JSX.Element => { const getSchemaOptions = () => { const queryModel = new QueryModel(query, getTemplateSrv()); const metaBuilder = new MetaQuery(query, queryModel); - return new Promise>>((resolve) => { + return new Promise((resolve) => { setTimeout(async () => { const response = await datasource.metricFindQuery(metaBuilder.buildSchemaQuery()); const result = response.map((res: any) => { @@ -389,7 +389,7 @@ export const QueryEditor = (props: Props): JSX.Element => { const getTableOptions = () => { const queryModel = new QueryModel(query, getTemplateSrv()); const metaBuilder = new MetaQuery(query, queryModel); - return new Promise>>((resolve) => { + return new Promise((resolve) => { setTimeout(async () => { const response = await datasource.metricFindQuery(metaBuilder.buildTableQuery()); const result = response.map((res: any) => { @@ -404,7 +404,7 @@ export const QueryEditor = (props: Props): JSX.Element => { const getTimeColumnOptions = () => { const queryModel = new QueryModel(query, getTemplateSrv()); const metaBuilder = new MetaQuery(query, queryModel); - return new Promise>>((resolve) => { + return new Promise[]>((resolve) => { setTimeout(async () => { const response = await datasource.metricFindQuery(metaBuilder.buildColumnQuery('time')); const result = response.map((res: any) => { @@ -419,7 +419,7 @@ export const QueryEditor = (props: Props): JSX.Element => { const getMetricColumnOptions = () => { const queryModel = new QueryModel(query, getTemplateSrv()); const metaBuilder = new MetaQuery(query, queryModel); - return new Promise>>((resolve) => { + return new Promise[]>((resolve) => { setTimeout(async () => { const response = await datasource.metricFindQuery(metaBuilder.buildColumnQuery('metric')); const result = response.map((res: any) => { @@ -434,7 +434,7 @@ export const QueryEditor = (props: Props): JSX.Element => { const getColumnOptions = useCallback(async () => { const queryModel = new QueryModel(query, getTemplateSrv()); const metaBuilder = new MetaQuery(query, queryModel); - return new Promise>>((resolve) => { + return new Promise((resolve) => { setTimeout(async () => { const response = await datasource.metricFindQuery(metaBuilder.buildColumnQuery('value')); const result = response.map((res: any) => { @@ -447,7 +447,7 @@ export const QueryEditor = (props: Props): JSX.Element => { // method to fetch all the columns selected in the SELECT section and TIME section const getSelectedColumnOptions = useCallback(() => { - return new Promise>>((resolve) => { + return new Promise((resolve) => { setTimeout(() => { const result: any = []; result.push(query.timeColumn); @@ -466,7 +466,7 @@ export const QueryEditor = (props: Props): JSX.Element => { // method to fetch all the group columns for the selected table const getGroupByOptions = () => { const queryModel = new QueryModel(query, getTemplateSrv()); - return new Promise>>((resolve) => { + return new Promise((resolve) => { setTimeout(async () => { const response = await getSelectedColumnOptions(); const options = []; @@ -486,7 +486,7 @@ export const QueryEditor = (props: Props): JSX.Element => { const { datasource } = props; const queryModel = new QueryModel(query, getTemplateSrv()); const metaBuilder = new MetaQuery(query, queryModel); - return new Promise>>((resolve) => { + return new Promise((resolve) => { setTimeout(async () => { const response = await datasource.metricFindQuery(metaBuilder.buildColumnQuery('')); const result = response.map((res: any) => { @@ -504,7 +504,7 @@ export const QueryEditor = (props: Props): JSX.Element => { query.select.map((item) => { const data: any = []; item.map((row) => { - const params: Array<{ value: string; options: (() => Promise>) | null }> = []; + const params: any[] = []; row.params.map((param, paramIndex) => { if (row.type === 'column') { params.push({ @@ -555,7 +555,7 @@ export const QueryEditor = (props: Props): JSX.Element => { const whereParts = useMemo(() => { const results: any = []; query.where?.map((part) => { - const params: Array<{ value: string; options: (() => Promise>) | null }> = []; + const params: any[] = []; let partName = ''; part.params.map((param, index) => { if (part.type === 'expression') { @@ -600,7 +600,7 @@ export const QueryEditor = (props: Props): JSX.Element => { const results: any = []; query.group && query.group.map((part) => { - const params: Array<{ value: string; options: (() => Promise>) | null }> = []; + const params: any[] = []; let partName = ''; part.params.map((param, index) => { if (part.type === 'time') { diff --git a/src/datasource.ts b/src/datasource.ts index 42fa28c..b402990 100644 --- a/src/datasource.ts +++ b/src/datasource.ts @@ -87,7 +87,7 @@ export class DataSource extends DataSourceWithBackend; name?: string; } @@ -22,8 +23,10 @@ export interface MyQuery extends DataQuery { rawSql?: string; queryText?: string; hide: boolean; + } +// eslint-disable-next-line @typescript-eslint/array-type export type PartParams = Array<{ value: string; options: (() => Promise>) | null; diff --git a/webpack.config.ts b/webpack.config.ts index 7f5d535..a5ebd4a 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -14,4 +14,4 @@ const config = async (env): Promise => { }); }; -export default config; \ No newline at end of file +export default config;