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 Jun 28, 2023
1 parent 06d39c2 commit 278451d
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 25 deletions.
6 changes: 3 additions & 3 deletions client/src/boot/registerComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default () => {
(updater) => {
// Add CMS page history GraphQL query to the HistoryViewer
updater.component('HistoryViewer.pages-controller-cms-content', readOnePageQuery, 'PageHistoryViewer');
}
},
);

Injector.transform(
Expand All @@ -24,8 +24,8 @@ export default () => {
// arguments. The "rollback" mutation correctly handles relations and is a more consumable
// API endpoint.
rollbackPageMutation,
'PageRevertMutation'
'PageRevertMutation',
);
}
},
);
};
14 changes: 7 additions & 7 deletions client/src/components/AnchorSelectorField/AnchorSelectorField.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class AnchorSelectorField extends SilverStripeComponent {
// Query endpoint for anchors for this page
const fetchURL = props.data.endpoint.replace(/:id/, props.pageId);
return fetch(fetchURL, { credentials: 'same-origin' })
.then(response => response.json())
.then((response) => response.json())
.then((anchors) => {
// Fold in field anchors and ensure array has only unique values
const allAnchors = [...new Set([...anchors, ...fieldAnchors])];
Expand All @@ -82,9 +82,9 @@ class AnchorSelectorField extends SilverStripeComponent {
* @return {Array}
*/
getDropdownOptions() {
const options = this.props.anchors.map(value => ({ value }));
const options = this.props.anchors.map((value) => ({ value }));
// Ensure value is available in the list
if (this.props.value && !this.props.anchors.find(value => value === this.props.value)) {
if (this.props.value && !this.props.anchors.find((value) => value === this.props.value)) {
options.unshift({ value: this.props.value });
}
return options;
Expand Down Expand Up @@ -153,8 +153,8 @@ AnchorSelectorField.propTypes = {
pageId: PropTypes.number,
anchors: PropTypes.array,
loadingState: PropTypes.oneOf(Object
.keys(anchorSelectorStates)
.map((key) => anchorSelectorStates[key])),
.keys(anchorSelectorStates)
.map((key) => anchorSelectorStates[key])),
onLoadingError: PropTypes.func,
data: PropTypes.shape({
endpoint: PropTypes.string,
Expand All @@ -167,7 +167,7 @@ AnchorSelectorField.defaultProps = {
extraClass: '',
onLoadingError: noop,
attributes: {},
CreatableSelectComponent: CreatableSelect
CreatableSelectComponent: CreatableSelect,
};

function mapStateToProps(state, ownProps) {
Expand All @@ -179,7 +179,7 @@ function mapStateToProps(state, ownProps) {
// Load anchors from page
let anchors = [];
const page = pageId
? state.cms.anchorSelector.pages.find(next => next.id === pageId)
? state.cms.anchorSelector.pages.find((next) => next.id === pageId)
: null;
if (page
&& (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/* global jest, test, describe, beforeEach, it, expect, setTimeout */

import React from 'react';
import { Component as AnchorSelectorField } from '../AnchorSelectorField';
import anchorSelectorStates from 'state/anchorSelector/AnchorSelectorStates';
import { render, screen } from '@testing-library/react';
import { Component as AnchorSelectorField } from '../AnchorSelectorField';

jest.mock('isomorphic-fetch', () =>
() => Promise.resolve({
json: () => ['anchor3', 'anchor4'],
jest.mock('isomorphic-fetch', () => () => Promise.resolve({
json: () => ['anchor3', 'anchor4'],
}));
jest.mock('i18n');

Expand All @@ -24,7 +23,7 @@ function makeProps(obj = {}) {
loadingState: anchorSelectorStates.SUCCESS,
CreatableSelectComponent: ({ options }) => (
<div data-testid="test-creatable-select">
{options.map(option => <div key={option.value} data-option={option.value}/>)}
{options.map((option) => <div key={option.value} data-option={option.value} />)}
</div>
),
...obj,
Expand All @@ -50,7 +49,7 @@ test('AnchorSelectorField componentDidMount() Loads dirty selectors', async () =

test('AnchorSelectorField Merges value with page anchors', async () => {
const beginUpdating = jest.fn();
const { container } = render(<AnchorSelectorField {...makeProps({
render(<AnchorSelectorField {...makeProps({
loadingState: anchorSelectorStates.DIRTY,
actions: {
anchorSelector: {
Expand Down
2 changes: 1 addition & 1 deletion client/src/state/anchorSelector/AnchorSelectorReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function anchorSelectorReducer(state = initialState, action = nul
const id = action.payload.pageId;
return deepFreeze({
pages: [
...state.pages.filter(next => next.id !== id),
...state.pages.filter((next) => next.id !== id),
{
id,
loadingState,
Expand Down
8 changes: 4 additions & 4 deletions client/src/state/history/readOnePageQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const config = {
},
ownProps: {
actions = {
versions: {}
versions: {},
},
limit,
recordId,
Expand All @@ -88,12 +88,12 @@ const config = {
versions: {
...versions,
goToPage(page) {
refetch({
refetch({
offset: ((page || 1) - 1) * limit,
limit,
page_id: recordId,
});
}
});
},
},
},
};
Expand Down
4 changes: 2 additions & 2 deletions client/src/state/history/revertToPageVersionMutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const config = {
},
options: {
// Refetch versions after mutation is completed
refetchQueries: ['ReadHistoryViewerPage']
}
refetchQueries: ['ReadHistoryViewerPage'],
},
};

export { mutation, config };
Expand Down
4 changes: 2 additions & 2 deletions client/src/state/history/rollbackPageMutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const config = {
},
options: {
// Refetch versions after mutation is completed
refetchQueries: ['ReadHistoryViewerPage']
}
refetchQueries: ['ReadHistoryViewerPage'],
},
};

export { mutation, config };
Expand Down

0 comments on commit 278451d

Please sign in to comment.