Skip to content

Commit 3aef4f4

Browse files
authored
Merge pull request #293 from manosim/eslint-prettier
Re-Setup eslint & Prettier
2 parents bd7130d + 01a1815 commit 3aef4f4

Some content is hidden

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

63 files changed

+1839
-1128
lines changed

.eslintrc

+19-60
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,29 @@
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",
17+
"prettier"
1918
],
2019
"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,
20+
import/no-unresolved: 2,
21+
"react/jsx-indent-props": 0,
22+
"prettier/prettier": ["error", {
23+
"singleQuote": true,
24+
"trailingComma": "es5",
25+
"bracketSpacing": true,
26+
}],
27+
quotes: ["error", "single", { "avoidEscape": true }]
6928
}
7029
}

main.js

+46-36
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ const appMenuTemplate = require('./electron/app-menu-template');
77
const iconIdle = path.join(__dirname, 'images', 'tray-idleTemplate.png');
88
const iconActive = path.join(__dirname, 'images', 'tray-active.png');
99

10-
const isDarwin = (process.platform === 'darwin');
11-
const isLinux = (process.platform === 'linux');
12-
const isWindows = (process.platform === 'win32');
10+
const isDarwin = process.platform === 'darwin';
11+
const isLinux = process.platform === 'linux';
12+
const isWindows = process.platform === 'win32';
1313

1414
let appWindow;
1515
let appIcon = null;
@@ -18,7 +18,7 @@ let isQuitting = false;
1818
const autoStart = new AutoLaunch({
1919
name: 'Gitify',
2020
path: process.execPath.match(/.*?\.app/)[0],
21-
isHidden: true
21+
isHidden: true,
2222
});
2323

