Skip to content

Commit

Permalink
Merge branch 'equinor:main' into new-las
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbasti authored Oct 11, 2024
2 parents b869d3d + 010251f commit 6063317
Show file tree
Hide file tree
Showing 18 changed files with 352 additions and 293 deletions.
44 changes: 0 additions & 44 deletions .eslintrc.json

This file was deleted.

3 changes: 3 additions & 0 deletions .github/workflows/ci_desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
- name: Install dependencies
run: yarn --network-timeout 100000
working-directory: ./Src/WitsmlExplorer.Desktop
- name: Linting
run: yarn lint
working-directory: ./Src/WitsmlExplorer.Desktop
- name: Package
run: yarn electron:pack
working-directory: ./Src/WitsmlExplorer.Desktop
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ Src/WitsmlExplorer.Frontend/bin
*.yml
.prettierignore
.github
.eslintrc.json
eslint.config.js
3 changes: 2 additions & 1 deletion Src/WitsmlExplorer.Desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"preview": "yarn build:api && electron-vite preview",
"electron:pack": "yarn build && electron-builder --dir -c electron-builder.json",
"electron:dist": "yarn build && electron-builder -c electron-builder.json",
"test:pack": "cross-env ELECTRON_IS_TEST=true playwright test"
"test:pack": "cross-env ELECTRON_IS_TEST=true playwright test",
"lint": "eslint . --report-unused-disable-directives --max-warnings 0"
},
"main": "./dist/main/main.js",
"lint-staged": {
Expand Down
1 change: 1 addition & 0 deletions Src/WitsmlExplorer.Desktop/src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function readOrCreateAppConfig() {
// Merge the configs to ensure that new properties are added to the existing config.
config = { ...defaultConfig, ...existingConfig };
} catch (err) {
console.error(err);
config = defaultConfig;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const useClipboardComponentReferences: () => ComponentReferences | null =
parseStringToComponentReferences(clipboardText);
setReferences(componentReferences);
} catch (e) {
console.error(e);
//Not a valid object on the clipboard? That is fine, we won't use it.
}
};
Expand All @@ -39,8 +40,8 @@ export function parseStringToComponentReferences(
let jsonObject: ComponentReferences;
try {
jsonObject = JSON.parse(input);
} catch (error) {
throw new Error("Invalid input given.");
} catch (e) {
throw new Error("Invalid input given.", e);
}
verifyRequiredProperties(jsonObject);
return jsonObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const useClipboardReferences = (
const objectReferences = parseStringToReferences(clipboardText);
setReferences(objectReferences);
} catch (e) {
console.error(e);
//Not a valid object on the clipboard? That is fine, we won't use it.
}
};
Expand Down Expand Up @@ -45,8 +46,8 @@ export function parseStringToReferences(input: string): ObjectReferences {
let jsonObject: ObjectReferences;
try {
jsonObject = JSON.parse(input);
} catch (error) {
throw new Error("Invalid input given.");
} catch (e) {
throw new Error("Invalid input given.", e);
}
verifyRequiredProperties(jsonObject);
return jsonObject;
Expand Down
2 changes: 2 additions & 0 deletions Src/WitsmlExplorer.Frontend/components/DateFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ function formatDateString(
const offset = getOffsetFromTimeZone(timeZone);
return formatInTimeZone(parsed, offset, dateTimeFormat);
} catch (e) {
console.error(e);
return "Invalid date";
}
}

export default formatDateString;

