Skip to content
This repository was archived by the owner on Jan 16, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"arrow": "parens",
"condition": "parens",
"logical": "parens",
"prop": "parens"
"prop": "ignore"
}],
"react/jsx-boolean-value": ["error", "always"],
"react/jsx-closing-tag-location": ["error"],
Expand All @@ -83,7 +83,7 @@
"react/jsx-indent": ["error", 2],
"react/jsx-indent-props": ["error", 2],
"react/jsx-key": ["error"],
"react/jsx-max-depth": ["error", { "max": 2}],
"react/jsx-max-depth":["error", { "max": 5}],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆

"react/jsx-max-props-per-line": ["error", {"maximum": 3, "when": "multiline" }],
"react/jsx-no-bind": ["error"],
"react/jsx-no-comment-textnodes": ["error"],
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
"typescriptreact"
],
"typescript.tsdk": "node_modules/typescript/lib"
}
}
1 change: 1 addition & 0 deletions jest/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'raf/polyfill';
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { GlobalWithFetchMock } from 'jest-fetch-mock';
import 'mutationobserver-shim';

// @ts-ignore : Only a void function can be called with the 'new' keyword
configure({ adapter: new Adapter() });
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"lockfile-lint": "3.0.3",
"lodash": "^4.17.15",
"mini-css-extract-plugin": "0.8.0",
"mutationobserver-shim": "0.3.3",
"node-mocks-http": "1.8.0",
"normalize.css": "8.0.1",
"optimize-css-assets-webpack-plugin": "5.0.3",
Expand All @@ -96,6 +97,7 @@
"react": "16.12.0",
"react-autosuggest": "9.4.3",
"react-dom": "16.12.0",
"react-hook-form": "3.28.12",
"react-hot-loader": "4.12.18",
"react-router-dom": "5.1.2",
"request": "2.88.0",
Expand Down Expand Up @@ -136,7 +138,7 @@
"bundlesize": [
{
"path": "./static/vendors.*.js",
"maxSize": "180 kB"
"maxSize": "185 kB"
},
{
"path": "./static/main.*.js",
Expand Down Expand Up @@ -213,6 +215,5 @@
"type": "opencollective",
"url": "https://opencollective.com/verdaccio",
"logo": "https://opencollective.com/verdaccio/logo.txt"
},
"dependencies": {}
}
}
1 change: 0 additions & 1 deletion src/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const StyledBoxContent = styled(Box)({
},
});

