Skip to content

Commit 8db046c

Browse files
committed
Update eslint-config
1 parent bd7130d commit 8db046c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+459
-231
lines changed

.eslintrc

Lines changed: 12 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,22 @@
11
{
2-
env: {
2+
"parser": "babel-eslint",
3+
"env": {
34
browser: true,
4-
es6: true,
55
node: true,
6+
es6: true,
67
jest: true,
7-
jasmine: true,
8+
jasmine: true
89
},
9-
"parserOptions": {
10-
"ecmaVersion": 6,
11-
"sourceType": "module",
12-
"ecmaFeatures": {
13-
"jsx": true
14-
}
15-
},
16-
"parser": "babel-eslint",
10+
"extends": [
11+
"dabapps/react",
12+
"dabapps/es6",
13+
"dabapps/browser"
14+
],
1715
"plugins": [
18-
"react"
16+
"import",
1917
],
2018
"rules": {
21-
"strict": [2, "global"],
22-
"indent": [2, 2, {"SwitchCase": 1}],
23-
"quotes": [2, "single"],
24-
"linebreak-style": [2, "unix"],
25-
"semi": [2, "always"],
26-
"comma-style": [2, "last"],
27-
"comma-spacing": [2, {"before": false, "after": true}],
28-
"no-multiple-empty-lines": [2, {"max": 2}],
29-
"max-len": [2, 120, 2, {"ignoreComments": true}],
30-
"no-trailing-spaces": [2, {"skipBlankLines": false}],
31-
"dot-location": [2, "property"],
32-
"keyword-spacing": 2,
33-
"space-before-blocks": 2,
34-
"space-before-function-paren": 0,
35-
"space-infix-ops": 2,
36-
"space-unary-ops": 2,
37-
"no-lone-blocks": 2,
38-
"eqeqeq": 2,
39-
"block-scoped-var": 2,
40-
"no-constant-condition": 2,
41-
"no-nested-ternary": 2,
42-
"no-mixed-spaces-and-tabs": 2,
43-
"no-undef": 2,
44-
"no-unreachable": 2,
45-
"no-dupe-keys": 2,
46-
"no-extra-boolean-cast": 2,
47-
"no-irregular-whitespace": 2,
48-
"no-multi-spaces": 2,
49-
"no-else-return": 0,
50-
"no-eval": 2,
51-
"no-multi-str": 2,
52-
"no-self-compare": 2,
53-
"no-useless-call": 2,
54-
"no-shadow-restricted-names": 2,
55-
"no-shadow": 2,
56-
"no-undef-init": 2,
57-
"no-use-before-define": 2,
58-
"radix": 2,
59-
"curly": 2,
60-
"no-fallthrough": 0,
61-
"default-case": 0,
62-
"no-plusplus": 0,
63-
"dot-notation": 0,
64-
"jsx-quotes": [2, "prefer-double"],
65-
"eol-last": 2,
66-
"no-unused-vars": [2, {"vars": "all", "args": "none"}],
67-
68-
"react/jsx-uses-vars": 2,
19+
import/no-unresolved: 2,
20+
"react/jsx-indent-props": 0,
6921
}
7022
}

main.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ app.on('ready', function() {
5252
title: 'Update Available',
5353
cancelId: 99,
5454
message: 'There is an update available. Would you like to update Gitify now?'
55-
}, function (response) {
56-
console.log('Exit: ' + response);
55+
}, (response) => {
56+
console.log('Exit: ' + response); // eslint-disable-line no-console
57+
5758
if (response === 0) {
5859
updater.install();
5960
}
@@ -72,11 +73,13 @@ app.on('ready', function() {
7273
const updater = new GhReleases(autoUpdateOptions);
7374

7475
updater.on('error', (event, message) => {
76+
/* eslint-disable no-console */
7577
console.log('ERRORED.');
7678
console.log('Event: ' + JSON.stringify(event) + '. MESSAGE: ' + message);
79+
/* eslint-enable no-console */
7780
});
7881

79-
updater.on('update-downloaded', (info) => {
82+
updater.on('update-downloaded', () => {
8083
// Restart the app(ask) and install the update
8184
confirmAutoUpdate(updater);
8285
});
@@ -101,7 +104,7 @@ app.on('ready', function() {
101104
}
102105

103106
function initWindow () {
104-
var defaults = {
107+
let defaults = {
105108
width: 500,
106109
height: 600,
107110
minHeight: 300,
@@ -185,6 +188,6 @@ app.on('window-all-closed', () => {
185188
}
186189
});
187190

188-
app.on('before-quit', (event) => {
191+
app.on('before-quit', () => {
189192
isQuitting = true;
190193
});

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"dist": "npm run build && npm run package && npm run codesign",
1717
"lint-js": "eslint 'src/js/' 'src/js/app.js' 'main.js'",
1818
"lint-sass": "sass-lint -c .sass-lint.yml -v -q",
19+
"prettier": "prettier --single-quote --trailing-comma es5 --write 'src/js/**/*.js'",
1920
"jest": "jest",
2021
"test": "npm run lint-js && npm run lint-sass && npm run jest -- --coverage",
2122
"start": "electron . –enable-logging"
@@ -102,10 +103,13 @@
102103
"electron-packager": "=8.7.0",
103104
"enzyme": "=2.8.2",
104105
"eslint": "=3.19.0",
105-
"eslint-plugin-react": "=7.0.1",
106+
"eslint-config-dabapps": "github:dabapps/eslint-config-dabapps#v3.1.1",
107+
"eslint-plugin-import": "=2.3.0",
108+
"eslint-plugin-prettier": "=2.1.1",
106109
"jest": "=20.0.4",
107110
"nock": "=9.0.13",
108111
"node-sass": "=4.5.3",
112+
"prettier": "=1.4.4",
109113
"react-test-renderer": "=15.5.4",
110114
"redux-logger": "=3.0.6",
111115
"redux-mock-store": "=1.2.3",

src/js/__mocks__/electron.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
window.Notification = function (title, options) {
1+
window.Notification = function (title) {
22
this.title = title;
33

44
return {

src/js/__mocks__/react-icheck.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
23

34
export class Checkbox extends React.PureComponent {
5+
static propTypes = {
6+
label: PropTypes.string.isRequired,
7+
onChange: PropTypes.func.isRequired,
8+
defaultChecked: PropTypes.bool,
9+
}
10+
411
render() {
512
return (
613
<div>
714
<strong>{this.props.label}</strong>
815
<input
916
type="checkbox"
1017
checked={this.props.defaultChecked}
11-
onChange={(evt) => this.props.onChange(evt)} />
18+
onChange={(evt) => this.props.onChange(evt)}
19+
/>
1220
</div>
1321
);
14-
};
22+
}
1523
}
1624

1725
export class Radio extends React.PureComponent {
26+
static propTypes = {
27+
label: PropTypes.string.isRequired,
28+
value: PropTypes.string.isRequired,
29+
defaultChecked: PropTypes.bool,
30+
}
31+
1832
render() {
1933
return (
2034
<div>
@@ -23,18 +37,23 @@ export class Radio extends React.PureComponent {
2337
type="radio"
2438
value={this.props.value}
2539
checked={this.props.defaultChecked}
26-
onChange={(evt) => this.props.onChange(evt)} />
40+
/>
2741
</div>
2842
);
29-
};
43+
}
3044
}
3145

3246
export class RadioGroup extends React.PureComponent {
47+
static propTypes = {
48+
children: PropTypes.node.isRequired,
49+
onChange: PropTypes.func.isRequired,
50+
}
51+
3352
render() {
3453
return (
3554
<div>
3655
{this.props.children}
3756
</div>
3857
);
39-
};
58+
}
4059
}

src/js/__mocks__/react-modal.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
23

34
export default class Modal extends React.PureComponent {
5+
static propTypes = {
6+
isOpen: PropTypes.bool.isRequired,
7+
children: PropTypes.node,
8+
}
9+
410
render() {
511
return this.props.isOpen ? (
612
<div>{this.props.children}</div>
713
) : null;
8-
};
14+
}
915
}

src/js/__mocks__/redux-logger.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export function createLogger () {
2-
return ({ getState }) => (next) => (action) => {
2+
return () => (next) => (action) => {
33
return next(action);
44
};
5-
};
5+
}

src/js/__mocks__/redux-storage.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { Map } from 'immutable';
22

3-
export function createMiddleware(engine, actionBlacklist = [], actionWhitelist = []) {
4-
return ({ dispatch, getState }) => {
3+
export function createMiddleware() {
4+
return () => {
55
return (next) => (action) => {
66
return next(action);
77
};
88
};
9-
};
9+
}
1010

1111
export function createLoader() {
1212
const state = {
@@ -20,4 +20,4 @@ export function createLoader() {
2020

2121
export function reducer (clb) {
2222
return (state, action) => clb(state, action);
23-
};
23+
}

src/js/__tests__/components/__snapshots__/settings-modal.js.snap

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ exports[`components/settings-modal.js should render itself & its children (open
107107
</strong>
108108
<input
109109
checked={undefined}
110-
onChange={[Function]}
111110
type="radio"
112111
value="both"
113112
/>
@@ -118,7 +117,6 @@ exports[`components/settings-modal.js should render itself & its children (open
118117
</strong>
119118
<input
120119
checked={undefined}
121-
onChange={[Function]}
122120
type="radio"
123121
value="tray"
124122
/>
@@ -129,7 +127,6 @@ exports[`components/settings-modal.js should render itself & its children (open
129127
</strong>
130128
<input
131129
checked={undefined}
132-
onChange={[Function]}
133130
type="radio"
134131
value="dock"
135132
/>

src/js/__tests__/components/loading.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ import NProgress from 'nprogress';
66
import { Loading, mapStateToProps } from '../../components/loading';
77

88
describe('components/loading.js', function () {
9-
const props = {
10-
11-
};
12-
139
beforeEach(() => {
1410
NProgress.start = jest.fn();
1511
NProgress.done = jest.fn();
@@ -35,7 +31,9 @@ describe('components/loading.js', function () {
3531
});
3632

3733
it('should render itself & its children', function () {
38-
const wrapper = shallow(<Loading {...props} />);
34+
const isLoading = false;
35+
const caseProps = { isLoading };
36+
const wrapper = shallow(<Loading {...caseProps} />);
3937

4038
expect(wrapper).toBeDefined();
4139
expect(wrapper.children().length).toBe(0);
@@ -56,7 +54,7 @@ describe('components/loading.js', function () {
5654
});
5755

5856
it('should receive props', function () {
59-
spyOn(Loading.prototype, 'componentDidMount').and.callThrough();;
57+
spyOn(Loading.prototype, 'componentDidMount').and.callThrough();
6058

6159
const isLoading = true;
6260
const caseProps = { isLoading };
@@ -67,24 +65,22 @@ describe('components/loading.js', function () {
6765
expect(NProgress.start).toHaveBeenCalledTimes(1);
6866

6967
wrapper.setProps({
70-
...props,
7168
isLoading: false
7269
});
7370
expect(NProgress.done).toHaveBeenCalledTimes(1);
7471

7572
wrapper.setProps({
76-
...props,
7773
isLoading: true
7874
});
7975
expect(NProgress.start).toHaveBeenCalledTimes(2);
8076
});
8177

8278
it('should unmount the component', function () {
83-
spyOn(Loading.prototype, 'componentWillUnmount').and.callThrough();;
79+
spyOn(Loading.prototype, 'componentWillUnmount').and.callThrough();
8480

8581
const isLoading = true;
86-
const caseProps = { isLoading };
87-
const wrapper = mount(<Loading {...caseProps} />);
82+
const props = { isLoading };
83+
const wrapper = mount(<Loading {...props} />);
8884

8985
expect(wrapper).toBeDefined();
9086
expect(wrapper.children().length).toEqual(0);

0 commit comments

Comments
 (0)