Skip to content

Commit d254886

Browse files
committed
Merge branch 'snyk-fix-eb53f75091fd633edfffc343640116d7' into equinor#2561
2 parents 4250d4a + 579cfd1 commit d254886

18 files changed

+373
-286
lines changed

.eslintrc.json

-44
This file was deleted.

Src/WitsmlExplorer.Frontend/components/ContentViews/table/ContentTable.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { TableBody, TableHead } from "@mui/material";
22
import {
33
ColumnSizingState,
4+
flexRender,
5+
getCoreRowModel,
6+
getFilteredRowModel,
7+
getSortedRowModel,
48
Header,
59
Row,
610
RowData,
711
RowSelectionState,
812
SortDirection,
913
Table,
10-
flexRender,
11-
getCoreRowModel,
12-
getFilteredRowModel,
13-
getSortedRowModel,
1414
useReactTable
1515
} from "@tanstack/react-table";
1616
import { defaultRangeExtractor, useVirtualizer } from "@tanstack/react-virtual";

Src/WitsmlExplorer.Frontend/components/ContextMenus/UseClipboardComponentReferences.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const useClipboardComponentReferences: () => ComponentReferences | null =
1515
parseStringToComponentReferences(clipboardText);
1616
setReferences(componentReferences);
1717
} catch (e) {
18+
console.error(e);
1819
//Not a valid object on the clipboard? That is fine, we won't use it.
1920
}
2021
};
@@ -40,7 +41,7 @@ export function parseStringToComponentReferences(
4041
try {
4142
jsonObject = JSON.parse(input);
4243
} catch (error) {
43-
throw new Error("Invalid input given.");
44+
throw new Error("Invalid input given.", error);
4445
}
4546
verifyRequiredProperties(jsonObject);
4647
return jsonObject;

Src/WitsmlExplorer.Frontend/components/ContextMenus/UseClipboardReferences.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const useClipboardReferences = (
1313
const objectReferences = parseStringToReferences(clipboardText);
1414
setReferences(objectReferences);
1515
} catch (e) {
16+
console.error(e);
1617
//Not a valid object on the clipboard? That is fine, we won't use it.
1718
}
1819
};
@@ -46,7 +47,7 @@ export function parseStringToReferences(input: string): ObjectReferences {
4647
try {
4748
jsonObject = JSON.parse(input);
4849
} catch (error) {
49-
throw new Error("Invalid input given.");
50+
throw new Error("Invalid input given.", error);
5051
}
5152
verifyRequiredProperties(jsonObject);
5253
return jsonObject;

Src/WitsmlExplorer.Frontend/components/DateFormatter.ts

+2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ function formatDateString(
4040
const offset = getOffsetFromTimeZone(timeZone);
4141
return formatInTimeZone(parsed, offset, dateTimeFormat);
4242
} catch (e) {
43+
console.error(e);
4344
return "Invalid date";
4445
}
4546
}
47+
4648
export default formatDateString;
4749

4850
export function getOffsetFromTimeZone(timeZone: TimeZone): string {

Src/WitsmlExplorer.Frontend/components/Modals/MissingDataAgentModal.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ const MissingDataAgentModal = (
6868
: [];
6969
return checks.map((check) => ({ ...check, id: uuid() }));
7070
} catch (error) {
71+
console.error(error);
7172
return [];
7273
}
7374
};

