Skip to content

Commit e7e97fc

Browse files
committed
added eslint rules
1 parent 90abd53 commit e7e97fc

27 files changed

+910
-825
lines changed

.eslintrc.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es6": true
5+
},
6+
"extends": [
7+
"react-app"
8+
],
9+
"rules": {
10+
"template-curly-spacing": "off",
11+
"indent": [
12+
"warn",
13+
2,
14+
{
15+
"ignoredNodes": ["TemplateLiteral"],
16+
"SwitchCase": 1 }
17+
],
18+
"linebreak-style": [
19+
"error",
20+
"unix"
21+
],
22+
"quotes": [
23+
"error",
24+
"single"
25+
],
26+
"arrow-body-style": [
27+
2,
28+
"as-needed"
29+
],
30+
"lines-between-class-members": ["error", "always"] ,
31+
"comma-dangle": [ "error", {
32+
"arrays": "never",
33+
"objects": "never",
34+
"imports": "never",
35+
"exports": "never",
36+
"functions": "ignore"
37+
}],
38+
"no-confusing-arrow": "error",
39+
"no-console": "warn",
40+
"no-use-before-define": 1,
41+
"prefer-template": 2,
42+
"no-restricted-imports": [
43+
"error", { "patterns": [ "../*" ]}
44+
],
45+
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0}],
46+
"max-len": [2, {"code": 120, "tabWidth": 4, "ignoreUrls": true, "comments": 120, "ignorePattern": "import"}],
47+
"arrow-spacing": "error",
48+
"func-call-spacing": ["error", "never"],
49+
"space-infix-ops": ["error", { "int32Hint": false }],
50+
"no-nested-ternary": "error"
51+
}
52+
}

src/App.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
import './App.css';
2-
import { Routes, Route } from "react-router-dom";
3-
import Dashboard from "pages/dashboard";
4-
import Login from "pages/login";
5-
import Register from "pages/register";
6-
import Home from "pages/home";
7-
import ForgotPassword from "pages/forgot-password";
8-
import PasswordReset from "pages/password-reset";
9-
import NotFoundPage from "pages/404";
2+
import { Routes, Route } from 'react-router-dom';
3+
import Dashboard from 'pages/dashboard';
4+
import Login from 'pages/login';
5+
import Register from 'pages/register';
6+
import Home from 'pages/home';
7+
import ForgotPassword from 'pages/forgot-password';
8+
import PasswordReset from 'pages/password-reset';
9+
import NotFoundPage from 'pages/404';
1010

1111
function App() {
12-
return (
13-
<div className="antialiased">
14-
<Routes>
15-
<Route path="/" element={<Home />} />
16-
<Route path="/login" element={<Login />} />
17-
<Route path="/register" element={<Register />} />
18-
<Route path="/forgot-password" element={<ForgotPassword />} />
19-
<Route path="/password-reset/:token" element={<PasswordReset />} />
20-
<Route path="/dashboard" element={<Dashboard />} />
21-
<Route path="*" element={<NotFoundPage/>}
22-
/>
23-
</Routes>
24-
</div>
25-
);
12+
return (
13+
<div className="antialiased">
14+
<Routes>
15+
<Route path="/" element={<Home />} />
16+
<Route path="/login" element={<Login />} />
17+
<Route path="/register" element={<Register />} />
18+
<Route path="/forgot-password" element={<ForgotPassword />} />
19+
<Route path="/password-reset/:token" element={<PasswordReset />} />
20+
<Route path="/dashboard" element={<Dashboard />} />
21+
<Route path="*" element={<NotFoundPage/>}
22+
/>
23+
</Routes>
24+
</div>
25+
);
2626
}
2727

2828
export default App;

src/components/ApplicationLogo.js

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/AuthCard.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
const AuthCard = ({ logo, children }) => (
2-
<div className="min-h-screen flex flex-col sm:justify-center items-center pt-6 sm:pt-0 bg-gray-100">
3-
<div>{logo}</div>
4-
<div className="w-full sm:max-w-md mt-6 px-6 py-4 bg-white shadow-md overflow-hidden sm:rounded-lg">
5-
{children}
6-
</div>
2+
<div className="min-h-screen flex flex-col sm:justify-center items-center pt-6 sm:pt-0 bg-gray-100">
3+
<div>{logo}</div>
4+
<div className="w-full sm:max-w-md mt-6 px-6 py-4 bg-white shadow-md overflow-hidden sm:rounded-lg">
5+
{children}
76
</div>
7+
</div>
88
)
99