export function getOffsetFromTimeZone(timeZone: TimeZone): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ const MissingDataAgentModal = (
? checksObj
: [];
return checks.map((check) => ({ ...check, id: uuid() }));
} catch (error) {
} catch (e) {
console.error(e);
return [];
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const ObjectPickerModal = ({
setFetchError(`The target ${objectType} was not found`);
}
} catch (e) {
console.error(e);
setFetchError("Failed to fetch");
} finally {
setIsLoading(false);
Expand Down
5 changes: 3 additions & 2 deletions Src/WitsmlExplorer.Frontend/components/RefreshHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ const RefreshHandler = (): React.ReactElement => {
}
refreshSearchQueries(refreshAction);
}
} catch (error) {
} catch (e) {
console.error(
`Unable to perform refresh action for action: ${refreshAction.refreshType} and entity: ${refreshAction.entityType}`
`Unable to perform refresh action for action: ${refreshAction.refreshType} and entity: ${refreshAction.entityType}`,
e
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useConnectedServer } from "contexts/connectedServerContext";
import {
FilterContext,
FilterType,
FilterTypes,
getFilterTypeInformation,
isObjectFilterType,
isWellboreFilterType
Expand All @@ -23,7 +24,7 @@ import styled, { CSSProp } from "styled-components";
import { Colors } from "styles/Colors";
import Icons from "styles/Icons";

const searchOptions = Object.values(FilterType);
const searchOptions = Object.values(FilterTypes);

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

const SearchBarContainer = styled.div`
width: 85%;
.small-padding-left {
padding-left: 4px;
}
.small-padding-right {
padding-right: 4px;
}
Expand Down
2 changes: 1 addition & 1 deletion Src/WitsmlExplorer.Frontend/contexts/filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export type FilterType =
| WellboreFilterType
| WellPropertyFilterType
| ObjectFilterType;
export const FilterType = {
export const FilterTypes = {
...WellFilterType,
...WellboreFilterType,
...WellPropertyFilterType,
Expand Down
18 changes: 8 additions & 10 deletions Src/WitsmlExplorer.Frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint": "eslint . --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"test": "vitest run",
"test:watch": "vitest watch"
Expand All @@ -17,11 +17,6 @@
"prettier -w"
]
},
"eslintIgnore": [
"node_modules/",
"dist/",
"out/"
],
"dependencies": {
"@azure/msal-browser": "^2.28.3",
"@azure/msal-react": "^1.4.7",
Expand Down Expand Up @@ -61,6 +56,7 @@
"uuid": "^9.0.0"
},
"devDependencies": {
"@eslint/js": "^9.12.0",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^15.0.7",
"@testing-library/user-event": "^14.4.3",
Expand All @@ -73,16 +69,18 @@
"@types/react-window": "^1.8.5",
"@types/styled-components": "^5.1.26",
"@types/uuidv4": "^5.0.0",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"@typescript-eslint/eslint-plugin": "^8.8.1",
"@typescript-eslint/parser": "^8.8.1",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.57.0",
"eslint": "^9.12.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react": "^7.37.1",
"globals": "^15.11.0",
"jsdom": "^24.0.0",
"lint-staged": "^13.0.3",
"typescript": "^5.4.3",
"typescript-eslint": "^8.8.1",
"vite": "^5.2.8",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.0"
Expand Down
1 change: 1 addition & 0 deletions Src/WitsmlExplorer.Frontend/services/apiClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ export async function getBaseUrl(): Promise<URL> {
baseUrl = new URL(`${protocol}://${host}${port}`);
}
} catch (e) {
console.error(e);
baseUrl = new URL("http://localhost");
}
return baseUrl;
Expand Down
2 changes: 1 addition & 1 deletion Src/WitsmlExplorer.Frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"noFallthroughCasesInSwitch": true,
"types": ["vitest/globals"]
},
"exclude": ["node_modules"],
"exclude": ["node_modules", "eslint.config.js"],
"include": ["vite-env.d.ts", "**/*.ts", "**/*.tsx", "."],
"references": [{ "path": "./tsconfig.node.json" }]
}
68 changes: 68 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
const eslint = require("@eslint/js");
const tsEslint = require("typescript-eslint");
const globals = require("globals");
const tsEslintParser = require("@typescript-eslint/parser");
const tsEslintPlugin = require("@typescript-eslint/eslint-plugin");
const reactPlugin = require("eslint-plugin-react");

module.exports = tsEslint.config(
eslint.configs.recommended,
...tsEslint.configs.recommended,
{
settings: {
react: {
version: "detect"
}
},

languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
parser: tsEslintParser,
globals: {
...globals.browser,
...globals.node,
...globals.jest,
React: "readonly",
HeadersInit: "readonly",
RequestInit: "readonly",
NodeJS: "readonly",
JSX: "readonly",
vi: "readonly"
}
},
files: ["**/*.ts", "**/*.tsx"],
plugins: {
"@typescript-eslint": tsEslintPlugin,
"react": reactPlugin
},
rules: {
"react-hooks/exhaustive-deps": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/no-duplicate-enum-values": "off",
"no-unused-vars": "off", //we want to ignore this and handle unused vars by @typescript-eslint plugin rule
"no-console": ["error", { allow: ["warn", "error"] }],
"react/prop-types": 1,
"no-empty-pattern": "off"
}
},
// standalone global ignores config due to default behaviour of minimal matching strategy
{
ignores: [
"**/*.config.js",
"**/*.config.ts",
"node_modules",
"**/bin",
"**/.idea",
"**/dist",
"**/out",
"**/obj"
]
}
);
Loading

0 comments on commit 6063317

Please sign in to comment.