chore: always lint JS in docs/fiddles (#38025)
This commit is contained in:
parent
141f65b291
commit
9b41ab1e53
16 changed files with 86 additions and 98 deletions
|
@ -2,5 +2,5 @@ const NOTIFICATION_TITLE = 'Title'
|
||||||
const NOTIFICATION_BODY = 'Notification from the Renderer process. Click to log to console.'
|
const NOTIFICATION_BODY = 'Notification from the Renderer process. Click to log to console.'
|
||||||
const CLICK_MESSAGE = 'Notification clicked!'
|
const CLICK_MESSAGE = 'Notification clicked!'
|
||||||
|
|
||||||
new Notification(NOTIFICATION_TITLE, { body: NOTIFICATION_BODY })
|
new window.Notification(NOTIFICATION_TITLE, { body: NOTIFICATION_BODY })
|
||||||
.onclick = () => document.getElementById('output').innerText = CLICK_MESSAGE
|
.onclick = () => { document.getElementById('output').innerText = CLICK_MESSAGE }
|
||||||
|
|
|
@ -4,16 +4,31 @@ const path = require('path')
|
||||||
|
|
||||||
app.disableHardwareAcceleration()
|
app.disableHardwareAcceleration()
|
||||||
|
|
||||||
let win
|
function createWindow () {
|
||||||
|
const win = new BrowserWindow({
|
||||||
|
width: 800,
|
||||||
|
height: 600,
|
||||||
|
webPreferences: {
|
||||||
|
offscreen: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
|
||||||
win = new BrowserWindow({ webPreferences: { offscreen: true } })
|
|
||||||
win.loadURL('https://github.com')
|
win.loadURL('https://github.com')
|
||||||
win.webContents.on('paint', (event, dirty, image) => {
|
win.webContents.on('paint', (event, dirty, image) => {
|
||||||
fs.writeFileSync('ex.png', image.toPNG())
|
fs.writeFileSync('ex.png', image.toPNG())
|
||||||
})
|
})
|
||||||
win.webContents.setFrameRate(60)
|
win.webContents.setFrameRate(60)
|
||||||
console.log(`The screenshot has been successfully saved to ${path.join(process.cwd(), 'ex.png')}`)
|
console.log(`The screenshot has been successfully saved to ${path.join(process.cwd(), 'ex.png')}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
app.whenReady().then(() => {
|
||||||
|
createWindow()
|
||||||
|
|
||||||
|
app.on('activate', () => {
|
||||||
|
if (BrowserWindow.getAllWindows().length === 0) {
|
||||||
|
createWindow()
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
|
@ -21,9 +36,3 @@ app.on('window-all-closed', () => {
|
||||||
app.quit()
|
app.quit()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('activate', () => {
|
|
||||||
if (BrowserWindow.getAllWindows().length === 0) {
|
|
||||||
createWindow()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ function createWindow () {
|
||||||
selectBluetoothCallback('')
|
selectBluetoothCallback('')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
// Listen for a message from the renderer to get the response for the Bluetooth pairing.
|
// Listen for a message from the renderer to get the response for the Bluetooth pairing.
|
||||||
ipcMain.on('bluetooth-pairing-response', (event, response) => {
|
ipcMain.on('bluetooth-pairing-response', (event, response) => {
|
||||||
bluetoothPinCallback(response)
|
bluetoothPinCallback(response)
|
||||||
|
|
|
@ -7,7 +7,7 @@ async function testIt () {
|
||||||
|
|
||||||
document.getElementById('clickme').addEventListener('click', testIt)
|
document.getElementById('clickme').addEventListener('click', testIt)
|
||||||
|
|
||||||
function cancelRequest() {
|
function cancelRequest () {
|
||||||
window.electronAPI.cancelBluetoothRequest()
|
window.electronAPI.cancelBluetoothRequest()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,15 +18,15 @@ window.electronAPI.bluetoothPairingRequest((event, details) => {
|
||||||
|
|
||||||
switch (details.pairingKind) {
|
switch (details.pairingKind) {
|
||||||
case 'confirm': {
|
case 'confirm': {
|
||||||
response.confirmed = confirm(`Do you want to connect to device ${details.deviceId}?`)
|
response.confirmed = window.confirm(`Do you want to connect to device ${details.deviceId}?`)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'confirmPin': {
|
case 'confirmPin': {
|
||||||
response.confirmed = confirm(`Does the pin ${details.pin} match the pin displayed on device ${details.deviceId}?`)
|
response.confirmed = window.confirm(`Does the pin ${details.pin} match the pin displayed on device ${details.deviceId}?`)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'providePin': {
|
case 'providePin': {
|
||||||
const pin = prompt(`Please provide a pin for ${details.deviceId}.`)
|
const pin = window.prompt(`Please provide a pin for ${details.deviceId}.`)
|
||||||
if (pin) {
|
if (pin) {
|
||||||
response.pin = pin
|
response.pin = pin
|
||||||
response.confirmed = true
|
response.confirmed = true
|
||||||
|
|
|
@ -23,6 +23,7 @@ function createWindow () {
|
||||||
if (portList && portList.length > 0) {
|
if (portList && portList.length > 0) {
|
||||||
callback(portList[0].portId)
|
callback(portList[0].portId)
|
||||||
} else {
|
} else {
|
||||||
|
// eslint-disable-next-line standard/no-callback-literal
|
||||||
callback('') // Could not find any matching devices
|
callback('') // Could not find any matching devices
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -20,7 +20,7 @@ async function testIt () {
|
||||||
const grantedDevice = await navigator.usb.requestDevice({
|
const grantedDevice = await navigator.usb.requestDevice({
|
||||||
filters: []
|
filters: []
|
||||||
})
|
})
|
||||||
grantedDeviceList += `<hr>${getDeviceDetails(device)}</hr>`
|
grantedDeviceList += `<hr>${getDeviceDetails(grantedDevice)}</hr>`
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
if (ex.name === 'NotFoundError') {
|
if (ex.name === 'NotFoundError') {
|
||||||
grantedDeviceList = noDevicesFoundMsg
|
grantedDeviceList = noDevicesFoundMsg
|
||||||
|
|
|
@ -5,17 +5,3 @@ const exLinksBtn = document.getElementById('open-ex-links')
|
||||||
exLinksBtn.addEventListener('click', (event) => {
|
exLinksBtn.addEventListener('click', (event) => {
|
||||||
shell.openExternal('https://electronjs.org')
|
shell.openExternal('https://electronjs.org')
|
||||||
})
|
})
|
||||||
|
|
||||||
const OpenAllOutboundLinks = () => {
|
|
||||||
const links = document.querySelectorAll('a[href]')
|
|
||||||
|
|
||||||
Array.prototype.forEach.call(links, (link) => {
|
|
||||||
const url = link.getAttribute('href')
|
|
||||||
if (url.indexOf('http') === 0) {
|
|
||||||
link.addEventListener('click', (e) => {
|
|
||||||
e.preventDefault()
|
|
||||||
shell.openExternal(url)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
|
@ -4,5 +4,5 @@ const copyInput = document.getElementById('copy-to-input')
|
||||||
copyBtn.addEventListener('click', () => {
|
copyBtn.addEventListener('click', () => {
|
||||||
if (copyInput.value !== '') copyInput.value = ''
|
if (copyInput.value !== '') copyInput.value = ''
|
||||||
copyInput.placeholder = 'Copied! Paste here to see.'
|
copyInput.placeholder = 'Copied! Paste here to see.'
|
||||||
clipboard.writeText('Electron Demo!')
|
window.clipboard.writeText('Electron Demo!')
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const pasteBtn = document.getElementById('paste-to')
|
const pasteBtn = document.getElementById('paste-to')
|
||||||
|
|
||||||
pasteBtn.addEventListener('click', async () => {
|
pasteBtn.addEventListener('click', async () => {
|
||||||
await clipboard.writeText('What a demo!')
|
await window.clipboard.writeText('What a demo!')
|
||||||
const message = `Clipboard contents: ${await clipboard.readText()}`
|
const message = `Clipboard contents: ${await window.clipboard.readText()}`
|
||||||
document.getElementById('paste-from').innerHTML = message
|
document.getElementById('paste-from').innerHTML = message
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const { ipcRenderer } = require('electron')
|
const { ipcRenderer, shell } = require('electron')
|
||||||
|
|
||||||
const appInfoBtn = document.getElementById('app-info')
|
const appInfoBtn = document.getElementById('app-info')
|
||||||
const electron_doc_link = document.querySelectorAll('a[href]')
|
const electronDocLink = document.querySelectorAll('a[href]')
|
||||||
|
|
||||||
appInfoBtn.addEventListener('click', () => {
|
appInfoBtn.addEventListener('click', () => {
|
||||||
ipcRenderer.send('get-app-path')
|
ipcRenderer.send('get-app-path')
|
||||||
|
@ -12,7 +12,8 @@ ipcRenderer.on('got-app-path', (event, path) => {
|
||||||
document.getElementById('got-app-info').innerHTML = message
|
document.getElementById('got-app-info').innerHTML = message
|
||||||
})
|
})
|
||||||
|
|
||||||
electron_doc_link.addEventListener('click', (e) => {
|
electronDocLink.addEventListener('click', (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
const url = e.target.getAttribute('href')
|
||||||
shell.openExternal(url)
|
shell.openExternal(url)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
const information = document.getElementById('info')
|
const information = document.getElementById('info')
|
||||||
information.innerText = `This app is using Chrome (v${versions.chrome()}), Node.js (v${versions.node()}), and Electron (v${versions.electron()})`
|
information.innerText = `This app is using Chrome (v${window.versions.chrome()}), Node.js (v${window.versions.node()}), and Electron (v${window.versions.electron()})`
|
||||||
|
|
|
@ -23,23 +23,21 @@ function createWindow () {
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
// Some APIs can only be used after this event occurs.
|
// Some APIs can only be used after this event occurs.
|
||||||
app.whenReady().then(createWindow)
|
app.whenReady().then(() => {
|
||||||
|
createWindow()
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
app.on('activate', function () {
|
||||||
app.on('window-all-closed', function () {
|
// On macOS it's common to re-create a window in the app when the
|
||||||
// On macOS it is common for applications and their menu bar
|
// dock icon is clicked and there are no other windows open.
|
||||||
// to stay active until the user quits explicitly with Cmd + Q
|
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||||
if (process.platform !== 'darwin') {
|
})
|
||||||
app.quit()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('activate', function () {
|
// Quit when all windows are closed, except on macOS. There, it's common
|
||||||
// On macOS it is common to re-create a window in the app when the
|
// for applications and their menu bar to stay active until the user quits
|
||||||
// dock icon is clicked and there are no other windows open.
|
// explicitly with Cmd + Q.
|
||||||
if (mainWindow === null) {
|
app.on('window-all-closed', function () {
|
||||||
createWindow()
|
if (process.platform !== 'darwin') app.quit()
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// In this file you can include the rest of your app's specific main process
|
// In this file you can include the rest of your app's specific main process
|
||||||
|
|
|
@ -18,7 +18,7 @@ ipcMain.on('create-demo-window', (event) => {
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
mainWindow = new BrowserWindow({
|
const mainWindow = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
|
@ -33,23 +33,21 @@ function createWindow () {
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
// Some APIs can only be used after this event occurs.
|
// Some APIs can only be used after this event occurs.
|
||||||
app.whenReady().then(createWindow)
|
app.whenReady().then(() => {
|
||||||
|
createWindow()
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
app.on('activate', function () {
|
||||||
app.on('window-all-closed', function () {
|
// On macOS it's common to re-create a window in the app when the
|
||||||
// On macOS it is common for applications and their menu bar
|
// dock icon is clicked and there are no other windows open.
|
||||||
// to stay active until the user quits explicitly with Cmd + Q
|
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||||
if (process.platform !== 'darwin') {
|
})
|
||||||
app.quit()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('activate', function () {
|
// Quit when all windows are closed, except on macOS. There, it's common
|
||||||
// On macOS it is common to re-create a window in the app when the
|
// for applications and their menu bar to stay active until the user quits
|
||||||
// dock icon is clicked and there are no other windows open.
|
// explicitly with Cmd + Q.
|
||||||
if (mainWindow === null) {
|
app.on('window-all-closed', function () {
|
||||||
createWindow()
|
if (process.platform !== 'darwin') app.quit()
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// In this file you can include the rest of your app's specific main process
|
// In this file you can include the rest of your app's specific main process
|
||||||
|
|
|
@ -23,23 +23,21 @@ function createWindow () {
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
// Some APIs can only be used after this event occurs.
|
// Some APIs can only be used after this event occurs.
|
||||||
app.whenReady().then(createWindow)
|
app.whenReady().then(() => {
|
||||||
|
createWindow()
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
app.on('activate', function () {
|
||||||
app.on('window-all-closed', function () {
|
// On macOS it's common to re-create a window in the app when the
|
||||||
// On macOS it is common for applications and their menu bar
|
// dock icon is clicked and there are no other windows open.
|
||||||
// to stay active until the user quits explicitly with Cmd + Q
|
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||||
if (process.platform !== 'darwin') {
|
})
|
||||||
app.quit()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('activate', function () {
|
// Quit when all windows are closed, except on macOS. There, it's common
|
||||||
// On macOS it is common to re-create a window in the app when the
|
// for applications and their menu bar to stay active until the user quits
|
||||||
// dock icon is clicked and there are no other windows open.
|
// explicitly with Cmd + Q.
|
||||||
if (mainWindow === null) {
|
app.on('window-all-closed', function () {
|
||||||
createWindow()
|
if (process.platform !== 'darwin') app.quit()
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// In this file you can include the rest of your app's specific main process
|
// In this file you can include the rest of your app's specific main process
|
||||||
|
|
|
@ -41,23 +41,21 @@ function createWindow () {
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
// Some APIs can only be used after this event occurs.
|
// Some APIs can only be used after this event occurs.
|
||||||
app.whenReady().then(createWindow)
|
app.whenReady().then(() => {
|
||||||
|
createWindow()
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
app.on('activate', function () {
|
||||||
app.on('window-all-closed', function () {
|
// On macOS it's common to re-create a window in the app when the
|
||||||
// On macOS it is common for applications and their menu bar
|
// dock icon is clicked and there are no other windows open.
|
||||||
// to stay active until the user quits explicitly with Cmd + Q
|
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||||
if (process.platform !== 'darwin') {
|
})
|
||||||
app.quit()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('activate', function () {
|
// Quit when all windows are closed, except on macOS. There, it's common
|
||||||
// On macOS it is common to re-create a window in the app when the
|
// for applications and their menu bar to stay active until the user quits
|
||||||
// dock icon is clicked and there are no other windows open.
|
// explicitly with Cmd + Q.
|
||||||
if (mainWindow === null) {
|
app.on('window-all-closed', function () {
|
||||||
createWindow()
|
if (process.platform !== 'darwin') app.quit()
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// In this file you can include the rest of your app's specific main process
|
// In this file you can include the rest of your app's specific main process
|
||||||
|
|
|
@ -94,7 +94,7 @@
|
||||||
"lint:objc": "node ./script/lint.js --objc",
|
"lint:objc": "node ./script/lint.js --objc",
|
||||||
"lint:py": "node ./script/lint.js --py",
|
"lint:py": "node ./script/lint.js --py",
|
||||||
"lint:gn": "node ./script/lint.js --gn",
|
"lint:gn": "node ./script/lint.js --gn",
|
||||||
"lint:docs": "remark docs -qf && npm run lint:js-in-markdown && npm run create-typescript-definitions && npm run lint:docs-relative-links && npm run lint:markdownlint",
|
"lint:docs": "remark docs -qf && npm run lint:js-in-markdown && npm run create-typescript-definitions && npm run lint:docs-fiddles && npm run lint:docs-relative-links && npm run lint:markdownlint",
|
||||||
"lint:docs-fiddles": "standard \"docs/fiddles/**/*.js\"",
|
"lint:docs-fiddles": "standard \"docs/fiddles/**/*.js\"",
|
||||||
"lint:docs-relative-links": "ts-node script/lint-docs-links.ts",
|
"lint:docs-relative-links": "ts-node script/lint-docs-links.ts",
|
||||||
"lint:markdownlint": "markdownlint -r ./script/markdownlint-emd001.js \"*.md\" \"docs/**/*.md\"",
|
"lint:markdownlint": "markdownlint -r ./script/markdownlint-emd001.js \"*.md\" \"docs/**/*.md\"",
|
||||||
|
|
Loading…
Reference in a new issue