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 #22

Closed
wants to merge 2 commits into from
Closed
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
26 changes: 26 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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"
}
},

};

32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
lint:
name: ESLint
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Setup node ${{matrix.node-version}}
uses: actions/setup-node@v2
with:
node-version: ${{matrix.node-version}}
cache: 'npm'

- name: Install node dependencies
run: npm ci

- name: Run ESLint
run: npm run lint
69 changes: 48 additions & 21 deletions package-lock.json

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

22 changes: 12 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"test": "react-scripts test",
"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 All @@ -23,27 +24,28 @@
"homepage": "https://github.com/humphd/my-photohub/#readme",
"dependencies": {
"@fontsource/poppins": "^4.5.10",
"parcel": "^2.7.0",
"photoswipe": "^5.3.3",
"@octokit/rest": "^19.0.5",
"bootstrap": "^5.2.2",
"eslint": "^8.27.0",
"http-status-codes": "^2.2.0",
"wrangler": "^2.1.15",
"octokit": "^2.0.10",
"@octokit/rest": "^19.0.5",
"parcel": "^2.7.0",
"photoswipe": "^5.3.3",
"react": "^18.2.0",
"bootstrap": "^5.2.2",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"react-bootstrap": "^2.6.0",
"react-dom": "^18.2.0",
"react-drag-drop-files": "^2.3.7",
"react-scripts": "5.0.1",
"workbox-core": "^6.5.4",
"workbox-expiration": "^6.5.4",
"workbox-precaching": "^6.5.4",
"workbox-routing": "^6.5.4",
"workbox-strategies": "^6.5.4"
"workbox-strategies": "^6.5.4",
"wrangler": "^2.1.15"
},
"devDependencies": {
"eslint": "^8.27.0"
"eslint": "^8.27.0",
"eslint-plugin-react": "^7.31.11"
},
"browserslist": {
"production": [
Expand Down
16 changes: 14 additions & 2 deletions src/AuthDialog.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
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 +66,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
16 changes: 13 additions & 3 deletions src/NavigationBar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
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 +28,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