Skip to content

Commit 7f782f0

Browse files
feat(frontend): typescript, eslint, prettier added
1 parent f868cc9 commit 7f782f0

10 files changed

Lines changed: 449 additions & 19 deletions

File tree

frontend/.eslintrc.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module.exports = {
2+
extends: [
3+
"plugin:@typescript-eslint/recommended",
4+
"plugin:jest/recommended",
5+
"plugin:prettier/recommended",
6+
],
7+
plugins: ["react", "@typescript-eslint", "jest"],
8+
env: {
9+
browser: true,
10+
es6: true,
11+
jest: true,
12+
},
13+
parser: "@typescript-eslint/parser",
14+
parserOptions: {
15+
ecmaFeatures: {
16+
jsx: true,
17+
},
18+
ecmaVersion: 2018,
19+
sourceType: "module",
20+
project: "./tsconfig.json",
21+
},
22+
rules: {
23+
"prettier/prettier": [
24+
"error",
25+
{
26+
endOfLine: "auto",
27+
},
28+
],
29+
},
30+
};

frontend/.prettierrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
trailingComma: "es5",
3+
tabWidth: 2,
4+
semi: true,
5+
singleQuote: false,
6+
};

frontend/package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,18 @@
3535
"last 1 firefox version",
3636
"last 1 safari version"
3737
]
38+
},
39+
"devDependencies": {
40+
"@types/node": "^15.0.2",
41+
"@types/react": "^17.0.5",
42+
"@types/react-dom": "^17.0.3",
43+
"@types/react-router-dom": "^5.1.7",
44+
"@typescript-eslint/eslint-plugin": "^4.23.0",
45+
"@typescript-eslint/parser": "^4.23.0",
46+
"eslint": "^7.26.0",
47+
"eslint-config-prettier": "^8.3.0",
48+
"eslint-plugin-prettier": "^3.4.0",
49+
"prettier": "^2.3.0",
50+
"typescript": "^4.2.4"
3851
}
3952
}

frontend/src/App.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { render, screen } from '@testing-library/react';
2-
import App from './App';
1+
import { render, screen } from "@testing-library/react";
2+
import Routes from "./Routes";
33

4-
test('renders learn react link', () => {
5-
render(<App />);
4+
test("renders learn react link", () => {
5+
render(<Routes />);
66
const linkElement = screen.getByText(/learn react/i);
77
expect(linkElement).toBeInTheDocument();
88
});
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import './App.css';
1+
import "./App.css";
2+
import React from "react";
23
import HomePage from "./components/homePage";
34
import Nav from "./components/nav";
4-
import { Route, Switch } from 'react-router-dom';
5+
import { Route, Switch } from "react-router-dom";
56

6-
function App() {
7+
const Routes: React.FC = () => {
78
return (
89
<div className="App">
910
<Nav />
@@ -12,6 +13,6 @@ function App() {
1213
</Switch>
1314
</div>
1415
);
15-
}
16+
};
1617

17-
export default App;
18+
export default Routes;
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import React from 'react';
2-
import ReactDOM from 'react-dom';
3-
import './index.css';
4-
import App from './App';
5-
import reportWebVitals from './reportWebVitals';
6-
import { BrowserRouter } from 'react-router-dom';
1+
import ReactDOM from "react-dom";
2+
import "./index.css";
3+
import Routes from "./Routes";
4+
import reportWebVitals from "./reportWebVitals";
5+
import { BrowserRouter } from "react-router-dom";
76

87
ReactDOM.render(
98
<BrowserRouter>
10-
<App />
9+
<Routes />
1110
</BrowserRouter>,
12-
document.getElementById('root')
11+
document.getElementById("root")
1312
);
1413

1514
// If you want to start measuring performance in your app, pass a function

frontend/src/logo.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

frontend/src/react-app-env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="react-scripts" />

frontend/tsconfig.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": ".",
4+
"outDir": "build/dist",
5+
"module": "esnext",
6+
"target": "es5",
7+
"lib": [
8+
"es6",
9+
"dom",
10+
"esnext.asynciterable"
11+
],
12+
"sourceMap": true,
13+
"allowJs": true,
14+
"jsx": "react-jsx",
15+
"moduleResolution": "node",
16+
"rootDir": "src",
17+
"forceConsistentCasingInFileNames": true,
18+
"noImplicitReturns": true,
19+
"noImplicitThis": true,
20+
"noImplicitAny": true,
21+
"strictNullChecks": true,
22+
"suppressImplicitAnyIndexErrors": true,
23+
"noUnusedLocals": true,
24+
"skipLibCheck": true,
25+
"allowSyntheticDefaultImports": true,
26+
"esModuleInterop": true,
27+
"strict": true,
28+
"noFallthroughCasesInSwitch": true,
29+
"resolveJsonModule": true,
30+
"isolatedModules": true,
31+
"noEmit": true
32+
},
33+
"exclude": [
34+
"node_modules",
35+
"build",
36+
"scripts",
37+
"acceptance-tests",
38+
"webpack",
39+
"jest",
40+
"src/setupTests.ts"
41+
],
42+
"include": [
43+
"src"
44+
]
45+
}

0 commit comments

Comments
 (0)