Skip to content

Commit 829cfd4

Browse files
committed
Configure eslint and prettier and fix linting issues across the repository.
1 parent 51dc12e commit 829cfd4

31 files changed

+5456
-4560
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["@babel/preset-react"]
3+
}

.eslintrc

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"root": true,
3+
"extends": ["airbnb", "airbnb/hooks", "plugin:react/recommended", "prettier"],
4+
"plugins": ["react", "prettier"],
5+
"env": {
6+
"browser": true,
7+
"jest": true,
8+
"node": true,
9+
"es6": true
10+
},
11+
"globals": {
12+
"Atomics": "readonly",
13+
"SharedBufferArray": "readonly"
14+
},
15+
"parser": "babel-eslint",
16+
"parserOptions": {
17+
"ecmaVersion": 2020,
18+
"sourceType": "module",
19+
"ecmaFeatures": { "jsx": true },
20+
"allowImportExportEverywhere": false,
21+
"codeFrame": false
22+
},
23+
"settings": {
24+
"react": {
25+
"pragma": "React",
26+
"version": "detect"
27+
}
28+
},
29+
"rules": {
30+
"max-len": ["error", { "code": 100 }],
31+
"prefer-promise-reject-errors": ["off"],
32+
"react/jsx-filename-extension": ["off"],
33+
"no-return-assign": ["off"],
34+
"react/prop-types": 0,
35+
"import/prefer-default-export": 0,
36+
"no-use-before-define": 0,
37+
"click-events-have-key-events": 0,
38+
"no-static-element-interactions": 0,
39+
"prefer-destructuring": 1,
40+
"react/display-name": 0,
41+
"func-names": 0
42+
}
43+
}

.eslintrc.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

.prettierrc.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
{
2+
"printWidth": 100,
3+
"trailingComma": "all",
4+
"tabWidth": 2,
25
"semi": true,
36
"singleQuote": true,
4-
"tabWidth": 2,
5-
"useTabs": false,
6-
"trailingComma": "all"
7-
}
7+
"arrowParens": "always",
8+
"bracketSpacing": true,
9+
"endOfLine": "auto",
10+
"proseWrap": "preserve",
11+
"quoteProps": "as-needed",
12+
"jsxBracketSameLine": false,
13+
"jsxSingleQuote": true
14+
}

package-lock.json

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

