diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..c5e1946 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,7 @@ +node_modules +/data +/build +/target +/.eslintrc.js +/cypress.config.js +!.cypress/ diff --git a/.eslintrc.js b/.eslintrc.js index b16a8b2..638f288 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,7 +1,58 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +const LICENSE_HEADER = `/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */`; + module.exports = { root: true, - extends: ['@elastic/eslint-config-kibana', 'plugin:@elastic/eui/recommended'], + extends: [ + '@elastic/eslint-config-kibana', + 'plugin:@elastic/eui/recommended', + 'plugin:react-hooks/recommended', + 'plugin:jest/recommended', + 'plugin:prettier/recommended', + ], rules: { - '@osd/eslint/require-license-header': 'off', + '@typescript-eslint/no-unused-vars': [ + 'error', + { + argsIgnorePattern: '^_', + varsIgnorePattern: '^_', + caughtErrorsIgnorePattern: '^_', + }, + ], + '@osd/eslint/no-restricted-paths': [ + 'error', + { + basePath: __dirname, + zones: [ + { + target: ['(public|server)/**/*'], + from: ['../../packages/**/*','packages/**/*'], + }, + ], + }, + ], }, + overrides: [ + { + files: ['**/*.{js,ts,tsx}'], + rules: { + '@typescript-eslint/no-explicit-any': 'warn', + 'no-console': 0, + '@osd/eslint/require-license-header': [ + 'error', + { + licenses: [LICENSE_HEADER], + }, + ], + }, + }, + ], + "ignorePatterns": ["**/*.d.ts"] }; diff --git a/common/index.ts b/common/index.ts index f721e8c..47c02d3 100644 --- a/common/index.ts +++ b/common/index.ts @@ -1,2 +1,7 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + export const PLUGIN_ID = 'queryInsightsDashboards'; export const PLUGIN_NAME = 'query-insights-dashboards'; diff --git a/package.json b/package.json index 8b50281..43a0b8e 100644 --- a/package.json +++ b/package.json @@ -55,5 +55,9 @@ "lint-staged": "^10.2.0", "ts-loader": "^6.2.1", "string.prototype.replaceall": "1.0.7" - } + }, + "eslintIgnore": [ + "node_modules/*", + "target/*" + ] } diff --git a/public/application.tsx b/public/application.tsx index 5b6ec41..154bf8b 100644 --- a/public/application.tsx +++ b/public/application.tsx @@ -1,3 +1,8 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + import React from 'react'; import ReactDOM from 'react-dom'; import { HashRouter as Router } from 'react-router-dom'; diff --git a/public/components/app.test.tsx b/public/components/app.test.tsx index 8e494ca..eae7f7e 100644 --- a/public/components/app.test.tsx +++ b/public/components/app.test.tsx @@ -1,7 +1,6 @@ /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 - * @jest-environment jsdom */ import React from 'react'; diff --git a/public/components/app.tsx b/public/components/app.tsx index 603d189..be652f5 100644 --- a/public/components/app.tsx +++ b/public/components/app.tsx @@ -1,3 +1,8 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + import React from 'react'; import { Route } from 'react-router-dom'; import TopNQueries from '../pages/TopNQueries/TopNQueries'; diff --git a/public/index.ts b/public/index.ts index 6959d2f..49c8e18 100644 --- a/public/index.ts +++ b/public/index.ts @@ -1,3 +1,8 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + import './index.scss'; import { QueryInsightsDashboardsPlugin } from './plugin'; diff --git a/public/pages/Configuration/Configuration.tsx b/public/pages/Configuration/Configuration.tsx index d3ca0d7..8978cf1 100644 --- a/public/pages/Configuration/Configuration.tsx +++ b/public/pages/Configuration/Configuration.tsx @@ -1,3 +1,8 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + import React, { useMemo, useCallback, useState, useEffect } from 'react'; import { EuiBottomBar, diff --git a/public/pages/QueryDetails/Components/QuerySummary.tsx b/public/pages/QueryDetails/Components/QuerySummary.tsx index 7d6d5fb..7110599 100644 --- a/public/pages/QueryDetails/Components/QuerySummary.tsx +++ b/public/pages/QueryDetails/Components/QuerySummary.tsx @@ -1,3 +1,8 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + import React from 'react'; import { EuiFlexGrid, EuiFlexItem, EuiHorizontalRule, EuiPanel, EuiText } from '@elastic/eui'; diff --git a/public/pages/QueryDetails/QueryDetails.tsx b/public/pages/QueryDetails/QueryDetails.tsx index ce9e9d7..6bc091f 100644 --- a/public/pages/QueryDetails/QueryDetails.tsx +++ b/public/pages/QueryDetails/QueryDetails.tsx @@ -1,3 +1,8 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + import React, { useEffect } from 'react'; import Plotly from 'plotly.js-dist'; import { diff --git a/public/pages/QueryInsights/QueryInsights.tsx b/public/pages/QueryInsights/QueryInsights.tsx index 1d476dd..67912de 100644 --- a/public/pages/QueryInsights/QueryInsights.tsx +++ b/public/pages/QueryInsights/QueryInsights.tsx @@ -1,3 +1,8 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + import React, { useEffect, useState } from 'react'; import { EuiBasicTableColumn, EuiInMemoryTable, EuiLink, EuiSuperDatePicker } from '@elastic/eui'; import { useHistory, useLocation } from 'react-router-dom'; diff --git a/public/pages/TopNQueries/TopNQueries.tsx b/public/pages/TopNQueries/TopNQueries.tsx index b6a6af3..cacec6e 100644 --- a/public/pages/TopNQueries/TopNQueries.tsx +++ b/public/pages/TopNQueries/TopNQueries.tsx @@ -1,11 +1,16 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + import React, { useCallback, useEffect, useState } from 'react'; import { Redirect, Route, Switch, useHistory, useLocation } from 'react-router-dom'; import { EuiTab, EuiTabs, EuiTitle, EuiSpacer } from '@elastic/eui'; import dateMath from '@elastic/datemath'; +import { CoreStart } from 'opensearch-dashboards/public'; import QueryInsights from '../QueryInsights/QueryInsights'; import Configuration from '../Configuration/Configuration'; import QueryDetails from '../QueryDetails/QueryDetails'; -import { CoreStart } from '../../../../../src/core/public'; export const QUERY_INSIGHTS = '/queryInsights'; export const CONFIGURATION = '/configuration'; @@ -142,7 +147,6 @@ const TopNQueries = ({ core }: { core: CoreStart }) => { ).map((item) => JSON.parse(item)); setQueries(noDuplicates); } catch (error) { - // eslint-disable-next-line no-console console.error('Error retrieving queries:', error); } finally { setLoading(false); @@ -195,7 +199,6 @@ const TopNQueries = ({ core }: { core: CoreStart }) => { }); } } catch (error) { - // eslint-disable-next-line no-console console.error('Failed to retrieve settings:', error); } } else { @@ -215,7 +218,6 @@ const TopNQueries = ({ core }: { core: CoreStart }) => { }, }); } catch (error) { - // eslint-disable-next-line no-console console.error('Failed to set settings:', error); } } diff --git a/public/plugin.ts b/public/plugin.ts index 6dd0032..9371fdf 100644 --- a/public/plugin.ts +++ b/public/plugin.ts @@ -1,3 +1,8 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + import { i18n } from '@osd/i18n'; import { AppMountParameters, CoreSetup, CoreStart, Plugin } from '../../../src/core/public'; import { QueryInsightsDashboardsPluginSetup, QueryInsightsDashboardsPluginStart } from './types'; @@ -41,7 +46,7 @@ export class QueryInsightsDashboardsPlugin }; } - public start(core: CoreStart): QueryInsightsDashboardsPluginStart { + public start(_core: CoreStart): QueryInsightsDashboardsPluginStart { return {}; } diff --git a/public/types.ts b/public/types.ts index 06c5cc5..e0e892a 100644 --- a/public/types.ts +++ b/public/types.ts @@ -1,3 +1,8 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + import { NavigationPublicPluginStart } from '../../../src/plugins/navigation/public'; export interface QueryInsightsDashboardsPluginSetup { diff --git a/server/index.ts b/server/index.ts index 32152e0..683eba6 100644 --- a/server/index.ts +++ b/server/index.ts @@ -1,3 +1,8 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + import { PluginInitializerContext } from '../../../src/core/server'; import { QueryInsightsDashboardsPlugin } from './plugin'; diff --git a/server/plugin.ts b/server/plugin.ts index d48449f..fa7755f 100644 --- a/server/plugin.ts +++ b/server/plugin.ts @@ -1,3 +1,8 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + import { PluginInitializerContext, CoreSetup, @@ -42,7 +47,7 @@ export class QueryInsightsDashboardsPlugin return {}; } - public start(core: CoreStart) { + public start(_core: CoreStart) { this.logger.debug('query-insights-dashboards: Started'); return {}; } diff --git a/server/routes/index.ts b/server/routes/index.ts index cd59293..6e06207 100644 --- a/server/routes/index.ts +++ b/server/routes/index.ts @@ -1,3 +1,8 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + import { schema } from '@osd/config-schema'; import { IRouter } from '../../../../src/core/server'; export function defineRoutes(router: IRouter) { diff --git a/server/types.ts b/server/types.ts index 9dfec61..1eb3660 100644 --- a/server/types.ts +++ b/server/types.ts @@ -1,3 +1,8 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface QueryInsightsDashboardsPluginSetup {} // eslint-disable-next-line @typescript-eslint/no-empty-interface diff --git a/yarn.lock b/yarn.lock index f241347..6955c37 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4869,6 +4869,11 @@ object-copy@^0.1.0: define-property "^0.2.5" kind-of "^3.0.3" +object-hash@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-3.0.0.tgz#73f97f753e7baffc0e2cc9d6e079079744ac82e9" + integrity sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw== + object-inspect@^1.13.1: version "1.13.2" resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.2.tgz#dea0088467fb991e67af4058147a24824a3043ff" @@ -5128,6 +5133,11 @@ please-upgrade-node@^3.2.0: dependencies: semver-compare "^1.0.0" +plotly.js-dist@^2.34.0: + version "2.35.2" + resolved "https://registry.yarnpkg.com/plotly.js-dist/-/plotly.js-dist-2.35.2.tgz#2bda4b53e6cfe264daac25e2e6adaf1aa69d4aa6" + integrity sha512-zbKfz7jXGcLGoyPJxjGrKLttPiqvsEjIMHON/dEU/mnOJ+/yYoEctEEQ3qp5zQmvoovw1L47kCsQpq/GTbejBA== + posix-character-classes@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"