add eslint config (#53)

* eslint

* workflow

* lint main
This commit is contained in:
Ven 2022-10-06 00:42:58 +02:00 committed by GitHub
parent e563521416
commit 74c3930e0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 141 additions and 87 deletions

28
.eslintrc.json Normal file

@ -0,0 +1,28 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"ignorePatterns": ["dist"],
"rules": {
"quotes": [
"error",
"double",
{
"avoidEscape": true
}
],
"jsx-quotes": ["error", "prefer-double"],
"no-mixed-spaces-and-tabs": "error",
"indent": ["error", 4, { "SwitchCase": 1 }],
"arrow-parens": ["error", "as-needed"],
"eol-last": ["error", "always"],
"func-call-spacing": ["error", "never"],
"no-multi-spaces": "error",
"no-trailing-spaces": "error",
"no-whitespace-before-property": "error",
"semi": ["error", "always"],
"semi-style": ["error", "last"],
"space-in-parens": ["error", "never"],
"block-spacing": ["error", "always"],
"object-curly-spacing": ["error", "always"]
}
}

22
.github/workflows/lint.yml vendored Normal file

@ -0,0 +1,22 @@
name: lint
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install pnpm
run: npm i -g pnpm
- name: Install deps
run: pnpm i
- name: Run ESLint
run: pnpm run lint

@ -13,7 +13,7 @@ const watch = process.argv.includes("--watch");
* @type {esbuild.Plugin} * @type {esbuild.Plugin}
*/ */
const makeAllPackagesExternalPlugin = { const makeAllPackagesExternalPlugin = {
name: 'make-all-packages-external', name: "make-all-packages-external",
setup(build) { setup(build) {
let filter = /^[^.\/]|^\.[^.\/]|^\.\.[^\/]/; // Must not start with "/" or "./" or "../" let filter = /^[^.\/]|^\.[^.\/]|^\.\.[^\/]/; // Must not start with "/" or "./" or "../"
build.onResolve({ filter }, args => ({ path: args.path, external: true })); build.onResolve({ filter }, args => ({ path: args.path, external: true }));

@ -3,8 +3,11 @@
"@types/node": "^18.7.13", "@types/node": "^18.7.13",
"@types/react": "^18.0.17", "@types/react": "^18.0.17",
"@types/yazl": "^2.4.2", "@types/yazl": "^2.4.2",
"@typescript-eslint/parser": "^5.39.0",
"electron": "^20.1.0", "electron": "^20.1.0",
"esbuild": "^0.15.5", "esbuild": "^0.15.5",
"eslint": "^8.24.0",
"typescript": "^4.8.4",
"yazl": "^2.5.1" "yazl": "^2.5.1"
}, },
"dependencies": { "dependencies": {
@ -17,6 +20,8 @@
"build": "node build.mjs", "build": "node build.mjs",
"watch": "node build.mjs --watch", "watch": "node build.mjs --watch",
"inject": "node scripts/patcher/install.js", "inject": "node scripts/patcher/install.js",
"uninject": "node scripts/patcher/uninstall.js" "uninject": "node scripts/patcher/uninstall.js",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"lint:fix": "pnpm lint --fix"
} }
} }

