Skip to content

Commit a35a39a

Browse files
committed
adding config, precommit and lint error fixes
Signed-off-by: kohinoor98 <[email protected]>
1 parent 569911e commit a35a39a

File tree

23 files changed

+63
-33
lines changed

23 files changed

+63
-33
lines changed

.github/workflows/links.yml

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
name: Link Checker
1+
name: Link Checker and ESLint Run
22
on:
33
push:
4-
branches: [ main ]
4+
branches: [main]
55
pull_request:
6-
branches: [ main ]
6+
branches: [main]
77

88
jobs:
99
linkchecker:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v2
13+
14+
- name: Run ESLint Run
15+
run: yarn eslint:run
16+
1317
- name: lychee Link Checker
1418
id: lychee
1519
uses: lycheeverse/lychee-action@master
1620
with:
1721
args: --accept=200,403,429 --exclude=localhost "**/*.html" "**/*.md" "**/*.txt" "**/*.json"
1822
env:
1923
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
24+
2025
- name: Fail if there were link errors
2126
run: exit ${{ steps.lychee.outputs.exit_code }}

.lintstagedrc

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"*.{ts,tsx}": [
3+
"npx eslint --fix",
34
"prettier --write"
45
],
56
"*.{js,jsx,json,css,md}": [

.new.lintstagedrc

-9
This file was deleted.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"opensearch": "node ../../scripts/opensearch",
2020
"lint": "node ../../scripts/eslint . && node ../../scripts/stylelint",
2121
"eslint:fix": "npx eslint '**/*.{ts,tsx}' --fix",
22+
"eslint:run": "npx eslint '**/*.{ts,tsx}'",
2223
"plugin-helpers": "node ../../scripts/plugin_helpers",
2324
"test:jest": "../../node_modules/.bin/jest --config ./test/jest.config.js",
2425
"build": "yarn plugin-helpers build",

public/components/MappingLabel/MappingLabel.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
* Copyright OpenSearch Contributors
1818
* SPDX-License-Identifier: Apache-2.0
1919
*/
20+
21+
/* eslint-disable jsx-a11y/click-events-have-key-events */
22+
2023
import React, { forwardRef, useCallback, useRef, useImperativeHandle } from "react";
2124
import {
2225
EuiIcon,

public/pages/Aliases/containers/AliasActions/AliasActions.test.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ describe("<AliasesActions /> spec", () => {
584584
browserServicesMock.commonService.apiCaller = jest.fn(
585585
async (payload): Promise<any> => {
586586
if (payload.endpoint === "cluster.state") {
587+
// eslint-disable-next-line no-throw-literal
587588
throw "failed to call cluster.state";
588589
} else if (payload.endpoint === "indices.refresh") {
589590
return {
@@ -628,6 +629,7 @@ describe("<AliasesActions /> spec", () => {
628629
browserServicesMock.commonService.apiCaller = jest.fn(
629630
async (payload): Promise<any> => {
630631
if (payload.endpoint === "cluster.state") {
632+
// eslint-disable-next-line no-throw-literal
631633
throw "failed to call cluster.state";
632634
} else if (payload.endpoint === "indices.refresh") {
633635
return {

public/pages/ComposableTemplates/containers/AssociatedTemplatesModal/AssociatedTemplatesModal.test.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ describe("<AssociatedTemplatesModal /> spec", () => {
7171
<AssociatedTemplatesModal
7272
componentTemplate="test_component_template"
7373
renderProps={({ setVisible }) => (
74+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
7475
<div data-test-subj="test" onClick={() => setVisible(true)}>
7576
123
7677
</div>

public/pages/CreateComposableTemplate/containers/TemplateDetail/TemplateDetail.tsx

+26-18
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,21 @@ const TemplateDetail = (props: TemplateDetailProps, ref: Ref<IComponentTemplateD
9898
};
9999
}
100100
};
101-
const onClickSubmit = useCallback(async () => {
102-
const result = await onSubmit();
103-
if (result) {
104-
if (result.ok) {
105-
coreServices.notifications.toasts.addSuccess(`${values.name} has been successfully created.`);
106-
onSubmitSuccess && onSubmitSuccess(values.name);
107-
} else {
108-
coreServices.notifications.toasts.addDanger(result.error);
101+
const onClickSubmit = useCallback(
102+
async () => {
103+
const result = await onSubmit();
104+
if (result) {
105+
if (result.ok) {
106+
coreServices.notifications.toasts.addSuccess(`${values.name} has been successfully created.`);
107+
if (onSubmitSuccess) onSubmitSuccess(values.name);
108+
} else {
109+
coreServices.notifications.toasts.addDanger(result.error);
110+
}
109111
}
110-
}
111-
}, [onSubmit]);
112+
},
113+
// eslint-disable-next-line react-hooks/exhaustive-deps
114+
[onSubmit]
115+
);
112116
useImperativeHandle(ref, () => ({
113117
submit: onClickSubmit,
114118
}));
@@ -126,14 +130,18 @@ const TemplateDetail = (props: TemplateDetailProps, ref: Ref<IComponentTemplateD
126130
props.history.replace(ROUTES.COMPOSABLE_TEMPLATES);
127131
});
128132
};
129-
useEffect(() => {
130-
if (isEdit) {
131-
refreshTemplate();
132-
}
133-
return () => {
134-
destroyRef.current = true;
135-
};
136-
}, []);
133+
useEffect(
134+
() => {
135+
if (isEdit) {
136+
refreshTemplate();
137+
}
138+
return () => {
139+
destroyRef.current = true;
140+
};
141+
},
142+
// eslint-disable-next-line react-hooks/exhaustive-deps
143+
[]
144+
);
137145
const values: ComponentTemplateEdit = field.getValues();
138146
const subCompontentProps = {
139147
...props,

public/pages/DataStreams/containers/DataStreamsActions/DataStreamsActions.test.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,7 @@ describe("<DataStreamsActions /> spec", () => {
703703
browserServicesMock.commonService.apiCaller = jest.fn(
704704
async (payload): Promise<any> => {
705705
if (payload.endpoint === "cluster.state") {
706+
// eslint-disable-next-line no-throw-literal
706707
throw "failed to call cluster.state";
707708
} else if (payload.endpoint === "indices.refresh") {
708709
return {
@@ -751,6 +752,7 @@ describe("<DataStreamsActions /> spec", () => {
751752
browserServicesMock.commonService.apiCaller = jest.fn(
752753
async (payload): Promise<any> => {
753754
if (payload.endpoint === "cluster.state") {
755+
// eslint-disable-next-line no-throw-literal
754756
throw "failed to call cluster.state";
755757
} else if (payload.endpoint === "indices.refresh") {
756758
return {

public/pages/Indices/containers/IndicesActions/IndicesActions.test.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,7 @@ describe("<IndicesActions /> spec", () => {
12851285
browserServicesMock.commonService.apiCaller = jest.fn(
12861286
async (payload): Promise<any> => {
12871287
if (payload.endpoint === "cluster.state") {
1288+
// eslint-disable-next-line no-throw-literal
12881289
throw "failed to call cluster.state";
12891290
} else if (payload.endpoint === "indices.refresh") {
12901291
return {
@@ -1329,6 +1330,7 @@ describe("<IndicesActions /> spec", () => {
13291330
browserServicesMock.commonService.apiCaller = jest.fn(
13301331
async (payload): Promise<any> => {
13311332
if (payload.endpoint === "cluster.state") {
1333+
// eslint-disable-next-line no-throw-literal
13321334
throw "failed to call cluster.state";
13331335
} else if (payload.endpoint === "indices.refresh") {
13341336
return {

public/pages/Indices/utils/helpers.ts

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { getClusterInfo } from "../../../utils/helpers";
3333

3434
export function getURLQueryParams(location: { search: string }): IndicesQueryParams {
3535
const { from, size, search, sortField, sortDirection, showDataStreams } = queryString.parse(location.search);
36+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
3637
return <IndicesQueryParams>{
3738
// @ts-ignore
3839
from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10),

public/pages/ManagedIndices/utils/helpers.ts

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { ManagedIndicesQueryParams } from "../models/interfaces";
2525
export function getURLQueryParams(location: { search: string }): ManagedIndicesQueryParams {
2626
const { from, size, search, sortField, sortDirection, showDataStreams } = queryString.parse(location.search);
2727

28+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
2829
return <ManagedIndicesQueryParams>{
2930
// @ts-ignore
3031
from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10),

public/pages/Policies/utils/helpers.ts

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { PoliciesQueryParams } from "../models/interfaces";
2727
export function getURLQueryParams(location: { search: string }): PoliciesQueryParams {
2828
const { from, size, search, sortField, sortDirection } = queryString.parse(location.search);
2929

30+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
3031
return <PoliciesQueryParams>{
3132
// @ts-ignore
3233
from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10),

public/pages/Repositories/containers/Repositories/Repositories.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ export default class Repositories extends Component<RepositoriesProps, Repositor
280280
columns={this.columns}
281281
pagination={true}
282282
isSelectable={true}
283+
// eslint-disable-next-line no-shadow
283284
selection={{ onSelectionChange: (selectedItems) => this.setState({ selectedItems }) }}
284285
search={search}
285286
loading={loading}

public/pages/Rollups/utils/helpers.ts

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { RollupQueryParams } from "../models/interfaces";
2727
export function getURLQueryParams(location: { search: string }): RollupQueryParams {
2828
const { from, size, search, sortField, sortDirection } = queryString.parse(location.search);
2929

30+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
3031
return <RollupQueryParams>{
3132
// @ts-ignores
3233
from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10),

public/pages/ShrinkIndex/container/ShrinkIndex/ShrinkIndex.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ interface ShrinkIndexProps extends RouteComponentProps {
7777
interface ShrinkIndexState {
7878
sourceIndex: CatIndex;
7979
requestPayload: Required<IndexItem>["settings"];
80+
// eslint-disable-next-line @typescript-eslint/ban-types
8081
sourceIndexSettings: Object;
8182
loading: boolean;
8283
}

public/pages/SnapshotPolicies/helpers.ts

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { DEFAULT_QUERY_PARAMS, PROMPT_TEXT } from "./constants";
2525

2626
export function getSMPoliciesQueryParamsFromURL(location: { search: string }): SMPoliciesQueryParams {
2727
const { from, size, sortField, sortOrder, search } = queryString.parse(location.search);
28+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
2829
return <SMPoliciesQueryParams>{
2930
// @ts-ignore
3031
from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10),

public/pages/Snapshots/components/RestoreSnapshotFlyout/RestoreSnapshotFlyout.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* SPDX-License-Identifier: Apache-2.0
1919
*/
2020

21+
/* eslint-disable jsx-a11y/click-events-have-key-events */
22+
2123
import {
2224
EuiComboBoxOptionOption,
2325
EuiHealth,
@@ -379,7 +381,7 @@ export default class RestoreSnapshotFlyout extends Component<RestoreSnapshotProp
379381

380382
const status = snapshot ? snapshot?.state[0] + snapshot?.state.slice(1).toLowerCase() : undefined;
381383
const restoreDisabled = snapshot?.failed_shards && !snapshot?.partial;
382-
const snapshotIndices: IndexItem[] = snapshot?.indices.map((index) => ({ index }));
384+
const snapshotIndices: IndexItem[] = snapshot?.indices.map((index) => ({ index })) || [];
383385

384386
return (
385387
<EuiFlyout ownFocus={false} maxWidth={600} onClose={onCloseFlyout} size="m" hideCloseButton>

public/pages/Transforms/utils/helpers.ts

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { DEFAULT_QUERY_PARAMS } from "./constants";
2626
export function getURLQueryParams(location: { search: string }): TransformQueryParams {
2727
const { from, size, search, sortField, sortDirection } = queryString.parse(location.search);
2828

29+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
2930
return <TransformQueryParams>{
3031
// @ts-ignores
3132
from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10),

public/pages/VisualCreatePolicy/components/UIActions/NotificationUIAction.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* SPDX-License-Identifier: Apache-2.0
1919
*/
2020

21+
/* eslint-disable max-classes-per-file */
22+
2123
import React, { ChangeEvent } from "react";
2224
import { UIAction, NotificationAction } from "../../../../../models/interfaces";
2325
import { NotificationService, ServicesConsumer } from "../../../../services";

public/utils/helpers.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ describe("helpers spec", () => {
124124
});
125125
try {
126126
await getBlockedIndices(browserServicesMock);
127+
// eslint-disable-next-line no-throw-literal
127128
throw "fail";
128129
} catch (err) {
129130
expect(err).toEqual("test");

server/services/ManagedIndexService.ts

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* SPDX-License-Identifier: Apache-2.0
1919
*/
2020

21+
/* eslint-disable prefer-const */
22+
2123
import _ from "lodash";
2224
import { RequestParams } from "@elastic/elasticsearch";
2325
import {

tsconfig.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"compilerOptions": {
99
"skipLibCheck": true,
1010
"esModuleInterop": true,
11-
"outDir": "./target",
12-
"strictNullChecks": true
11+
"outDir": "./target"
1312
}
1413
}

0 commit comments

Comments
 (0)