Skip to content

Commit 353005d

Browse files
committed
Use prettier
1 parent d5a25cd commit 353005d

File tree

6 files changed

+491
-53
lines changed

6 files changed

+491
-53
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ Run `npm run develop` and access the dev server at the address it reports.
1111
Run `npm build`, and a built version will be written to `/dist`. This will
1212
also update the markdown files that define our code of conduct, speaker
1313
questionnaire, and sponsorship levels from the [admin repository](https://github.com/javascriptmn/javascriptmn)
14+
15+
## Style
16+
This repository is configured to use [prettier](https://prettier.io/) on commit.
17+
18+
It will lint and format your changes automatically, so don't worry about following
19+
format standards (so long as your code passes the lint-staged step).

components/Meetup.js

Lines changed: 53 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,73 +9,85 @@ export default class Meetup extends React.Component {
99
state = {
1010
name: '',
1111
time: Date.now(),
12-
venue: {name: ''},
12+
venue: { name: '' },
1313
loading: false,
1414
error: false
1515
}
1616

17-
componentDidMount () {
17+
componentDidMount() {
1818
this.setState({
1919
loading: true,
2020
error: false
2121
})
22-
window.fetch(NEXT_MEETUP_URI)
23-
.then((res) => {
22+
window
23+
.fetch(NEXT_MEETUP_URI)
24+
.then(res => {
2425
// Gotta love network errors...
2526
if (!res.ok) throw Error(response.statusText)
2627
return response
2728
})
28-
.then((res) => res.json())
29-
.then((json) => this.setState({
30-
...json,
31-
loading: false
32-
}))
33-
.catch(_ => this.setState({loading: false, error: true}))
29+
.then(res => res.json())
30+
.then(json =>
31+
this.setState({
32+
...json,
33+
loading: false
34+
})
35+
)
36+
.catch(_ => this.setState({ loading: false, error: true }))
3437
}
3538

36-
render () {
39+
render() {
3740
const meetupStyles = {
38-
container: {
39-
textAlign: 'center',
40-
border: '1px solid black',
41-
display: 'inline block',
42-
margin: '8rem'
43-
},
44-
title: {
45-
fontSize: '2rem',
46-
margin: '1rem'
47-
},
48-
bug: {},
49-
rsvpButton: {}
41+
container: {
42+
textAlign: 'center',
43+
border: '1px solid black',
44+
display: 'inline block',
45+
margin: '8rem'
46+
},
47+
title: {
48+
fontSize: '2rem',
49+
margin: '1rem'
50+
},
51+
bug: {},
52+
rsvpButton: {}
5053
}
5154

52-
const MeetupDescription = ({name, time, venue}) => (<div className="next-event">
55+
const MeetupDescription = ({ name, time, venue }) => (
56+
<div className="next-event">
5357
<div className="next-event-tagline">
5458
<strong>Next Event:</strong>
55-
<div className="event-name">
56-
{name}
57-
</div>
58-
{
59-
(time && venue && venue.name) &&
60-
(<span className="next-event-timestamp">{format(new Date(time), 'dddd, MMMM Do, YYYY')} at <strong>{ venue.name }</strong></span>)
61-
}
59+
<div className="event-name">{name}</div>
60+
{time &&
61+
venue &&
62+
venue.name && (
63+
<span className="next-event-timestamp">
64+
{format(new Date(time), 'dddd, MMMM Do, YYYY')} at{' '}
65+
<strong>{venue.name}</strong>
66+
</span>
67+
)}
6268
</div>
63-
</div>)
69+
</div>
70+
)
6471

65-
if (this.state.loading)
66-
return (<MeetupDescription
67-
name={'Loading...'}
68-
/>)
72+
if (this.state.loading) return <MeetupDescription name={'Loading...'} />
6973

7074
if (this.state.error)
71-
return (<MeetupDescription
72-
name={(<a href='https://meetup.com/javascriptmn'>Check Meetup.com for updates</a>)}
73-
/>)
75+
return (
76+
<MeetupDescription
77+
name={
78+
<a href="https://meetup.com/javascriptmn">
79+
Check Meetup.com for updates
80+
</a>
81+
}
82+
/>
83+
)
7484

75-
return (<MeetupDescription
85+
return (
86+
<MeetupDescription
7687
name={this.state.name}
7788
time={this.state.time}
7889
venue={this.state.venue}
79-
/>)
90+
/>
91+
)
8092
}
8193
}

css/markdown-styles.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
.warning {
2-
color: #9F6000;
3-
background-color: #FEEFB3;
2+
color: #9f6000;
3+
background-color: #feefb3;
44
padding: 18px;
55
}
66
.warning:before {
7-
content:'\26A0';
7+
content: '\26A0';
88
margin-right: 9px;
99
}
1010

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,24 @@
33
"description": "JavaScriptMN website",
44
"version": "1.0.0",
55
"private": true,
6-
"author": "JavaScriptMN Organizers <javascriptmn@gmail.com",
6+
"author": "JavaScriptMN Organizers <javascriptmn@gmail.com>",
77
"dependencies": {
88
"date-fns": "^1.28.5",
99
"front-matter": "^2.1.1",
1010
"gatsby": "^0.12.20",
1111
"highlight.js": "^9.8.0",
1212
"history": "^2.0.2",
13+
"husky": "^0.14.3",
1314
"js-yaml": "^3.7.0",
15+
"lint-staged": "^6.0.0",
1416
"markdown-it": "^7.0.1",
1517
"markdown-it-abbr": "^1.0.3",
1618
"markdown-it-attrs": "^0.6.3",
1719
"markdown-it-deflist": "^2.0.1",
1820
"markdown-it-footnote": "^3.0.1",
1921
"markdown-it-sub": "^1.0.0",
2022
"object-assign": "^4.1.0",
23+
"prettier": "^1.8.2",
2124
"react-headroom": "^2.1.2",
2225
"react-helmet": "^3.2.2",
2326
"react-responsive-grid": "^0.3.3",
@@ -36,6 +39,10 @@
3639
"build": "gatsby build",
3740
"deploy": "gatsby build --prefix-links && gh-pages -a -d public -b master",
3841
"develop": "gatsby develop",
42+
"precommit": "lint-staged",
3943
"test": "echo \"Error: no test specified\" && exit 1"
44+
},
45+
"lint-staged": {
46+
"{pages,components,css}/**/*.{js,json,css}": ["prettier --write --no-semi --single-quote", "git add"]
4047
}
4148
}

pages/styles.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
list-style: none;
1010
}
1111

12-
& li { display: inline-block; }
12+
& li {
13+
display: inline-block;
14+
}
1315

1416
& a {
1517
background: var(--color);
@@ -24,5 +26,3 @@
2426
.the-postcss-class {
2527
text-decoration: underline;
2628
}
27-
28-

0 commit comments

Comments
 (0)