Skip to content

Commit

Permalink
xStream-581 Adding aristid eslint plugin
Browse files Browse the repository at this point in the history
xstream-581 Adding aristid eslint plugin
  • Loading branch information
fatb38 authored May 2, 2024
2 parents 68973b1 + b489977 commit 616b7e5
Show file tree
Hide file tree
Showing 310 changed files with 4,017 additions and 2,969 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ require('@rushstack/eslint-patch/modern-module-resolution');

module.exports = {
env: {browser: true, node: true, es6: true},
ignorePatterns: ['**/_gqlTypes/*.ts', '**/dist/*'],
ignorePatterns: ['**/_gqlTypes/*.ts', '**/dist/*', '**/plugins/*'],
parser: '@typescript-eslint/parser',
parserOptions: {tsconfigRootDir: __dirname},
plugins: ['@typescript-eslint', 'react-app', 'react-refresh'],
settings: {react: {version: 'latest'}},
extends: ['plugin:@aristid/recommended'],
rules: {
'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/array-type': ['error', {default: 'array-simple', readonly: 'array-simple'}],
Expand Down
12 changes: 4 additions & 8 deletions apps/admin/src/components/app/App/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@ import {enableFetchMocks} from 'jest-fetch-mock';

enableFetchMocks();

jest.mock('../Home', () => {
return function Home() {
jest.mock('../Home', () => function Home() {
return <div>Home</div>;
};
});
});

jest.mock('../MessagesDisplay', () => {
return function MessagesDisplay() {
jest.mock('../MessagesDisplay', () => function MessagesDisplay() {
return <div>MessagesDisplay</div>;
};
});
});

jest.mock('../../../constants', () => ({
APP_ENDPOINT: 'admin'
Expand Down
6 changes: 2 additions & 4 deletions apps/admin/src/components/app/Header/Header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import React from 'react';
import {render, screen} from '_tests/testUtils';
import Header from './Header';

jest.mock('components/applications/ApplicationsSwitcher', () => {
return function ApplicationsSwitcher() {
jest.mock('components/applications/ApplicationsSwitcher', () => function ApplicationsSwitcher() {
return <div>ApplicationsSwitcher</div>;
};
});
});

describe('Header', () => {
test('Render menu', async () => {
Expand Down
18 changes: 6 additions & 12 deletions apps/admin/src/components/app/Home/Home.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,17 @@ import React from 'react';
import {act, render, screen} from '_tests/testUtils';
import Home from './Home';

jest.mock('../Routes', () => {
return function Routes() {
jest.mock('../Routes', () => function Routes() {
return <div>Routes</div>;
};
});
});

jest.mock('../Header', () => {
return function Header() {
jest.mock('../Header', () => function Header() {
return <div>Header</div>;
};
});
});

jest.mock('../AppMenu', () => {
return function AppMenu() {
jest.mock('../AppMenu', () => function AppMenu() {
return <div>AppMenu</div>;
};
});
});

jest.mock('../../../constants', () => ({
APPS_ENDPOINT: '',
Expand Down
30 changes: 10 additions & 20 deletions apps/admin/src/components/app/Routes/Routes.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,25 @@ import {MemoryRouter} from 'react-router-dom-v5';
import {act, render, screen} from '_tests/testUtils';
import Routes from './Routes';

jest.mock('components/shared/ProtectedRoute', () => {
return function ProtectedRoute() {
jest.mock('components/shared/ProtectedRoute', () => function ProtectedRoute() {
return <div>ProtectedRoute</div>;
};
});
});

jest.mock('components/general/General', () => {
return function General() {
jest.mock('components/general/General', () => function General() {
return <div>General</div>;
};
});
});

jest.mock('../Dashboard', () => {
return function Dashboard() {
jest.mock('../Dashboard', () => function Dashboard() {
return <div>Dashboard</div>;
};
});
});

jest.mock('components/applications/Applications', () => {
return function Applications() {
jest.mock('components/applications/Applications', () => function Applications() {
return <div>Applications</div>;
};
});
});

jest.mock('components/applications/EditApplication', () => {
return function EditApplication() {
jest.mock('components/applications/EditApplication', () => function EditApplication() {
return <div>EditApplication</div>;
};
});
});

describe('Routes', () => {
test('Render test', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const Applications = (): JSX.Element => {
</Grid.Column>
{userData.permissions[PermissionsActions.admin_create_application] && (
<Grid.Column floated="right" width={6} textAlign="right" verticalAlign="middle">
<Button primary icon labelPosition="left" size="medium" as={Link} to={'/applications/edit/'}>
<Button primary icon labelPosition="left" size="medium" as={Link} to="/applications/edit/">
<Icon name="plus" />
{t('applications.new')}
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,17 @@ import {Mockify} from '_types/Mockify';
import {mockApplicationDetails} from '__mocks__/common/applications';
import EditApplication, {IEditApplicationMatchParams} from './EditApplication';

jest.mock('./EditApplicationTabs/InfosTab', () => {
return function InfosTab() {
jest.mock('./EditApplicationTabs/InfosTab', () => function InfosTab() {
return <div>InfosTab</div>;
};
});
});

jest.mock('./EditApplicationTabs/PermissionsTab', () => {
return function PermissionsTab() {
jest.mock('./EditApplicationTabs/PermissionsTab', () => function PermissionsTab() {
return <div>PermissionsTab</div>;
};
});
});

jest.mock('./EditApplicationTabs/SettingsTab', () => {
return function SettingsTab() {
jest.mock('./EditApplicationTabs/SettingsTab', () => function SettingsTab() {
return <div>SettingsTab</div>;
};
});
});

jest.mock('react-router-v5', () => ({
...jest.requireActual('react-router-v5'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,7 @@ function InfosForm({onSubmitInfos, errors, onCheckIdIsUnique, loading}: IInfosFo
}
};

const _onSubmit = () => {
return handleSubmit();
};
const _onSubmit = () => handleSubmit();

return (
<FormWrapper onSubmit={_onSubmit} aria-label="infos-form" isNewApp={isNewApp}>
Expand Down Expand Up @@ -280,12 +278,10 @@ function InfosForm({onSubmitInfos, errors, onCheckIdIsUnique, loading}: IInfosFo
name="type"
aria-label="type"
onChange={_handleChangeWithSubmit}
options={Object.keys(ApplicationType).map(appType => {
return {
options={Object.keys(ApplicationType).map(appType => ({
text: t('applications.types.' + appType),
value: appType
};
})}
}))}
value={values.type}
/>
</FormFieldWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ import {act, render, screen, waitFor, within} from '_tests/testUtils';
import {mockApplicationDetails, mockApplicationsModules} from '__mocks__/common/applications';
import InfosTab from './InfosTab';

jest.mock('components/shared/FileSelector', () => {
return function FileSelector() {
jest.mock('components/shared/FileSelector', () => function FileSelector() {
return <div>FileSelector</div>;
};
});
});

describe('InfosTab', () => {
test('Display form, edit value and submit on blur', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import {act, render, screen} from '_tests/testUtils';
import {mockApplicationDetails} from '__mocks__/common/applications';
import PermissionsTab from './PermissionsTab';

jest.mock('components/permissions/DefinePermByUserGroupView', () => {
return function DefinePermByUserGroupView() {
jest.mock('components/permissions/DefinePermByUserGroupView', () => function DefinePermByUserGroupView() {
return <div>DefinePermByUserGroupView</div>;
};
});
});
describe('GeneralAdminPermissionsTab', () => {
test('Render test', async () => {
await act(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import {shallow} from 'enzyme';
import React from 'react';
import AttributeCreationModal from './AttributeCreationModal';

jest.mock('../EditAttribute', () => {
return function EditAttribute() {
jest.mock('../EditAttribute', () => function EditAttribute() {
return <div>Edit attribute</div>;
};
});
});

describe('AttributeCreationModal', () => {
const onClose = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ import {AttributeType} from '../../../_gqlTypes/globalTypes';
import {mockAttrSimple} from '../../../__mocks__/attributes';
import AttributeSelector from './AttributeSelector';

jest.mock('./AttributeSelectorField', () => {
return function AttributeSelectorField() {
jest.mock('./AttributeSelectorField', () => function AttributeSelectorField() {
return <div>AttributeSelectorField</div>;
};
});
});

describe('AttributeSelector', () => {
test('Loading and success state', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import {mockAttrSimple} from '__mocks__/attributes';
import {Mockify} from '../../../_types/Mockify';
import Attributes from './Attributes';

jest.mock('../AttributesList', () => {
return function AttributesList() {
jest.mock('../AttributesList', () => function AttributesList() {
return <div>AttributesList</div>;
};
});
});

describe('Attributes', () => {
test('Snapshot test', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const Attributes = (props: IAttributesProps): JSX.Element => {
</Grid.Column>
{userData.permissions[PermissionsActions.admin_create_attribute] && (
<Grid.Column floated="right" width={6} textAlign="right" verticalAlign="middle">
<Button primary icon labelPosition="left" size="medium" as={Link} to={'/attributes/edit/'}>
<Button primary icon labelPosition="left" size="medium" as={Link} to="/attributes/edit/">
<Icon name="plus" />
{t('attributes.new')}
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ import {mockAttrSimple} from '../../../__mocks__/attributes';
import MockedProviderWithFragments from '../../../__mocks__/MockedProviderWithFragments';
import AttributesSelectionModal from './AttributesSelectionModal';

jest.mock('./AttributesSelectionList', () => {
return function AttributesSelectionList() {
jest.mock('./AttributesSelectionList', () => function AttributesSelectionList() {
return <div>AttributesSelectionList</div>;
};
});
});

describe('AttributesSelection', () => {
test('Loading and success state', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,13 @@ jest.mock('hooks/useLang');
jest.mock('react-dnd', () => ({
useDrag: () => {
const isDragging = false;
const drag = () => {
return true;
};
const preview = () => {
return true;
};
const drag = () => true;
const preview = () => true;
return [{isDragging}, drag, preview];
},
useDrop: sth => {
const isOver = false;
const drop = () => {
return true;
};
const drop = () => true;
return [{isOver}, drop];
},
DndProvider: ({backend, children}) => children
Expand All @@ -41,7 +35,7 @@ describe('ALCCard', () => {
const comp = render(
<DndProvider backend={TestBackend}>
<ALCCard
id={'0'}
id="0"
action={{
id: 'action',
list_id: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ function ALCCard({
collect: monitor => ({
isDragging: !!monitor.isDragging()
}),
canDrag: monitor => {
return !blockedCard;
}
canDrag: monitor => !blockedCard
});

const [{isOver}, drop] = useDrop({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,13 @@ const actionsMock = [
// return undefined;
// }

const wait = () => {
return new Promise((res, rej) => {
const wait = () => new Promise((res, rej) => {
setTimeout(res, 200);
});
};

jest.mock('../ALCList', () => {
return function ALCList() {
jest.mock('../ALCList', () => function ALCList() {
return <></>;
};
});
});

describe('ALCContainer', () => {
test('renders the reserve and the list', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ function ALCContainer({availableActions = [], attribute}: IALCContainerProps): J

//////////////////// INDEX AND OBJECT MANIPULATIONS

const getNewId = () => {
return currentActionList ? currentActionList[currentActionListName].higherId + 1 : 0;
};
const getNewId = () => currentActionList ? currentActionList[currentActionListName].higherId + 1 : 0;

const getActionFromId = (id: string, listId: number = currentActionList[currentActionListName].higherId + 1) => {
if (!availableActions) {
Expand Down Expand Up @@ -194,12 +192,10 @@ function ALCContainer({availableActions = [], attribute}: IALCContainerProps): J

/////////////// SAVE CONFIG FUNCTIONS

const extractParamConfig = (param: IParam): IParamConfig => {
return {
const extractParamConfig = (param: IParam): IParamConfig => ({
name: param.name,
value: param.value ? param.value : param.default_value
};
};
});

const getConfigActionFromAction = act => {
const params = act.params && act.params.length ? act.params.map(param => extractParamConfig(param)) : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,9 @@ function onSelectorChangeMock(event) {
return undefined;
}

jest.mock('../ALCCard', () => {
return function ALCCard() {
jest.mock('../ALCCard', () => function ALCCard() {
return <div>Card</div>;
};
});
});

describe('ALCList', () => {
test('One action get instanciated in list', async () => {
Expand Down
Loading

0 comments on commit 616b7e5

Please sign in to comment.