Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update en fix all linting problems #676

Merged
merged 3 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/pr-676-2005320517.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

---
"fusion-project-portal": patch
---
Es lint update for better code quality.
81 changes: 0 additions & 81 deletions client/.eslintrc.json

This file was deleted.

87 changes: 87 additions & 0 deletions client/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import tsdoc from 'eslint-plugin-tsdoc';
import tsParser from '@typescript-eslint/parser';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: [
'**/*.md',
'**/*.svg',
'**/*.d.ts',
'**/*.ico',
'**/*.html',
'**/*.js',
'**/coverage/**/*',
'**/*.jpg',
'**/*.png',
],
},
...compat.extends('plugin:@typescript-eslint/recommended'),
{
plugins: {
tsdoc,
},

languageOptions: {
parser: tsParser,
},

rules: {
'tsdoc/syntax': 'warn',
'prefer-destructuring': 'off',
'prefer-arrow-callback': 'warn',
'prefer-const': 'warn',
'lines-between-class-members': 'warn',
'class-methods-use-this': 'warn',
curly: ['error', 'multi-line'],

'default-case': [
'error',
{
commentPattern: '^no default$',
},
],

'max-classes-per-file': ['error', 1],
'no-constructor-return': 'error',

'no-empty-function': [
'error',
{
allow: ['arrowFunctions', 'functions', 'methods'],
},
],

'no-eval': 'error',
'no-lone-blocks': 'error',
'no-loop-func': 'error',
'no-new-func': 'error',
'no-redeclare': 'error',
'no-return-assign': ['error', 'always'],
'@typescript-eslint/no-unused-vars': 'off',
'no-self-assign': [
'error',
{
props: true,
},
],

'no-self-compare': 'error',
'no-throw-literal': 'error',
'no-useless-catch': 'error',
'no-useless-return': 'error',
'no-restricted-globals': 'off',
},
},
];
4 changes: 2 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@vitejs/plugin-react": "^4.2.1",
"@vitest/coverage-v8": "^1.2.1",
"@vitest/ui": "^1.2.1",
"eslint": "^9.0.0",
"eslint": "^9.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.32.2",
Expand Down Expand Up @@ -105,4 +105,4 @@
"workspaces": [
"packages/**"
]
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { IHttpClient } from '@equinor/fusion-framework-module-http';
import { Task } from '../types/task';

Expand Down
1 change: 0 additions & 1 deletion client/packages/core/src/app/utils/app-element.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { describe, test, expect } from 'vitest';
import { createAppElement } from './app-element';
import { JSDOM } from 'jsdom';
Expand Down
4 changes: 2 additions & 2 deletions client/packages/core/src/context/types/relations.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/consistent-type-definitions */
/* eslint-disable @typescript-eslint/no-explicit-any */

export type RelationsTypes =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable class-methods-use-this */
import { BaseConfigBuilder, ConfigBuilderCallbackArgs } from '@equinor/fusion-framework-module';
import { AppManifestResponse, IClient, PortalConfiguration, PortalRoutes, PortalState } from './types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable tsdoc/syntax */
import { useMemo } from 'react';
import { usePortalConfig } from './use-portal-config';
import { appsToAppCategory } from '../utils/appsToAppCategory';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class PortalConfigProvider implements IPortalConfigProvider {
return this._AppsBuContext({ portalId, contextId });
};

// eslint-disable-next-line @typescript-eslint/no-unused-vars
public getPortalRoutesById$ = (_portalId?: string): Observable<PortalRoutes> => {
return new Observable((sub) => sub.next(this.#config.portalConfig.routes));
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Search, Switch } from '@equinor/eds-core-react';
import { Search } from '@equinor/eds-core-react';
import { InfoMessage, MenuScrim, StyledCategoryItem } from '@equinor/portal-ui';
import { appGroupArraySort, getDisabledApps, getPinnedAppsGroup, usePortalMenu, useTelemetry } from '@portal/core';

import { appsMatchingSearch, usePortalApps } from '@portal/core';
import { useState, useMemo } from 'react';
import { useFeature } from '@equinor/fusion-framework-react-app/feature-flag';
import { useFavorites } from '@portal/core';
import styled from 'styled-components';
import { AppContextMessage, AppGroup, LoadingMenu } from '@portal/components';
Expand Down Expand Up @@ -69,7 +68,7 @@ export function MenuGroups() {
const { appCategories, isLoading } = usePortalApps();
const { searchText, closeMenu, setSearchText } = usePortalMenu();
const [activeItem, setActiveItem] = useState('All Apps');

const { addFavorite, appGroups, favorites } = useFavorites();

const categoryItems = ['Pinned Apps', ...(appCategories?.map((item) => item.name) ?? []), 'All Apps'];
Expand Down Expand Up @@ -130,7 +129,7 @@ export function MenuGroups() {
onClick={() => handleToggle(item)}
/>
))}
</Styles.CategoryWrapper>
</Styles.CategoryWrapper>
</Styles.Divider>
<div>
<AppContextMessage />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Client } from '@portal/types';

const manifestMapper =
(basePath: string) =>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(value: any): AppManifest => {
const { appKey, appInformation, isLegacy } = value;
return { ...appInformation, entry: `${basePath}/api/bundles/${appKey}`, isLegacy };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const SEARCH_PARM_TAB = 'tab';

export const FacilityPage = () => {
const { contextId } = useParams();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [searchParams, setSearchparams] = useSearchParams();

const [activeTab, setActiveTab] = useState(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-var-requires */
import styled from 'styled-components';
import { tokens } from '@equinor/eds-tokens';
import { Button, Typography } from '@equinor/eds-core-react';
Expand Down
2 changes: 1 addition & 1 deletion client/packages/utils/src/rxjs/observable-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function createObservableProxy<T extends Record<PropertyKey, unknown>>(
}

subjects.get(`${String(index)}$`)?.next(newVal);
// eslint-disable-next-line no-param-reassign
prop[index as keyof T] = newVal;
return true;
},
Expand Down
Loading