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

MNT ESLint Issues following rules from main and import libs #1532

Merged
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
4 changes: 2 additions & 2 deletions client/dist/js/bundle.js

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions client/src/boot/BootRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,20 @@ class BootRoutes {
const rootRoute = reactRouteRegister.getRootRoute();
const router = createBrowserRouter(
createRoutesFromElements(
<Route
path={rootRoute.path}
element={
<rootRoute.component>
<NavigationBlocker shouldBlockFn={this.shouldConfirmBeforeUnload} blockMessage={this.getUnsavedChangesMessage()} />
</rootRoute.component>
<Route
path={rootRoute.path}
element={
<rootRoute.component>
<NavigationBlocker shouldBlockFn={this.shouldConfirmBeforeUnload} blockMessage={this.getUnsavedChangesMessage()} />
</rootRoute.component>
}
>
{reactRouteRegister.getChildRoutes().map(
(route) => (
<Route key={route.path} path={route.path} element={<route.component />} />
)
)}
</Route>
>
{reactRouteRegister.getChildRoutes().map(
(route) => (
<Route key={route.path} path={route.path} element={<route.component />} />
)
)}
</Route>
),
{ basename: joinUrlPaths(Config.get('baseUrl'), Config.get('adminUrl')) }
);
Expand Down
26 changes: 13 additions & 13 deletions client/src/boot/apollo/buildClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import buildNetworkComponents from './buildNetworkComponents';
import buildCache from './buildCache';

const buildClient = async (baseUrl) => {
const graphQLConfig = Config.getSection('SilverStripe\\Admin\\LeftAndMain').graphql;
const cachedTypenames = graphQLConfig && graphQLConfig.cachedTypenames;
let fragmentData;
// GraphQL may not return what we want (e.g. if schema is empty, so fail gracefully)
try {
fragmentData = await getGraphqlFragments(baseUrl, cachedTypenames);
} catch (e) {
fragmentData = null;
}
const cache = buildCache(fragmentData);
const components = buildNetworkComponents(baseUrl);
const link = from(components);
return new ApolloClient({ cache, link });
const graphQLConfig = Config.getSection('SilverStripe\\Admin\\LeftAndMain').graphql;
const cachedTypenames = graphQLConfig && graphQLConfig.cachedTypenames;
let fragmentData;
// GraphQL may not return what we want (e.g. if schema is empty, so fail gracefully)
try {
fragmentData = await getGraphqlFragments(baseUrl, cachedTypenames);
} catch (e) {
fragmentData = null;
}
const cache = buildCache(fragmentData);
const components = buildNetworkComponents(baseUrl);
const link = from(components);
return new ApolloClient({ cache, link });
};

export default buildClient;
1 change: 0 additions & 1 deletion client/src/boot/registerReducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import applyFormMiddleware from 'lib/dependency-injection/applyFormMiddleware';
import ViewModeReducer from 'state/viewMode/ViewModeReducer';
import ToastsReducer from 'state/toasts/ToastsReducer';


export default (extra = {}) => {
const FormReducer = combineReducers({
formState: ReduxFormReducer,
Expand Down
4 changes: 2 additions & 2 deletions client/src/boot/tests/BootRoutes-test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* global jest, describe, afterEach, it, expect, window */

import BootRoutes from '../BootRoutes';

jest.unmock('../BootRoutes.js');
jest.unmock('lib/Config');
jest.unmock('lib/Router');

import BootRoutes from '../BootRoutes';

describe('Bootroutes', () => {
beforeEach(() => {
// Set window config
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Accordion/tests/Accordion-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* global jest, test, describe, it, expect */

import React from 'react';
import Accordion from '../Accordion';
import { render } from '@testing-library/react';
import Accordion from '../Accordion';

test('Accordion render() renders with children', () => {
const { container } = render(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* global jest, test, describe, it, expect */

import React from 'react';
import AccordionBlock from '../AccordionBlock';
import { render } from '@testing-library/react';
import AccordionBlock from '../AccordionBlock';

test('AccordionBlock render() renders with children', () => {
const { container } = render(
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/ActionMenu/ActionMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ActionMenu extends PureComponent {

// Force setting state to the end of the execution queue to clear a potential race condition
// with entwine click handlers
window.setTimeout(() => this.setState({ isOpen: !this.state.isOpen }), 0);
window.setTimeout(() => this.setState((prevState) => ({ isOpen: !prevState.isOpen })), 0);
emteknetnz marked this conversation as resolved.
Show resolved Hide resolved
}

render() {
Expand Down
1 change: 0 additions & 1 deletion client/src/components/Badge/tests/Badge-story.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { jsxDecorator } from 'storybook-addon-jsx';
import Badge, { statuses } from 'components/Badge/Badge';

Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Badge/tests/Badge-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* global jest, test, describe, it, expect */

import React from 'react';
import Badge from '../Badge';
import { render } from '@testing-library/react';
import Badge from '../Badge';

test('Badge render() should return null if status is empty', () => {
const { container } = render(
Expand Down
2 changes: 0 additions & 2 deletions client/src/components/Breadcrumb/tests/Breadcrumb-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { action } from '@storybook/addon-actions';

import { Component as Breadcrumb } from 'components/Breadcrumb/Breadcrumb';


// Simple values to displays in the select fields.
const icons = [
'',
Expand Down Expand Up @@ -127,4 +126,3 @@ export const _Breadcrumb = (args) => {
const { level, icon } = args;
return (<Breadcrumb crumbs={buildBreadCrumb(0, level, icon)}/>);
};

2 changes: 1 addition & 1 deletion client/src/components/Breadcrumb/tests/Breadcrumb-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* global jest, test, describe, beforeEach, it, expect */

import React from 'react';
import { Component as Breadcrumb } from '../Breadcrumb';
import { render } from '@testing-library/react';
import { Component as Breadcrumb } from '../Breadcrumb';

test('BreadcrumbsComponent renderBreadcrumbs() should convert the props.crumbs array into jsx to be rendered', () => {
const { container } = render(
Expand Down
20 changes: 0 additions & 20 deletions client/src/components/Button/tests/BackButton-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,6 @@ import { jsxDecorator } from 'storybook-addon-jsx';
import { action } from '@storybook/addon-actions';
import BackButton from '../BackButton';

const colors = [
'primary',
'secondary',
'success',
'info',
'warning',
'danger',
'link',
];
const sizes = ['sm', 'md', 'lg'];
const icons = [
'',
'search',
'sync',
'plus-circled',
'cancel-circled',
'check-mark',
'edit',
];

const onClick = (event) => {
event.preventDefault();
return action('onClick')(event);
Expand Down
1 change: 0 additions & 1 deletion client/src/components/Button/tests/Button-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,3 @@ _Button.args = {
className: '',
children: 'click me'
};

Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ export default {
defaultValue: { summary: '' },
}
},
value: {
control: 'text'
},
message: {
control: 'object',
table: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,6 @@ export default {
defaultValue: { summary: '{}' },
}
},
value: {
description: 'Whether this is checked or not, *this does not hold an explicit value*!',
control: 'inline-radio',
options: [1, 2, 3, 4],
table: {
type: { summary: 'string|number' },
defaultValue: { summary: '' },
}
},
source: {
description: `Array of items to appear in the list with the following properties.
\* value (string|number): The value for item.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ test('CheckboxSetField renders with two inputs checked', () => {
expect(container.querySelectorAll('span')[3].innerHTML).toBe('4');
});


test('CheckboxSetField renders with string value', () => {
const { container } = render(
<CheckboxSetField {...makeProps({
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/DateField/DateField.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import fieldHolder from 'components/FieldHolder/FieldHolder';
import { Component as TextField } from '../TextField/TextField';
import moment from 'moment';
import modernizr from 'modernizr';
import i18n from 'i18n';
import PropTypes from 'prop-types';
import { Component as TextField } from '../TextField/TextField';

const localFormat = 'L';

Expand All @@ -18,7 +18,7 @@ class DateField extends TextField {
}

getLang() {
const lang = this.asHTML5() ? this.props.isoLang : this.props.lang;
const lang = this.asHTML5() ? this.props.isoLang : this.props.lang;

return lang || moment().locale();
}
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/DateField/tests/DateField-test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* global jest, test, describe, beforeEach, it, expect, modernizr, Event */

jest.mock('modernizr', () => {});

import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import { Component as DateField } from '../DateField';

jest.mock('modernizr', () => {});

function getSharedProps() {
return {
id: 'date',
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/DatetimeField/DatetimeField.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fieldHolder from 'components/FieldHolder/FieldHolder';
import { Component as DateField } from '../DateField/DateField';
import moment from 'moment';
import i18n from 'i18n';
import { Component as DateField } from '../DateField/DateField';

const localFormat = 'L LT';
const dateOnlyLocalFormat = 'L';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,6 @@ export default {
defaultValue: { summary: false },
}
},
value: {
description: 'The value to display for the field - localised date time format or ISO 8601 date format',
control: 'text',
table: {
type: { summary: 'string' },
defaultValue: { summary: '' },
}
},
lang: {
description: 'Locale string. E.g. `en_NZ`.',
control: 'text',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* global jest, test, describe, beforeEach, it, expect, modernizr */

import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import { Component as DatetimeField } from '../DatetimeField';
import { render, fireEvent, screen } from '@testing-library/react';

jest.mock('modernizr', () => ({
inputtypes: {
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/FieldGroup/tests/FieldGroup-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* global jest, test, describe, it, expect */

import React from 'react';
import FieldGroup from '../FieldGroup';
import { render } from '@testing-library/react';
import FieldGroup from '../FieldGroup';

test('FieldGroup renders children', () => {
const { container } = render(
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/FieldHolder/tests/FieldHolder-test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* global jest, test, describe, it, expect, beforeEach */

jest.mock('components/FormAlert/FormAlert');

import React from 'react';
import { render } from '@testing-library/react';
import fieldHolder from '../FieldHolder';

jest.mock('components/FormAlert/FormAlert');

const InnerField = () => <div id="innerfield">Field</div>;
const FieldHolder = fieldHolder(InnerField);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ export default {
defaultValue: { summary: false },
}
},
includeBackground: {
control: 'boolean'
},
placement: {
description: 'Reactstramp tooltip position.',
control: 'select',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* global jest, test, describe, it, expect */

import React from 'react';
import Focusedzone from '../Focusedzone';
import { render } from '@testing-library/react';
import Focusedzone from '../Focusedzone';

test('Focusedzone.render() renders with children', () => {
const { container } = render(
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Form/tests/Form-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* global jest, test, expect */

import React from 'react';
import { Component as Form } from '../Form';
import { render, screen } from '@testing-library/react';
import { Component as Form } from '../Form';

function makeProps(obj = {}) {
return {
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/FormAction/tests/FormAction-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* global jest, test, describe, it, expect, beforeEach */

import FormAction from '../FormAction';
import React from 'react';
import { render } from '@testing-library/react';
import FormAction from '../FormAction';

test('FormAction.isPrimary() detects via the name if the button should be primary', () => {
const { container } = render(
Expand Down
1 change: 0 additions & 1 deletion client/src/components/FormAlert/tests/FormAlert-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ _FormAlert.args = {
value: "This is a 'success'/'good' alert"
};


export const Types = () => (
<div>
<FormAlert type="success" value="This is a 'success'/'good' alert" />
Expand Down
1 change: 0 additions & 1 deletion client/src/components/FormBuilder/FormBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ class FormBuilder extends Component {
throw Error(`Component not found in injector: ${componentProps.schemaComponent}`);
}


// Provides container components a place to hook in
// and apply customisations to scaffolded components.
const createFn = this.props.createFn;
Expand Down
4 changes: 1 addition & 3 deletions client/src/components/FormBuilder/tests/FormBuilder-test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/* global jest, test, describe, expect, it, beforeEach */

import React from 'react';
import { Component as FormBuilder } from '../FormBuilder';
import schemaFieldValues, { findField, schemaMerge } from 'lib/schemaFieldValues';
import { render } from '@testing-library/react';

const apiMock = jest.fn();
apiMock.mockImplementation(() => Promise.resolve({}));
Expand Down Expand Up @@ -57,7 +55,7 @@ function makeSchema() {
}
};
}

/* eslint-disable-next-line no-unused-vars */
function makePropsWithSchema(obj = {}) {
return makeProps({
...makeSchema(),
Expand Down
Loading