feat: upgraded to node v18, added .nvmrc and updated workflows (#281)

Co-authored-by: Abdullah Waheed <abdullah.waheed@arbisoft.com>
This commit is contained in:
Bilal Qamar
2023-05-26 18:52:56 +05:00
committed by GitHub
parent d80b6faaad
commit 2199a24dd7
32 changed files with 6392 additions and 48055 deletions

View File

@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-extraneous-dependencies
const { createConfig } = require('@edx/frontend-build');
const config = createConfig('eslint', {
@@ -5,23 +6,24 @@ const config = createConfig('eslint', {
'import/no-named-as-default': 'off',
'import/no-named-as-default-member': 'off',
'import/no-self-import': 'off',
'spaced-comment': ['error', 'always', { 'block': { 'exceptions': ['*'] } }],
'spaced-comment': ['error', 'always', { block: { exceptions: ['*'] } }],
'react-hooks/rules-of-hooks': 'off',
'react-hooks/exhaustive-deps': 'off',
'radix': 'off',
'no-promise-executor-return': 'off',
radix: 'off',
},
});
config.settings = {
"import/resolver": {
'import/resolver': {
alias: {
map: [
['editors', './src/editors'],
],
},
node: {
paths: ["editors", "node_modules"],
extensions: [".js", ".jsx"],
paths: ['editors', 'node_modules'],
extensions: ['.js', '.jsx'],
},
},
};

View File

@@ -10,5 +10,4 @@ on:
jobs:
version-check:
uses: edx/.github/.github/workflows/lockfileversion-check.yml@master
uses: edx/.github/.github/workflows/lockfileversion-check-v3.yml@master

2
.nvmrc
View File

@@ -1 +1 @@
v16
18

29825
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -38,8 +38,8 @@
"homepage": "https://github.com/edx/frontend-lib-content-components#readme",
"devDependencies": {
"@edx/browserslist-config": "^1.1.1",
"@edx/frontend-build": "^11.0.2",
"@edx/frontend-platform": "2.4.0",
"@edx/frontend-build": "12.8.27",
"@edx/frontend-platform": "4.2.0",
"@edx/paragon": "^20.32.0",
"@edx/reactifex": "^2.1.1",
"@testing-library/dom": "^8.13.0",
@@ -67,6 +67,7 @@
"@codemirror/lint": "^6.2.1",
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"@edx/browserslist-config": "^1.1.1",
"@reduxjs/toolkit": "^1.8.1",
"@tinymce/tinymce-react": "^3.14.0",
"babel-polyfill": "6.26.0",
@@ -91,7 +92,7 @@
"xmlchecker": "^0.1.0"
},
"peerDependencies": {
"@edx/frontend-platform": ">1.15.0",
"@edx/frontend-platform": "^4.0.0",
"@edx/paragon": "^20.27.0",
"prop-types": "^15.5.10",
"react": "^16.14.0",

View File

@@ -1,15 +1,13 @@
import React from 'react';
function Placeholder() {
return (
<div className="Placeholder">
<h1>
Under Construction
<br />
Coming Soon
</h1>
</div>
);
}
const Placeholder = () => (
<div className="Placeholder">
<h1>
Under Construction
<br />
Coming Soon
</h1>
</div>
);
export default Placeholder;

View File

@@ -31,6 +31,7 @@ EditableHeader.defaultProps = {
EditableHeader.propTypes = {
inputRef: PropTypes.oneOfType([
PropTypes.func,
// eslint-disable-next-line react/forbid-prop-types
PropTypes.shape({ current: PropTypes.any }),
]),
handleChange: PropTypes.func.isRequired,

View File

@@ -129,6 +129,7 @@ describe('TitleHeader hooks', () => {
output = hooks.localTitleHooks({ dispatch });
});
afterEach(() => {
// eslint-disable-next-line no-import-assign
hooks.hooks = oldHooks;
});
it('returns isEditing, startEditing, and stopEditing, tied to the isEditing hook', () => {

View File

@@ -18,7 +18,9 @@ jest.mock('@edx/frontend-platform/i18n', () => ({
getLocale: jest.fn(),
}));
jest.mock('./AnswerOption', () => () => <div>MockAnswerOption</div>);
jest.mock('./AnswerOption', () => function () {
return <div>MockAnswerOption</div>;
});
jest.mock('../../../../../data/redux', () => ({
actions: {

View File

@@ -50,6 +50,7 @@ export const SettingsWidget = ({
</div>
);
}
// eslint-disable-next-line react/jsx-no-useless-fragment
return (<></>);
};

View File

@@ -25,9 +25,7 @@ describe('RandomizationCard', () => {
describe('behavior', () => {
it(' calls generalFeedbackHooks with props when initialized', () => {
shallow(<GeneralFeedbackCard {...props} />);
expect(generalFeedbackHooks).toHaveBeenCalledWith(
props.generalFeedback, props.updateSettings,
);
expect(generalFeedbackHooks).toHaveBeenCalledWith(props.generalFeedback, props.updateSettings);
});
});

View File

@@ -15,9 +15,10 @@ jest.mock('@edx/frontend-platform/i18n', () => ({
)),
}));
jest.mock('../../SettingsOption', () => ({ children, summary }) => (
<div className="SettingsOption" data-testid="Settings-Option">{summary}{children}</div>
));
// eslint-disable-next-line react/prop-types
jest.mock('../../SettingsOption', () => function ({ children, summary }) {
return <div className="SettingsOption" data-testid="Settings-Option">{summary}{children}</div>;
});
jest.mock('@edx/paragon', () => ({
Alert: jest.fn(({ children }) => (

View File

@@ -66,7 +66,7 @@ ProblemEditor.propTypes = {
studioViewFinished: PropTypes.bool.isRequired,
problemType: PropTypes.string.isRequired,
initializeProblemEditor: PropTypes.func.isRequired,
blockValue: PropTypes.objectOf(PropTypes.object).isRequired,
blockValue: PropTypes.objectOf(PropTypes.shape({})).isRequired,
};
export const mapStateToProps = (state) => ({

View File

@@ -14,6 +14,7 @@ export const MAX_WIDTH = 1280;
export const MAX_HEIGHT = 720;
export const MIN_WIDTH = 640;
export const MIN_HEIGHT = 360;
// eslint-disable-next-line no-loss-of-precision
export const ASPECT_RATIO = 1.7777777777777777777;
export const ASPECT_RATIO_ERROR_MARGIN = 0.1;
export default {

View File

@@ -46,6 +46,7 @@ export const Transcript = ({
}) => {
const { inDeleteConfirmation, launchDeleteConfirmation, cancelDelete } = module.hooks.setUpDeleteConfirmation();
return (
// eslint-disable-next-line react/jsx-no-useless-fragment
<>
{inDeleteConfirmation
? (

View File

@@ -1,3 +1,4 @@
/* eslint-disable no-import-assign */
import { RequestStates } from '../../constants/requests';
// import * in order to mock in-file references

View File

@@ -1,3 +1,4 @@
/* eslint-disable no-import-assign */
import { actions } from '..';
import { camelizeKeys } from '../../../utils';
import * as thunkActions from './app';

View File

@@ -174,6 +174,7 @@ describe('requests thunkActions module', () => {
};
describe('network request actions', () => {
beforeEach(() => {
// eslint-disable-next-line no-import-assign
requests.networkRequest = jest.fn(args => ({ networkRequest: args }));
});
describe('fetchBlock', () => {

View File

@@ -256,7 +256,7 @@ export const processVideoIds = ({
};
export const isEdxVideo = (src) => {
const uuid4Regex = new RegExp(/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/);
const uuid4Regex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/;
if (src && src.match(uuid4Regex)) {
return true;
}
@@ -264,7 +264,7 @@ export const isEdxVideo = (src) => {
};
export const parseYoutubeId = (src) => {
const youtubeRegex = new RegExp(/^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube\.com|youtu.be))(\/(?:[\w-]+\?v=|embed\/|v\/)?)([\w-]+)(\S+)?$/);
const youtubeRegex = /^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube\.com|youtu.be))(\/(?:[\w-]+\?v=|embed\/|v\/)?)([\w-]+)(\S+)?$/;
if (!src.match(youtubeRegex)) {
return null;
}

View File

@@ -1,3 +1,4 @@
/* eslint-disable no-import-assign */
import * as utils from '../../../utils';
import * as api from './api';
import * as mockApi from './mockApi';

View File

@@ -45,6 +45,7 @@ export const CodeEditor = ({
CodeEditor.propTypes = {
innerRef: PropTypes.oneOfType([
PropTypes.func,
// eslint-disable-next-line react/forbid-prop-types
PropTypes.shape({ current: PropTypes.any }),
]).isRequired,
value: PropTypes.string.isRequired,

View File

@@ -13,10 +13,12 @@ export const hooks = {
},
dismissalHooks: ({ dismissError, isError }) => {
const [isDismissed, setIsDismissed] = hooks.state.isDismissed(false);
React.useEffect(() => {
setIsDismissed(isDismissed && !isError);
},
[isError]);
React.useEffect(
() => {
setIsDismissed(isDismissed && !isError);
},
[isError],
);
return {
isDismissed,
dismissAlert: () => {

View File

@@ -11,7 +11,9 @@ jest.mock('@edx/frontend-platform/logging', () => ({
}));
// stubbing this to avoid needing to inject a stubbed intl into an internal component
jest.mock('./ErrorPage', () => () => <p>Error Page</p>);
jest.mock('./ErrorPage', () => function () {
return <p>Error Page</p>;
});
describe('ErrorBoundary', () => {
it('should render children if no error', () => {

View File

@@ -129,6 +129,7 @@ ImageUploadModal.propTypes = {
close: PropTypes.func.isRequired,
editorRef: PropTypes.oneOfType([
PropTypes.func,
// eslint-disable-next-line react/forbid-prop-types
PropTypes.shape({ current: PropTypes.any }),
]),
isOpen: PropTypes.bool.isRequired,

View File

@@ -1,3 +1,4 @@
/* eslint-disable no-import-assign */
import React from 'react';
import { shallow } from 'enzyme';

View File

@@ -43,6 +43,7 @@ RawEditor.defaultProps = {
RawEditor.propTypes = {
editorRef: PropTypes.oneOfType([
PropTypes.func,
// eslint-disable-next-line react/forbid-prop-types
PropTypes.shape({ current: PropTypes.any }),
]),
content: PropTypes.oneOfType([

View File

@@ -90,7 +90,7 @@ Gallery.propTypes = {
isLoaded: PropTypes.bool.isRequired,
galleryIsEmpty: PropTypes.bool.isRequired,
searchIsEmpty: PropTypes.bool.isRequired,
displayList: PropTypes.arrayOf(PropTypes.object).isRequired,
displayList: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
highlighted: PropTypes.string,
onHighlightChange: PropTypes.func.isRequired,
emptyGalleryLabel: PropTypes.shape({}).isRequired,

View File

@@ -94,7 +94,7 @@ GalleryCard.propTypes = {
duration: PropTypes.number,
status: PropTypes.string,
statusBadgeVariant: PropTypes.string,
transcripts: PropTypes.array,
transcripts: PropTypes.shape([]),
}).isRequired,
};

View File

@@ -79,20 +79,22 @@ const mockUploadErrorAlertFn = jest.fn();
jest.mock('../BaseModal', () => 'BaseModal');
jest.mock('./SearchSort', () => 'SearchSort');
jest.mock('./Gallery', () => (componentProps) => {
jest.mock('./Gallery', () => function (componentProps) {
mockGalleryFn(componentProps);
return (<div>Gallery</div>);
});
jest.mock('../FileInput', () => (componentProps) => {
jest.mock('../FileInput', () => function (componentProps) {
mockFileInputFn(componentProps);
return (<div>FileInput</div>);
});
jest.mock('../ErrorAlerts/ErrorAlert', () => () => (<div>ErrorAlert</div>));
jest.mock('../ErrorAlerts/FetchErrorAlert', () => (componentProps) => {
jest.mock('../ErrorAlerts/ErrorAlert', () => function () {
return <div>ErrorAlert</div>;
});
jest.mock('../ErrorAlerts/FetchErrorAlert', () => function (componentProps) {
mockFetchErrorAlertFn(componentProps);
return (<div>FetchErrorAlert</div>);
});
jest.mock('../ErrorAlerts/UploadErrorAlert', () => (componentProps) => {
jest.mock('../ErrorAlerts/UploadErrorAlert', () => function (componentProps) {
mockUploadErrorAlertFn(componentProps);
return (<div>UploadErrorAlert</div>);
});

View File

@@ -50,6 +50,7 @@ SourceCodeModal.propTypes = {
close: PropTypes.func.isRequired,
editorRef: PropTypes.oneOfType([
PropTypes.func,
// eslint-disable-next-line react/forbid-prop-types
PropTypes.shape({ current: PropTypes.any }),
]).isRequired,
// injected

24509
www/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -12,9 +12,9 @@
"dependencies": {
"@edx/brand": "npm:@edx/brand-edx.org@^2.0.3",
"@edx/browserslist-config": "1.0.0",
"@edx/frontend-build": "^11.0.0",
"@edx/frontend-build": "12.8.27",
"@edx/frontend-lib-content-components": "file:..",
"@edx/frontend-platform": "2.5.1",
"@edx/frontend-platform": "4.2.0",
"@edx/paragon": "^20.32.0",
"core-js": "^3.21.1",
"dotenv": "^16.0.0",