Skip to content

Commit 8d41f1a

Browse files
committed
Add Prettier, ESLint, Pretty Quick & Husky 😎
1 parent 26ba50a commit 8d41f1a

File tree

18 files changed

+205
-128
lines changed

18 files changed

+205
-128
lines changed

.eslintrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "react-app",
3+
"plugins": ["prettier"],
4+
"rules": {
5+
"prettier/prettier": "error"
6+
}
7+
}

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": false,
3+
"trailingComma": "es5"
4+
}

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
"url": "https://github.com/deadcoder0904/wip-desktop.git"
1313
},
1414
"homepage": "https://akshaykadam.me/apps/wip-desktop",
15-
"version": "1.5.0",
15+
"version": "1.6.0",
1616
"license": "MIT",
1717
"scripts": {
18+
"precommit": "pretty-quick --staged",
1819
"dev": "electron-webpack dev",
1920
"compile": "electron-webpack",
2021
"pack": "electron-builder --dir",
@@ -122,7 +123,11 @@
122123
"electron": "^3.0.0-beta.1",
123124
"electron-builder": "^20.27.1",
124125
"electron-webpack": "^2.1.2",
126+
"eslint-plugin-prettier": "^2.6.2",
125127
"file-loader": "^1.1.11",
128+
"husky": "^0.14.3",
129+
"prettier": "1.14.2",
130+
"pretty-quick": "^1.6.0",
126131
"webpack": "^4.16.5"
127132
},
128133
"resolutions": {

src/components/Loading/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const Loading = ({
1414
type = "spinningBubbles",
1515
color = "#000",
1616
width = 50,
17-
height = 50
17+
height = 50,
1818
}) => (
1919
<Container>
2020
<ReactLoading type={type} color={color} width={width} height={height} />

src/components/Main/CreateTodo.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ class CreateTodoContainer extends React.Component {
5252
mutate({
5353
variables: {
5454
body: this.state.input,
55-
completedAt: status === "DONE" ? new Date().toISOString() : null
56-
}
55+
completedAt: status === "DONE" ? new Date().toISOString() : null,
56+
},
5757
});
5858
this._clearInput();
5959
}
@@ -94,24 +94,24 @@ class CreateTodoContainer extends React.Component {
9494
id: v4(),
9595
body: input,
9696
completed_at:
97-
status === "DONE" ? new Date().toISOString() : null
98-
}
97+
status === "DONE" ? new Date().toISOString() : null,
98+
},
9999
}}
100100
update={(cache, { data: { createTodo } }) => {
101101
const data = cache.readQuery({
102102
query: GET_TODOS_BY_PRODUCT,
103-
variables: { id, completed: status === "DONE" }
103+
variables: { id, completed: status === "DONE" },
104104
});
105105
const todos = data.product.todos.map(t => t); // make a shallow copy otherwise error "Object is not extensible" is thrown
106106
todos.push(createTodo);
107107
const newData = {
108108
...data,
109-
product: { ...data.product, todos }
109+
product: { ...data.product, todos },
110110
};
111111
cache.writeQuery({
112112
query: GET_TODOS_BY_PRODUCT,
113113
variables: { id, completed: status === "DONE" },
114-
data: newData
114+
data: newData,
115115
});
116116
}}
117117
>

src/components/Main/Status.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const StatusContainer = ({ theme }) => (
5757
const status = "PENDING";
5858
setStatus({ variables: { status } });
5959
state.set({
60-
status
60+
status,
6161
});
6262
}}
6363
highlight={status === "PENDING"}
@@ -69,7 +69,7 @@ const StatusContainer = ({ theme }) => (
6969
const status = "DONE";
7070
setStatus({ variables: { status } });
7171
state.set({
72-
status
72+
status,
7373
});
7474
}}
7575
highlight={status === "DONE"}

src/components/Main/index.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,17 @@ class MainContainer extends React.Component {
138138
__typename: "Todo",
139139
id: todo.id,
140140
body: todo.body,
141-
completed_at
142-
}
141+
completed_at,
142+
},
143143
}}
144144
update={(cache, { data }) => {
145145
// remove todo item from current status ,i.e, PENDING or DONE
146146
const cacheData1 = cache.readQuery({
147147
query: GET_TODOS_BY_PRODUCT,
148148
variables: {
149149
id: productId,
150-
completed
151-
}
150+
completed,
151+
},
152152
});
153153

154154
const todos1 = cacheData1.product.todos.filter(
@@ -159,26 +159,26 @@ class MainContainer extends React.Component {
159159
...cacheData1,
160160
product: {
161161
...cacheData1.product,
162-
todos: todos1
163-
}
162+
todos: todos1,
163+
},
164164
};
165165

166166
cache.writeQuery({
167167
query: GET_TODOS_BY_PRODUCT,
168168
variables: {
169169
id: productId,
170-
completed
170+
completed,
171171
},
172-
data: newData1
172+
data: newData1,
173173
});
174174

175175
// add todo item to current status ,i.e, PENDING or DONE
176176
const cacheData2 = cache.readQuery({
177177
query: GET_TODOS_BY_PRODUCT,
178178
variables: {
179179
id: productId,
180-
completed: status !== "DONE"
181-
}
180+
completed: status !== "DONE",
181+
},
182182
});
183183

184184
const todos2 = cacheData2.product.todos.map(
@@ -191,23 +191,23 @@ class MainContainer extends React.Component {
191191
: "completeTodo"
192192
],
193193
id: todo.id,
194-
completed_at
194+
completed_at,
195195
});
196196
const newData2 = {
197197
...cacheData2,
198198
product: {
199199
...cacheData2.product,
200-
todos: todos2
201-
}
200+
todos: todos2,
201+
},
202202
};
203203

204204
cache.writeQuery({
205205
query: GET_TODOS_BY_PRODUCT,
206206
variables: {
207207
id: productId,
208-
completed: status !== "DONE"
208+
completed: status !== "DONE",
209209
},
210-
data: newData2
210+
data: newData2,
211211
});
212212
}}
213213
>

src/components/Products/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ class ProductsContainer extends React.Component {
102102
const selectedProduct = {
103103
id: product.id,
104104
name: product.name,
105-
__typename: "Product"
105+
__typename: "Product",
106106
};
107107
state.set({ selectedProduct });
108108
mutate({
109-
variables: selectedProduct
109+
variables: selectedProduct,
110110
});
111111
}}
112112
>

src/components/Titlebar/Moon.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ const modeObject = {
2727
DARK: {
2828
src: LIGHT_MOON,
2929
alt: "Enable Light mode",
30-
pressed: "false"
30+
pressed: "false",
3131
},
3232
LIGHT: {
3333
src: DARK_MOON,
3434
alt: "Enable Dark mode",
35-
pressed: "true"
36-
}
35+
pressed: "true",
36+
},
3737
};
3838

3939
const MoonContainer = ({ theme }) => (

src/components/Titlebar/WindowButtons/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ export {
2525
Minimize,
2626
MinimizePressed,
2727
Maximize,
28-
MaximizePressed
28+
MaximizePressed,
2929
};

0 commit comments

Comments
 (0)