Skip to content

Commit

Permalink
refactor: Updated frontend-build to v12 (#270)
Browse files Browse the repository at this point in the history
* refactor: updated frontend-build to v12 & resolved eslint issues
  • Loading branch information
BilalQamar95 committed Jan 24, 2023
1 parent cb25fee commit 5f7e948
Show file tree
Hide file tree
Showing 18 changed files with 1,552 additions and 1,609 deletions.
3,102 changes: 1,518 additions & 1,584 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/catalog-search/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-extraneous-dependencies
const { createConfig } = require('@edx/frontend-build');
const extendESLintConfig = require('../../common/extendESLintConfig');

Expand Down
2 changes: 1 addition & 1 deletion packages/catalog-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"devDependencies": {
"@edx/browserslist-config": "1.1.0",
"@edx/frontend-build": "11.0.1",
"@edx/frontend-build": "12.3.0",
"@edx/frontend-platform": "1.15.6",
"@edx/paragon": "19.25.1",
"@fortawesome/free-solid-svg-icons": "5.8.1",
Expand Down
1 change: 0 additions & 1 deletion packages/catalog-search/src/SearchSuggestionItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ SearchSuggestionItem.propTypes = {
key: PropTypes.string,
title: PropTypes.string,
program_type: PropTypes.string,
authoring_organizations: PropTypes.array,
_highlightResult: PropTypes.shape({ title: PropTypes.shape({ value: PropTypes.string }) }),
}).isRequired,
disableSuggestionRedirect: PropTypes.bool.isRequired,
Expand Down
4 changes: 3 additions & 1 deletion packages/catalog-search/src/SearchSuggestions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ const SearchSuggestions = ({
};

SearchSuggestions.propTypes = {
autoCompleteHits: PropTypes.arrayOf(PropTypes.object).isRequired,
autoCompleteHits: PropTypes.arrayOf(PropTypes.shape({
content_type: PropTypes.string,
})).isRequired,
enterpriseSlug: PropTypes.string,
handleSubmit: PropTypes.func,
handleSuggestionClickSubmit: PropTypes.func,
Expand Down
2 changes: 1 addition & 1 deletion packages/catalog-search/src/data/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from './actions';
import { QUERY_PARAMS_TO_IGNORE } from './constants';

export const refinementsReducer = (state = {}, action) => {
export const refinementsReducer = (state = {}, action = {}) => {
const nextState = { ...state };
switch (action.type) {
case DELETE_REFINEMENT:
Expand Down
2 changes: 1 addition & 1 deletion packages/catalog-search/src/tests/FacetListBase.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ describe('<FacetListBase />', () => {
fireEvent.change(screen.queryByPlaceholderText('Find a skill...'), { target: { value: 'Blockchain' } });
});

await new Promise((r) => setTimeout(r, 210));
await new Promise((r) => { setTimeout(r, 210); });

expect(searchableDropdownProps.searchForItems).toHaveBeenCalledTimes(1);
expect(searchableDropdownProps.searchForItems).toHaveBeenCalledWith('Blockchain');
Expand Down
17 changes: 11 additions & 6 deletions packages/catalog-search/src/tests/SearchFilters.test.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useMemo } from 'react';
import { screen } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import { breakpoints, ResponsiveContext } from '@edx/paragon';
Expand All @@ -9,13 +9,18 @@ import { renderWithSearchContext } from './utils';
import '../../__mocks__/react-instantsearch-dom';
import SearchFilters from '../SearchFilters';

const SearchContextWrapper = () => {
const contextValue = useMemo(() => ({ width: breakpoints.large.maxWidth }), []);
return (
<ResponsiveContext.Provider value={contextValue}>
<SearchFilters />
</ResponsiveContext.Provider>
);
};

describe('<SearchFilters />', () => {
test('renders with a label', () => {
renderWithSearchContext(
<ResponsiveContext.Provider value={{ width: breakpoints.large.maxWidth }}>
<SearchFilters />
</ResponsiveContext.Provider>,
);
renderWithSearchContext(<SearchContextWrapper />);
SEARCH_FACET_FILTERS.forEach((filter) => {
expect(screen.getByText(filter.title)).toBeInTheDocument();
});
Expand Down
9 changes: 4 additions & 5 deletions packages/catalog-search/src/tests/SearchPagination.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ describe('<SearchPagination />', () => {
expect(history.location.search).toEqual('');
});
test('updates page query when navigating left to a previous page', () => {
const { history } = renderWithRouter(
const { history } = renderWithRouter((
<SearchData>
<SearchPaginationBase nbPages={4} currentRefinement={3} />
</SearchData>, {
route: 'search/?page=3',
},
);
</SearchData>), {
route: 'search/?page=3',
});

// assert SearchData adds showAll
expect(history.location.search).toEqual('?page=3');
Expand Down
1 change: 1 addition & 0 deletions packages/hotjar/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-extraneous-dependencies
const { createConfig } = require('@edx/frontend-build');
const extendESLintConfig = require('../../common/extendESLintConfig');

Expand Down
2 changes: 1 addition & 1 deletion packages/hotjar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"sideEffects": false,
"devDependencies": {
"@edx/browserslist-config": "1.1.0",
"@edx/frontend-build": "11.0.1",
"@edx/frontend-build": "12.3.0",
"react": "16.14.0",
"react-dom": "16.14.0",
"react-router-dom": "5.2.0"
Expand Down
1 change: 1 addition & 0 deletions packages/logistration/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-extraneous-dependencies
const { createConfig } = require('@edx/frontend-build');
const extendESLintConfig = require('../../common/extendESLintConfig');

Expand Down
2 changes: 1 addition & 1 deletion packages/logistration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"devDependencies": {
"@edx/browserslist-config": "1.1.0",
"@edx/frontend-build": "11.0.1",
"@edx/frontend-build": "12.3.0",
"@edx/frontend-platform": "1.15.6",
"@testing-library/jest-dom": "5.11.6",
"@testing-library/react": "11.2.6",
Expand Down
6 changes: 4 additions & 2 deletions packages/logistration/src/LoginRedirect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { getProxyLoginUrl } from './utils';
* @param {node} children The child nodes to render if there is an authenticated user.
* @param {element} loadingDisplay A React element to display while authenticated user is loading
*/
export default function LoginRedirect({ children, loadingDisplay: LoadingDisplay }) {
const LoginRedirect = ({ children, loadingDisplay: LoadingDisplay }) => {
const {
enterpriseSlug,
enterpriseCustomerInviteKey,
Expand All @@ -27,7 +27,7 @@ export default function LoginRedirect({ children, loadingDisplay: LoadingDisplay
global.location.href = getProxyLoginUrl(enterpriseSlug, enterpriseCustomerInviteKey);

return LoadingDisplay;
}
};

LoginRedirect.propTypes = {
children: PropTypes.node,
Expand All @@ -38,3 +38,5 @@ LoginRedirect.defaultProps = {
children: null,
loadingDisplay: null,
};

export default LoginRedirect;
1 change: 1 addition & 0 deletions packages/utils/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-extraneous-dependencies
const { createConfig } = require('@edx/frontend-build');
const extendESLintConfig = require('../../common/extendESLintConfig');

Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"devDependencies": {
"@edx/browserslist-config": "1.1.0",
"@edx/frontend-build": "11.0.1",
"@edx/frontend-build": "12.3.0",
"@edx/frontend-platform": "1.15.6",
"react": "16.14.0",
"react-dom": "16.14.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ export const sendEnterpriseTrackEventWithDelay = (
eventName,
properties,
);
return new Promise((resolve) => setTimeout(resolve, delay));
return new Promise((resolve) => { setTimeout(resolve, delay); });
};
4 changes: 1 addition & 3 deletions packages/utils/src/test-utils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ export const renderWithRouter = (
} = {},
) => {
// eslint-disable-next-line react/prop-types
const Wrapper = ({ children }) => (
<Router history={history}>{children}</Router>
);
const Wrapper = ({ children }) => <Router history={history}>{children}</Router>;
return {
...render(ui, { wrapper: Wrapper }),
// adding `history` to the returned utilities to allow us
Expand Down

0 comments on commit 5f7e948

Please sign in to comment.