/* eslint-disable react/jsx-max-depth */
/* eslint-disable react/jsx-no-bind */
/* eslint-disable react-hooks/exhaustive-deps */
const App: React.FC = () => {
Expand Down
4 changes: 0 additions & 4 deletions src/App/AppContext.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { createContext } from 'react';

import { FormError } from '../components/Login/Login';

export interface AppProps {
error?: FormError;
user?: User;
scope: string;
packages: any[];
Expand All @@ -15,7 +12,6 @@ export interface User {

export interface AppContextProps extends AppProps {
setUser: (user?: User) => void;
setError: (error?: FormError) => void;
}

const AppContext = createContext<undefined | AppContextProps>(undefined);
Expand Down
10 changes: 0 additions & 10 deletions src/App/AppContextProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React, { useState, useEffect } from 'react';

import { FormError } from '../components/Login/Login';

import AppContext, { AppProps, User } from './AppContext';

interface Props {
Expand Down Expand Up @@ -38,19 +36,11 @@ const AppContextProvider: React.FC<Props> = ({ children, packages, user }) => {
});
};

const setError = (error?: FormError) => {
setState({
...state,
error,
});
};

return (
<AppContext.Provider
value={{
...state,
setUser,
setError,
}}>
{children}
</AppContext.Provider>
Expand Down
1 change: 0 additions & 1 deletion src/App/AppRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const history = createBrowserHistory({
basename: window.__VERDACCIO_BASENAME_UI_OPTIONS && window.__VERDACCIO_BASENAME_UI_OPTIONS.url_prefix,
});

/* eslint react/jsx-max-depth: 0 */
const AppRoute: React.FC = () => {
const appContext = useContext(AppContext);

Expand Down
1 change: 0 additions & 1 deletion src/components/ActionBar/ActionBarAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export interface ActionBarActionProps {
}

/* eslint-disable react/jsx-no-bind */
/* eslint-disable react/jsx-max-depth */
const ActionBarAction: React.FC<ActionBarActionProps> = ({ type, link }) => {
switch (type) {
case 'VISIT_HOMEPAGE':
Expand Down
3 changes: 0 additions & 3 deletions src/components/Dist/Dist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@ import { StyledText, DistListItem, DistChips } from './styles';
const DistChip: FC<{ name: string }> = ({ name, children }) =>
children ? (
<DistChips
// lint rule conflicting with prettier
/* eslint-disable react/jsx-wrap-multilines */
label={
<>
<b>{name}</b>
{': '}
{children}
</>
}
/* eslint-enable */
/>
) : null;

Expand Down
2 changes: 0 additions & 2 deletions src/components/Engines/Engines.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const Engine: React.FC = () => {
return null;
}

/* eslint-disable react/jsx-max-depth */
return (
<Grid container={true}>
{engines.node && (
Expand All @@ -45,7 +44,6 @@ const Engine: React.FC = () => {
)}
</Grid>
);
/* eslint-enable react/jsx-max-depth */
};

export default Engine;
7 changes: 3 additions & 4 deletions src/components/Header/Header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('<Header /> component with logged in state', () => {
});

test('should open login dialog', async () => {
const { getByText, getByTestId } = render(
const { getByText } = render(
<Router>
<AppContextProvider packages={props.packages}>
<Header />
Expand All @@ -54,9 +54,8 @@ describe('<Header /> component with logged in state', () => {

const loginBtn = getByText('Login');
fireEvent.click(loginBtn);
// wait for login modal appearance and return the element
const registrationInfoModal = await waitForElement(() => getByTestId('login--form-container'));
expect(registrationInfoModal).toBeTruthy();
const loginDialog = await waitForElement(() => getByText('Sign in'));
expect(loginDialog).toBeTruthy();
});

test('should logout the user', async () => {
Expand Down
33 changes: 3 additions & 30 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import React, { useState, useContext } from 'react';

import storage from '../../utils/storage';
import { getRegistryURL } from '../../utils/url';
import { makeLogin } from '../../utils/login';
import Button from '../../muiComponents/Button';
import AppContext from '../../App/AppContext';
import LoginModal from '../Login';
import LoginDialog from '../LoginDialog';
import Search from '../Search';

import { NavBar, InnerNavBar, MobileNavBar, InnerMobileNavBar } from './styles';
Expand All @@ -17,7 +16,6 @@ interface Props {
withoutSearch?: boolean;
}

/* eslint-disable react/jsx-max-depth */
/* eslint-disable react/jsx-no-bind*/
const Header: React.FC<Props> = ({ withoutSearch }) => {
const appContext = useContext(AppContext);
Expand All @@ -29,29 +27,9 @@ const Header: React.FC<Props> = ({ withoutSearch }) => {
throw Error('The app Context was not correct used');
}

const { user, scope, error, setUser, setError } = appContext;
const { user, scope, setUser } = appContext;
const logo = window.VERDACCIO_LOGO;

/**
* handles login
* Required by: <Header />
*/
const handleDoLogin = async (usernameValue: string, passwordValue: string) => {
const { username, token, error } = await makeLogin(usernameValue, passwordValue);

if (username && token) {
storage.setItem('username', username);
storage.setItem('token', token);
setUser({ username });
setShowLoginModal(false);
}

if (error) {
setUser(undefined);
setError(error);
}
};

/**
* Logouts user
* Required by: <Header />
Expand Down Expand Up @@ -93,12 +71,7 @@ const Header: React.FC<Props> = ({ withoutSearch }) => {
</Button>
</MobileNavBar>
)}
<LoginModal
error={error}
onCancel={() => setShowLoginModal(false)}
onSubmit={handleDoLogin}
visibility={showLoginModal}
/>
{!user && <LoginDialog onClose={() => setShowLoginModal(false)} open={showLoginModal} />}
</>
);
};
Expand Down
1 change: 0 additions & 1 deletion src/components/Header/HeaderMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ interface Props {
onLoggedInMenuClose: () => void;
}

/* eslint-disable react/jsx-max-depth */
const HeaderMenu: React.FC<Props> = ({
onLogout,
username,
Expand Down
127 changes: 0 additions & 127 deletions src/components/Login/Login.test.tsx

This file was deleted.

Loading