Skip to content

Commit

Permalink
FIX ESLint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabina Talipova committed Jul 4, 2023
1 parent 82d0389 commit c3051d9
Show file tree
Hide file tree
Showing 226 changed files with 1,556 additions and 1,560 deletions.
4 changes: 2 additions & 2 deletions client/dist/js/bundle.js

Large diffs are not rendered by default.

15 changes: 7 additions & 8 deletions client/src/boot/BootRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import i18n from 'i18n';
import { isDirty } from 'redux-form';
import getFormState from 'lib/getFormState';
import { Route } from 'react-router';
import joinUrlPaths from 'lib/urls';
import { joinUrlPaths } from 'lib/urls';
import NavigationBlocker from '../components/NavigationBlocker/NavigationBlocker';

/**
Expand Down Expand Up @@ -122,19 +122,19 @@ class BootRoutes {
{reactRouteRegister.getChildRoutes().map(
(route) => (
<Route key={route.path} path={route.path} element={<route.component />} />
),
)
)}
</Route>,
</Route>
),
{ basename: joinUrlPaths(Config.get('baseUrl'), Config.get('adminUrl')) },
{ basename: joinUrlPaths(Config.get('baseUrl'), Config.get('adminUrl')) }
);

createRoot(document.getElementsByClassName('cms-content')[0]).render(
<ApolloProvider client={this.client}>
<ReduxProvider store={this.store}>
<RouterProvider router={router} />
</ReduxProvider>
</ApolloProvider>,
</ApolloProvider>
);
}

Expand All @@ -143,7 +143,7 @@ class BootRoutes {
*/
initLegacyRouter() {
const sections = Config.get('sections');
const { store } = this;
const store = this.store;

pageRouter('*', (ctx, next) => {
const msg = this.getUnsavedChangesMessage();
Expand Down Expand Up @@ -193,7 +193,6 @@ class BootRoutes {
// events that should be caught by react component event handlers.
// Note that this empty link is rendered into an element that doesn't exist in the DOM.
const root = createRoot(document.createElement('div'));
// eslint-disable-next-line jsx-a11y/anchor-has-content, jsx-a11y/anchor-is-valid
root.render(<a role="none" onClick={() => {}} />);

// Start the page router
Expand All @@ -212,7 +211,7 @@ class BootRoutes {
const schemas = state.form.formSchemas;

const changedForms = forms.filter((form) => {
const schema = Object.values(schemas).find((item) => item.name === form.name);
const schema = Object.values(schemas).find(item => item.name === form.name);

const notify = schema && schema.state && schema.state.notifyUnsavedChanges;

Expand Down
4 changes: 2 additions & 2 deletions client/src/boot/apollo/buildCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import dataIdFromObject from './dataIdFromObject';
const buildCache = (introspectionQueryResultData) => {
const possibleTypes = {};
if (introspectionQueryResultData) {
introspectionQueryResultData.__schema.types.forEach((supertype) => {
introspectionQueryResultData.__schema.types.forEach(supertype => {
if (supertype.possibleTypes) {
possibleTypes[supertype.name] = supertype.possibleTypes.map((subtype) => subtype.name);
possibleTypes[supertype.name] = supertype.possibleTypes.map(subtype => subtype.name);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/boot/apollo/buildNetworkComponents.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ApolloLink, HttpLink } from '@apollo/client';
import { onError } from '@apollo/client/link/error';
import Config from 'lib/Config';
import joinUrlPaths from 'lib/urls';
import { joinUrlPaths } from 'lib/urls';

const buildNetworkComponents = (baseUrl) => {
const httpLink = new HttpLink({
Expand Down
14 changes: 7 additions & 7 deletions client/src/boot/apollo/getGraphqlFragments.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import fetch from 'isomorphic-fetch';
import joinUrlPaths from 'lib/urls';
import { joinUrlPaths } from 'lib/urls';

const parseResponse = (result) => {
const parseResponse = result => {
const fragmentData = result.data;
fragmentData.__schema.types = fragmentData.__schema.types.filter(
(type) => type.possibleTypes !== null,
type => type.possibleTypes !== null,
);
return fragmentData;
};

const handleError = (response) => {
const handleError = response => {
if (!response.ok) {
throw new Error(
`The types.graphql file could not be loaded. You probably need to run a ?flush to generate it.
Alternatively, you can use the IntrospectionProvider extension to generate the file dynamically.
More information: https://github.com/silverstripe/silverstripe-graphql/#schema-introspection`,
More information: https://github.com/silverstripe/silverstripe-graphql/#schema-introspection`
);
}

Expand Down Expand Up @@ -50,7 +50,7 @@ const getGraphqlFragments = async (baseUrl, preferStatic = true) => {
const fetchConfig = {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Content-Type': 'application/json'
},
uri: baseUrl,
credentials: 'same-origin',
Expand All @@ -59,7 +59,7 @@ const getGraphqlFragments = async (baseUrl, preferStatic = true) => {
const fetchSchema = async (url) => (
fetch(url, fetchConfig)
.then(handleError)
.then((result) => result.json())
.then(result => result.json())
.then(parseResponse)
);

Expand Down
6 changes: 3 additions & 3 deletions client/src/boot/applyTransforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const applyTransforms = () => {
'FieldGroup',
];
fields.forEach((field) => updater.component('FieldGroup', fieldHolder, `${field}Holder`));
},
}
);
Injector.transform(
'form-action-changed',
Expand Down Expand Up @@ -78,13 +78,13 @@ const applyTransforms = () => {
}
return {
...curr,
[key]: errors,
[key]: errors
};
}, {});
Validation.addErrors(errorMap);

return Validation.getState();
},
}
);
});
};
Expand Down
4 changes: 2 additions & 2 deletions client/src/boot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { combineReducers, createStore, applyMiddleware } from 'redux';
import thunkMiddleware from 'redux-thunk';
import Config from 'lib/Config';
import buildApolloClient from 'boot/apollo/buildClient';
import setConfig from 'state/config/ConfigActions';
import { setConfig } from 'state/config/ConfigActions';
import registerComponents from 'boot/registerComponents';
import registerReducers from 'boot/registerReducers';
import applyDevtools from 'boot/applyDevtools';
Expand All @@ -19,7 +19,7 @@ async function appBoot() {
registerComponents();
registerReducers();
const middleware = [
thunkMiddleware,
thunkMiddleware
];
const debugging = Config.get('debugging');
let runMiddleware = applyMiddleware(...middleware);
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
Expand Up @@ -9,7 +9,7 @@ test('Accordion render() renders with children', () => {
<Accordion>
<p>lorem</p>
<p>ipsum</p>
</Accordion>,
</Accordion>
);
expect(container.querySelectorAll('div')).toHaveLength(1);
});
4 changes: 2 additions & 2 deletions client/src/components/Accordion/tests/AccordionBlock-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ test('AccordionBlock render() renders with children', () => {
const { container } = render(
<AccordionBlock {...{
groupid: 123,
title: 'My title',
title: 'My title'
}}
>
<p>lorem</p>
<p>ipsum</p>
</AccordionBlock>,
</AccordionBlock>
);
expect(container.querySelectorAll('div.accordion__block')).toHaveLength(1);
});
6 changes: 3 additions & 3 deletions client/src/components/ActionMenu/ActionMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ActionMenu extends PureComponent {

this.toggle = this.toggle.bind(this);
this.state = {
isOpen: false,
isOpen: false
};
}

Expand Down Expand Up @@ -38,7 +38,7 @@ class ActionMenu extends PureComponent {

const toggleClassName = classnames(
dropdownToggleClassNames,
dropdownToggleProps.className,
dropdownToggleProps.className
);
const menuClassName = classnames('action-menu__dropdown', dropdownMenuProps.className);

Expand Down Expand Up @@ -70,7 +70,7 @@ ActionMenu.defaultProps = {
'btn',
'btn--no-text',
'btn--icon-xl',
'font-icon-dot-3',
'font-icon-dot-3'
],
dropdownToggleProps: {},
dropdownMenuProps: {},
Expand Down
8 changes: 4 additions & 4 deletions client/src/components/ActionMenu/tests/ActionMenu-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ export default {
parameters: {
docs: {
description: {
component: 'ActionMenu Component description.',
component: 'ActionMenu Component description.'
},
canvas: {
sourceState: 'shown',
},
controls: {
sort: 'alpha',
},
},
}
}
},
argTypes: {},
argTypes: {}
};

export const Single = () => (
Expand Down
18 changes: 9 additions & 9 deletions client/src/components/Badge/tests/Badge-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ export default {
title: 'Admin/Badges/Badge',
component: Badge,
decorators: [
jsxDecorator,
jsxDecorator
],
tags: ['autodocs'],
parameters: {
docs: {
description: {
component: 'Badge component for displaying a message in a Bootstrap "badge" style.',
component: 'Badge component for displaying a message in a Bootstrap "badge" style.'
},
canvas: {
sourceState: 'shown',
},
},
}
},
argTypes: {
message: {
Expand All @@ -30,7 +30,7 @@ export default {
table: {
type: { summary: 'success, warning, danger, info, default' },
defaultValue: { summary: 'default' },
},
}
},
inverted: {
description: 'If the colours should be inverted.',
Expand All @@ -45,14 +45,14 @@ export default {
control: 'inline-radio',
options: {
'Empty class name': '',
'badge-pill class name': 'badge-pill',
'badge-pill class name': 'badge-pill'
},
table: {
type: { summary: 'string' },
defaultValue: { summary: 'badge-pill' },
},
},
},
}
}
};

/** Test message */
Expand All @@ -61,6 +61,6 @@ export const _Badge = {
message: 'Hello World!',
status: 'default',
className: 'badge-pill',
inverted: false,
},
inverted: false
}
};
8 changes: 4 additions & 4 deletions client/src/components/Badge/tests/Badge-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ test('Badge render() should return null if status is empty', () => {
<Badge {...{
status: null,
message: '',
className: '',
className: ''
}}
/>,
/>
);
expect(container.querySelector('.badge')).toBeNull();
});
Expand All @@ -21,9 +21,9 @@ test('Badge render() should return a Bootstrap style badge when valid', () => {
<Badge {...{
status: 'success',
message: 'Hello world',
className: 'customclass',
className: 'customclass'
}}
/>,
/>
);
expect(container.querySelectorAll('.badge').length).toBe(1);
expect(container.querySelectorAll('.badge-success').length).toBe(1);
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Breadcrumb/Breadcrumb.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Breadcrumb.propTypes = {
nodeName: PropTypes.string,
className: PropTypes.string,
onClick: PropTypes.func,
})),
}))
})),
};