Src/WitsmlExplorer.Frontend/components/Modals/ObjectPickerModal.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ const ObjectPickerModal = ({
109109
setFetchError(`The target ${objectType} was not found`);
110110
}
111111
} catch (e) {
112+
console.error(e);
112113
setFetchError("Failed to fetch");
113114
} finally {
114115
setIsLoading(false);

Src/WitsmlExplorer.Frontend/components/Modals/ReportModal.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import styled from "styled-components";
2727
import { Colors } from "styles/Colors";
2828
import ConfirmModal from "./ConfirmModal";
2929

30-
export interface ReportModal {
30+
export interface ReportModalI {
3131
report?: BaseReport;
3232
jobId?: string;
3333
}
@@ -44,7 +44,7 @@ export interface ReportModal {
4444
*
4545
* @returns {React.ReactElement} The rendered ReportModal component.
4646
*/
47-
export const ReportModal = (props: ReportModal): React.ReactElement => {
47+
export const ReportModal = (props: ReportModalI): React.ReactElement => {
4848
const { jobId, report: reportProp } = props;
4949
const {
5050
dispatchOperation,

Src/WitsmlExplorer.Frontend/components/RefreshHandler.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ const RefreshHandler = (): React.ReactElement => {
5555
}
5656
} catch (error) {
5757
console.error(
58-
`Unable to perform refresh action for action: ${refreshAction.refreshType} and entity: ${refreshAction.entityType}`
58+
`Unable to perform refresh action for action: ${refreshAction.refreshType} and entity: ${refreshAction.entityType}`,
59+
error
5960
);
6061
}
6162
}

Src/WitsmlExplorer.Frontend/components/Sidebar/SearchFilter.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { useConnectedServer } from "contexts/connectedServerContext";
1010
import {
1111
FilterContext,
1212
FilterType,
13+
FilterTypes,
1314
getFilterTypeInformation,
1415
isObjectFilterType,
1516
isWellboreFilterType
@@ -23,7 +24,7 @@ import styled, { CSSProp } from "styled-components";
2324
import { Colors } from "styles/Colors";
2425
import Icons from "styles/Icons";
2526

26-
const searchOptions = Object.values(FilterType);
27+
const searchOptions = Object.values(FilterTypes);
2728

2829
const SearchFilter = (): React.ReactElement => {
2930
const { dispatchOperation } = useOperationState();
@@ -219,9 +220,11 @@ const SearchIconLayout = styled.div`
219220

220221
const SearchBarContainer = styled.div`
221222
width: 85%;
223+
222224
.small-padding-left {
223225
padding-left: 4px;
224226
}
227+
225228
.small-padding-right {
226229
padding-right: 4px;
227230
}

Src/WitsmlExplorer.Frontend/contexts/filter.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export type FilterType =
113113
| WellboreFilterType
114114
| WellPropertyFilterType
115115
| ObjectFilterType;
116-
export const FilterType = {
116+
export const FilterTypes = {
117117
...WellFilterType,
118118
...WellboreFilterType,
119119
...WellPropertyFilterType,

Src/WitsmlExplorer.Frontend/contexts/queryContext.tsx

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import {
2+
getQueryTemplateWithPreset,
23
QueryTemplatePreset,
34
ReturnElements,
4-
StoreFunction,
5-
getQueryTemplateWithPreset
5+
StoreFunction
66
} from "components/ContentViews/QueryViewUtils";
77
import { useLocalStorageState } from "hooks/useLocalStorageState";
88
import React, { Dispatch, useEffect } from "react";
99
import {
10-
STORAGE_QUERYVIEW_DATA,
11-
getLocalStorageItem
10+
getLocalStorageItem,
11+
STORAGE_QUERYVIEW_DATA
1212
} from "tools/localStorageHelpers";
1313
import { v4 as uuid } from "uuid";
1414

@@ -20,20 +20,21 @@ export interface QueryElement {
2020
optionsIn: string;
2121
tabId: string;
2222
}
23+
2324
export interface QueryState {
2425
queries: QueryElement[];
2526
tabIndex: number;
2627
}
2728

2829
export type DispatchQuery = Dispatch<QueryAction>;
2930

30-
interface QueryContext {
31+
interface QueryContextI {
3132
queryState: QueryState;
3233
dispatchQuery: DispatchQuery;
3334
}
3435

35-
export const QueryContext = React.createContext<QueryContext>(
36-
{} as QueryContext
36+
export const QueryContext = React.createContext<QueryContextI>(
37+
{} as QueryContextI
3738
);
3839

3940
const getDefaultQueryElement = (): QueryElement => ({
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import eslint from "@eslint/js";
2+
import tsEslint from "typescript-eslint";
3+
import globals from "globals";
4+
import tsEslintParser from "@typescript-eslint/parser";
5+
import tsEslintPlugin from "@typescript-eslint/eslint-plugin";
6+
import reactPlugin from "eslint-plugin-react";
7+
import vitestPlugin from "eslint-plugin-vitest";
8+
import jestPlugin from "eslint-plugin-jest";
9+
10+
export default tsEslint.config(
11+
eslint.configs.recommended,
12+
...tsEslint.configs.recommended,
13+
{
14+
settings: {
15+
react: {
16+
version: "detect"
17+
}
18+
},
19+
20+
languageOptions: {
21+
ecmaVersion: "latest",
22+
sourceType: "module",
23+
parser: tsEslintParser,
24+
globals: {
25+
...globals.browser,
26+
...globals.node,
27+
...globals.jest,
28+
React: "readonly",
29+
HeadersInit: "readonly",
30+
RequestInit: "readonly",
31+
NodeJS: "readonly",
32+
JSX: "readonly",
33+
vi: "readonly"
34+
}
35+
},
36+
files: ["**/*.js", "**/*.ts", "**/*.jsx", "**/*.tsx"],
37+
ignores: [
38+
"**/*.config.js",
39+
"**/*.config.ts",
40+
"node_modules/*",
41+
"bin/*",
42+
".idea/*",
43+
"dist/*",
44+
"out/*"
45+
],
46+
plugins: {
47+
"@typescript-eslint": tsEslintPlugin,
48+
"react": reactPlugin,
49+
"vitest": vitestPlugin,
50+
"jest": jestPlugin
51+
},
52+
rules: {
53+
"react-hooks/exhaustive-deps": "off",
54+
"@typescript-eslint/ban-ts-comment": "off",
55+
"@typescript-eslint/explicit-member-accessibility": "off",
56+
"@typescript-eslint/explicit-function-return-type": "off",
57+
"@typescript-eslint/no-explicit-any": "off",
58+
"@typescript-eslint/no-use-before-define": "off",
59+
"@typescript-eslint/no-unused-vars": ["error"],
60+
"@typescript-eslint/no-unused-expressions": "off",
61+
"no-unused-vars": "off", //we want to ignore this and handle unused vars by @typescript-eslint plugin rule
62+
"no-console": ["error", { allow: ["warn", "error"] }],
63+
"react/prop-types": 1,
64+
"no-empty-pattern": "off"
65+
}
66+
}
67+
);

Src/WitsmlExplorer.Frontend/package.json

+15-13
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,19 @@
66
"scripts": {
77
"dev": "vite",
88
"build": "tsc && vite build",
9-
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
9+
"lint": "eslint . --report-unused-disable-directives --max-warnings 0",
1010
"preview": "vite preview",
1111
"test": "vitest run",
12-
"test:watch": "vitest watch"
12+
"test:watch": "vitest watch",
13+
"eslint": "eslint . --cache",
14+
"eslint:fix": "eslint . --cache --fix"
1315
},
1416
"lint-staged": {
1517
"**/*.{js,ts,tsx}": [
1618
"eslint --fix",
1719
"prettier -w"
1820
]
1921
},
20-
"eslintIgnore": [
21-
"node_modules/",
22-
"dist/",
23-
"out/"
24-
],
2522
"dependencies": {
2623
"@azure/msal-browser": "^2.28.3",
2724
"@azure/msal-react": "^1.4.7",
@@ -61,8 +58,10 @@
6158
"uuid": "^9.0.0"
6259
},
6360
"devDependencies": {
64-
"@testing-library/jest-dom": "^6.4.5",
6561
"@testing-library/react": "^15.0.7",
62+
"@testing-library/jest-dom": "^6.4.5",
63+
"@eslint/js": "^9.11.1",
64+
"@eslint/eslintrc": "^3.1.0",
6665
"@testing-library/user-event": "^14.4.3",
6766
"@types/enzyme": "^3.10.12",
6867
"@types/jest": "^29.1.0",
@@ -73,17 +72,20 @@
7372
"@types/react-window": "^1.8.5",
7473
"@types/styled-components": "^5.1.26",
7574
"@types/uuidv4": "^5.0.0",
76-
"@typescript-eslint/eslint-plugin": "^7.3.1",
77-
"@typescript-eslint/parser": "^7.3.1",
75+
"@typescript-eslint/eslint-plugin": "^8.8.0",
76+
"@typescript-eslint/parser": "^8.8.0",
7877
"@vitejs/plugin-react": "^4.2.1",
79-
"eslint": "^8.57.0",
78+
"eslint": "^9.11.1",
8079
"eslint-config-prettier": "^9.1.0",
81-
"eslint-plugin-jest": "^27.9.0",
82-
"eslint-plugin-react": "^7.34.1",
80+
"eslint-plugin-jest": "^28.2.0",
81+
"eslint-plugin-react": "^7.37.1",
82+
"eslint-plugin-vitest": "^0.5.4",
83+
"globals": "^15.9.0",
8384
"jsdom": "^24.0.0",
8485
"lint-staged": "^13.0.3",
8586
"typescript": "^5.4.3",
8687
"vite": "^5.2.8",
88+
"typescript-eslint": "^8.8.0",
8789
"vite-tsconfig-paths": "^4.3.2",
8890
"vitest": "^1.6.0"
8991
}

Src/WitsmlExplorer.Frontend/services/apiClient.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Server } from "models/server";
22
import { getAccessToken, msalEnabled } from "msal/MsalAuthProvider";
3-
43
import AuthorizationService, {
54
AuthorizationStatus
65
} from "services/authorizationService";
@@ -249,6 +248,7 @@ export async function getBaseUrl(): Promise<URL> {
249248
baseUrl = new URL(`${protocol}://${host}${port}`);
250249
}
251250
} catch (e) {
251+
console.error(e);
252252
baseUrl = new URL("http://localhost");
253253
}
254254
return baseUrl;

0 commit comments

Comments
 (0)