Skip to content
This repository has been archived by the owner on Jan 16, 2022. It is now read-only.

Commit

Permalink
feat(eslint-config): add order rule in import
Browse files Browse the repository at this point in the history
* refactor: added eslint-plugin-import

* refactor: disable some rules for muiComponents

* fix: fixed import
  • Loading branch information
priscilawebdev authored and sergiohgz committed Oct 7, 2019
1 parent 950f6de commit ae73772
Show file tree
Hide file tree
Showing 84 changed files with 149 additions and 94 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Expand Up @@ -3,6 +3,7 @@ coverage/
static/
.github/
.circleci/
build
*.md
*.lock
*.yaml
Expand Down
7 changes: 5 additions & 2 deletions .eslintrc
Expand Up @@ -5,7 +5,8 @@
"plugin:jest/recommended",
"plugin:prettier/recommended",
"plugin:verdaccio/recommended",
"plugin:jsx-a11y/recommended"
"plugin:jsx-a11y/recommended",
"plugin:import/typescript"
],
"plugins": [
"react",
Expand All @@ -14,7 +15,8 @@
"verdaccio",
"jsx-a11y",
"codeceptjs",
"react-hooks"
"react-hooks",
"import"
],
"settings": {
"react": {
Expand All @@ -28,6 +30,7 @@
}
},
"rules": {
"import/order": ["error", {"newlines-between": "always"}],
"babel/no-invalid-this": 0,
"no-invalid-this": 0,
"no-console": ["error", { "allow": ["warn", "error"] }],
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -49,6 +49,7 @@
"enzyme-to-json": "3.4.0",
"eslint": "6.5.1",
"eslint-plugin-codeceptjs": "1.1.0",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-prettier": "3.1.0",
"eslint-plugin-react": "7.14.3",
Expand Down Expand Up @@ -148,7 +149,7 @@
}
],
"scripts": {
"type-check": "tsc --noEmit",
"type-check": "tsc --noEmit --pretty",
"type-check:watch": "npm run type-check -- --watch",
"release": "standard-version -a",
"test:clean": "npx jest --clearCache",
Expand Down
5 changes: 3 additions & 2 deletions src/App/App.test.tsx
@@ -1,10 +1,11 @@
import React from 'react';
import { mount } from 'enzyme';
import storage from '../utils/storage';
import App from './App';

import storage from '../utils/storage';
import { generateTokenWithTimeRange } from '../../jest/unit/components/__mocks__/token';

import App from './App';

jest.mock('../utils/storage', () => {
class LocalStorageMock {
private store: object;
Expand Down
3 changes: 1 addition & 2 deletions src/App/App.tsx
Expand Up @@ -3,7 +3,6 @@ import isNil from 'lodash/isNil';

import storage from '../utils/storage';
import { makeLogin, isTokenExpire } from '../utils/login';

import Loading from '../components/Loading';
import LoginModal from '../components/Login';
import Header from '../components/Header';
Expand All @@ -14,7 +13,7 @@ import 'typeface-roboto/index.css';
import '../utils/styles/global';
import 'normalize.css';
import Footer from '../components/Footer';
import { FormError } from 'src/components/Login/Login';
import { FormError } from '../components/Login/Login';

export const AppContext = React.createContext<{}>({});
export const AppContextProvider = AppContext.Provider;
Expand Down
1 change: 1 addition & 0 deletions src/App/styles.ts
@@ -1,4 +1,5 @@
import { css } from 'emotion';

import colors from '../utils/styles/colors';

export const alertError = css({
Expand Down
1 change: 1 addition & 0 deletions src/components/ActionBar/ActionBar.test.tsx
@@ -1,5 +1,6 @@
import React from 'react';
import { mount } from 'enzyme';

import { ActionBar } from './ActionBar';

const mockPackageMeta: jest.Mock = jest.fn(() => ({
Expand Down
4 changes: 2 additions & 2 deletions src/components/ActionBar/ActionBar.tsx
@@ -1,16 +1,16 @@
import React, { Component, ReactElement } from 'react';

import BugReportIcon from '@material-ui/icons/BugReport';
import DownloadIcon from '@material-ui/icons/CloudDownload';
import HomeIcon from '@material-ui/icons/Home';
import List from '@material-ui/core/List';

import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/Version';
import { Fab, ActionListItem } from './styles';
import { isURL, extractFileName, downloadFile } from '../../utils/url';
import api from '../../utils/api';
import Tooltip from '../../muiComponents/Tooltip';

import { Fab, ActionListItem } from './styles';

export interface Action {
icon: string;
title: string;
Expand Down
5 changes: 2 additions & 3 deletions src/components/Author/Author.tsx
@@ -1,13 +1,12 @@
import React, { FC, useContext } from 'react';

import List from '@material-ui/core/List';

import { DetailContext } from '../../pages/Version';
import { Heading, AuthorListItem, AuthorListItemText } from './styles';
import { isEmail } from '../../utils/url';

import Avatar from '../../muiComponents/Avatar';

import { Heading, AuthorListItem, AuthorListItemText } from './styles';

const Author: FC = () => {
const { packageMeta } = useContext(DetailContext);

Expand Down
3 changes: 2 additions & 1 deletion src/components/Author/styles.ts
@@ -1,9 +1,10 @@
import styled from 'react-emotion';
import ListItem from '@material-ui/core/ListItem';
import Typography from '@material-ui/core/Typography';
import { fontWeight } from '../../utils/styles/sizes';
import ListItemText from '@material-ui/core/ListItemText';

import { fontWeight } from '../../utils/styles/sizes';

export const Heading = styled(Typography)({
'&&': {
fontWeight: fontWeight.bold,
Expand Down
5 changes: 4 additions & 1 deletion src/components/AutoComplete/AutoComplete.tsx
Expand Up @@ -6,6 +6,7 @@ import parse from 'autosuggest-highlight/parse';
import MenuItem from '@material-ui/core/MenuItem';

import { fontWeight } from '../../utils/styles/sizes';

import { Wrapper, InputField, SuggestionContainer } from './styles';

interface Props {
Expand All @@ -27,10 +28,13 @@ interface Props {
onBlur?: (event: KeyboardEvent<HTMLInputElement>) => void;
}

/* eslint-disable react/jsx-sort-props */
/* eslint-disable verdaccio/jsx-spread */
const renderInputComponent = (inputProps): JSX.Element => {
const { ref, startAdornment, disableUnderline, onKeyDown, ...others } = inputProps;
return (
<InputField
fullWidth={true}
InputProps={{
inputRef: node => {
ref(node);
Expand All @@ -39,7 +43,6 @@ const renderInputComponent = (inputProps): JSX.Element => {
disableUnderline,
onKeyDown,
}}
fullWidth={true}
{...others}
/>
);
Expand Down
1 change: 0 additions & 1 deletion src/components/AvatarTooltip/AvatarTooltip.tsx
@@ -1,7 +1,6 @@
import React, { FC } from 'react';

import { isEmail } from '../../utils/url';

import Tooltip from '../../muiComponents/Tooltip';
import Avatar from '../../muiComponents/Avatar';

Expand Down
3 changes: 2 additions & 1 deletion src/components/CopyToClipBoard/styles.ts
@@ -1,6 +1,7 @@
import IconButton from '../../muiComponents/IconButton';
import styled from 'react-emotion';

import IconButton from '../../muiComponents/IconButton';

export const ClipBoardCopy = styled('div')({
'&&': {
display: 'flex',
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dependencies/Dependencies.tsx
Expand Up @@ -3,9 +3,9 @@ import { withRouter, RouteComponentProps } from 'react-router-dom';
import CardContent from '@material-ui/core/CardContent';

import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/Version';
import NoItems from '../NoItems';

import { CardWrap, Heading, Tags, Tag } from './styles';
import NoItems from '../NoItems';

type DepDetailProps = {
name: string;
Expand Down
1 change: 1 addition & 0 deletions src/components/Dependencies/styles.ts
Expand Up @@ -2,6 +2,7 @@ import styled from 'react-emotion';
import Card from '@material-ui/core/Card';
import Typography from '@material-ui/core/Typography';
import Chip from '@material-ui/core/Chip';

import { fontWeight } from '../../utils/styles/sizes';

export const CardWrap = styled(Card)({
Expand Down
1 change: 0 additions & 1 deletion src/components/DetailContainer/DetailContainer.test.tsx
@@ -1,5 +1,4 @@
import React from 'react';

import { render } from '@testing-library/react';

import DetailContainer from './DetailContainer';
Expand Down
@@ -1,7 +1,6 @@
import React from 'react';

import { preventXSS } from '../../utils/sec-utils';

import Readme from '../Readme';

interface Props {
Expand Down
2 changes: 0 additions & 2 deletions src/components/DetailSidebar/DetailSidebar.tsx
@@ -1,5 +1,4 @@
import React, { ReactElement } from 'react';

import Card from '@material-ui/core/Card';
import CardContent from '@material-ui/core/CardContent';
import List from '@material-ui/core/List';
Expand All @@ -11,7 +10,6 @@ import Dist from '../Dist/Dist';
import Engine from '../Engines/Engines';
import Install from '../Install';
import Repository from '../Repository/Repository';

import { DetailContext } from '../../pages/Version';

import { TitleListItem, TitleListItemText, PackageDescription, PackageVersion } from './styles';
Expand Down
4 changes: 3 additions & 1 deletion src/components/Developers/Developers.test.tsx
@@ -1,8 +1,10 @@
import React from 'react';
import { mount } from 'enzyme';

import { DetailContextProvider } from '../../pages/Version';

import Developers, { DevelopersType } from './Developers';
import { Fab } from './styles';
import { DetailContextProvider } from '../../pages/Version';

describe('test Developers', () => {
const packageMeta = {
Expand Down
1 change: 1 addition & 0 deletions src/components/Developers/Developers.tsx
Expand Up @@ -3,6 +3,7 @@ import Add from '@material-ui/icons/Add';

import { DetailContext } from '../../pages/Version';
import { AvatarTooltip } from '../AvatarTooltip';

import { Details, Heading, Content, Fab } from './styles';

export type DevelopersType = 'contributors' | 'maintainers';
Expand Down
1 change: 1 addition & 0 deletions src/components/Dist/Dist.test.tsx
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { mount } from 'enzyme';

import { DetailContext } from '../../pages/Version';

import Dist from './Dist';

const withDistComponent = (packageMeta: React.ContextType<typeof DetailContext>['packageMeta']): JSX.Element => (
Expand Down
4 changes: 2 additions & 2 deletions src/components/Dist/Dist.tsx
@@ -1,12 +1,12 @@
import React, { FC, useContext } from 'react';

import List from '@material-ui/core/List';

import { DetailContext } from '../../pages/Version';
import { Heading, DistListItem, DistChips } from './styles';
import fileSizeSI from '../../utils/file-size';
import { formatLicense } from '../../utils/package';

import { Heading, DistListItem, DistChips } from './styles';

const DistChip: FC<{ name: string }> = ({ name, children }) =>
children ? (
<DistChips
Expand Down
1 change: 1 addition & 0 deletions src/components/Engines/Engines.test.tsx
@@ -1,5 +1,6 @@
import React from 'react';
import { mount } from 'enzyme';

import Engine from './Engines';

jest.mock('./img/node.png', () => '');
Expand Down
6 changes: 2 additions & 4 deletions src/components/Engines/Engines.tsx
@@ -1,17 +1,15 @@
import React, { Component, ReactElement } from 'react';

import Grid from '@material-ui/core/Grid';
import List from '@material-ui/core/List';
import ListItemText from '@material-ui/core/ListItemText';

import { VersionPageConsumerProps, DetailContextConsumer } from '../../pages/Version';
import { Heading, EngineListItem } from './styles';

import Avatar from '../../muiComponents/Avatar';
import npm from '../Install/img/npm.svg';

import { Heading, EngineListItem } from './styles';
// @ts-ignore
import node from './img/node.png';
import npm from '../Install/img/npm.svg';

const ICONS = {
'node-JS': <Avatar src={node} />,
Expand Down
1 change: 1 addition & 0 deletions src/components/Engines/styles.ts
@@ -1,6 +1,7 @@
import styled from 'react-emotion';
import ListItem from '@material-ui/core/ListItem';
import Typography from '@material-ui/core/Typography';

import { fontWeight } from '../../utils/styles/sizes';

export const Heading = styled(Typography)({
Expand Down
3 changes: 2 additions & 1 deletion src/components/Footer/Footer.tsx
@@ -1,8 +1,9 @@
import React from 'react';

import { Wrapper, Left, Right, Earth, Flags, Love, Flag, Logo, Inner, ToolTip } from './styles';
import { goToVerdaccioWebsite } from '../../utils/windows';

import { Wrapper, Left, Right, Earth, Flags, Love, Flag, Logo, Inner, ToolTip } from './styles';

const renderTooltip = (): JSX.Element => (
<ToolTip>
<Earth name="earth" size="md" />
Expand Down
1 change: 1 addition & 0 deletions src/components/Footer/styles.ts
@@ -1,4 +1,5 @@
import styled, { css } from 'react-emotion';

import mq from '../../utils/styles/media';
import Icon from '../Icon/Icon';
import colors from '../../utils/styles/colors';
Expand Down
1 change: 1 addition & 0 deletions src/components/Header/Header.test.tsx
@@ -1,6 +1,7 @@
import React from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
import { shallow } from 'enzyme';

import Header from './Header';

describe('<Header /> component with logged in state', () => {
Expand Down
2 changes: 0 additions & 2 deletions src/components/Header/Header.tsx
@@ -1,7 +1,6 @@
import React, { SyntheticEvent, Component, Fragment, ReactElement } from 'react';
import { Link } from 'react-router-dom';
import { css } from 'emotion';

import MenuItem from '@material-ui/core/MenuItem';
import Menu from '@material-ui/core/Menu';
import Info from '@material-ui/icons/Info';
Expand All @@ -15,7 +14,6 @@ import RegistryInfoDialog from '../RegistryInfoDialog/RegistryInfoDialog';
import Label from '../Label/Label';
import Search from '../Search/Search';
import RegistryInfoContent from '../RegistryInfoContent/RegistryInfoContent';

import IconButton from '../../muiComponents/IconButton';
import Tooltip from '../../muiComponents/Tooltip';
import Button from '../../muiComponents/Button';
Expand Down
1 change: 0 additions & 1 deletion src/components/Header/styles.ts
Expand Up @@ -4,7 +4,6 @@ import Toolbar from '@material-ui/core/Toolbar';

import colors from '../../utils/styles/colors';
import mq from '../../utils/styles/media';

import IconButton from '../../muiComponents/IconButton';
import ExternalLink from '../Link';

Expand Down
1 change: 1 addition & 0 deletions src/components/Help/Help.test.tsx
@@ -1,5 +1,6 @@
import React from 'react';
import { mount } from 'enzyme';

import Help from './Help';

describe('<Help /> component', () => {
Expand Down
1 change: 0 additions & 1 deletion src/components/Icon/Icon.tsx
Expand Up @@ -3,7 +3,6 @@ import capitalize from 'lodash/capitalize';
import { Breakpoint } from '@material-ui/core/styles/createBreakpoints';

import { Svg, Img, ImgWrapper } from './styles';

import brazil from './img/brazil.svg';
import china from './img/china.svg';
import india from './img/india.svg';
Expand Down
2 changes: 1 addition & 1 deletion src/components/Install/Install.test.tsx
Expand Up @@ -2,8 +2,8 @@ import React from 'react';
import { render } from '@testing-library/react';

import { DetailContext, DetailContextProps } from '../../pages/Version';
import data from './__partials__/data.json';

import data from './__partials__/data.json';
import Install from './Install';

const detailContextValue: Partial<DetailContextProps> = {
Expand Down
1 change: 1 addition & 0 deletions src/components/Label/Label.tsx
@@ -1,5 +1,6 @@
import React from 'react';
import styled from 'react-emotion';

import { fontWeight } from '../../utils/styles/sizes';

interface Props {
Expand Down

0 comments on commit ae73772

Please sign in to comment.