From 99f4a42d4135cf2a596abbb31782485e41734230 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Tue, 20 Sep 2022 20:25:33 +0200 Subject: [PATCH] chore: add missing .eslintrc.json files to limit imports properly (#35719) --- lib/browser/.eslintrc.json | 2 +- lib/common/.eslintrc.json | 23 +++++++++++++++++++++++ lib/common/api/clipboard.ts | 1 + lib/isolated_renderer/.eslintrc.json | 18 ++++++++++++++++++ lib/renderer/.eslintrc.json | 18 ++++++++++++++++++ lib/renderer/common-init.ts | 2 +- lib/renderer/inspector.ts | 2 +- lib/renderer/web-frame-init.ts | 2 +- lib/sandboxed_renderer/.eslintrc.json | 18 ++++++++++++++++++ lib/worker/.eslintrc.json | 18 ++++++++++++++++++ 10 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 lib/common/.eslintrc.json create mode 100644 lib/isolated_renderer/.eslintrc.json create mode 100644 lib/renderer/.eslintrc.json create mode 100644 lib/sandboxed_renderer/.eslintrc.json create mode 100644 lib/worker/.eslintrc.json diff --git a/lib/browser/.eslintrc.json b/lib/browser/.eslintrc.json index 27d223a509d9..dab1dafc3f26 100644 --- a/lib/browser/.eslintrc.json +++ b/lib/browser/.eslintrc.json @@ -18,4 +18,4 @@ } ] } -} \ No newline at end of file +} diff --git a/lib/common/.eslintrc.json b/lib/common/.eslintrc.json new file mode 100644 index 000000000000..42964484b5c3 --- /dev/null +++ b/lib/common/.eslintrc.json @@ -0,0 +1,23 @@ +{ + "rules": { + "no-restricted-imports": [ + "error", + { + "paths": [ + "electron", + "electron/main", + "electron/renderer" + ], + "patterns": [ + "./*", + "../*", + "@electron/internal/browser/*", + "@electron/internal/isolated_renderer/*", + "@electron/internal/renderer/*", + "@electron/internal/sandboxed_worker/*", + "@electron/internal/worker/*" + ] + } + ] + } +} diff --git a/lib/common/api/clipboard.ts b/lib/common/api/clipboard.ts index dd03b4f279d6..55f7958bc796 100644 --- a/lib/common/api/clipboard.ts +++ b/lib/common/api/clipboard.ts @@ -1,5 +1,6 @@ import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages'; +// eslint-disable-next-line no-restricted-imports import type * as ipcRendererUtilsModule from '@electron/internal/renderer/ipc-renderer-internal-utils'; const clipboard = process._linkedBinding('electron_common_clipboard'); diff --git a/lib/isolated_renderer/.eslintrc.json b/lib/isolated_renderer/.eslintrc.json new file mode 100644 index 000000000000..cb5f6cadaa4f --- /dev/null +++ b/lib/isolated_renderer/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "rules": { + "no-restricted-imports": [ + "error", + { + "paths": [ + "electron", + "electron/main" + ], + "patterns": [ + "./*", + "../*", + "@electron/internal/browser/*" + ] + } + ] + } +} diff --git a/lib/renderer/.eslintrc.json b/lib/renderer/.eslintrc.json new file mode 100644 index 000000000000..cb5f6cadaa4f --- /dev/null +++ b/lib/renderer/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "rules": { + "no-restricted-imports": [ + "error", + { + "paths": [ + "electron", + "electron/main" + ], + "patterns": [ + "./*", + "../*", + "@electron/internal/browser/*" + ] + } + ] + } +} diff --git a/lib/renderer/common-init.ts b/lib/renderer/common-init.ts index 4ceff37416d5..bfec34419ddd 100644 --- a/lib/renderer/common-init.ts +++ b/lib/renderer/common-init.ts @@ -1,4 +1,4 @@ -import { ipcRenderer } from 'electron'; +import { ipcRenderer } from 'electron/renderer'; import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal'; import type * as webViewInitModule from '@electron/internal/renderer/web-view/web-view-init'; diff --git a/lib/renderer/inspector.ts b/lib/renderer/inspector.ts index 346de2030ef4..8dd941d30619 100644 --- a/lib/renderer/inspector.ts +++ b/lib/renderer/inspector.ts @@ -2,7 +2,7 @@ import { internalContextBridge } from '@electron/internal/renderer/api/context-b import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal'; import * as ipcRendererUtils from '@electron/internal/renderer/ipc-renderer-internal-utils'; import { webFrame } from 'electron/renderer'; -import { IPC_MESSAGES } from '../common/ipc-messages'; +import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages'; const { contextIsolationEnabled } = internalContextBridge; diff --git a/lib/renderer/web-frame-init.ts b/lib/renderer/web-frame-init.ts index 37225cfb3428..ac4db7f9a74d 100644 --- a/lib/renderer/web-frame-init.ts +++ b/lib/renderer/web-frame-init.ts @@ -1,4 +1,4 @@ -import { webFrame, WebFrame } from 'electron'; +import { webFrame, WebFrame } from 'electron/renderer'; import * as ipcRendererUtils from '@electron/internal/renderer/ipc-renderer-internal-utils'; import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages'; diff --git a/lib/sandboxed_renderer/.eslintrc.json b/lib/sandboxed_renderer/.eslintrc.json new file mode 100644 index 000000000000..cb5f6cadaa4f --- /dev/null +++ b/lib/sandboxed_renderer/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "rules": { + "no-restricted-imports": [ + "error", + { + "paths": [ + "electron", + "electron/main" + ], + "patterns": [ + "./*", + "../*", + "@electron/internal/browser/*" + ] + } + ] + } +} diff --git a/lib/worker/.eslintrc.json b/lib/worker/.eslintrc.json new file mode 100644 index 000000000000..cb5f6cadaa4f --- /dev/null +++ b/lib/worker/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "rules": { + "no-restricted-imports": [ + "error", + { + "paths": [ + "electron", + "electron/main" + ], + "patterns": [ + "./*", + "../*", + "@electron/internal/browser/*" + ] + } + ] + } +}