Skip to content

Commit

Permalink
adding config, precommit and lint error fixes
Browse files Browse the repository at this point in the history
Signed-off-by: kohinoor98 <[email protected]>
  • Loading branch information
kohinoor98 committed Nov 13, 2023
1 parent 569911e commit a35a39a
Show file tree
Hide file tree
Showing 23 changed files with 63 additions and 33 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/links.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
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
with:
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 }}
1 change: 1 addition & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"*.{ts,tsx}": [
"npx eslint --fix",
"prettier --write"
],
"*.{js,jsx,json,css,md}": [
Expand Down
9 changes: 0 additions & 9 deletions .new.lintstagedrc

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions public/components/MappingLabel/MappingLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ describe("<AliasesActions /> spec", () => {
browserServicesMock.commonService.apiCaller = jest.fn(
async (payload): Promise<any> => {
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 {
Expand Down Expand Up @@ -628,6 +629,7 @@ describe("<AliasesActions /> spec", () => {
browserServicesMock.commonService.apiCaller = jest.fn(
async (payload): Promise<any> => {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ describe("<AssociatedTemplatesModal /> spec", () => {
<AssociatedTemplatesModal
componentTemplate="test_component_template"
renderProps={({ setVisible }) => (
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
<div data-test-subj="test" onClick={() => setVisible(true)}>
123
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,21 @@ const TemplateDetail = (props: TemplateDetailProps, ref: Ref<IComponentTemplateD
};
}
};
const onClickSubmit = useCallback(async () => {
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,
}));
Expand All @@ -126,14 +130,18 @@ const TemplateDetail = (props: TemplateDetailProps, ref: Ref<IComponentTemplateD
props.history.replace(ROUTES.COMPOSABLE_TEMPLATES);
});
};
useEffect(() => {
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ describe("<DataStreamsActions /> spec", () => {
browserServicesMock.commonService.apiCaller = jest.fn(
async (payload): Promise<any> => {
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 {
Expand Down Expand Up @@ -751,6 +752,7 @@ describe("<DataStreamsActions /> spec", () => {
browserServicesMock.commonService.apiCaller = jest.fn(
async (payload): Promise<any> => {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,7 @@ describe("<IndicesActions /> spec", () => {
browserServicesMock.commonService.apiCaller = jest.fn(
async (payload): Promise<any> => {
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 {
Expand Down Expand Up @@ -1329,6 +1330,7 @@ describe("<IndicesActions /> spec", () => {
browserServicesMock.commonService.apiCaller = jest.fn(
async (payload): Promise<any> => {
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 {
Expand Down
1 change: 1 addition & 0 deletions public/pages/Indices/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <IndicesQueryParams>{
// @ts-ignore
from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10),
Expand Down
1 change: 1 addition & 0 deletions public/pages/ManagedIndices/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ManagedIndicesQueryParams>{
// @ts-ignore
from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10),
Expand Down
1 change: 1 addition & 0 deletions public/pages/Policies/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <PoliciesQueryParams>{
// @ts-ignore
from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ export default class Repositories extends Component<RepositoriesProps, Repositor
columns={this.columns}
pagination={true}
isSelectable={true}
// eslint-disable-next-line no-shadow
selection={{ onSelectionChange: (selectedItems) => this.setState({ selectedItems }) }}
search={search}
loading={loading}
Expand Down
1 change: 1 addition & 0 deletions public/pages/Rollups/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <RollupQueryParams>{
// @ts-ignores
from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ interface ShrinkIndexProps extends RouteComponentProps {
interface ShrinkIndexState {
sourceIndex: CatIndex;
requestPayload: Required<IndexItem>["settings"];
// eslint-disable-next-line @typescript-eslint/ban-types
sourceIndexSettings: Object;
loading: boolean;
}
Expand Down
1 change: 1 addition & 0 deletions public/pages/SnapshotPolicies/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <SMPoliciesQueryParams>{
// @ts-ignore
from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

/* eslint-disable jsx-a11y/click-events-have-key-events */

import {
EuiComboBoxOptionOption,
EuiHealth,
Expand Down Expand Up @@ -379,7 +381,7 @@ export default class RestoreSnapshotFlyout extends Component<RestoreSnapshotProp

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

return (
<EuiFlyout ownFocus={false} maxWidth={600} onClose={onCloseFlyout} size="m" hideCloseButton>
Expand Down
1 change: 1 addition & 0 deletions public/pages/Transforms/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <TransformQueryParams>{
// @ts-ignores
from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions public/utils/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 2 additions & 0 deletions server/services/ManagedIndexService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

/* eslint-disable prefer-const */

import _ from "lodash";
import { RequestParams } from "@elastic/elasticsearch";
import {
Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"compilerOptions": {
"skipLibCheck": true,
"esModuleInterop": true,
"outDir": "./target",
"strictNullChecks": true
"outDir": "./target"
}
}

0 comments on commit a35a39a

Please sign in to comment.