mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-10-24 08:33:36 +00:00
xo: Prohibit main-only and renderer-only APIs in wrong processes.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
@@ -1,5 +1,36 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
const restrictedMainImports = [
|
||||||
|
{
|
||||||
|
name: "@sentry/electron/main",
|
||||||
|
message: "Cannot use main-only APIs here.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "electron/main",
|
||||||
|
message: "Cannot use main-only APIs here.",
|
||||||
|
allowTypeImports: true, // https://github.com/zulip/zulip-desktop/issues/915
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "electron-log/main",
|
||||||
|
message: "Cannot use main-only APIs here.",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const restrictedRendererImports = [
|
||||||
|
{
|
||||||
|
name: "@sentry/electron/renderer",
|
||||||
|
message: "Cannot use renderer-only APIs here.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "electron/renderer",
|
||||||
|
message: "Cannot use renderer-only APIs here.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "electron-log/renderer",
|
||||||
|
message: "Cannot use renderer-only APIs here.",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
prettier: true,
|
prettier: true,
|
||||||
settings: {
|
settings: {
|
||||||
@@ -113,5 +144,32 @@ module.exports = {
|
|||||||
"import/unambiguous": "off",
|
"import/unambiguous": "off",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
files: ["app/common/**"],
|
||||||
|
rules: {
|
||||||
|
"@typescript-eslint/no-restricted-imports": [
|
||||||
|
"error",
|
||||||
|
{paths: [...restrictedMainImports, ...restrictedRendererImports]},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["app/main/**"],
|
||||||
|
rules: {
|
||||||
|
"@typescript-eslint/no-restricted-imports": [
|
||||||
|
"error",
|
||||||
|
{paths: restrictedRendererImports},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["app/renderer/**"],
|
||||||
|
rules: {
|
||||||
|
"@typescript-eslint/no-restricted-imports": [
|
||||||
|
"error",
|
||||||
|
{paths: restrictedMainImports},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user