Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added linting and prop validation for react functional components #25

Merged
merged 1 commit into from
Nov 22, 2022
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
25 changes: 25 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
env: {
browser: true,
node: true,
commonjs: true,
es2021: true,
jest: true,
},
extends: ['eslint:recommended', 'plugin:react/recommended'],
overrides: [],
parserOptions: {
ecmaVersion: 'latest',
sourceType: "module",
ecmaFeatures: {
jsx: true
}
},
rules: {},
settings: {
react: {
version: "detect"
}
},

};
67 changes: 47 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"test": "jest --",
"eject": "react-scripts eject",
"auth-worker": "wrangler dev ./worker/index",
"auth-worker:login": "wrangler login"
"auth-worker:login": "wrangler login",
"lint": "eslint src/**/*.js"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -44,6 +45,7 @@
},
"devDependencies": {
"eslint": "^8.27.0",
"eslint-plugin-react": "^7.31.11",
"isomorphic-fetch": "^3.0.0",
"jest": "^27.5.1"
},
Expand Down
14 changes: 12 additions & 2 deletions src/AuthDialog.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useRef } from "react";
import React, { useRef } from "react";
import { Button, Form, Modal } from "react-bootstrap";
import PropTypes from 'prop-types';

export default function AuthDialog({ show, setShow, setToken, setRepository }) {
function AuthDialog({ show, setShow, setToken, setRepository }) {
const tokenEl = useRef(null);
const repoEl = useRef(null);

Expand Down Expand Up @@ -63,3 +64,12 @@ export default function AuthDialog({ show, setShow, setToken, setRepository }) {
</Modal>
);
}

AuthDialog.propTypes = {
show: PropTypes.bool,
setToken: PropTypes.func,
setRepository: PropTypes.func,
setShow: PropTypes.func
}

export default AuthDialog
15 changes: 12 additions & 3 deletions src/NavigationBar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Button, Container, Navbar } from "react-bootstrap";
import React, { Button, Container, Navbar } from "react-bootstrap";
import PropTypes from 'prop-types';

export default function NavigationBar({isAuthorized, repository, requestAuthDialog}) {
function NavigationBar({isAuthorized, repository, requestAuthDialog}) {
return <>
<Navbar bg="dark" variant="dark">
<Container className="Nav">
Expand All @@ -26,4 +27,12 @@ export default function NavigationBar({isAuthorized, repository, requestAuthDial
</Container>
</Navbar>
</>
}
}

NavigationBar.propTypes = {
isAuthorized:PropTypes.bool,
repository:PropTypes.string,
requestAuthDialog:PropTypes.func,
}

export default NavigationBar
11 changes: 9 additions & 2 deletions src/UploadInterface.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { useRef, useState } from "react";
import React, { useRef, useState } from "react";
import "./App.css";
import "bootstrap/dist/css/bootstrap.min.css";
import { FileUploader } from "react-drag-drop-files";
import { Button, OverlayTrigger, Tooltip } from "react-bootstrap";
import PropTypes from 'prop-types';

const fileTypes = ["jpg", "jpeg", "png", "bmp", "gif"];

export default function UploadInterface({ isAuthorized }) {
function UploadInterface({ isAuthorized }) {
const [image, setImage] = useState(null);
const imgPreviewEl = useRef(null);

Expand Down Expand Up @@ -63,3 +64,9 @@ export default function UploadInterface({ isAuthorized }) {
</div>
);
}

UploadInterface.propTypes = {
isAuthorized:PropTypes.bool
}

export default UploadInterface