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: solve eslint issues #993

Merged
merged 1 commit into from
Oct 2, 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
2 changes: 0 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ export default [
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-unnecessary-type-constraint': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'no-prototype-builtins': 'off',
},
languageOptions: {
Expand Down
15 changes: 8 additions & 7 deletions src/packages/application/app-context.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { createContext, PropsWithChildren, useContext, useState } from 'react';

export type AppProperties = {
authorizationHost: string;
modules: string[];
activeModules: string[];
defaultContributor: string;
maxLengthScopeNote: string;
};
type AppContextTypes = {
lg1: string;
lg2: string;
Expand All @@ -8,13 +15,7 @@ type AppContextTypes = {
value: boolean;
toggle: () => void;
};
properties: {
authorizationHost: string;
modules: string[];
activeModules: string[];
defaultContributor: string;
maxLengthScopeNote: string;
};
properties: AppProperties;
};

const AppContext = createContext<AppContextTypes | undefined>(undefined);
Expand Down
1 change: 0 additions & 1 deletion src/packages/application/router/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useLocation } from 'react-router-dom';
import Routes from './routes';
//@ts-ignore
import { PropsWithChildren } from 'react';
import 'react-app-polyfill/stable';
import bauhausLogo from '../../../img/logo_noir.svg';
Expand Down
1 change: 0 additions & 1 deletion src/packages/components/application-title/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//@ts-ignore
import bauhausLogo from '../../../img/logo.svg';
import './index.scss';
import { createAllDictionary } from '../../utils/dictionnary';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-ignore
import Modal from 'react-modal';
import { createAllDictionary } from '../../utils/dictionnary';
import { CloseButton, CloseIconButton } from '../buttons/buttons-with-icons';
Expand Down
1 change: 0 additions & 1 deletion src/packages/components/pagination/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useEffect, useState } from 'react';
import { useNavigate, useLocation } from 'react-router-dom';
import { Link } from '../link';
//@ts-ignore
import queryString from 'query-string';
import './pagination.scss';
import { createAllDictionary } from '../../utils/dictionnary';
Expand Down
1 change: 0 additions & 1 deletion src/packages/modules-codelists/components/home/home.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-ignore
import { useState, useEffect } from 'react';
import { Loading, PageTitle, Row, SearchableList } from '../../../components/';

Expand Down
3 changes: 1 addition & 2 deletions src/packages/modules-concepts/utils/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ const linkTypes = {
[IS_REPLACED_BY]: IS_REPLACED_BY,
};

