build: also lint mjs files (#44581)

This commit is contained in:
Samuel Attard 2024-11-06 15:46:09 -08:00 committed by GitHub
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 { parseDocs } from '@electron/docs-parser';
import { promises } from 'node:fs'; import { promises } from 'node:fs';
import { resolve } from 'node:path'; import { resolve } from 'node:path';

View file

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

View file

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

View file

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