package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6+
"@babel/plugin-proposal-decorators": "^7.16.7",
67
"@mdx-js/loader": "^1.6.22",
78
"@testing-library/jest-dom": "^5.11.4",
89
"@testing-library/user-event": "^12.1.10",
@@ -39,11 +40,19 @@
3940
]
4041
},
4142
"devDependencies": {
43+
"@babel/core": "^7.16.7",
44+
"@babel/eslint-parser": "^7.16.5",
45+
"@babel/preset-react": "^7.16.7",
4246
"@testing-library/react": "^11.2.7",
4347
"autoprefixer": "^9.8.6",
44-
"eslint": "^8.7.0",
48+
"eslint": "^7.11.0",
49+
"eslint-config": "^0.3.0",
50+
"eslint-config-airbnb": "^19.0.0",
4551
"eslint-config-prettier": "^8.3.0",
52+
"eslint-plugin-jest": "^24.3.6",
53+
"eslint-plugin-jsx-a11y": "^6.4.1",
4654
"eslint-plugin-prettier": "^4.0.0",
55+
"eslint-plugin-react": "^7.28.0",
4756
"jest-dom": "^4.0.0",
4857
"postcss": "^7.0.36",
4958
"prettier": "^2.5.1",

src/components/About.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import React from "react";
2-
import { Row, Col, Form, Button } from "react-bootstrap";
1+
/* eslint-disable no-unused-vars */
2+
import React from 'react';
3+
import { Row, Col, Form, Button } from 'react-bootstrap';
34

45
function About() {
56
return <section>About</section>;

src/components/AddJournal.js

Lines changed: 49 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
import { React, useState } from "react";
2-
import { Row, Col, Form, Button } from "react-bootstrap";
1+
/* eslint-disable no-alert */
2+
import { React, useState } from 'react';
3+
import { Row, Col, Form, Button } from 'react-bootstrap';
34

4-
const AddJournal = () => {
5-
const [title, setTitle] = useState("");
6-
const [url, setUrl] = useState("");
7-
const [issn, setIssn] = useState("");
8-
const [rating, setRating] = useState("");
9-
const [date, setDate] = useState("");
10-
const [policyTitle, setPolicyTitle] = useState("");
11-
const [firstYear, setFirstYear] = useState("");
12-
const [lastYear, setLastYear] = useState("");
13-
const [policyType, setPolicyType] = useState("");
14-
const [domain, setDomain] = useState("");
5+
function AddJournal() {
6+
const [title, setTitle] = useState('');
7+
const [url, setUrl] = useState('');
8+
const [issn, setIssn] = useState('');
9+
const [rating, setRating] = useState('');
10+
const [date, setDate] = useState('');
11+
const [policyTitle, setPolicyTitle] = useState('');
12+
const [firstYear, setFirstYear] = useState('');
13+
const [lastYear, setLastYear] = useState('');
14+
const [policyType, setPolicyType] = useState('');
15+
const [domain, setDomain] = useState('');
1516

1617
const handleSubmit = (e) => {
1718
e.preventDefault();
@@ -24,99 +25,95 @@ const AddJournal = () => {
2425
};
2526
const journal = { title, url, issn, rating, date, policies, domain };
2627

27-
fetch("https://journal-policy-tracker.herokuapp.com/api/journals", {
28-
method: "POST",
29-
headers: { "Content-Type": "application/json" },
28+
fetch('https://journal-policy-tracker.herokuapp.com/api/journals', {
29+
method: 'POST',
30+
headers: { 'Content-Type': 'application/json' },
3031
body: JSON.stringify(journal),
3132
}).then(() => {
32-
alert("Journal added successfully!");
33+
alert('Journal added successfully!');
3334
});
3435
};
3536

3637
return (
3738
<Row>
38-
<Col md={4}></Col>
39+
<Col md={4} />
3940
<Col md={4}>
40-
<Form className="login-form" onSubmit={handleSubmit}>
41-
<Form.Group className="mb-3" controlId="formBasicTitle">
41+
<Form className='login-form' onSubmit={handleSubmit}>
42+
<Form.Group className='mb-3' controlId='formBasicTitle'>
4243
<Form.Label>Title</Form.Label>
4344
<Form.Control
44-
type="text"
45-
placeholder="Journal title"
45+
type='text'
46+
placeholder='Journal title'
4647
onChange={(e) => setTitle(e.target.value)}
4748
/>
4849
</Form.Group>
49-
<Form.Group className="mb-3" controlId="formBasicUrl">
50+
<Form.Group className='mb-3' controlId='formBasicUrl'>
5051
<Form.Label>URL</Form.Label>
51-
<Form.Control
52-
type="text"
53-
placeholder="URL"
54-
onChange={(e) => setUrl(e.target.value)}
55-
/>
52+
<Form.Control type='text' placeholder='URL' onChange={(e) => setUrl(e.target.value)} />
5653
</Form.Group>
57-
<Form.Group className="mb-3" controlId="formBasicIssn">
54+
<Form.Group className='mb-3' controlId='formBasicIssn'>
5855
<Form.Label>ISSN</Form.Label>
5956
<Form.Control
60-
type="text"
61-
placeholder="ISSN"
57+
type='text'
58+
placeholder='ISSN'
6259
onChange={(e) => setIssn(e.target.value)}
6360
/>
6461
</Form.Group>
65-
<Form.Group className="mb-3" controlId="formBasicRating">
62+
<Form.Group className='mb-3' controlId='formBasicRating'>
6663
<Form.Label>Rating</Form.Label>
6764
<Form.Control
68-
type="text"
69-
placeholder="Rating"
65+
type='text'
66+
placeholder='Rating'
7067
onChange={(e) => setRating(e.target.value)}
7168
/>
7269
</Form.Group>
73-
<Form.Group className="mb-3" controlId="formBasicDate">
70+
<Form.Group className='mb-3' controlId='formBasicDate'>
7471
<Form.Label>Date</Form.Label>
7572
<Form.Control
76-
type="date"
77-
placeholder="Date"
73+
type='date'
74+
placeholder='Date'
7875
onChange={(e) => setDate(e.target.value)}
7976
/>
8077
</Form.Group>
81-
<Form.Group className="mb-3" controlId="formBasicPolicies">
78+
<Form.Group className='mb-3' controlId='formBasicPolicies'>
8279
<Form.Label>Policies</Form.Label>
8380
<Form.Control
84-
type="text"
85-
placeholder="Policy Title"
81+
type='text'
82+
placeholder='Policy Title'
8683
onChange={(e) => setPolicyTitle(e.target.value)}
8784
/>
8885
<Form.Control
89-
type="text"
90-
placeholder="First Year"
86+
type='text'
87+
placeholder='First Year'
9188
onChange={(e) => setFirstYear(e.target.value)}
9289
/>
9390
<Form.Control
94-
type="text"
95-
placeholder="Last Year"
91+
type='text'
92+
placeholder='Last Year'
9693
onChange={(e) => setLastYear(e.target.value)}
9794
/>
9895
<Form.Control
99-
type="text"
100-
placeholder="Type"
96+
type='text'
97+
placeholder='Type'
10198
onChange={(e) => setPolicyType(e.target.value)}
10299
/>
103100
</Form.Group>
104-
<Form.Group className="mb-3" controlId="formBasicDomain">
101+
<Form.Group className='mb-3' controlId='formBasicDomain'>
105102
<Form.Label>Domain</Form.Label>
106103
<Form.Control
107-
type="text"
108-
placeholder="Domain"
104+
type='text'
105+
placeholder='Domain'
109106
onChange={(e) => setDomain(e.target.value)}
110107
/>
111108
</Form.Group>
112-
<Button variant="primary" type="submit">
109+
<Button variant='primary' type='submit'>
113110
Add Journal
114111
</Button>
115112
</Form>
116113
</Col>
117-
<Col md={4}></Col>
114+
<Col md={4} />
118115
</Row>
119116
);
120-
};
117+
}
121118

122119
export default AddJournal;

src/components/AddJournal.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React from "react";
2-
import { render } from "@testing-library/react";
3-
import "@testing-library/jest-dom";
4-
import AddJournal from "./AddJournal";
1+
import React from 'react';
2+
import { render } from '@testing-library/react';
3+
import '@testing-library/jest-dom';
4+
import AddJournal from './AddJournal';
55

6-
test("Add Journal renders the form correctly", () => {
6+
test('Add Journal renders the form correctly', () => {
77
const { getByText, getByLabelText } = render(<AddJournal />);
88
const title = getByText(/Title/i);
99
const url = getByText(/URL/i);
@@ -16,5 +16,5 @@ test("Add Journal renders the form correctly", () => {
1616
expect(rating).toBeInTheDocument();
1717
expect(policies).toBeInTheDocument();
1818
const input = getByLabelText(/Date/i);
19-
expect(input).toHaveAttribute("type", "date");
19+
expect(input).toHaveAttribute('type', 'date');
2020
});

src/components/Footer.js

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,56 @@
1-
import React from "react";
1+
/* eslint-disable jsx-a11y/anchor-is-valid */
2+
import React from 'react';
23
import '../styles/Footer.css';
3-
import { Container, Row, Col } from "react-bootstrap";
4-
import { ImTwitter, ImMail, ImGithub } from "react-icons/im";
5-
import { IoLogoSlack } from "react-icons/io";
6-
import RocketImg from "../assets/rocket.webp";
4+
import { Container, Row, Col } from 'react-bootstrap';
5+
import { ImTwitter, ImMail, ImGithub } from 'react-icons/im';
6+
import { IoLogoSlack } from 'react-icons/io';
7+
import RocketImg from '../assets/rocket.webp';
78

89
function Footer() {
910
return (
1011
<Container fluid>
11-
<Row className="footer-above">
12+
<Row className='footer-above'>
1213
<Col xs={12} md={2}>
13-
<img src={RocketImg} height={130} width={69} />
14+
<img src={RocketImg} alt='' height={130} width={69} />
1415
</Col>
1516
<Col xs={12} sm={12} md={3}>
1617
<h4>Useful links</h4>
17-
<a
18-
href="https://github.com/codeisscience"
19-
target="_blank"
20-
rel="noreferrer"
21-
>
18+
<a href='https://github.com/codeisscience' target='_blank' rel='noreferrer'>
2219
Contribute
2320
</a>
2421
<a
25-
href="https://codeisscience.github.io/manifesto/manifesto.html"
26-
target="_blank"
27-
rel="noreferrer"
22+
href='https://codeisscience.github.io/manifesto/manifesto.html'
23+
target='_blank'
24+
rel='noreferrer'
2825
>
2926
Manifesto
3027
</a>
31-
<a href="#">Code of conduct</a>
28+
<a href='#'>Code of conduct</a>
3229
</Col>
3330
<Col xs={12} sm={12} md={3}>
3431
<h4>Resources</h4>
35-
<a href="#">Authors</a>
36-
<a href="#">Open science</a>
37-
<a href="#">Contributors</a>
32+
<a href='#'>Authors</a>
33+
<a href='#'>Open science</a>
34+
<a href='#'>Contributors</a>
3835
</Col>
3936
<Col xs={12} sm={12} md={3}>
4037
<h4>Contact Us</h4>
41-
<a
42-
href="mailto:[email protected]"
43-
target="_blank"
44-
rel="noreferrer"
45-
>
38+
<a href='mailto:[email protected]' target='_blank' rel='noreferrer'>
4639
<ImMail /> Email
4740
</a>
48-
<a
49-
href="https://twitter.com/codeisscience"
50-
target="_blank"
51-
rel="noreferrer"
52-
>
41+
<a href='https://twitter.com/codeisscience' target='_blank' rel='noreferrer'>
5342
<ImTwitter />
5443
&nbsp;Twitter
5544
</a>
56-
<a
57-
href="https://github.com/codeisscience"
58-
target="_blank"
59-
rel="noreferrer"
60-
>
45+
<a href='https://github.com/codeisscience' target='_blank' rel='noreferrer'>
6146
<ImGithub /> GitHub
6247
</a>
63-
<a href="#">
48+
<a href='#'>
6449
<IoLogoSlack /> Slack
6550
</a>
6651
</Col>
6752
</Row>
68-
<Row className="footer-below">
53+
<Row className='footer-below'>
6954
<p>2021 Code is Science</p>
7055
</Row>
7156
</Container>

0 commit comments

Comments
 (0)