2424
app.on('ready', function() {
@@ -28,16 +28,18 @@ app.on('ready', function() {
2828
const trayMenu = Menu.buildFromTemplate([
2929
{
3030
label: 'Show Gitify',
31-
click () { appWindow.show(); }
31+
click() {
32+
appWindow.show();
33+
},
3234
},
3335
{
34-
type: 'separator'
36+
type: 'separator',
3537
},
3638
{
3739
label: 'Quit',
3840
accelerator: isDarwin ? 'Command+Q' : 'Alt+F4',
39-
role: 'quit'
40-
}
41+
role: 'quit',
42+
},
4143
]);
4244

4345
trayIcon.setToolTip('GitHub Notifications on your menu bar.');
@@ -46,37 +48,45 @@ app.on('ready', function() {
4648
}
4749

4850
function confirmAutoUpdate(updater) {
49-
dialog.showMessageBox({
50-
type: 'question',
51-
buttons: ['Update & Restart', 'Cancel'],
52-
title: 'Update Available',
53-
cancelId: 99,
54-
message: 'There is an update available. Would you like to update Gitify now?'
55-
}, function (response) {
56-
console.log('Exit: ' + response);
57-
if (response === 0) {
58-
updater.install();
51+
dialog.showMessageBox(
52+
{
53+
type: 'question',
54+
buttons: ['Update & Restart', 'Cancel'],
55+
title: 'Update Available',
56+
cancelId: 99,
57+
message:
58+
'There is an update available. Would you like to update Gitify now?',
59+
},
60+
response => {
61+
console.log('Exit: ' + response); // eslint-disable-line no-console
62+
63+
if (response === 0) {
64+
updater.install();
65+
}
5966
}
60-
} );
67+
);
6168
}
6269

6370
function checkAutoUpdate(showAlert) {
64-
65-
if (isWindows || isLinux) { return; }
71+
if (isWindows || isLinux) {
72+
return;
73+
}
6674

6775
let autoUpdateOptions = {
6876
repo: 'manosim/gitify',
69-
currentVersion: app.getVersion()
77+
currentVersion: app.getVersion(),
7078
};
7179

7280
const updater = new GhReleases(autoUpdateOptions);
7381

7482
updater.on('error', (event, message) => {
83+
/* eslint-disable no-console */
7584
console.log('ERRORED.');
7685
console.log('Event: ' + JSON.stringify(event) + '. MESSAGE: ' + message);
86+
/* eslint-enable no-console */
7787
});
7888

79-
updater.on('update-downloaded', (info) => {
89+
updater.on('update-downloaded', () => {
8090
// Restart the app(ask) and install the update
8191
confirmAutoUpdate(updater);
8292
});
@@ -89,7 +99,7 @@ app.on('ready', function() {
8999
type: 'info',
90100
buttons: ['Close'],
91101
title: 'No update available',
92-
message: 'You are currently running the latest version of Gitify.'
102+
message: 'You are currently running the latest version of Gitify.',
93103
});
94104
}
95105
}
@@ -100,8 +110,8 @@ app.on('ready', function() {
100110
});
101111
}
102112

103-
function initWindow () {
104-
var defaults = {
113+
function initWindow() {
114+
let defaults = {
105115
width: 500,
106116
height: 600,
107117
minHeight: 300,
@@ -111,15 +121,15 @@ app.on('ready', function() {
111121
fullscreenable: false,
112122
titleBarStyle: 'hidden-inset',
113123
webPreferences: {
114-
overlayScrollbars: true
115-
}
124+
overlayScrollbars: true,
125+
},
116126
};
117127

118128
appWindow = new BrowserWindow(defaults);
119129
appWindow.loadURL('file://' + __dirname + '/index.html');
120130
appWindow.show();
121131

122-
appWindow.on('close', function (event) {
132+
appWindow.on('close', function(event) {
123133
if (!isQuitting) {
124134
event.preventDefault();
125135
appWindow.hide();
@@ -134,12 +144,12 @@ app.on('ready', function() {
134144
appIcon = createAppIcon();
135145
initWindow();
136146

137-
ipcMain.on('reopen-window', () => appWindow.show() );
138-
ipcMain.on('startup-enable', () => autoStart.enable() );
139-
ipcMain.on('startup-disable', () => autoStart.disable() );
140-
ipcMain.on('check-update', () => checkAutoUpdate(true) );
147+
ipcMain.on('reopen-window', () => appWindow.show());
148+
ipcMain.on('startup-enable', () => autoStart.enable());
149+
ipcMain.on('startup-disable', () => autoStart.disable());
150+
ipcMain.on('check-update', () => checkAutoUpdate(true));
141151
ipcMain.on('set-badge', (event, count) => app.setBadgeCount(count));
142-
ipcMain.on('app-quit', () => app.quit() );
152+
ipcMain.on('app-quit', () => app.quit());
143153

144154
ipcMain.on('update-icon', (event, arg) => {
145155
if (!appIcon.isDestroyed()) {
@@ -177,14 +187,14 @@ app.on('ready', function() {
177187
});
178188
});
179189

180-
app.on('activate', () => appWindow.show() );
190+
app.on('activate', () => appWindow.show());
181191

182192
app.on('window-all-closed', () => {
183193
if (!isDarwin) {
184194
app.quit();
185195
}
186196
});
187197

188-
app.on('before-quit', (event) => {
198+
app.on('before-quit', () => {
189199
isQuitting = true;
190200
});

package.json

+5-1
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

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
window.Notification = function (title, options) {
1+
window.Notification = function(title) {
22
this.title = title;
33

44
return {
5-
onclick: jest.fn()
5+
onclick: jest.fn(),
66
};
77
};
88

@@ -16,11 +16,13 @@ window.Audio = class Audio {
1616

1717
window.localStorage = {
1818
store: {},
19-
getItem: function (key) { return this.store[key]; },
20-
setItem: function (key, item) {
19+
getItem: function(key) {
20+
return this.store[key];
21+
},
22+
setItem: function(key, item) {
2123
this.store[key] = item;
2224
},
23-
removeItem: jest.fn()
25+
removeItem: jest.fn(),
2426
};
2527

2628
window.alert = jest.fn();
@@ -32,7 +34,7 @@ const browserWindow = {
3234
},
3335
on: () => {},
3436
close: jest.fn(),
35-
destroy: jest.fn()
37+
destroy: jest.fn(),
3638
};
3739

3840
const dialog = {
@@ -44,14 +46,14 @@ module.exports = {
4446
BrowserWindow: () => browserWindow,
4547
dialog: dialog,
4648
app: {
47-
getVersion: () => '0.0.1'
48-
}
49+
getVersion: () => '0.0.1',
50+
},
4951
},
5052
ipcRenderer: {
5153
send: jest.fn(),
5254
on: jest.fn(),
5355
},
5456
shell: {
55-
openExternal: jest.fn()
57+
openExternal: jest.fn(),
5658
},
5759
};

0 commit comments

Comments
 (0)