mirror of
https://github.com/scratchfoundation/scratch-desktop.git
synced 2025-06-07 02:24:21 -04:00
Use eslint-config-scratch
This commit is contained in:
parent
6145b0b9a1
commit
13391df515
10 changed files with 2554 additions and 230 deletions
11
.editorconfig
Normal file
11
.editorconfig
Normal 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
2
.eslintignore
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
node_modules/*
|
||||||
|
dist/*
|
7
.eslintrc.js
Normal file
7
.eslintrc.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
module.exports = {
|
||||||
|
root: true,
|
||||||
|
env: {
|
||||||
|
node: true
|
||||||
|
},
|
||||||
|
extends: ['scratch', 'scratch/node']
|
||||||
|
};
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.eslintcache
|
||||||
dist/
|
dist/
|
||||||
node_modules/
|
node_modules/
|
||||||
thumbs.db
|
thumbs.db
|
||||||
|
|
2645
package-lock.json
generated
2645
package-lock.json
generated
File diff suppressed because it is too large
Load diff
10
package.json
10
package.json
|
@ -6,16 +6,22 @@
|
||||||
"start": "electron-webpack dev",
|
"start": "electron-webpack dev",
|
||||||
"compile": "electron-webpack",
|
"compile": "electron-webpack",
|
||||||
"dist": "npm run compile && electron-builder",
|
"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": {
|
"dependencies": {
|
||||||
"source-map-support": "^0.5.9"
|
"source-map-support": "^0.5.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"babel-eslint": "^8.2.6",
|
||||||
"electron": "2.0.7",
|
"electron": "2.0.7",
|
||||||
"electron-builder": "^20.28.1",
|
"electron-builder": "^20.28.1",
|
||||||
"electron-webpack": "^2.1.2",
|
"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": {
|
"resolutions": {
|
||||||
"upath": "^1.0.5"
|
"upath": "^1.0.5"
|
||||||
|
|
7
src/.eslintrc.js
Normal file
7
src/.eslintrc.js
Normal 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
7
src/main/.eslintrc.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
module.exports = {
|
||||||
|
root: true,
|
||||||
|
env: {
|
||||||
|
node: true
|
||||||
|
},
|
||||||
|
extends: ['scratch', 'scratch/es6', 'scratch/node']
|
||||||
|
};
|
|
@ -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'
|
const isDevelopment = process.env.NODE_ENV !== 'production';
|
||||||
import * as path from 'path'
|
|
||||||
import { format as formatUrl } from 'url'
|
|
||||||
|
|
||||||
const isDevelopment = process.env.NODE_ENV !== 'production'
|
|
||||||
|
|
||||||
// global reference to mainWindow (necessary to prevent window from being garbage collected)
|
// global reference to mainWindow (necessary to prevent window from being garbage collected)
|
||||||
let mainWindow
|
let mainWindow;
|
||||||
|
|
||||||
function createMainWindow() {
|
const createMainWindow = () => {
|
||||||
const window = new BrowserWindow()
|
const window = new BrowserWindow();
|
||||||
|
|
||||||
if (isDevelopment) {
|
if (isDevelopment) {
|
||||||
window.webContents.openDevTools()
|
window.webContents.openDevTools();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDevelopment) {
|
if (isDevelopment) {
|
||||||
window.loadURL(`http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}`)
|
window.loadURL(`http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}`);
|
||||||
}
|
} else {
|
||||||
else {
|
window.loadURL(formatUrl({
|
||||||
window.loadURL(formatUrl({
|
pathname: path.join(__dirname, 'index.html'),
|
||||||
pathname: path.join(__dirname, 'index.html'),
|
protocol: 'file',
|
||||||
protocol: 'file',
|
slashes: true
|
||||||
slashes: true
|
}));
|
||||||
}))
|
}
|
||||||
}
|
|
||||||
|
|
||||||
window.on('closed', () => {
|
window.on('closed', () => {
|
||||||
mainWindow = null
|
mainWindow = null;
|
||||||
})
|
});
|
||||||
|
|
||||||
window.webContents.on('devtools-opened', () => {
|
window.webContents.on('devtools-opened', () => {
|
||||||
window.focus()
|
window.focus();
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
window.focus()
|
window.focus();
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
return window
|
return window;
|
||||||
}
|
};
|
||||||
|
|
||||||
// quit application when all windows are closed
|
// quit application when all windows are closed
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
// on macOS it is common for applications to stay open until the user explicitly quits
|
// on macOS it is common for applications to stay open until the user explicitly quits
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
app.quit()
|
app.quit();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
app.on('activate', () => {
|
app.on('activate', () => {
|
||||||
// on macOS it is common to re-create a window even after all windows have been closed
|
// on macOS it is common to re-create a window even after all windows have been closed
|
||||||
if (mainWindow === null) {
|
if (mainWindow === null) {
|
||||||
mainWindow = createMainWindow()
|
mainWindow = createMainWindow();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
// create main BrowserWindow when electron is ready
|
// create main BrowserWindow when electron is ready
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
mainWindow = createMainWindow()
|
mainWindow = createMainWindow();
|
||||||
})
|
});
|
||||||
|
|
7
src/renderer/.eslintrc.js
Normal file
7
src/renderer/.eslintrc.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
module.exports = {
|
||||||
|
root: true,
|
||||||
|
env: {
|
||||||
|
browser: true
|
||||||
|
},
|
||||||
|
extends: ['scratch', 'scratch/react']
|
||||||
|
};
|
Loading…
Add table
Add a link
Reference in a new issue