diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml
index 423dca420..5e99abb1f 100644
--- a/.github/workflows/links.yml
+++ b/.github/workflows/links.yml
@@ -1,15 +1,19 @@
-name: Link Checker
+name: Link Checker and ESLint Run
on:
push:
- branches: [ main ]
+ branches: [main]
pull_request:
- branches: [ main ]
+ branches: [main]
jobs:
linkchecker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
+
+ - name: Run ESLint Run
+ run: yarn eslint:run
+
- name: lychee Link Checker
id: lychee
uses: lycheeverse/lychee-action@master
@@ -17,5 +21,6 @@ jobs:
args: --accept=200,403,429 --exclude=localhost "**/*.html" "**/*.md" "**/*.txt" "**/*.json"
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
+
- name: Fail if there were link errors
run: exit ${{ steps.lychee.outputs.exit_code }}
diff --git a/.lintstagedrc b/.lintstagedrc
index 941def6d0..e155bc449 100644
--- a/.lintstagedrc
+++ b/.lintstagedrc
@@ -1,5 +1,6 @@
{
"*.{ts,tsx}": [
+ "npx eslint --fix",
"prettier --write"
],
"*.{js,jsx,json,css,md}": [
diff --git a/.new.lintstagedrc b/.new.lintstagedrc
deleted file mode 100644
index e155bc449..000000000
--- a/.new.lintstagedrc
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "*.{ts,tsx}": [
- "npx eslint --fix",
- "prettier --write"
- ],
- "*.{js,jsx,json,css,md}": [
- "prettier --write"
- ]
-}
diff --git a/package.json b/package.json
index b2018485c..3832dff8d 100644
--- a/package.json
+++ b/package.json
@@ -19,6 +19,7 @@
"opensearch": "node ../../scripts/opensearch",
"lint": "node ../../scripts/eslint . && node ../../scripts/stylelint",
"eslint:fix": "npx eslint '**/*.{ts,tsx}' --fix",
+ "eslint:run": "npx eslint '**/*.{ts,tsx}'",
"plugin-helpers": "node ../../scripts/plugin_helpers",
"test:jest": "../../node_modules/.bin/jest --config ./test/jest.config.js",
"build": "yarn plugin-helpers build",
diff --git a/public/components/MappingLabel/MappingLabel.tsx b/public/components/MappingLabel/MappingLabel.tsx
index a0f7ab8ce..fb72f8fb4 100644
--- a/public/components/MappingLabel/MappingLabel.tsx
+++ b/public/components/MappingLabel/MappingLabel.tsx
@@ -17,6 +17,9 @@
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
+
+/* eslint-disable jsx-a11y/click-events-have-key-events */
+
import React, { forwardRef, useCallback, useRef, useImperativeHandle } from "react";
import {
EuiIcon,
diff --git a/public/pages/Aliases/containers/AliasActions/AliasActions.test.tsx b/public/pages/Aliases/containers/AliasActions/AliasActions.test.tsx
index ee69358fa..b7ac6c4e5 100644
--- a/public/pages/Aliases/containers/AliasActions/AliasActions.test.tsx
+++ b/public/pages/Aliases/containers/AliasActions/AliasActions.test.tsx
@@ -584,6 +584,7 @@ describe(" spec", () => {
browserServicesMock.commonService.apiCaller = jest.fn(
async (payload): Promise => {
if (payload.endpoint === "cluster.state") {
+ // eslint-disable-next-line no-throw-literal
throw "failed to call cluster.state";
} else if (payload.endpoint === "indices.refresh") {
return {
@@ -628,6 +629,7 @@ describe(" spec", () => {
browserServicesMock.commonService.apiCaller = jest.fn(
async (payload): Promise => {
if (payload.endpoint === "cluster.state") {
+ // eslint-disable-next-line no-throw-literal
throw "failed to call cluster.state";
} else if (payload.endpoint === "indices.refresh") {
return {
diff --git a/public/pages/ComposableTemplates/containers/AssociatedTemplatesModal/AssociatedTemplatesModal.test.tsx b/public/pages/ComposableTemplates/containers/AssociatedTemplatesModal/AssociatedTemplatesModal.test.tsx
index b8f90fbe2..360d681e0 100644
--- a/public/pages/ComposableTemplates/containers/AssociatedTemplatesModal/AssociatedTemplatesModal.test.tsx
+++ b/public/pages/ComposableTemplates/containers/AssociatedTemplatesModal/AssociatedTemplatesModal.test.tsx
@@ -71,6 +71,7 @@ describe(" spec", () => {
(
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events
setVisible(true)}>
123
diff --git a/public/pages/CreateComposableTemplate/containers/TemplateDetail/TemplateDetail.tsx b/public/pages/CreateComposableTemplate/containers/TemplateDetail/TemplateDetail.tsx
index 40012e601..7093136e4 100644
--- a/public/pages/CreateComposableTemplate/containers/TemplateDetail/TemplateDetail.tsx
+++ b/public/pages/CreateComposableTemplate/containers/TemplateDetail/TemplateDetail.tsx
@@ -98,17 +98,21 @@ const TemplateDetail = (props: TemplateDetailProps, ref: Ref {
- const result = await onSubmit();
- if (result) {
- if (result.ok) {
- coreServices.notifications.toasts.addSuccess(`${values.name} has been successfully created.`);
- onSubmitSuccess && onSubmitSuccess(values.name);
- } else {
- coreServices.notifications.toasts.addDanger(result.error);
+ const onClickSubmit = useCallback(
+ async () => {
+ const result = await onSubmit();
+ if (result) {
+ if (result.ok) {
+ coreServices.notifications.toasts.addSuccess(`${values.name} has been successfully created.`);
+ if (onSubmitSuccess) onSubmitSuccess(values.name);
+ } else {
+ coreServices.notifications.toasts.addDanger(result.error);
+ }
}
- }
- }, [onSubmit]);
+ },
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [onSubmit]
+ );
useImperativeHandle(ref, () => ({
submit: onClickSubmit,
}));
@@ -126,14 +130,18 @@ const TemplateDetail = (props: TemplateDetailProps, ref: Ref {
- if (isEdit) {
- refreshTemplate();
- }
- return () => {
- destroyRef.current = true;
- };
- }, []);
+ useEffect(
+ () => {
+ if (isEdit) {
+ refreshTemplate();
+ }
+ return () => {
+ destroyRef.current = true;
+ };
+ },
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ []
+ );
const values: ComponentTemplateEdit = field.getValues();
const subCompontentProps = {
...props,
diff --git a/public/pages/DataStreams/containers/DataStreamsActions/DataStreamsActions.test.tsx b/public/pages/DataStreams/containers/DataStreamsActions/DataStreamsActions.test.tsx
index 80370ce62..ae9e4d4e5 100644
--- a/public/pages/DataStreams/containers/DataStreamsActions/DataStreamsActions.test.tsx
+++ b/public/pages/DataStreams/containers/DataStreamsActions/DataStreamsActions.test.tsx
@@ -703,6 +703,7 @@ describe(" spec", () => {
browserServicesMock.commonService.apiCaller = jest.fn(
async (payload): Promise => {
if (payload.endpoint === "cluster.state") {
+ // eslint-disable-next-line no-throw-literal
throw "failed to call cluster.state";
} else if (payload.endpoint === "indices.refresh") {
return {
@@ -751,6 +752,7 @@ describe(" spec", () => {
browserServicesMock.commonService.apiCaller = jest.fn(
async (payload): Promise => {
if (payload.endpoint === "cluster.state") {
+ // eslint-disable-next-line no-throw-literal
throw "failed to call cluster.state";
} else if (payload.endpoint === "indices.refresh") {
return {
diff --git a/public/pages/Indices/containers/IndicesActions/IndicesActions.test.tsx b/public/pages/Indices/containers/IndicesActions/IndicesActions.test.tsx
index 3a24edf2b..38a5f767a 100644
--- a/public/pages/Indices/containers/IndicesActions/IndicesActions.test.tsx
+++ b/public/pages/Indices/containers/IndicesActions/IndicesActions.test.tsx
@@ -1285,6 +1285,7 @@ describe(" spec", () => {
browserServicesMock.commonService.apiCaller = jest.fn(
async (payload): Promise => {
if (payload.endpoint === "cluster.state") {
+ // eslint-disable-next-line no-throw-literal
throw "failed to call cluster.state";
} else if (payload.endpoint === "indices.refresh") {
return {
@@ -1329,6 +1330,7 @@ describe(" spec", () => {
browserServicesMock.commonService.apiCaller = jest.fn(
async (payload): Promise => {
if (payload.endpoint === "cluster.state") {
+ // eslint-disable-next-line no-throw-literal
throw "failed to call cluster.state";
} else if (payload.endpoint === "indices.refresh") {
return {
diff --git a/public/pages/Indices/utils/helpers.ts b/public/pages/Indices/utils/helpers.ts
index 6d2a6806a..05fb23131 100644
--- a/public/pages/Indices/utils/helpers.ts
+++ b/public/pages/Indices/utils/helpers.ts
@@ -33,6 +33,7 @@ import { getClusterInfo } from "../../../utils/helpers";
export function getURLQueryParams(location: { search: string }): IndicesQueryParams {
const { from, size, search, sortField, sortDirection, showDataStreams } = queryString.parse(location.search);
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
return {
// @ts-ignore
from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10),
diff --git a/public/pages/ManagedIndices/utils/helpers.ts b/public/pages/ManagedIndices/utils/helpers.ts
index 69310755f..57ac73fcd 100644
--- a/public/pages/ManagedIndices/utils/helpers.ts
+++ b/public/pages/ManagedIndices/utils/helpers.ts
@@ -25,6 +25,7 @@ import { ManagedIndicesQueryParams } from "../models/interfaces";
export function getURLQueryParams(location: { search: string }): ManagedIndicesQueryParams {
const { from, size, search, sortField, sortDirection, showDataStreams } = queryString.parse(location.search);
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
return {
// @ts-ignore
from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10),
diff --git a/public/pages/Policies/utils/helpers.ts b/public/pages/Policies/utils/helpers.ts
index 19ab7fbb3..0ba678857 100644
--- a/public/pages/Policies/utils/helpers.ts
+++ b/public/pages/Policies/utils/helpers.ts
@@ -27,6 +27,7 @@ import { PoliciesQueryParams } from "../models/interfaces";
export function getURLQueryParams(location: { search: string }): PoliciesQueryParams {
const { from, size, search, sortField, sortDirection } = queryString.parse(location.search);
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
return {
// @ts-ignore
from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10),
diff --git a/public/pages/Repositories/containers/Repositories/Repositories.tsx b/public/pages/Repositories/containers/Repositories/Repositories.tsx
index 0a45c20be..a0eee94b9 100644
--- a/public/pages/Repositories/containers/Repositories/Repositories.tsx
+++ b/public/pages/Repositories/containers/Repositories/Repositories.tsx
@@ -280,6 +280,7 @@ export default class Repositories extends Component this.setState({ selectedItems }) }}
search={search}
loading={loading}
diff --git a/public/pages/Rollups/utils/helpers.ts b/public/pages/Rollups/utils/helpers.ts
index 492c937c5..0d1eaeb8a 100644
--- a/public/pages/Rollups/utils/helpers.ts
+++ b/public/pages/Rollups/utils/helpers.ts
@@ -27,6 +27,7 @@ import { RollupQueryParams } from "../models/interfaces";
export function getURLQueryParams(location: { search: string }): RollupQueryParams {
const { from, size, search, sortField, sortDirection } = queryString.parse(location.search);
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
return {
// @ts-ignores
from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10),
diff --git a/public/pages/ShrinkIndex/container/ShrinkIndex/ShrinkIndex.tsx b/public/pages/ShrinkIndex/container/ShrinkIndex/ShrinkIndex.tsx
index 1b87f4756..5635c00be 100644
--- a/public/pages/ShrinkIndex/container/ShrinkIndex/ShrinkIndex.tsx
+++ b/public/pages/ShrinkIndex/container/ShrinkIndex/ShrinkIndex.tsx
@@ -77,6 +77,7 @@ interface ShrinkIndexProps extends RouteComponentProps {
interface ShrinkIndexState {
sourceIndex: CatIndex;
requestPayload: Required["settings"];
+ // eslint-disable-next-line @typescript-eslint/ban-types
sourceIndexSettings: Object;
loading: boolean;
}
diff --git a/public/pages/SnapshotPolicies/helpers.ts b/public/pages/SnapshotPolicies/helpers.ts
index 179770b19..7dc757836 100644
--- a/public/pages/SnapshotPolicies/helpers.ts
+++ b/public/pages/SnapshotPolicies/helpers.ts
@@ -25,6 +25,7 @@ import { DEFAULT_QUERY_PARAMS, PROMPT_TEXT } from "./constants";
export function getSMPoliciesQueryParamsFromURL(location: { search: string }): SMPoliciesQueryParams {
const { from, size, sortField, sortOrder, search } = queryString.parse(location.search);
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
return {
// @ts-ignore
from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10),
diff --git a/public/pages/Snapshots/components/RestoreSnapshotFlyout/RestoreSnapshotFlyout.tsx b/public/pages/Snapshots/components/RestoreSnapshotFlyout/RestoreSnapshotFlyout.tsx
index 48ae20b49..c07549d6a 100644
--- a/public/pages/Snapshots/components/RestoreSnapshotFlyout/RestoreSnapshotFlyout.tsx
+++ b/public/pages/Snapshots/components/RestoreSnapshotFlyout/RestoreSnapshotFlyout.tsx
@@ -18,6 +18,8 @@
* SPDX-License-Identifier: Apache-2.0
*/
+/* eslint-disable jsx-a11y/click-events-have-key-events */
+
import {
EuiComboBoxOptionOption,
EuiHealth,
@@ -379,7 +381,7 @@ export default class RestoreSnapshotFlyout extends Component ({ index }));
+ const snapshotIndices: IndexItem[] = snapshot?.indices.map((index) => ({ index })) || [];
return (
diff --git a/public/pages/Transforms/utils/helpers.ts b/public/pages/Transforms/utils/helpers.ts
index e13a96366..90f1d8e39 100644
--- a/public/pages/Transforms/utils/helpers.ts
+++ b/public/pages/Transforms/utils/helpers.ts
@@ -26,6 +26,7 @@ import { DEFAULT_QUERY_PARAMS } from "./constants";
export function getURLQueryParams(location: { search: string }): TransformQueryParams {
const { from, size, search, sortField, sortDirection } = queryString.parse(location.search);
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
return {
// @ts-ignores
from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10),
diff --git a/public/pages/VisualCreatePolicy/components/UIActions/NotificationUIAction.tsx b/public/pages/VisualCreatePolicy/components/UIActions/NotificationUIAction.tsx
index 80cc0856b..65bc8ec53 100644
--- a/public/pages/VisualCreatePolicy/components/UIActions/NotificationUIAction.tsx
+++ b/public/pages/VisualCreatePolicy/components/UIActions/NotificationUIAction.tsx
@@ -18,6 +18,8 @@
* SPDX-License-Identifier: Apache-2.0
*/
+/* eslint-disable max-classes-per-file */
+
import React, { ChangeEvent } from "react";
import { UIAction, NotificationAction } from "../../../../../models/interfaces";
import { NotificationService, ServicesConsumer } from "../../../../services";
diff --git a/public/utils/helpers.test.ts b/public/utils/helpers.test.ts
index 3cb13480f..347cd7ffd 100644
--- a/public/utils/helpers.test.ts
+++ b/public/utils/helpers.test.ts
@@ -124,6 +124,7 @@ describe("helpers spec", () => {
});
try {
await getBlockedIndices(browserServicesMock);
+ // eslint-disable-next-line no-throw-literal
throw "fail";
} catch (err) {
expect(err).toEqual("test");
diff --git a/server/services/ManagedIndexService.ts b/server/services/ManagedIndexService.ts
index dbc3e1b2e..90a101026 100644
--- a/server/services/ManagedIndexService.ts
+++ b/server/services/ManagedIndexService.ts
@@ -18,6 +18,8 @@
* SPDX-License-Identifier: Apache-2.0
*/
+/* eslint-disable prefer-const */
+
import _ from "lodash";
import { RequestParams } from "@elastic/elasticsearch";
import {
diff --git a/tsconfig.json b/tsconfig.json
index a3674d086..4f79bdc75 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -8,7 +8,6 @@
"compilerOptions": {
"skipLibCheck": true,
"esModuleInterop": true,
- "outDir": "./target",
- "strictNullChecks": true
+ "outDir": "./target"
}
}