const getType = (typeOfLink: string) => {
//@ts-ignore
const getType = (typeOfLink: keyof typeof linkTypes) => {
const type: string = linkTypes[typeOfLink];
if (type) return type;
throw new TypeError(
Expand Down
1 change: 0 additions & 1 deletion src/packages/modules-datasets/distributions/home/home.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-ignore
import D from '../../../deprecated-locales/build-dictionary';
import { useDistributions } from '../../datasets';
import { HomePageMenu } from './menu';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('Document Visualization Page Menu', () => {
it('a user without Admin or INDICATOR_CONTRIBUTOR or SERIES_CONTRIBUTOR role cannot create a document', () => {
render(
<RBACMock roles={[]}>
<Menu document={{} as any} type="type" />
<Menu document={{} as Document} type="type" />
</RBACMock>,
);

Expand Down
3 changes: 2 additions & 1 deletion src/packages/redux/actions/classifications/general.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as A from '../../actions/constants';
import { ClassificationsApi } from '../../../sdk/classification';
import { Dispatch } from 'redux';

const fetchClassificationGeneral = (id: string) => (dispatch: any) => {
const fetchClassificationGeneral = (id: string) => (dispatch: Dispatch) => {
dispatch({
type: A.LOAD_CLASSIFICATION_GENERAL,
payload: {
Expand Down
5 changes: 3 additions & 2 deletions src/packages/redux/actions/operations/utils/setup.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { CL_SOURCE_CATEGORY, CL_FREQ } from '../../constants/codeList';
import * as A from '../../../actions/constants';
import { CodeListApi } from '../../../../sdk';
import { Dispatch } from 'redux';

export const loadSetup = () => (dispatch: any) => {
export const loadSetup = () => (dispatch: Dispatch) => {
loadCodesList([CL_SOURCE_CATEGORY, CL_FREQ], dispatch);
};
export function loadCodesList(notations: any, dispatch: any) {
export function loadCodesList(notations: string[], dispatch: Dispatch) {
notations.forEach((notation: string) => {
return Promise.all([
CodeListApi.getCodesList(notation),
Expand Down
4 changes: 2 additions & 2 deletions src/packages/sdk/geographie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { buildApi } from './build-api';

const apiConfig = {
getAll: () => ['territories'],
postTerritory: (territory: any) => [
postTerritory: (territory: unknown) => [
`territory`,
{
headers: {
Expand All @@ -13,7 +13,7 @@ const apiConfig = {
},
(res: Response) => res.text(),
],
putTerritory: (id: string, territory: any) => [
putTerritory: (id: string, territory: unknown) => [
`territory/` + id,
{
headers: {
Expand Down
11 changes: 9 additions & 2 deletions src/packages/utils/hooks/useLocales.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { renderHook } from '@testing-library/react';
import { useLocales } from './useLocales';
import { AppContextProvider } from '../../application/app-context';
import {
AppContextProvider,
AppProperties,
} from '../../application/app-context';

describe('useLocales', () => {
it('returns the correct initial value and toggle function', () => {
const wrapper = ({ children }: { children: React.ReactNode }) => (
<AppContextProvider lg1="English" lg2="French" properties={{} as any}>
<AppContextProvider
lg1="English"
lg2="French"
properties={{} as AppProperties}
>
{children}
</AppContextProvider>
);
Expand Down
2 changes: 1 addition & 1 deletion src/packages/utils/hooks/useUrlQueryParameters.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useSearchParams } from 'react-router-dom';

const useUrlQueryParameters = (defaultValue: any) => {
const useUrlQueryParameters = (defaultValue: Record<string, string>) => {
const [searchParams, setSearchParams] = useSearchParams();

const handleChange = (property: string, stateChange: string) => {
Expand Down
6 changes: 3 additions & 3 deletions src/packages/utils/html-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ describe('build rmes version of html from raw html', () => {
describe('html length', () => {
it('returns 0 for empty string', () => {
expect(htmlUtils.htmlLength('')).toEqual(0);
expect(htmlUtils.htmlLength(undefined as any)).toEqual(0);
expect(htmlUtils.htmlLength(undefined as unknown as string)).toEqual(0);
});
});

describe('html to raw text', () => {
it('returns an empty string for empty html', () => {
expect(htmlUtils.htmlToRawText('')).toEqual('');
expect(htmlUtils.htmlToRawText(undefined as any)).toEqual('');
expect(htmlUtils.htmlToRawText(undefined as unknown as string)).toEqual('');
});

it('returns the text content', () => {
Expand Down Expand Up @@ -74,7 +74,7 @@ describe('delete p tags', () => {
describe('is empty', () => {
it('returns true if there is not text content', () => {
expect(htmlUtils.htmlIsEmpty('')).toBe(true);
expect(htmlUtils.htmlIsEmpty(undefined as any)).toBe(true);
expect(htmlUtils.htmlIsEmpty(undefined as unknown as string)).toBe(true);
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/packages/utils/html-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '../components/rich-editor/draftjs/mdToDraftjs';
import { draftjsToMd } from '../components/rich-editor/draftjs/draftjsToMd';

export const containUnsupportedStyles = (attr: any = {}) => {
export const containUnsupportedStyles = (attr: Record<string, string> = {}) => {
return !!REGEXPS.map((r) => r.regexp).find(
(regexp) => !!Object.keys(attr).find((key) => regexp.test(attr[key])),
);
Expand Down
5 changes: 4 additions & 1 deletion src/packages/utils/item-to-select-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export function mergedItemsToSelectModels(
...items: { type: string; label: string }[][]
) {
return sortArrayByLabel(
items.reduce((acc: any, values) => [...acc, ...values], []),
items.reduce(
(acc: { type: string; label: string }[], values) => [...acc, ...values],
[],
),
).map((elt: { type: string; label: string }) => {
return {
...elt,
Expand Down
1 change: 1 addition & 0 deletions src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
declare module 'react-select';
declare module 'react-modal';
declare module 'draft-js';