build: also lint mjs files (#44581)
This commit is contained in:
parent
ea7b0a4cc8
commit
e3d75b3087
5 changed files with 21 additions and 18 deletions
|
@ -1,4 +1,5 @@
|
|||
import { parseDocs } from '@electron/docs-parser';
|
||||
|
||||
import { promises } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
7
spec/fixtures/api/pdf-reader.mjs
vendored
7
spec/fixtures/api/pdf-reader.mjs
vendored
|
@ -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();
|
||||
|
|
25
spec/fixtures/esm/import-meta/main.mjs
vendored
25
spec/fixtures/esm/import-meta/main.mjs
vendored
|
@ -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();
|
||||
});
|
||||
|
|
4
spec/fixtures/esm/import-meta/preload.mjs
vendored
4
spec/fixtures/esm/import-meta/preload.mjs
vendored
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue