Skip to content

Commit cc7e273

Browse files
committed
Add ESLint ❤️
1 parent 8d41f1a commit cc7e273

File tree

21 files changed

+663
-156
lines changed

21 files changed

+663
-156
lines changed

.eslintrc

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

.eslintrc.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"extends": ["airbnb", "eslint:recommended", "plugin:react/recommended"],
3+
"parser": "babel-eslint",
4+
"plugins": ["prettier"],
5+
"rules": {
6+
"prettier/prettier": "error",
7+
"quotes": [
8+
"error",
9+
"double",
10+
{
11+
"avoidEscape": true,
12+
"allowTemplateLiterals": true
13+
}
14+
],
15+
"import/prefer-default-export": "off",
16+
"no-console": "off",
17+
"no-undef": "off",
18+
"no-unused-vars": "off",
19+
"react/prop-types": "off",
20+
"react/jsx-filename-extension": "off",
21+
"react/jsx-indent-props": "off",
22+
"import/no-extraneous-dependencies": "off",
23+
"no-useless-escape": "off"
24+
}
25+
}

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"prettier.eslintIntegration": true,
3+
"editor.formatOnSave": true,
4+
"files.exclude": {
5+
"**/*.git": true,
6+
"**/*.DS_Store": true
7+
}
8+
}

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
"version": "1.6.0",
1616
"license": "MIT",
1717
"scripts": {
18-
"precommit": "pretty-quick --staged",
18+
"lint": "eslint src/",
19+
"lint:fix": "eslint src/ --fix",
20+
"precommit": "npm run lint && pretty-quick --staged",
1921
"dev": "electron-webpack dev",
2022
"compile": "electron-webpack",
2123
"pack": "electron-builder --dir",
@@ -119,11 +121,17 @@
119121
"@babel/plugin-transform-runtime": "^7.0.0-beta.56",
120122
"@babel/preset-env": "^7.0.0-beta.56",
121123
"@babel/preset-react": "^7.0.0-beta.56",
124+
"babel-eslint": "^8.2.6",
122125
"babel-plugin-emotion": "^9.2.6",
123126
"electron": "^3.0.0-beta.1",
124127
"electron-builder": "^20.27.1",
125128
"electron-webpack": "^2.1.2",
129+
"eslint": "^4.19.1",
130+
"eslint-config-airbnb": "^16.1.0",
131+
"eslint-plugin-import": "^2.13.0",
132+
"eslint-plugin-jsx-a11y": "^6.0.3",
126133
"eslint-plugin-prettier": "^2.6.2",
134+
"eslint-plugin-react": "^7.10.0",
127135
"file-loader": "^1.1.11",
128136
"husky": "^0.14.3",
129137
"prettier": "1.14.2",

src/components/Main/CreateTodo.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { Error } from "../Error/index";
1212

1313
import { GET_TODOS_BY_PRODUCT } from "../../graphql/queries/GET_TODOS_BY_PRODUCT";
1414
import { CREATE_TODO } from "../../graphql/mutation/CREATE_TODO";
15-
import { SWITCH_SELECTED_PRODUCT } from "../../graphql/mutation/Local/SWITCH_SELECTED_PRODUCT";
1615
import { GET_STATUS } from "../../graphql/queries/Local/GET_STATUS";
1716

1817
const InputBox = styled.div`

src/components/Main/Status.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const Btn = styled.button`
3838
const StatusContainer = ({ theme }) => (
3939
<Query query={GET_STATUS}>
4040
{({ data: { status }, loading, error }) => {
41-
if (loading)
41+
if (loading) {
4242
return (
4343
<Loading
4444
color={theme.loading.color}
@@ -47,6 +47,7 @@ const StatusContainer = ({ theme }) => (
4747
height={30}
4848
/>
4949
);
50+
}
5051
if (error) return <Error err={error} />;
5152
return (
5253
<Mutation mutation={SET_STATUS}>

src/components/Main/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import { GET_STATUS } from "../../graphql/queries/Local/GET_STATUS";
1919
import { COMPLETE_TODO } from "../../graphql/mutation/COMPLETE_TODO";
2020
import { UNCOMPLETE_TODO } from "../../graphql/mutation/UNCOMPLETE_TODO";
2121

22-
import { state } from "../../utils/state";
23-
2422
const Content = styled.div`
2523
background: ${props => props.theme.global.bgColor};
2624
height: 100vh;

src/components/Products/index.js

Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import { SearchBar } from "../SearchBar/index";
1010

1111
import { SWITCH_SELECTED_PRODUCT } from "../../graphql/mutation/Local/SWITCH_SELECTED_PRODUCT";
1212
import { GET_SELECTED_PRODUCT } from "../../graphql/queries/Local/GET_SELECTED_PRODUCT";
13-
import { GET_TODOS_BY_PRODUCT } from "../../graphql/queries/GET_TODOS_BY_PRODUCT";
14-
import { GET_STATUS } from "../../graphql/queries/Local/GET_STATUS";
1513

1614
import { state } from "../../utils/state";
1715

@@ -56,7 +54,7 @@ class ProductsContainer extends React.Component {
5654
const { products, theme } = this.props;
5755

5856
return (
59-
<>
57+
<React.Fragment>
6058
<SearchBar
6159
input={input}
6260
onInputChange={this._onInputChange}
@@ -77,55 +75,39 @@ class ProductsContainer extends React.Component {
7775
return (
7876
<Container>
7977
{this._filterProducts(products, input).map((product, i) => (
80-
<Query query={GET_STATUS} key={v4()}>
81-
{({ data: { status } }) => {
82-
if (loading)
83-
return (
84-
<Loading
85-
color={theme.loading.color}
86-
type="bubbles"
87-
width={50}
88-
height={50}
89-
/>
90-
);
91-
if (error) return <Error err={error} />;
78+
<Mutation key={v4()} mutation={SWITCH_SELECTED_PRODUCT}>
79+
{mutate => {
80+
const highlightedProduct = selectedProduct
81+
? product.name === selectedProduct.name
82+
: i === 0;
9283
return (
93-
<Mutation mutation={SWITCH_SELECTED_PRODUCT}>
94-
{mutate => {
95-
const highlightedProduct = selectedProduct
96-
? product.name === selectedProduct.name
97-
: i === 0;
98-
return (
99-
<Product
100-
onClick={() => {
101-
if (highlightedProduct) return;
102-
const selectedProduct = {
103-
id: product.id,
104-
name: product.name,
105-
__typename: "Product",
106-
};
107-
state.set({ selectedProduct });
108-
mutate({
109-
variables: selectedProduct,
110-
});
111-
}}
112-
>
113-
<Name highlight={highlightedProduct}>
114-
{product.name}
115-
</Name>
116-
</Product>
117-
);
84+
<Product
85+
onClick={() => {
86+
if (highlightedProduct) return;
87+
const selectedProduct = {
88+
id: product.id,
89+
name: product.name,
90+
__typename: "Product",
91+
};
92+
state.set({ selectedProduct });
93+
mutate({
94+
variables: selectedProduct,
95+
});
11896
}}
119-
</Mutation>
97+
>
98+
<Name highlight={highlightedProduct}>
99+
{product.name}
100+
</Name>
101+
</Product>
120102
);
121103
}}
122-
</Query>
104+
</Mutation>
123105
))}
124106
</Container>
125107
);
126108
}}
127109
</Query>
128-
</>
110+
</React.Fragment>
129111
);
130112
}
131113
}

src/components/Titlebar/Moon.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { Mutation, Query } from "react-apollo";
33
import styled from "react-emotion";
44
import { withTheme } from "emotion-theming";
55

6+
import { Loading } from "../Loading/index";
7+
import { Error } from "../Error/index";
8+
69
import { SWITCH_MODE } from "../../graphql/mutation/Local/SWITCH_MODE";
710
import { GET_MODE } from "../../graphql/queries/Local/GET_MODE";
811

@@ -41,7 +44,7 @@ const MoonContainer = ({ theme }) => (
4144
{switchMode => (
4245
<Query query={GET_MODE}>
4346
{({ data: { mode }, loading, error }) => {
44-
if (loading)
47+
if (loading) {
4548
return (
4649
<Loading
4750
color={theme.loading.color}
@@ -50,6 +53,7 @@ const MoonContainer = ({ theme }) => (
5053
height={10}
5154
/>
5255
);
56+
}
5357
if (error) return <Error err={error} />;
5458
const { src, alt, pressed } = modeObject[mode];
5559
return (

src/components/Titlebar/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from "react";
22
import styled, { css } from "react-emotion";
33
import { callMain, answerMain } from "electron-better-ipc";
4-
import { Mutation } from "react-apollo";
54

65
import {
76
Close,
@@ -13,9 +12,6 @@ import {
1312
Unfocused,
1413
} from "./WindowButtons/index";
1514
import { Moon } from "./Moon";
16-
import { Logo } from "../Logo/index";
17-
18-
import construction from "../../static/construction.svg";
1915

2016
const Container = styled.div`
2117
display: flex;
@@ -37,7 +33,7 @@ export class Titlebar extends React.Component {
3733
state = { iconsHovered: false, isFullScreen: false };
3834

3935
componentDidMount() {
40-
answerMain("window-blur", isBlur => {
36+
answerMain("window-blur", () => {
4137
this.setState(prevState => ({
4238
isBlur: !prevState.isBlur,
4339
}));

0 commit comments

Comments
 (0)