1010
export default AuthCard

src/components/AuthSessionStatus.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
const AuthSessionStatus = ({ status, className, ...props }) => (
2-
<>
3-
{status && (
4-
<div
5-
className={`${className} font-medium text-sm text-green-600`}
6-
{...props}>
7-
{status}
8-
</div>
9-
)}
10-
</>
2+
<>
3+
{status && (
4+
<div
5+
className={`${className} font-medium text-sm text-green-600`}
6+
{...props}>
7+
{status}
8+
</div>
9+
)}
10+
</>
1111
)
1212

1313
export default AuthSessionStatus
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
const AuthValidationErrors = ({ errors = [], ...props }) => (
2-
<>
3-
{errors.length > 0 && (
4-
<div {...props}>
5-
<div className="font-medium text-red-600">
6-
Whoops! Something went wrong.
7-
</div>
8-
<ul className="mt-3 list-disc list-inside text-sm text-red-600">
9-
{errors.map(error => (
10-
<li key={error}>{error}</li>
11-
))}
12-
</ul>
13-
</div>
14-
)}
15-
</>
2+
<>
3+
{errors.length > 0 && (
4+
<div {...props}>
5+
<div className="font-medium text-red-600">
6+
Whoops! Something went wrong.
7+
</div>
8+
<ul className="mt-3 list-disc list-inside text-sm text-red-600">
9+
{errors.map(error => (
10+
<li key={error}>{error}</li>
11+
))}
12+
</ul>
13+
</div>
14+
)}
15+
</>
1616
)
1717

1818
export default AuthValidationErrors

src/components/Button.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
const Button = ({ type = 'submit', className, ...props }) => (
2-
<button
3-
type={type}
4-
className={`${className} inline-flex items-center px-4 py-2 bg-gray-800 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-gray-700 active:bg-gray-900 focus:outline-none focus:border-gray-900 focus:ring ring-gray-300 disabled:opacity-25 transition ease-in-out duration-150`}
5-
{...props}
6-
/>
2+
<button
3+
type={type}
4+
className={`${className} inline-flex items-center px-4
5+
py-2 bg-gray-800 border border-transparent rounded-md font-semibold
6+
text-xs text-white uppercase tracking-widest hover:bg-gray-700
7+
active:bg-gray-900 focus:outline-none focus:border-gray-900
8+
focus:ring ring-gray-300 disabled:opacity-25 transition ease-in-out duration-150`}
9+
{...props}
10+
/>
711
)
812

913
export default Button

src/components/Dropdown.js

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,59 @@ import React from 'react'
22
import { Menu, Transition } from '@headlessui/react'
33

44
const Dropdown = ({
5-
align = 'right',
6-
width = 48,
7-
contentClasses = 'py-1 bg-white',
8-
trigger,
9-
children,
5+
align = 'right',
6+
width = 48,
7+
contentClasses = 'py-1 bg-white',
8+
trigger,
9+
children
1010
}) => {
11-
let alignmentClasses
11+
let alignmentClasses
1212

13-
switch (width) {
14-
case '48':
15-
width = 'w-48'
16-
break
17-
}
13+
switch (width) {
14+
case '48':
15+
width = 'w-48'
16+
break
17+
}
1818

19-
switch (align) {
20-
case 'left':
21-
alignmentClasses = 'origin-top-left left-0'
22-
break
23-
case 'top':
24-
alignmentClasses = 'origin-top'
25-
break
26-
case 'right':
27-
default:
28-
alignmentClasses = 'origin-top-right right-0'
29-
break
30-
}
19+
switch (align) {
20+
case 'left':
21+
alignmentClasses = 'origin-top-left left-0'
22+
break
23+
case 'top':
24+
alignmentClasses = 'origin-top'
25+
break
26+
case 'right':
27+
default:
28+
alignmentClasses = 'origin-top-right right-0'
29+
break
30+
}
3131

32-
return (
33-
<Menu as="div" className="relative">
34-
{({ open }) => (
35-
<>
36-
<Menu.Button as={React.Fragment}>{trigger}</Menu.Button>
37-
<Transition
38-
show={open}
39-
enter="transition ease-out duration-200"
40-
enterFrom="transform opacity-0 scale-95"
41-
enterTo="transform opacity-100 scale-100"
42-
leave="transition ease-in duration-75"
43-
leaveFrom="transform opacity-100 scale-100"
44-
leaveTo="transform opacity-0 scale-95"
45-
>
46-
<div className={`absolute z-50 mt-2 ${width} rounded-md shadow-lg ${alignmentClasses}`}>
47-
<Menu.Items className={`rounded-md focus:outline-none ring-1 ring-black ring-opacity-5 ${contentClasses}`} static>
48-
{children}
49-
</Menu.Items>
50-
</div>
51-
</Transition>
52-
</>
53-
)}
54-
</Menu>
55-
)
32+
return (
33+
<Menu as="div" className="relative">
34+
{({ open }) => (
35+
<>
36+
<Menu.Button as={React.Fragment}>{trigger}</Menu.Button>
37+
<Transition
38+
show={open}
39+
enter="transition ease-out duration-200"
40+
enterFrom="transform opacity-0 scale-95"
41+
enterTo="transform opacity-100 scale-100"
42+
leave="transition ease-in duration-75"
43+
leaveFrom="transform opacity-100 scale-100"
44+
leaveTo="transform opacity-0 scale-95"
45+
>
46+
<div className={`absolute z-50 mt-2 ${width} rounded-md shadow-lg ${alignmentClasses}`}>
47+
<Menu.Items
48+
className={`rounded-md focus:outline-none ring-1 ring-black ring-opacity-5 ${contentClasses}`}
49+
static>
50+
{children}
51+
</Menu.Items>
52+
</div>
53+
</Transition>
54+
</>
55+
)}
56+
</Menu>
57+
)
5658
}
5759

