Skip to content

Commit

Permalink
fix: eslint ci problems
Browse files Browse the repository at this point in the history
  • Loading branch information
johnvente committed Mar 13, 2024
1 parent 7dd8692 commit 50bdf03
Show file tree
Hide file tree
Showing 7 changed files with 1,759 additions and 301 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ dist
docs
node_modules
src/analytics/segment.js
src/react/PluggableComponent
src/react/utils/contextFactory
2,017 changes: 1,731 additions & 286 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"docs": "jsdoc -c jsdoc.json",
"docs-watch": "nodemon -w src -w docs/template -w README.md -e js,jsx --exec npm run docs",
"lint": "fedx-scripts eslint --ext .js --ext .jsx .",
"lint:fix": "fedx-scripts eslint --fix --ext .js --ext .jsx ./src/react/PluggableComponent",
"i18n_extract": "fedx-scripts formatjs extract",
"snapshot": "fedx-scripts jest --updateSnapshot",
"start": "fedx-scripts webpack-dev-server --progress",
Expand All @@ -35,7 +36,7 @@
"devDependencies": {
"@edx/brand": "npm:@openedx/brand-openedx@^1.2.2",
"@edx/browserslist-config": "1.2.0",
"@openedx/frontend-build": "git+https://github.com/johnvente/frontend-build.git#jv/feat-ui-slot-config",
"@openedx/frontend-build": "git+https://github.com/eduNEXT/frontend-build.git#jv/feat-ui-slot-config",
"@openedx/paragon": "22.1.1",
"@testing-library/jest-dom": "6.4.2",
"@testing-library/react": "12.1.5",
Expand Down
6 changes: 3 additions & 3 deletions src/react/PluggableComponent/MultiplePlugins.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import PropTypes from 'prop-types';

import { isPluginAvailable, getPluginsByPrefix } from './utils';

const MultiplePlugins = ({
function MultiplePlugins({
plugins,
pluggableComponentProps,
prefix,
loadingComponent,
containerPluginsProps,
}) => {
}) {
const [pluginComponents, setPluginComponents] = useState({});
const loadedAllPluginsRef = useRef(null);

Expand Down Expand Up @@ -95,7 +95,7 @@ const MultiplePlugins = ({
))}
</div>
);
};
}

MultiplePlugins.defaultProps = {
plugins: [],
Expand Down
12 changes: 9 additions & 3 deletions src/react/PluggableComponent/MultiplePlugins.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ describe('MultiplePlugins', () => {
{ id: 'plugin1', name: 'any-mfe-plugins-test' },
];

const MockPluginComponent = () => <div data-testid="plugin1">Mocked Plugin Component</div>;
function MockPluginComponent() {
return <div data-testid="plugin1">Mocked Plugin Component</div>;
}

jest.mock(
'@node_modules/@openedx-plugins/any-mfe-plugins-test',
Expand All @@ -55,7 +57,9 @@ describe('MultiplePlugins', () => {
});

test('loads a plugin successfully with prefix', async () => {
const MockPluginComponent = () => <div data-testid="any-mfe-plugins-test">Mocked Plugin Component</div>;
function MockPluginComponent() {
return <div data-testid="any-mfe-plugins-test">Mocked Plugin Component</div>;
}

jest.mock(
'@node_modules/@openedx-plugins/any-mfe-plugins-test',
Expand All @@ -77,7 +81,9 @@ describe('MultiplePlugins', () => {
});

test('loads a plugin successfully with prefix changing component props', async () => {
const MockPluginComponent = (props) => <div data-testid="mock-plugin-props">{props.title}</div>;
function MockPluginComponent(props) {
return <div data-testid="mock-plugin-props">{props.title}</div>;
}

jest.mock(
'@node_modules/@openedx-plugins/any-mfe-plugins-test',
Expand Down
6 changes: 3 additions & 3 deletions src/react/PluggableComponent/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import MultiplePlugins from './MultiplePlugins';
* Useful for passing classNames or styles for layout.
* @returns {React.ReactNode} - Rendered component
*/
const PluggableComponent = ({
function PluggableComponent({
children,
loadingComponent,
as,
Expand All @@ -33,7 +33,7 @@ const PluggableComponent = ({
plugins,
containerPluginsProps,
...pluggableComponentProps
}) => {
}) {
const [newComponent, setNewComponent] = useState(children || null);
const loadedComponentRef = useRef(null);
const [isLoadingComponent, setIsLoadingComponent] = useState(false);
Expand Down Expand Up @@ -109,7 +109,7 @@ const PluggableComponent = ({
}

return newComponent;
};
}

PluggableComponent.defaultProps = {
loadingComponent: null,
Expand Down
14 changes: 9 additions & 5 deletions src/react/PluggableComponent/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
} from '@testing-library/react';
import PluggableComponent from '.';

const ToggleContentComponent = () => {
function ToggleContentComponent() {
const [showContent, setShowContent] = useState(false);

return (
Expand All @@ -15,7 +15,7 @@ const ToggleContentComponent = () => {
{showContent && <div data-testid="toggle-content">Toggle On</div>}
</div>
);
};
}

describe('PluggableComponent', () => {
beforeEach(() => {
Expand Down Expand Up @@ -117,7 +117,7 @@ describe('PluggableComponent', () => {
await waitFor(() => {
expect(screen.getByText('Testing a new title component')).toBeInTheDocument();
});
});
});

test('updates component when children change', async () => {
const { getByText, getByTestId } = render(
Expand Down Expand Up @@ -169,7 +169,9 @@ describe('PluggableComponent', () => {
});

test('renders multiple plugins', async () => {
const MockPluginComponent = () => <div data-testid="plugin-test">Mocked Plugin Component</div>;
function MockPluginComponent() {
return <div data-testid="plugin-test">Mocked Plugin Component</div>;
}

// Mock the dynamic import to resolve with the MockPluginComponent
jest.mock('@node_modules/@openedx-plugins/any-mfe-plugins-test', () => MockPluginComponent, { virtual: true });
Expand All @@ -190,7 +192,9 @@ describe('PluggableComponent', () => {
});

test('renders multiple plugins with prefix', async () => {
const MockPluginComponent = () => <div data-testid="plugin-test">Mocked Plugin Component</div>;
function MockPluginComponent() {
return <div data-testid="plugin-test">Mocked Plugin Component</div>;
}

// Mock the dynamic import to resolve with the MockPluginComponent
jest.mock('@node_modules/@openedx-plugins/any-mfe-plugins-test', () => MockPluginComponent, { virtual: true });
Expand Down

0 comments on commit 50bdf03

Please sign in to comment.