Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix eslint config and related linting issues #20

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
/data
/build
/target
/.eslintrc.js
/cypress.config.js
!.cypress/
55 changes: 53 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -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"]
};
5 changes: 5 additions & 0 deletions common/index.ts
Original file line number Diff line number Diff line change
@@ -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';
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,9 @@
"lint-staged": "^10.2.0",
"ts-loader": "^6.2.1",
"string.prototype.replaceall": "1.0.7"
}
},
"eslintIgnore": [
"node_modules/*",
"target/*"
]
}
5 changes: 5 additions & 0 deletions public/application.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
1 change: 0 additions & 1 deletion public/components/app.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
* @jest-environment jsdom
*/

import React from 'react';
Expand All @@ -24,13 +23,13 @@
<QueryInsightsDashboardsApp
basename="/"
core={coreStart}
http={mockHttpStart as any}

Check warning on line 26 in public/components/app.test.tsx

View workflow job for this annotation

GitHub Actions / Run lint

Unexpected any. Specify a different type
navigation={
{
ui: { TopNavMenu: () => null },
} as any

Check warning on line 30 in public/components/app.test.tsx

View workflow job for this annotation

GitHub Actions / Run lint

Unexpected any. Specify a different type
}
notifications={{} as any}

Check warning on line 32 in public/components/app.test.tsx

View workflow job for this annotation

GitHub Actions / Run lint

Unexpected any. Specify a different type
/>
</Router>
);
Expand Down
5 changes: 5 additions & 0 deletions public/components/app.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
5 changes: 5 additions & 0 deletions public/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import './index.scss';

import { QueryInsightsDashboardsPlugin } from './plugin';
Expand Down
5 changes: 5 additions & 0 deletions public/pages/Configuration/Configuration.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React, { useMemo, useCallback, useState, useEffect } from 'react';
import {
EuiBottomBar,
Expand Down Expand Up @@ -31,7 +36,7 @@
latencySettings: MetricSettings;
cpuSettings: MetricSettings;
memorySettings: MetricSettings;
configInfo: any;

Check warning on line 39 in public/pages/Configuration/Configuration.tsx

View workflow job for this annotation

GitHub Actions / Run lint

Unexpected any. Specify a different type
core: CoreStart;
}) => {
const metricTypes = [
Expand Down Expand Up @@ -95,11 +100,11 @@
]);
}, [core.chrome, history, location]);

const onMetricChange = (e: any) => {

Check warning on line 103 in public/pages/Configuration/Configuration.tsx

View workflow job for this annotation

GitHub Actions / Run lint

Unexpected any. Specify a different type
setMetric(e.target.value);
};

const onEnabledChange = (e: any) => {

Check warning on line 107 in public/pages/Configuration/Configuration.tsx

View workflow job for this annotation

GitHub Actions / Run lint

Unexpected any. Specify a different type
setIsEnabled(e.target.checked);
};

Expand Down
5 changes: 5 additions & 0 deletions public/pages/QueryDetails/Components/QuerySummary.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { EuiFlexGrid, EuiFlexItem, EuiHorizontalRule, EuiPanel, EuiText } from '@elastic/eui';

const QuerySummary = ({ query }: { query: any }) => {

Check warning on line 9 in public/pages/QueryDetails/Components/QuerySummary.tsx

View workflow job for this annotation

GitHub Actions / Run lint

Unexpected any. Specify a different type
const convertTime = (unixTime: number) => {
const date = new Date(unixTime);
const loc = date.toDateString().split(' ');
Expand Down
5 changes: 5 additions & 0 deletions public/pages/QueryDetails/QueryDetails.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -18,9 +23,9 @@
import QuerySummary from './Components/QuerySummary';
import { QUERY_INSIGHTS } from '../TopNQueries/TopNQueries';

const QueryDetails = ({ queries, core }: { queries: any; core: CoreStart }) => {

Check warning on line 26 in public/pages/QueryDetails/QueryDetails.tsx

View workflow job for this annotation

GitHub Actions / Run lint

Unexpected any. Specify a different type
const { hashedQuery } = useParams<{ hashedQuery: string }>();
const query = queries.find((q: any) => hash(q) === hashedQuery);

Check warning on line 28 in public/pages/QueryDetails/QueryDetails.tsx

View workflow job for this annotation

GitHub Actions / Run lint

Unexpected any. Specify a different type

const convertTime = (unixTime: number) => {
const date = new Date(unixTime);
Expand Down
5 changes: 5 additions & 0 deletions public/pages/QueryInsights/QueryInsights.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -24,7 +29,7 @@
currEnd,
core,
}: {
queries: any[];

Check warning on line 32 in public/pages/QueryInsights/QueryInsights.tsx

View workflow job for this annotation

GitHub Actions / Run lint

Unexpected any. Specify a different type
loading: boolean;
onTimeChange: any;
recentlyUsedRanges: any[];
Expand Down
10 changes: 6 additions & 4 deletions public/pages/TopNQueries/TopNQueries.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand All @@ -215,7 +218,6 @@ const TopNQueries = ({ core }: { core: CoreStart }) => {
},
});
} catch (error) {
// eslint-disable-next-line no-console
console.error('Failed to set settings:', error);
}
}
Expand Down
7 changes: 6 additions & 1 deletion public/plugin.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -41,7 +46,7 @@ export class QueryInsightsDashboardsPlugin
};
}

public start(core: CoreStart): QueryInsightsDashboardsPluginStart {
public start(_core: CoreStart): QueryInsightsDashboardsPluginStart {
return {};
}

Expand Down
5 changes: 5 additions & 0 deletions public/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { NavigationPublicPluginStart } from '../../../src/plugins/navigation/public';

export interface QueryInsightsDashboardsPluginSetup {
Expand Down
5 changes: 5 additions & 0 deletions server/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { PluginInitializerContext } from '../../../src/core/server';
import { QueryInsightsDashboardsPlugin } from './plugin';

Expand Down
7 changes: 6 additions & 1 deletion server/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import {
PluginInitializerContext,
CoreSetup,
Expand Down Expand Up @@ -42,7 +47,7 @@ export class QueryInsightsDashboardsPlugin
return {};
}

public start(core: CoreStart) {
public start(_core: CoreStart) {
this.logger.debug('query-insights-dashboards: Started');
return {};
}
Expand Down
5 changes: 5 additions & 0 deletions server/routes/index.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions server/types.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
Loading