Skip to content

Commit

Permalink
fix eslint config and related linting issues (#20)
Browse files Browse the repository at this point in the history
Signed-off-by: Chenyang Ji <cyji@amazon.com>
  • Loading branch information
ansjcy authored Sep 11, 2024
1 parent 1076e81 commit 4e7549d
Show file tree
Hide file tree
Showing 20 changed files with 153 additions and 10 deletions.
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 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
5 changes: 5 additions & 0 deletions public/pages/QueryDetails/Components/QuerySummary.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 { EuiFlexGrid, EuiFlexItem, EuiHorizontalRule, EuiPanel, EuiText } from '@elastic/eui';

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 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 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

0 comments on commit 4e7549d

Please sign in to comment.