Skip to content

Commit 6a3eeb9

Browse files
committed
typescript config and clean up
Signed-off-by: kohinoor98 <[email protected]>
1 parent 1c8f0c6 commit 6a3eeb9

File tree

821 files changed

+14952
-2249
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

821 files changed

+14952
-2249
lines changed

.eslintrc.js

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
/*
2-
* Copyright OpenSearch Contributors
3-
* SPDX-License-Identifier: Apache-2.0
4-
*/
5-
61
const LICENSE_HEADER = `
72
/*
8-
* Copyright OpenSearch Contributors
9-
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright OpenSearch Contributors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License").
6+
* You may not use this file except in compliance with the License.
7+
* A copy of the License is located at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* or in the "license" file accompanying this file. This file is distributed
12+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13+
* express or implied. See the License for the specific language governing
14+
* permissions and limitations under the License.
1015
*/
1116
`;
1217

@@ -15,6 +20,28 @@ module.exports = {
1520
extends: ["@elastic/eslint-config-kibana", "plugin:@elastic/eui/recommended"],
1621
rules: {
1722
// "@osd/eslint/require-license-header": "off"
23+
"import/no-default-export": "off",
24+
"@typescript-eslint/naming-convention": [
25+
"error",
26+
{
27+
selector: "default",
28+
format: ["camelCase", "UPPER_CASE", "PascalCase", "snake_case"],
29+
leadingUnderscore: "allow",
30+
trailingUnderscore: "allow",
31+
},
32+
],
33+
"@osd/eslint/no-restricted-paths": [
34+
"error",
35+
{
36+
basePath: __dirname,
37+
zones: [
38+
{
39+
target: ["(public|server)/**/*"],
40+
from: ["../../packages/**/*", "packages/**/*"],
41+
},
42+
],
43+
},
44+
],
1845
},
1946
overrides: [
2047
{

.lintstagedrc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"*.{ts,tsx,js,jsx,json,css,md}": ["prettier --write", "git add"]
2+
"*.{ts,tsx}": [
3+
"npx eslint --fix",
4+
"prettier --write"
5+
],
6+
"*.{js,jsx,json,css,md}": [
7+
"prettier --write"
8+
]
39
}

cypress/support/index.d.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
116
/*
217
* Copyright OpenSearch Contributors
318
* SPDX-License-Identifier: Apache-2.0
419
*/
520

6-
/// <reference types="cypress" />
21+
// / <reference types="cypress" />
722

823
declare namespace Cypress {
924
interface Chainable<Subject> {

models/interfaces.ts

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
116
/*
217
* Copyright OpenSearch Contributors
318
* SPDX-License-Identifier: Apache-2.0
@@ -41,13 +56,13 @@ export type DiffableMappingsPropertiesObject = Record<
4156
}
4257
>;
4358

44-
export type MappingsProperties = {
59+
export type MappingsProperties = Array<{
4560
fieldName: string;
4661
type: string;
4762
path?: string;
4863
analyzer?: string;
4964
properties?: MappingsProperties;
50-
}[];
65+
}>;
5166

5267
export interface IndexItem {
5368
index: string;
@@ -525,14 +540,14 @@ export interface Transform {
525540
enabled_at: number | null;
526541
updated_at: number;
527542
metadata_id: string | null;
528-
aggregations: Map<String, any>;
543+
aggregations: Map<string, any>;
529544
page_size: number;
530545
schedule: IntervalSchedule | CronSchedule;
531546
schema_version: number;
532547
source_index: string;
533548
target_index: string;
534-
roles: String[];
535-
data_selection_query: Map<String, any>;
549+
roles: string[];
550+
data_selection_query: Map<string, any>;
536551
}
537552

538553
export interface TransformMetadata {
@@ -571,15 +586,15 @@ export interface CronSchedule {
571586
};
572587
}
573588

574-
//Frontend dimension data model
589+
// Frontend dimension data model
575590
export interface DimensionItem {
576591
sequence: number;
577592
field: FieldItem;
578593
aggregationMethod: string;
579594
interval?: number;
580595
}
581596

582-
//Frontend metric data model
597+
// Frontend metric data model
583598
export interface MetricItem {
584599
source_field: FieldItem;
585600
all: boolean;
@@ -620,18 +635,23 @@ interface HistogramItem {
620635
};
621636
}
622637

623-
//Backend dimension data model
638+
// Backend dimension data model
624639
export type RollupDimensionItem = DateHistogramItem | TermsItem | HistogramItem;
625640

626-
//Backend metric data model
641+
// Backend metric data model
627642
export interface RollupMetricItem {
628643
source_field: string;
629644
metrics: [
630645
{
646+
// eslint-disable-next-line @typescript-eslint/ban-types
631647
min?: Object;
648+
// eslint-disable-next-line @typescript-eslint/ban-types
632649
max?: Object;
650+
// eslint-disable-next-line @typescript-eslint/ban-types
633651
sum?: Object;
652+
// eslint-disable-next-line @typescript-eslint/ban-types
634653
avg?: Object;
654+
// eslint-disable-next-line @typescript-eslint/ban-types
635655
value_count?: Object;
636656
}
637657
];

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"osd": "node ../../scripts/osd",
1919
"opensearch": "node ../../scripts/opensearch",
2020
"lint": "node ../../scripts/eslint . && node ../../scripts/stylelint",
21+
"eslint:fix": "npx eslint '**/*.{ts,tsx}' --fix",
2122
"plugin-helpers": "node ../../scripts/plugin_helpers",
2223
"test:jest": "../../node_modules/.bin/jest --config ./test/jest.config.js",
2324
"build": "yarn plugin-helpers build",
@@ -73,4 +74,4 @@
7374
"engines": {
7475
"yarn": "^1.21.1"
7576
}
76-
}
77+
}

public/JobHandler/callbacks/force_merge.test.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
116
/*
217
* Copyright OpenSearch Contributors
318
* SPDX-License-Identifier: Apache-2.0
419
*/
520

21+
import { CoreSetup } from "opensearch-dashboards/public";
622
import { callbackForForceMerge, callbackForForceMergeTimeout } from "./force_merge";
723
import { coreServicesMock, httpClientMock } from "../../../test/mocks";
824
import { ListenType } from "../../lib/JobScheduler";
9-
import { CoreSetup } from "opensearch-dashboards/public";
1025

1126
const getMockFn = (response = {}, ok = true) => {
1227
return jest.fn().mockResolvedValue({
@@ -33,7 +48,7 @@ const core = ({
3348
describe("callbackForForceMerge spec", () => {
3449
it("callback when error", async () => {
3550
httpClientMock.fetch = getMockFn({}, false);
36-
let result = await callbackForForceMerge(forceMergeMetaData, {
51+
const result = await callbackForForceMerge(forceMergeMetaData, {
3752
core,
3853
});
3954
expect(result).toBe(false);

public/JobHandler/callbacks/force_merge.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
116
/*
217
* Copyright OpenSearch Contributors
318
* SPDX-License-Identifier: Apache-2.0
@@ -15,11 +30,11 @@ type ForceMergeTaskResult = TaskResult<{
1530
successful: number;
1631
total: number;
1732
failed: number;
18-
failures?: {
33+
failures?: Array<{
1934
index: string;
2035
status: string;
2136
shard: number;
22-
}[];
37+
}>;
2338
};
2439
}>;
2540

public/JobHandler/callbacks/open.test.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
116
/*
217
* Copyright OpenSearch Contributors
318
* SPDX-License-Identifier: Apache-2.0
419
*/
20+
import { CoreSetup } from "opensearch-dashboards/public";
521
import { callbackForOpen, callbackForOpenTimeout } from "./open";
622
import { coreServicesMock, httpClientMock } from "../../../test/mocks";
723
import { ListenType } from "../../lib/JobScheduler";
8-
import { CoreSetup } from "opensearch-dashboards/public";
924

1025
const getMockFn = (response = {}, ok = true) => {
1126
return jest.fn().mockResolvedValue({
@@ -32,7 +47,7 @@ const core = ({
3247
describe("callbackForOpen spec", () => {
3348
it("callback when error", async () => {
3449
httpClientMock.fetch = getMockFn({}, false);
35-
let result = await callbackForOpen(openMetaData, {
50+
const result = await callbackForOpen(openMetaData, {
3651
core,
3752
});
3853
expect(result).toBe(false);

public/JobHandler/callbacks/open.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
/*
2-
* Copyright OpenSearch Contributors
3-
* SPDX-License-Identifier: Apache-2.0
2+
* Copyright OpenSearch Contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
414
*/
15+
516
import React from "react";
617
import { CallbackType, TaskResult } from "../interface";
718
import { OpenJobMetaData } from "../../models/interfaces";

public/JobHandler/callbacks/reindex.test.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
116
/*
217
* Copyright OpenSearch Contributors
318
* SPDX-License-Identifier: Apache-2.0
419
*/
20+
import { CoreSetup } from "opensearch-dashboards/public";
521
import { callbackForReindex, callbackForReindexTimeout } from "./reindex";
622
import { coreServicesMock, httpClientMock } from "../../../test/mocks";
723
import { ListenType } from "../../lib/JobScheduler";
8-
import { CoreSetup } from "opensearch-dashboards/public";
924

1025
const getMockFn = (response = {}, ok = true) => {
1126
return jest.fn().mockResolvedValue({
@@ -35,7 +50,7 @@ const core = ({
3550
describe("callbackForOpen spec", () => {
3651
it("callback when error", async () => {
3752
httpClientMock.fetch = getMockFn({}, false);
38-
let result = await callbackForReindex(reindexMetaData, {
53+
const result = await callbackForReindex(reindexMetaData, {
3954
core,
4055
});
4156
expect(result).toBe(false);

0 commit comments

Comments
 (0)