Use eslint-config-scratch

This commit is contained in:
Christopher Willis-Ford 2018-09-19 15:15:02 -07:00
parent 6145b0b9a1
commit 13391df515
10 changed files with 2554 additions and 230 deletions

11
.editorconfig Normal file
View file

@ -0,0 +1,11 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_size = 4
trim_trailing_whitespace = true
[*.{js,html}]
indent_style = space

2
.eslintignore Normal file
View file

@ -0,0 +1,2 @@
node_modules/*
dist/*

7
.eslintrc.js Normal file
View file

@ -0,0 +1,7 @@
module.exports = {
root: true,
env: {
node: true
},
extends: ['scratch', 'scratch/node']
};

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
.DS_Store
.eslintcache
dist/
node_modules/
thumbs.db

2645
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -6,16 +6,22 @@
"start": "electron-webpack dev",
"compile": "electron-webpack",
"dist": "npm run compile && electron-builder",
"dist:dir": "npm run dist -- --dir -c.compression=store -c.mac.identity=null"
"dist:dir": "npm run dist -- --dir -c.compression=store -c.mac.identity=null",
"lint": "eslint --cache --color --ext .jsx,.js ."
},
"dependencies": {
"source-map-support": "^0.5.9"
},
"devDependencies": {
"babel-eslint": "^8.2.6",
"electron": "2.0.7",
"electron-builder": "^20.28.1",
"electron-webpack": "^2.1.2",
"webpack": "^4.16.5"
"webpack": "^4.16.5",
"eslint": "^4.19.1",
"eslint-config-scratch": "^5.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-react": "^7.11.1"
},
"resolutions": {
"upath": "^1.0.5"

7
src/.eslintrc.js Normal file
View file

@ -0,0 +1,7 @@
module.exports = {
root: true,
env: {
'shared-node-browser': true
},
extends: ['scratch', 'scratch/es6']
};

7
src/main/.eslintrc.js Normal file
View file

@ -0,0 +1,7 @@
module.exports = {
root: true,
env: {
node: true
},
extends: ['scratch', 'scratch/es6', 'scratch/node']
};

View file

@ -1,62 +1,59 @@
'use strict'
import {app, BrowserWindow} from 'electron';
import * as path from 'path';
import {format as formatUrl} from 'url';
import { app, BrowserWindow } from 'electron'
import * as path from 'path'
import { format as formatUrl } from 'url'
const isDevelopment = process.env.NODE_ENV !== 'production'
const isDevelopment = process.env.NODE_ENV !== 'production';
// global reference to mainWindow (necessary to prevent window from being garbage collected)
let mainWindow
let mainWindow;
function createMainWindow() {
const window = new BrowserWindow()
const createMainWindow = () => {
const window = new BrowserWindow();
if (isDevelopment) {
window.webContents.openDevTools()
}
if (isDevelopment) {
window.webContents.openDevTools();
}
if (isDevelopment) {
window.loadURL(`http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}`)
}
else {
window.loadURL(formatUrl({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file',
slashes: true
}))
}
if (isDevelopment) {
window.loadURL(`http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}`);
} else {
window.loadURL(formatUrl({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file',
slashes: true
}));
}
window.on('closed', () => {
mainWindow = null
})
window.on('closed', () => {
mainWindow = null;
});
window.webContents.on('devtools-opened', () => {
window.focus()
setImmediate(() => {
window.focus()
})
})
window.webContents.on('devtools-opened', () => {
window.focus();
setImmediate(() => {
window.focus();
});
});
return window
}
return window;
};
// quit application when all windows are closed
app.on('window-all-closed', () => {
// on macOS it is common for applications to stay open until the user explicitly quits
if (process.platform !== 'darwin') {
app.quit()
}
})
// on macOS it is common for applications to stay open until the user explicitly quits
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
// on macOS it is common to re-create a window even after all windows have been closed
if (mainWindow === null) {
mainWindow = createMainWindow()
}
})
// on macOS it is common to re-create a window even after all windows have been closed
if (mainWindow === null) {
mainWindow = createMainWindow();
}
});
// create main BrowserWindow when electron is ready
app.on('ready', () => {
mainWindow = createMainWindow()
})
mainWindow = createMainWindow();
});

View file

@ -0,0 +1,7 @@
module.exports = {
root: true,
env: {
browser: true
},
extends: ['scratch', 'scratch/react']
};