Expand Down
20 changes: 10 additions & 10 deletions client/src/components/Breadcrumb/tests/Breadcrumb-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,38 +60,38 @@ export default {
title: 'Admin/Breadcrumb',
component: Breadcrumb,
decorators: [
jsxDecorator,
jsxDecorator
],
tags: ['autodocs'],
parameters: {
docs: {
description: {
component: 'The breadcrumbs for the current section of the CMS.',
component: 'The breadcrumbs for the current section of the CMS.'
},
canvas: {
sourceState: 'shown',
},
controls: {
sort: 'alpha',
},
},
}
}
},
argTypes: {
href: {
table: {
type: { summary: 'string' },
},
}
},
text: {
table: {
type: { summary: 'string' },
},
}
},
crumbs: {
description: 'An array of objects, each object should have a `text` and `href` key.',
table: {
type: { summary: 'array' },
},
}
},
level: {
control: 'select',
Expand All @@ -117,12 +117,12 @@ export default {
},
args: {
level: 'First',
icon: '',
},
icon: ''
}
};

export const _Breadcrumb = (args) => {
// eslint-disable-next-line no-shadow
const { level, icon } = args;
return (<Breadcrumb crumbs={buildBreadCrumb(0, level, icon)} />);
return (<Breadcrumb crumbs={buildBreadCrumb(0, level, icon)}/>);
};
Loading

0 comments on commit c3051d9

Please sign in to comment.