5860
export default Dropdown

src/components/DropdownLink.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
import { Menu } from '@headlessui/react'
2-
import { NavLink } from "react-router-dom";
2+
import { NavLink } from 'react-router-dom';
33

44
const DropdownLink = ({ children, ...props }) => (
5-
<Menu.Item>{({ active }) => (
6-
<NavLink
7-
{...props}
8-
className={`w-full text-left block px-4 py-2 text-sm leading-5 text-gray-700 ${({isActive}) => isActive ? 'bg-gray-100' : ''} focus:outline-none transition duration-150 ease-in-out`}>
9-
{children}
10-
</NavLink>
11-
)}
12-
</Menu.Item>
5+
<Menu.Item>{({ active }) => (
6+
<NavLink
7+
{...props}
8+
className={`w-full text-left block px-4
9+
py-2 text-sm leading-5 text-gray-700 ${({isActive}) => (isActive ?
10+
'bg-gray-100' : '')} focus:outline-none transition duration-150 ease-in-out`}>
11+
{children}
12+
</NavLink>
13+
)}
14+
</Menu.Item>
1315
)
1416

1517
export const DropdownButton = ({ children, ...props }) => (
16-
<Menu.Item>
17-
{({ active }) => (
18-
<button
19-
className={`w-full text-left block px-4 py-2 text-sm leading-5 text-gray-700 ${active ? 'bg-gray-100' : ''} focus:outline-none transition duration-150 ease-in-out`}
20-
{...props}>
21-
{children}
22-
</button>
18+
<Menu.Item>
19+
{({ active }) => (
20+
<button
21+
className={`w-full text-left block px-4 py-2
22+
text-sm leading-5 text-gray-700 ${active ? 'bg-gray-100' : ''}
23+
focus:outline-none transition duration-150 ease-in-out`}
24+
{...props}>
25+
{children}
26+
</button>
2327
)}
24-
</Menu.Item>
28+
</Menu.Item>
2529
)
2630

2731
export default DropdownLink

src/components/Input.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
const Input = ({ disabled = false, className, ...props }) => (
2-
<input
3-
disabled={disabled}
4-
className={`${className} rounded-md shadow-sm border-gray-300 focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50`}
5-
{...props}
6-
/>
2+
<input
3+
disabled={disabled}
4+
className={`${className} rounded-md shadow-sm border-gray-300
5+
focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50`}
6+
{...props}
7+
/>
78
)
89

910
export default Input

src/components/Label.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
const Label = ({ className, children, ...props }) => (
2-
<label
3-
className={`${className} block font-medium text-sm text-gray-700`}
4-
{...props}>
5-
{children}
6-
</label>
2+
<label
3+
className={`${className} block font-medium text-sm text-gray-700`}
4+
{...props}>
5+
{children}
6+
</label>
77
)
88

99
export default Label

0 commit comments

Comments
 (0)