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

Setup husky and lint-staged #69

Merged
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
7 changes: 7 additions & 0 deletions Frontend/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# node node_modules
/node_modules/*

#build artefacts
dist/*
build/*
coverage/*
25 changes: 25 additions & 0 deletions Frontend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
env: {
browser: true,
es2021: true,
node: true,
},
extends: ["plugin:react/recommended", "airbnb", "prettier"],
overrides: [],
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
plugins: ["react", "prettier"],
rules: {
"prettier/prettier": ["error"],
"no-unused-vars": "warn",
"react/no-unescaped-entities": 0,
"jsx-a11y/anchor-is-valid": 0,
"react/button-has-type": 0,
"react/self-closing-comp": "warn",
"import/newline-after-import": "warn",
"import/order": "warn",
"no-console": "warn"
}
}
6 changes: 6 additions & 0 deletions Frontend/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

cd Frontend
yarn lint-staged

4 changes: 4 additions & 0 deletions Frontend/.husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# include other rules here eg. unit tests
5 changes: 5 additions & 0 deletions Frontend/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!include:../.gitignore
node_modules/

# html files
*.html
25 changes: 25 additions & 0 deletions Frontend/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"printWidth": 100,
"trailingComma": "all",
"tabWidth": 2,
"semi": false,
"singleQuote": false,
"arrowParens": "always",
"requirePragma": true,
"endOfLine": "lf",
"overrides": [
{
"files": "*.json",
"options": {
"singleQuote": false
}
},
{
"files": ".*rc",
"options": {
"singleQuote": false,
"parser": "json"
}
}
]
}
4 changes: 4 additions & 0 deletions Frontend/lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
'*.{js,jsx}': ['yarn lint'],
'*.{js,json,css,jsx}': ['yarn format'],
}
58 changes: 39 additions & 19 deletions Frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,41 @@
{
"name": "oscsa",
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.4.2"
},
"devDependencies": {
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"@vitejs/plugin-react": "^2.1.0",
"vite": "^3.1.0"
}
"name": "oscsa",
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"lint": "eslint --fix",
"lint:fix": "eslint --fix */**/*.{jsx,js,tsx} --color",
"lint:check": "eslint */**/*.{jsx,js,tsx} --color",
"prettier": "prettier .",
"format": "prettier --write",
"format:fix": "yarn prettier -- --write",
"format:check": "yarn prettier -- --check",
"prepare": "cd .. && husky install Frontend/.husky",
"lint-staged": "lint-staged --config lint-staged.config.js"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.4.2"
},
"devDependencies": {
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"@vitejs/plugin-react": "^2.1.0",
"eslint": "^7.32.0 || ^8.2.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"prettier": "^2.7.1",
"vite": "^3.1.0"
}
}
9 changes: 5 additions & 4 deletions Frontend/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import "./GlobalStyles.css";
import Layout from "./utils/Routing";
import React from "react"
import "./GlobalStyles.css"
import Layout from "./utils/Routing"

function App() {
return <Layout />;
return <Layout />
}

export default App;
export default App
10 changes: 5 additions & 5 deletions Frontend/src/GlobalStyles.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Poppins", sans-serif;
}
20 changes: 10 additions & 10 deletions Frontend/src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import { BrowserRouter } from "react-router-dom";
import React from "react"
import ReactDOM from "react-dom/client"
import { BrowserRouter } from "react-router-dom"
import App from "./App"

ReactDOM.createRoot(document.getElementById("root")).render(
<React.StrictMode>
<BrowserRouter>
<App />
</BrowserRouter>
</React.StrictMode>
);
<React.StrictMode>
<BrowserRouter>
<App />
</BrowserRouter>
</React.StrictMode>,
)
28 changes: 14 additions & 14 deletions Frontend/src/pages/landing-page/LandingPage.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import React from "react";
import { Link } from "react-router-dom";
import "./landingpage.css";
import React from "react"
import { Link } from "react-router-dom"
import "./landingpage.css"

function LandingPage() {
return (
<div className="landing-page">
<h1>
<Link to="/login">Go to Login Page</Link>
</h1>
return (
<div className="landing-page">
<h1>
<Link to="/login">Go to Login Page</Link>
</h1>

<h1>
<Link to="/signup">Go to Sign Up Page</Link>
</h1>
</div>
);
<h1>
<Link to="/signup">Go to Sign Up Page</Link>
</h1>
</div>
)
}

export default LandingPage;
export default LandingPage
2 changes: 1 addition & 1 deletion Frontend/src/pages/landing-page/landingpage.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@

.landing-page a:hover {
text-decoration: underline;
}
}
99 changes: 50 additions & 49 deletions Frontend/src/pages/login/Login.jsx
Original file line number Diff line number Diff line change
@@ -1,58 +1,59 @@
import React from "react";
import "./login.css";
import { Link } from "react-router-dom";
import React from "react"
import "./login.css"
import { Link } from "react-router-dom"

function Login() {
return (
<div>
<section className="container forms">
<div className="form login">
<div className="form-content">
<header>Login to MOOCs</header>
return (
<div>
<section className="container forms">
<div className="form login">
<div className="form-content">
<header>Login to MOOCs</header>

<div className="media-options">
<a href="#" className="field google">
<img
src="https://cdn-icons-png.flaticon.com/512/2991/2991148.png"
alt=""
className="google-img"
/>
<span>Login with Google</span>
</a>
</div>
<div className="line"></div>
<div className="media-options">
<a href="#" className="field google">
<img
src="https://cdn-icons-png.flaticon.com/512/2991/2991148.png"
alt=""
className="google-img"
/>
<span>Login with Google</span>
</a>
</div>
<div className="line" />

<form action="#">
<div className="field input-field">
<input type="email" placeholder="Email" className="input" />
</div>
<form action="#">
<div className="field input-field">
<input type="email" placeholder="Email" className="input" />
</div>

<div className="field input-field">
<input
type="password"
placeholder="Password"
className="password"
/>
<i className="bx bx-hide eye-icon"></i>
</div>
<div className="field input-field">
<input
type="password"
placeholder="Password"
className="password"
/>
<i className="bx bx-hide eye-icon" />
</div>

<div className="field button-field">
<button>Login</button>
</div>
</form>
<div className="field button-field">
<button>Login</button>
</div>
</form>

<div className="form-link">
<span>
Don't have an account?{" "}
<Link to="/signup" className="link signup-link">
Sign Up
</Link>
</span>
</div>
</div>
<div className="form-link">
<span>
Don't have an account?{" "}
<Link to="/signup" className="link signup-link">
Sign Up
</Link>
</span>
</div>
</div>
</div>
</section>
</div>
</section>
</div>
);
)
}

export default Login;
export default Login
14 changes: 6 additions & 8 deletions Frontend/src/pages/login/login.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* Google Fonts - Poppins */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');

@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap");

.container {
height: 100vh;
Expand All @@ -17,7 +16,7 @@
width: 80%;
padding: 30px;
border-radius: 6px;
background: #FFF;
background: #fff;
}

.form.signup {
Expand Down Expand Up @@ -129,12 +128,12 @@ form {
}

.line::before {
content: 'Or';
content: "Or";
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #FFF;
background-color: #fff;
color: #8b8b8b;
padding: 0 15px;
}
Expand Down Expand Up @@ -177,7 +176,7 @@ img.google-img {
}

a.google {
border: 1px solid #CACACA;
border: 1px solid #cacaca;
}

a.google span {
Expand All @@ -190,5 +189,4 @@ a.google span {
.form {
padding: 20px 10px;
}

}
}
Loading