@ -63,8 +63,8 @@ function question(question) {
terminal: false, terminal: false,
}); });
return new Promise((resolve) => { return new Promise(resolve => {
rl.question(question, (answer) => { rl.question(question, answer => {
rl.close(); rl.close();
resolve(answer); resolve(answer);
}); });
@ -72,7 +72,7 @@ function question(question) {
} }
async function getMenuItem(installations) { async function getMenuItem(installations) {
let menuItems = installations.map((info) => ({ let menuItems = installations.map(info => ({
title: info.patched ? "[MODIFIED] " + info.location : info.location, title: info.patched ? "[MODIFIED] " + info.location : info.location,
info, info,
})); }));
@ -122,9 +122,9 @@ function getWindowsDirs() {
const appDirs = fs const appDirs = fs
.readdirSync(location, { withFileTypes: true }) .readdirSync(location, { withFileTypes: true })
.filter((file) => file.isDirectory()) .filter(file => file.isDirectory())
.filter((file) => file.name.startsWith("app-")) .filter(file => file.name.startsWith("app-"))
.map((file) => path.join(location, file.name)); .map(file => path.join(location, file.name));
let versions = []; let versions = [];
let patched = false; let patched = false;
@ -169,9 +169,9 @@ function getDarwinDirs() {
const appDirs = fs const appDirs = fs
.readdirSync(location, { withFileTypes: true }) .readdirSync(location, { withFileTypes: true })
.filter((file) => file.isDirectory()) .filter(file => file.isDirectory())
.filter((file) => file.name.startsWith("Resources")) .filter(file => file.name.startsWith("Resources"))
.map((file) => path.join(location, file.name)); .map(file => path.join(location, file.name));
let versions = []; let versions = [];
let patched = false; let patched = false;
@ -239,13 +239,13 @@ function getLinuxDirs() {
} else { } else {
appDirs = fs appDirs = fs
.readdirSync(location, { withFileTypes: true }) .readdirSync(location, { withFileTypes: true })
.filter((file) => file.isDirectory()) .filter(file => file.isDirectory())
.filter( .filter(
(file) => file =>
file.name.startsWith("app-") || file.name.startsWith("app-") ||
file.name === "resources" file.name === "resources"
) )
.map((file) => path.join(location, file.name)); .map(file => path.join(location, file.name));
} }
let versions = []; let versions = [];

@ -96,7 +96,7 @@ async function install(installations) {
const requiredFiles = ["index.js", "package.json"]; const requiredFiles = ["index.js", "package.json"];
if (requiredFiles.every((f) => fs.existsSync(path.join(dir, f)))) { if (requiredFiles.every(f => fs.existsSync(path.join(dir, f)))) {
console.log( console.log(
"Successfully patched", "Successfully patched",
version.name version.name

@ -12,7 +12,7 @@ export { Settings };
import "./webpack/patchWebpack"; import "./webpack/patchWebpack";
import "./utils/quickCss"; import "./utils/quickCss";
import { checkForUpdates, UpdateLogger } from './utils/updater'; import { checkForUpdates, UpdateLogger } from "./utils/updater";
import { onceReady } from "./webpack"; import { onceReady } from "./webpack";
import { Router } from "./webpack/common"; import { Router } from "./webpack/common";

@ -1,5 +1,5 @@
import IPC_EVENTS from './utils/IpcEvents'; import IPC_EVENTS from "./utils/IpcEvents";
import { IpcRenderer, ipcRenderer } from 'electron'; import { IpcRenderer, ipcRenderer } from "electron";
function assertEventAllowed(event: string) { function assertEventAllowed(event: string) {
if (!(event in IPC_EVENTS)) throw new Error(`Event ${event} not allowed.`); if (!(event in IPC_EVENTS)) throw new Error(`Event ${event} not allowed.`);

@ -1,5 +1,5 @@
import { Channel, Guild } from "discord-types/general"; import { Channel, Guild } from "discord-types/general";
import { waitFor } from '../webpack'; import { waitFor } from "../webpack";
export function _init(cmds: Command[]) { export function _init(cmds: Command[]) {
try { try {

@ -1,5 +1,5 @@
import type { Message, Channel } from 'discord-types/general'; import type { Message, Channel } from "discord-types/general";
import Logger from '../utils/logger'; import Logger from "../utils/logger";
const MessageEventsLogger = new Logger("MessageEvents", "#e5c890"); const MessageEventsLogger = new Logger("MessageEvents", "#e5c890");

@ -1,7 +1,7 @@
import plugins from "plugins"; import plugins from "plugins";
import IpcEvents from "../utils/IpcEvents"; import IpcEvents from "../utils/IpcEvents";
import { React } from "../webpack/common"; import { React } from "../webpack/common";
import { mergeDefaults } from '../utils/misc'; import { mergeDefaults } from "../utils/misc";
interface Settings { interface Settings {
notifyAboutUpdates: boolean; notifyAboutUpdates: boolean;

@ -15,7 +15,7 @@ const NO_ERROR = {};
export default class ErrorBoundary extends React.Component<React.PropsWithChildren<Props>> { export default class ErrorBoundary extends React.Component<React.PropsWithChildren<Props>> {
static wrap<T = any>(Component: React.ComponentType<T>): (props: T) => React.ReactElement { static wrap<T = any>(Component: React.ComponentType<T>): (props: T) => React.ReactElement {
return (props) => ( return props => (
<ErrorBoundary> <ErrorBoundary>
<Component {...props as any/* I hate react typings ??? */} /> <Component {...props as any/* I hate react typings ??? */} />
</ErrorBoundary> </ErrorBoundary>

@ -1,5 +1,4 @@
import { PropsWithChildren } from "react"; import type { React } from "../webpack/common";
import type { React } from '../webpack/common';
export function Flex(props: React.PropsWithChildren<{ export function Flex(props: React.PropsWithChildren<{
flexDirection?: React.CSSProperties["flexDirection"]; flexDirection?: React.CSSProperties["flexDirection"];

@ -1,14 +1,14 @@
import { classes, humanFriendlyJoin, useAwaiter } from "../utils/misc"; import { classes, humanFriendlyJoin, useAwaiter } from "../utils/misc";
import Plugins from 'plugins'; import Plugins from "plugins";
import { useSettings } from "../api/settings"; import { useSettings } from "../api/settings";
import IpcEvents from "../utils/IpcEvents"; import IpcEvents from "../utils/IpcEvents";
import { Button, Switch, Forms, React, Margins, Toasts, Alerts, Parser } from "../webpack/common"; import { Button, Switch, Forms, React, Margins, Toasts, Alerts, Parser } from "../webpack/common";
import ErrorBoundary from "./ErrorBoundary"; import ErrorBoundary from "./ErrorBoundary";
import { startPlugin } from "../plugins"; import { startPlugin } from "../plugins";
import { stopPlugin } from '../plugins/index'; import { stopPlugin } from "../plugins/index";
import { Flex } from './Flex'; import { Flex } from "./Flex";
import { ChangeList } from '../utils/ChangeList'; import { ChangeList } from "../utils/ChangeList";
function showErrorToast(message: string) { function showErrorToast(message: string) {
Toasts.show({ Toasts.show({
@ -35,7 +35,7 @@ export default ErrorBoundary.wrap(function Settings() {
<div>{changes.map((s, i) => ( <div>{changes.map((s, i) => (
<> <>
{i > 0 && ", "} {i > 0 && ", "}
{Parser.parse('`' + s + '`')} {Parser.parse("`" + s + "`")}
</> </>
))}</div> ))}</div>
</> </>
@ -69,7 +69,7 @@ export default ErrorBoundary.wrap(function Settings() {
</Forms.FormTitle> </Forms.FormTitle>
<Forms.FormText> <Forms.FormText>
SettingsDir: <code style={{ userSelect: 'text', cursor: 'text' }}>{settingsDir}</code> SettingsDir: <code style={{ userSelect: "text", cursor: "text" }}>{settingsDir}</code>
</Forms.FormText> </Forms.FormText>
{!IS_WEB && <Flex className={classes(Margins.marginBottom20)}> {!IS_WEB && <Flex className={classes(Margins.marginBottom20)}>

@ -1,8 +1,8 @@
import gitHash from "git-hash"; import gitHash from "git-hash";
import { changes, checkForUpdates, getRepo, rebuild, update, UpdateLogger, updateError, isOutdated, isNewer } from '../utils/updater'; import { changes, checkForUpdates, getRepo, rebuild, update, UpdateLogger, updateError, isOutdated, isNewer } from "../utils/updater";
import { React, Forms, Button, Margins, Alerts, Card, Parser, Toasts } from '../webpack/common'; import { React, Forms, Button, Margins, Alerts, Card, Parser, Toasts } from "../webpack/common";
import { Flex } from "./Flex"; import { Flex } from "./Flex";
import { classes, useAwaiter } from '../utils/misc'; import { classes, useAwaiter } from "../utils/misc";
import { Link } from "./Link"; import { Link } from "./Link";
import ErrorBoundary from "./ErrorBoundary"; import ErrorBoundary from "./ErrorBoundary";
import { ErrorCard } from "./ErrorCard"; import { ErrorCard } from "./ErrorCard";

@ -1,9 +1,9 @@
import { app, BrowserWindow, desktopCapturer, ipcMain, shell } from "electron"; import { app, BrowserWindow, desktopCapturer, ipcMain, shell } from "electron";
import { mkdirSync, readFileSync, watch } from "fs"; import { mkdirSync, readFileSync, watch } from "fs";
import { open, readFile, writeFile } from "fs/promises"; import { open, readFile, writeFile } from "fs/promises";
import { join } from 'path'; import { join } from "path";
import { debounce } from "../utils/debounce"; import { debounce } from "../utils/debounce";
import IpcEvents from '../utils/IpcEvents'; import IpcEvents from "../utils/IpcEvents";
import "./updater"; import "./updater";
@ -47,7 +47,7 @@ ipcMain.handle(IpcEvents.OPEN_EXTERNAL, (_, url) => {
ipcMain.handle(IpcEvents.GET_QUICK_CSS, () => readCss()); ipcMain.handle(IpcEvents.GET_QUICK_CSS, () => readCss());
ipcMain.handle(IpcEvents.GET_SETTINGS_DIR, () => SETTINGS_DIR); ipcMain.handle(IpcEvents.GET_SETTINGS_DIR, () => SETTINGS_DIR);
ipcMain.on(IpcEvents.GET_SETTINGS, (e) => e.returnValue = readSettings()); ipcMain.on(IpcEvents.GET_SETTINGS, e => e.returnValue = readSettings());
let settingsWriteQueue = Promise.resolve(); let settingsWriteQueue = Promise.resolve();
ipcMain.handle(IpcEvents.SET_SETTINGS, (_, s) => { ipcMain.handle(IpcEvents.SET_SETTINGS, (_, s) => {

@ -1,10 +1,10 @@
import { ipcMain } from 'electron'; import { ipcMain } from "electron";
import { promisify } from "util"; import { promisify } from "util";
import IpcEvents from "../utils/IpcEvents"; import IpcEvents from "../utils/IpcEvents";
import { execFile as cpExecFile } from 'child_process'; import { execFile as cpExecFile } from "child_process";
import { join } from 'path'; import { join } from "path";
import { createReadStream } from 'fs'; import { createReadStream } from "fs";
import { createHash } from 'crypto'; import { createHash } from "crypto";
const VENCORD_SRC_DIR = join(__dirname, ".."); const VENCORD_SRC_DIR = join(__dirname, "..");
@ -64,7 +64,7 @@ async function getRepo() {
async function calculateGitChanges() { async function calculateGitChanges() {
await git("fetch"); await git("fetch");
const res = await git("log", `HEAD...origin/main`, "--pretty=format:%an/%h/%s"); const res = await git("log", "HEAD...origin/main", "--pretty=format:%an/%h/%s");
const commits = res.stdout.trim(); const commits = res.stdout.trim();
return commits ? commits.split("\n").map(line => { return commits ? commits.split("\n").map(line => {

@ -1,7 +1,7 @@
import electron, { app, BrowserWindowConstructorOptions } from "electron"; import electron, { app, BrowserWindowConstructorOptions } from "electron";
import installExt, { REACT_DEVELOPER_TOOLS } from "electron-devtools-installer"; import installExt, { REACT_DEVELOPER_TOOLS } from "electron-devtools-installer";
import { join } from "path"; import { join } from "path";
import { initIpc } from './ipcMain'; import { initIpc } from "./ipcMain";
console.log("[Vencord] Starting up..."); console.log("[Vencord] Starting up...");
@ -49,7 +49,7 @@ process.env.DATA_DIR = join(app.getPath("userData"), "..", "Vencord");
electron.app.whenReady().then(() => { electron.app.whenReady().then(() => {
installExt(REACT_DEVELOPER_TOOLS) installExt(REACT_DEVELOPER_TOOLS)
.then(() => console.info("Installed React DevTools")) .then(() => console.info("Installed React DevTools"))
.catch((err) => console.error("Failed to install React DevTools", err)); .catch(err => console.error("Failed to install React DevTools", err));
// Remove CSP // Remove CSP
electron.session.defaultSession.webRequest.onHeadersReceived(({ responseHeaders, url }, cb) => { electron.session.defaultSession.webRequest.onHeadersReceived(({ responseHeaders, url }, cb) => {

@ -1,5 +1,5 @@
import definePlugin from "../utils/types"; import definePlugin from "../utils/types";
import { Devs } from '../utils/constants'; import { Devs } from "../utils/constants";
export default definePlugin({ export default definePlugin({
name: "STFU", name: "STFU",

@ -7,7 +7,7 @@ export default definePlugin({
description: "Api required by anything that uses commands", description: "Api required by anything that uses commands",
patches: [ patches: [
{ {
find: `"giphy","tenor"`, find: '"giphy","tenor"',
replacement: [ replacement: [
{ {
// Matches BUILT_IN_COMMANDS. This is not exported so this is // Matches BUILT_IN_COMMANDS. This is not exported so this is

@ -13,7 +13,7 @@ export default definePlugin({
{ {
match: /;(.{1,2}=null;)(?=.{0,50}updateNotice)/g, match: /;(.{1,2}=null;)(?=.{0,50}updateNotice)/g,
replace: replace:
';if(Vencord.Api.Notices.currentNotice)return !1;$1' ";if(Vencord.Api.Notices.currentNotice)return !1;$1"
}, },
{ {
match: /(?<=NOTICE_DISMISS:function.+?){(?=if\(null==(.+?)\))/, match: /(?<=NOTICE_DISMISS:function.+?){(?=if\(null==(.+?)\))/,

@ -90,7 +90,7 @@ export default definePlugin({
} }
// Check all universal rules // Check all universal rules
this.universalRules.forEach((rule) => { this.universalRules.forEach(rule => {
url.searchParams.forEach((_value, param, parent) => { url.searchParams.forEach((_value, param, parent) => {
this.removeParam(rule, param, parent); this.removeParam(rule, param, parent);
}); });
@ -99,7 +99,7 @@ export default definePlugin({
// Check rules for each hosts that match // Check rules for each hosts that match
this.hostRules.forEach((regex, hostRuleName) => { this.hostRules.forEach((regex, hostRuleName) => {
if (!regex.test(url.hostname)) return; if (!regex.test(url.hostname)) return;
this.rulesByHost.get(hostRuleName).forEach((rule) => { this.rulesByHost.get(hostRuleName).forEach(rule => {
url.searchParams.forEach((_value, param, parent) => { url.searchParams.forEach((_value, param, parent) => {
this.removeParam(rule, param, parent); this.removeParam(rule, param, parent);
}); });
@ -114,7 +114,7 @@ export default definePlugin({
if (msg.content.match(/http(s)?:\/\//)) { if (msg.content.match(/http(s)?:\/\//)) {
msg.content = msg.content.replace( msg.content = msg.content.replace(
/(https?:\/\/[^\s<]+[^<.,:;"'>)|\]\s])/g, /(https?:\/\/[^\s<]+[^<.,:;"'>)|\]\s])/g,
(match) => this.replacer(match) match => this.replacer(match)
); );
} }
}, },

@ -1,6 +1,6 @@
import { Devs } from "../utils/constants"; import { Devs } from "../utils/constants";
import definePlugin from "../utils/types"; import definePlugin from "../utils/types";
import { Toasts } from '../webpack/common'; import { Toasts } from "../webpack/common";
export default definePlugin({ export default definePlugin({
name: "ClickableRoleDot", name: "ClickableRoleDot",

@ -1,5 +1,5 @@
import { Devs } from "../utils/constants"; import { Devs } from "../utils/constants";
import definePlugin from '../utils/types'; import definePlugin from "../utils/types";
export default definePlugin({ export default definePlugin({
name: "Experiments", name: "Experiments",

@ -12,7 +12,7 @@ export default definePlugin({
name: "lenny", name: "lenny",
description: "Sends a lenny face", description: "Sends a lenny face",
options: [OptionalMessageOption], options: [OptionalMessageOption],
execute: (opts) => ({ execute: opts => ({
content: findOption(opts, "message", "") + " ( ͡° ͜ʖ ͡°)" content: findOption(opts, "message", "") + " ( ͡° ͜ʖ ͡°)"
}), }),
}, },

@ -1,4 +1,4 @@
import { addClickListener, removeClickListener } from '../api/MessageEvents'; import { addClickListener, removeClickListener } from "../api/MessageEvents";
import { Devs } from "../utils/constants"; import { Devs } from "../utils/constants";
import definePlugin from "../utils/types"; import definePlugin from "../utils/types";
import { find, findByProps } from "../webpack"; import { find, findByProps } from "../webpack";

@ -14,4 +14,4 @@ export default definePlugin({
} }
} }
], ],
}) });

@ -1,8 +1,8 @@
import { addPreSendListener, addPreEditListener, SendListener, removePreSendListener, removePreEditListener } from '../api/MessageEvents'; import { addPreSendListener, addPreEditListener, removePreSendListener, removePreEditListener } from "../api/MessageEvents";
import { findByProps } from "../webpack"; import { findByProps } from "../webpack";
import definePlugin from "../utils/types"; import definePlugin from "../utils/types";
import { Devs } from '../utils/constants'; import { Devs } from "../utils/constants";
import { UserStore } from '../webpack/common'; import { UserStore } from "../webpack/common";
export default definePlugin({ export default definePlugin({
name: "NitroBypass", name: "NitroBypass",
@ -11,7 +11,7 @@ export default definePlugin({
dependencies: ["MessageEventsAPI"], dependencies: ["MessageEventsAPI"],
patches: [ patches: [
{ {
find: `canUseAnimatedEmojis:function`, find: "canUseAnimatedEmojis:function",
replacement: [ replacement: [
"canUseAnimatedEmojis", "canUseAnimatedEmojis",
"canUseEmojisEverywhere", "canUseEmojisEverywhere",
@ -58,8 +58,8 @@ export default definePlugin({
if (!emoji.require_colons) continue; if (!emoji.require_colons) continue;
if (emoji.guildId === guildId && !emoji.animated) continue; if (emoji.guildId === guildId && !emoji.animated) continue;
const emojiString = `<${emoji.animated ? 'a' : ''}:${emoji.originalName || emoji.name}:${emoji.id}>`; const emojiString = `<${emoji.animated ? "a" : ""}:${emoji.originalName || emoji.name}:${emoji.id}>`;
const url = emoji.url.replace(/\?size=[0-9]+/, `?size=48`); const url = emoji.url.replace(/\?size=[0-9]+/, "?size=48");
messageObj.content = messageObj.content.replace(emojiString, (match, offset, origStr) => { messageObj.content = messageObj.content.replace(emojiString, (match, offset, origStr) => {
return `${getWordBoundary(origStr, offset - 1)}${url}${getWordBoundary(origStr, offset + match.length)}`; return `${getWordBoundary(origStr, offset - 1)}${url}${getWordBoundary(origStr, offset + match.length)}`;
}); });
@ -74,7 +74,7 @@ export default definePlugin({
if (emoji == null || (emoji.guildId === guildId && !emoji.animated)) continue; if (emoji == null || (emoji.guildId === guildId && !emoji.animated)) continue;
if (!emoji.require_colons) continue; if (!emoji.require_colons) continue;
const url = emoji.url.replace(/\?size=[0-9]+/, `?size=48`); const url = emoji.url.replace(/\?size=[0-9]+/, "?size=48");
messageObj.content = messageObj.content.replace(emojiStr, (match, offset, origStr) => { messageObj.content = messageObj.content.replace(emojiStr, (match, offset, origStr) => {
return `${getWordBoundary(origStr, offset - 1)}${url}${getWordBoundary(origStr, offset + match.length)}`; return `${getWordBoundary(origStr, offset - 1)}${url}${getWordBoundary(origStr, offset + match.length)}`;
}); });

@ -16,4 +16,4 @@ export default definePlugin({
} }
} }
] ]
}) });

@ -1,5 +1,5 @@
import definePlugin from "../utils/types"; import definePlugin from "../utils/types";
import { Devs } from '../utils/constants'; import { Devs } from "../utils/constants";
export default definePlugin({ export default definePlugin({
name: "NoTrack", name: "NoTrack",

@ -23,6 +23,6 @@ export default definePlugin({
{ length: 7 }, { length: 7 },
() => chars[Math.floor(Math.random() * chars.length)] () => chars[Math.floor(Math.random() * chars.length)]
).join(""); ).join("");
return rand + (file.lastIndexOf(".") > -1 ? file.slice(file.lastIndexOf(".")) : "") return rand + (file.lastIndexOf(".") > -1 ? file.slice(file.lastIndexOf(".")) : "");
}, },
}); });

@ -1,6 +1,6 @@
import definePlugin from "../utils/types"; import definePlugin from "../utils/types";
import gitHash from "git-hash"; import gitHash from "git-hash";
import { Devs } from '../utils/constants'; import { Devs } from "../utils/constants";
export default definePlugin({ export default definePlugin({
name: "Settings", name: "Settings",
@ -30,8 +30,8 @@ export default definePlugin({
match: /\{section:(.{1,2})\.ID\.HEADER,\s*label:(.{1,2})\..{1,2}\.Messages\.ACTIVITY_SETTINGS\}/, match: /\{section:(.{1,2})\.ID\.HEADER,\s*label:(.{1,2})\..{1,2}\.Messages\.ACTIVITY_SETTINGS\}/,
replace: (m, mod) => replace: (m, mod) =>
`{section:${mod}.ID.HEADER,label:"Vencord"},` + `{section:${mod}.ID.HEADER,label:"Vencord"},` +
`{section:"VencordSetting",label:"Vencord",element:Vencord.Components.Settings},` + '{section:"VencordSetting",label:"Vencord",element:Vencord.Components.Settings},' +
`{section:"VencordUpdater",label:"Updater",element:Vencord.Components.Updater,predicate:()=>!IS_WEB},` + '{section:"VencordUpdater",label:"Updater",element:Vencord.Components.Updater,predicate:()=>!IS_WEB},' +
`{section:${mod}.ID.DIVIDER},${m}` `{section:${mod}.ID.DIVIDER},${m}`
} }

@ -1,5 +1,5 @@
import definePlugin from '../utils/types'; import definePlugin from "../utils/types";
import { Devs } from '../utils/constants'; import { Devs } from "../utils/constants";
export default definePlugin({ export default definePlugin({
name: "SilentTyping", name: "SilentTyping",

@ -1,6 +1,6 @@
import definePlugin from "../utils/types"; import definePlugin from "../utils/types";
import { addPreSendListener, addPreEditListener, MessageObject, removePreSendListener, removePreEditListener } from '../api/MessageEvents'; import { addPreSendListener, addPreEditListener, MessageObject, removePreSendListener, removePreEditListener } from "../api/MessageEvents";
import { Devs } from '../utils/constants'; import { Devs } from "../utils/constants";
export default definePlugin({ export default definePlugin({
name: "Unindent", name: "Unindent",

@ -1,6 +1,6 @@
import { Devs } from "../utils/constants"; import { Devs } from "../utils/constants";
import IpcEvents from "../utils/IpcEvents"; import IpcEvents from "../utils/IpcEvents";
import definePlugin from '../utils/types'; import definePlugin from "../utils/types";
const OPEN_URL = "Vencord.Plugins.plugins.ViewIcons.openImage("; const OPEN_URL = "Vencord.Plugins.plugins.ViewIcons.openImage(";
export default definePlugin({ export default definePlugin({

@ -2,7 +2,7 @@ import electron, { contextBridge, webFrame } from "electron";
import { readFileSync } from "fs"; import { readFileSync } from "fs";
import { join } from "path"; import { join } from "path";
import VencordNative from "./VencordNative"; import VencordNative from "./VencordNative";
import { ipcRenderer } from 'electron'; import { ipcRenderer } from "electron";
import IpcEvents from "./utils/IpcEvents"; import IpcEvents from "./utils/IpcEvents";
if (electron.desktopCapturer === void 0) { if (electron.desktopCapturer === void 0) {
@ -15,7 +15,7 @@ if (electron.desktopCapturer === void 0) {
require.cache[electronPath]!.exports = { require.cache[electronPath]!.exports = {
...electron, ...electron,
desktopCapturer: { desktopCapturer: {
getSources: (opts) => ipcRenderer.invoke(IpcEvents.GET_DESKTOP_CAPTURE_SOURCES, opts) getSources: opts => ipcRenderer.invoke(IpcEvents.GET_DESKTOP_CAPTURE_SOURCES, opts)
} }
}; };
} }

@ -18,11 +18,11 @@ let modalId = 1337;
*/ */
export function openModal(Component: React.ComponentType, modalProps: Record<string, any>) { export function openModal(Component: React.ComponentType, modalProps: Record<string, any>) {
let key = `Vencord${modalId++}`; let key = `Vencord${modalId++}`;
modals.openModal(props => modals.openModal(props => (
<Modal.ModalRoot {...props} {...modalProps}> <Modal.ModalRoot {...props} {...modalProps}>
<Component /> <Component />
</Modal.ModalRoot> </Modal.ModalRoot>
, { modalKey: key }); ), { modalKey: key });
return key; return key;
}; };

@ -1,7 +1,7 @@
import IpcEvents from "./IpcEvents"; import IpcEvents from "./IpcEvents";
import Logger from "./logger"; import Logger from "./logger";
import { IpcRes } from './types'; import { IpcRes } from "./types";
import gitHash from 'git-hash'; import gitHash from "git-hash";
export const UpdateLogger = new Logger("Updater", "white"); export const UpdateLogger = new Logger("Updater", "white");
export let isOutdated = false; export let isOutdated = false;

@ -1,8 +1,8 @@
import { waitFor, filters, _resolveReady } from './webpack'; import { waitFor, filters, _resolveReady } from "./webpack";
import type Components from "discord-types/components"; import type Components from "discord-types/components";
import type Stores from "discord-types/stores"; import type Stores from "discord-types/stores";
import type Other from "discord-types/other"; import type Other from "discord-types/other";
import { lazyWebpack } from '../utils/misc'; import { lazyWebpack } from "../utils/misc";
export const Margins = lazyWebpack(filters.byProps(["marginTop20"])); export const Margins = lazyWebpack(filters.byProps(["marginTop20"]));

@ -1,4 +1,4 @@
import { WEBPACK_CHUNK } from '../utils/constants'; import { WEBPACK_CHUNK } from "../utils/constants";
import Logger from "../utils/logger"; import Logger from "../utils/logger";
import { _initWebpack } from "."; import { _initWebpack } from ".";
@ -8,7 +8,7 @@ const logger = new Logger("WebpackInterceptor", "#8caaee");
Object.defineProperty(window, WEBPACK_CHUNK, { Object.defineProperty(window, WEBPACK_CHUNK, {
get: () => webpackChunk, get: () => webpackChunk,
set: (v) => { set: v => {
if (v?.push !== Array.prototype.push) { if (v?.push !== Array.prototype.push) {
logger.info(`Patching ${WEBPACK_CHUNK}.push`); logger.info(`Patching ${WEBPACK_CHUNK}.push`);
_initWebpack(v); _initWebpack(v);
@ -141,7 +141,7 @@ function patchPush() {
handlePush.original = window[WEBPACK_CHUNK].push; handlePush.original = window[WEBPACK_CHUNK].push;
Object.defineProperty(window[WEBPACK_CHUNK], "push", { Object.defineProperty(window[WEBPACK_CHUNK], "push", {
get: () => handlePush, get: () => handlePush,
set: (v) => (handlePush.original = v), set: v => (handlePush.original = v),
configurable: true configurable: true
}); });
} }

@ -36,7 +36,7 @@ export type CallbackFn = (mod: any) => void;
export function _initWebpack(instance: typeof window.webpackChunkdiscord_app) { export function _initWebpack(instance: typeof window.webpackChunkdiscord_app) {
if (cache !== void 0) throw "no."; if (cache !== void 0) throw "no.";
wreq = instance.push([[Symbol()], {}, (r) => r]); wreq = instance.push([[Symbol()], {}, r => r]);
cache = wreq.c; cache = wreq.c;
instance.pop(); instance.pop();
} }