build: also lint mjs files (#44581)

This commit is contained in:
Samuel Attard 2024-11-06 15:46:09 -08:00 committed by GitHub
parent ea7b0a4cc8
commit e3d75b3087
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 21 additions and 18 deletions

View file

@ -1,4 +1,5 @@
import { parseDocs } from '@electron/docs-parser';
import { promises } from 'node:fs';
import { resolve } from 'node:path';

View file

@ -138,7 +138,7 @@ const LINTERS = [{
key: 'javascript',
roots: ['build', 'default_app', 'lib', 'npm', 'script', 'spec'],
ignoreRoots: ['spec/node_modules'],
test: filename => filename.endsWith('.js') || filename.endsWith('.ts'),
test: filename => filename.endsWith('.js') || filename.endsWith('.ts') || filename.endsWith('.mjs'),
run: async (opts, filenames) => {
const eslint = new ESLint({
// Do not use the lint cache on CI builds

View file

@ -1,6 +1,6 @@
import * as pdfjs from 'pdfjs-dist';
async function getPDFDoc() {
async function getPDFDoc () {
try {
const doc = await pdfjs.getDocument(process.argv[2]).promise;
const page = await doc.getPage(1);
@ -11,12 +11,13 @@ async function getPDFDoc() {
view: page.view,
textContent: items,
markInfo
}
};
console.log(JSON.stringify(pdfInfo));
process.exit();
} catch (ex) {
console.error(ex);
process.exit(1);
}
}
getPDFDoc();
getPDFDoc();

View file

@ -1,8 +1,9 @@
import { app, BrowserWindow } from 'electron'
import { fileURLToPath } from 'node:url'
import { dirname, join } from 'node:path';
import { app, BrowserWindow } from 'electron';
async function createWindow() {
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
async function createWindow () {
const mainWindow = new BrowserWindow({
show: false,
webPreferences: {
@ -10,9 +11,9 @@ async function createWindow() {
sandbox: false,
contextIsolation: false
}
})
});
await mainWindow.loadFile('index.html')
await mainWindow.loadFile('index.html');
const importMetaPreload = await mainWindow.webContents.executeJavaScript('window.importMetaPath');
const expected = join(dirname(fileURLToPath(import.meta.url)), 'preload.mjs');
@ -21,13 +22,13 @@ async function createWindow() {
}
app.whenReady().then(() => {
createWindow()
createWindow();
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})
if (process.platform !== 'darwin') app.quit();
});

View file

@ -1,3 +1,3 @@
import { fileURLToPath } from 'node:url'
import { fileURLToPath } from 'node:url';
window.importMetaPath = fileURLToPath(import.meta.url)
window.importMetaPath = fileURLToPath(import.meta.url);