mirror of
https://github.com/electron/electron.git
synced 2026-10-28 11:44:46 +08:00
build: update @electron/lint-roller to 4.0.0 (#54139)
lint-roller 4 drops `lint-roller-markdown-standard` (and with it the
transitive eslint/standard dependency tree, roughly 1,900 lines of
yarn.lock) in favour of `lint-roller-markdown-oxlint`, which lints the JS
code blocks in docs/ with the repo's own oxlint and .oxlintrc.json. It
also makes `lint-roller-markdown-ts-check` work with TypeScript 6 and 7.
- `lint:js-in-markdown` now runs `lint-roller-markdown-oxlint`.
- `lint:docs-fiddles` ran the `standard` binary, which was only ever
installed as a dependency of lint-roller 3, so it now runs oxlint over
docs/fiddles instead. The dozen findings that surfaced (unused trailing
callback parameters, one `require('path')`, one stale eslint-disable
comment) are fixed in the fiddles, and the one tutorial that inlines an
affected fiddle is kept in sync.
- The `<!-- eslint-... -->` HTML comments in docs were directives for
lint-roller-markdown-standard and are removed, and the docs style guide
no longer points at standard-markdown.
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
7880c689d5
commit
5eefaea339
20 files changed
+53
-1935
No files matched your search
@@ -15,8 +15,6 @@ Process: [Main](../glossary.md#main-process)
|
||||
|
||||
Example:
|
||||
|
||||
<!-- eslint-disable import/order -->
|
||||
|
||||
```js
|
||||
// Main process
|
||||
const { BrowserWindow, MessageChannelMain } = require('electron')
|
||||
|
||||
@@ -165,8 +165,6 @@ An example of the contents of this file can be found [here](../../lib/browser/ap
|
||||
|
||||
Add your module to the module list found at `"lib/browser/api/module-list.ts"` like so:
|
||||
|
||||
<!-- eslint-disable semi -->
|
||||
|
||||
```ts title='lib/browser/api/module-list.ts' @ts-nocheck
|
||||
export const browserModuleList: ElectronInternal.ModuleEntry[] = [
|
||||
{ name: 'apiName', loader: () => require('./api-name') }
|
||||
|
||||
@@ -55,7 +55,7 @@ There are a few style guidelines that aren't covered by the linter rules:
|
||||
purposes.
|
||||
* No nesting lists more than 2 levels (due to the markdown renderer).
|
||||
* All `js` and `javascript` code blocks are linted with
|
||||
[standard-markdown](https://www.npmjs.com/package/standard-markdown).
|
||||
[oxlint](https://oxc.rs/docs/guide/usage/linter) as part of `npm run lint:docs`.
|
||||
* For unordered lists, use asterisks instead of dashes.
|
||||
|
||||
## Picking words
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const { app, BrowserWindow, BrowserView, ipcMain } = require('electron')
|
||||
const path = require('path')
|
||||
const path = require('node:path')
|
||||
|
||||
function createWindow () {
|
||||
const mainWindow = new BrowserWindow({
|
||||
|
||||
@@ -27,7 +27,7 @@ function createWindow () {
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.on('cancel-bluetooth-request', (event) => {
|
||||
ipcMain.on('cancel-bluetooth-request', () => {
|
||||
selectBluetoothCallback('')
|
||||
})
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ function createWindow () {
|
||||
if (portList && portList.length > 0) {
|
||||
callback(portList[0].portId)
|
||||
} else {
|
||||
// eslint-disable-next-line n/no-callback-literal
|
||||
callback('') // Could not find any matching devices
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const screenshot = document.getElementById('screen-shot')
|
||||
const screenshotMsg = document.getElementById('screenshot-path')
|
||||
|
||||
screenshot.addEventListener('click', async (event) => {
|
||||
screenshot.addEventListener('click', async () => {
|
||||
screenshotMsg.textContent = 'Gathering screens...'
|
||||
screenshotMsg.textContent = await window.electronAPI.takeScreenshot()
|
||||
})
|
||||
@@ -59,7 +59,7 @@ app.on('activate', function () {
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.on('open-error-dialog', event => {
|
||||
ipcMain.on('open-error-dialog', () => {
|
||||
dialog.showErrorBox('An Error Message', 'Demonstrating an error message.')
|
||||
})
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
const exLinksBtn = document.getElementById('open-ex-links')
|
||||
const fileManagerBtn = document.getElementById('open-file-manager')
|
||||
|
||||
fileManagerBtn.addEventListener('click', (event) => {
|
||||
fileManagerBtn.addEventListener('click', () => {
|
||||
window.electronAPI.openHomeDir()
|
||||
})
|
||||
|
||||
exLinksBtn.addEventListener('click', (event) => {
|
||||
exLinksBtn.addEventListener('click', () => {
|
||||
window.electronAPI.openExternal('https://electronjs.org')
|
||||
})
|
||||
@@ -17,7 +17,7 @@ const gotTheLock = app.requestSingleInstanceLock()
|
||||
if (!gotTheLock) {
|
||||
app.quit()
|
||||
} else {
|
||||
app.on('second-instance', (event, commandLine, workingDirectory) => {
|
||||
app.on('second-instance', (event, commandLine) => {
|
||||
// Someone tried to run a second instance, we should focus our window.
|
||||
if (mainWindow) {
|
||||
if (mainWindow.isMinimized()) mainWindow.restore()
|
||||
|
||||
@@ -3,7 +3,7 @@ const path = require('node:path')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
ipcMain.handle('get-app-path', (event) => app.getAppPath())
|
||||
ipcMain.handle('get-app-path', () => app.getAppPath())
|
||||
|
||||
function createWindow () {
|
||||
const windowOptions = {
|
||||
|
||||
@@ -6,6 +6,6 @@ window.electronAPI.onBoundsChanged((event, bounds) => {
|
||||
manageWindowReply.textContent = message
|
||||
})
|
||||
|
||||
manageWindowBtn.addEventListener('click', (event) => {
|
||||
manageWindowBtn.addEventListener('click', () => {
|
||||
window.electronAPI.createDemoWindow()
|
||||
})
|
||||
@@ -1,6 +1,6 @@
|
||||
const newWindowBtn = document.getElementById('new-window')
|
||||
|
||||
newWindowBtn.addEventListener('click', (event) => {
|
||||
newWindowBtn.addEventListener('click', () => {
|
||||
const url = 'https://electronjs.org'
|
||||
window.electronAPI.newWindow({ url, width: 400, height: 320 })
|
||||
})
|
||||
@@ -7,7 +7,7 @@ const hideFocusBtn = () => {
|
||||
focusModalBtn.removeEventListener('click', focusWindow)
|
||||
}
|
||||
|
||||
const showFocusBtn = (btn) => {
|
||||
const showFocusBtn = () => {
|
||||
focusModalBtn.classList.add('smooth-appear')
|
||||
focusModalBtn.classList.remove('disappear')
|
||||
focusModalBtn.addEventListener('click', focusWindow)
|
||||
|
||||
@@ -85,8 +85,6 @@ The `@babel/plugin-transform-modules-commonjs` plugin will transform
|
||||
ESM imports down to `require` calls. The exact syntax will depend on the
|
||||
[`importInterop` setting](https://babeljs.io/docs/babel-plugin-transform-modules-commonjs#importinterop).
|
||||
|
||||
<!-- eslint-skip -->
|
||||
|
||||
```js @nolint @ts-nocheck title='@babel/plugin-transform-modules-commonjs'
|
||||
import foo from "foo";
|
||||
import { bar } from "bar";
|
||||
|
||||
@@ -416,8 +416,6 @@ function createWindow () {
|
||||
For the purposes of the tutorial, it's important to note that the `click` handler
|
||||
sends a message (either `1` or `-1`) to the renderer process through the `update-counter` channel.
|
||||
|
||||
<!-- eslint-skip -->
|
||||
|
||||
```js @ts-type={mainWindow:Electron.BrowserWindow}
|
||||
click: () => mainWindow.webContents.send('update-counter', -1)
|
||||
```
|
||||
|
||||
@@ -78,7 +78,7 @@ const gotTheLock = app.requestSingleInstanceLock()
|
||||
if (!gotTheLock) {
|
||||
app.quit()
|
||||
} else {
|
||||
app.on('second-instance', (event, commandLine, workingDirectory) => {
|
||||
app.on('second-instance', (event, commandLine) => {
|
||||
// Someone tried to run a second instance, we should focus our window.
|
||||
if (mainWindow) {
|
||||
if (mainWindow.isMinimized()) mainWindow.restore()
|
||||
|
||||
@@ -269,8 +269,6 @@ Let's break down this code:
|
||||
|
||||
Now, let's create a JavaScript wrapper to make the addon easier to use. Create `js/index.js`:
|
||||
|
||||
<!-- eslint-disable import/newline-after-import,import/order -->
|
||||
|
||||
```js title='js/index.js' @ts-expect-error=[5]
|
||||
const EventEmitter = require('node:events')
|
||||
|
||||
|
||||
+3
-3
@@ -10,7 +10,7 @@
|
||||
"@electron/docs-parser": "^3.0.1",
|
||||
"@electron/fiddle-core": "^2.2.2",
|
||||
"@electron/github-app-auth": "^3.2.0",
|
||||
"@electron/lint-roller": "^3.2.0",
|
||||
"@electron/lint-roller": "^4.0.0",
|
||||
"@electron/typescript-definitions": "^9.2.0",
|
||||
"@hurdlegroup/robotjs": "^0.12.3",
|
||||
"@octokit/rest": "^22.0.1",
|
||||
@@ -51,11 +51,11 @@
|
||||
"lint:py": "node ./script/lint.js --py",
|
||||
"lint:gn": "node ./script/lint.js --gn",
|
||||
"lint:docs": "npm run lint:js-in-markdown && npm run create-typescript-definitions && npm run lint:ts-check-js-in-markdown && npm run lint:docs-fiddles && npm run lint:docs-relative-links && npm run lint:markdown && npm run lint:api-history",
|
||||
"lint:docs-fiddles": "standard \"docs/fiddles/**/*.js\"",
|
||||
"lint:docs-fiddles": "oxlint docs/fiddles",
|
||||
"lint:docs-relative-links": "lint-roller-markdown-links --resource-root . --root docs \"**/*.md\"",
|
||||
"lint:markdown": "node ./script/lint.js --md",
|
||||
"lint:ts-check-js-in-markdown": "lint-roller-markdown-ts-check --root docs \"**/*.md\" --ignore \"breaking-changes.md\"",
|
||||
"lint:js-in-markdown": "lint-roller-markdown-standard --root docs \"**/*.md\"",
|
||||
"lint:js-in-markdown": "lint-roller-markdown-oxlint --root docs \"**/*.md\"",
|
||||
"lint:api-history": "lint-roller-markdown-api-history --root \"./docs/api/\" --schema \"./docs/api-history.schema.json\" --breaking-changes-file \"./docs/breaking-changes.md\" --check-placement --check-strings \"*.md\"",
|
||||
"lint:chromium-roller": "node ./script/lint-roller-chromium-changes.mjs",
|
||||
"create-api-json": "node script/create-api-json.mjs",
|
||||
|
||||
Reference in new issue
Block a user