diff --git a/.eslintrc.json b/.eslintrc.json
new file mode 100644
index 0000000..ab5b5aa
--- /dev/null
+++ b/.eslintrc.json
@@ -0,0 +1,41 @@
+{
+ "env": {
+ "es2021": true,
+ "node": true
+ },
+ "extends": [
+ "eslint:recommended",
+ "plugin:react/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "parser": "@typescript-eslint/parser",
+ "parserOptions": {
+ "ecmaFeatures": {
+ "jsx": true
+ },
+ "ecmaVersion": "latest",
+ "sourceType": "module"
+ },
+ "plugins": [
+ "react",
+ "@typescript-eslint"
+ ],
+ "rules": {
+ "indent": [
+ "error",
+ 4
+ ],
+ "quotes": [
+ "error",
+ "double"
+ ],
+ "semi": [
+ "error",
+ "always"
+ ],
+ "@typescript-eslint/no-explicit-any": "off",
+ "@typescript-eslint/ban-ts-comment": "off",
+ "@typescript-eslint/triple-slash-reference": "off",
+ "eol-last": "error"
+ }
+}
diff --git a/build.mjs b/build.mjs
index 12e53aa..677b678 100644
--- a/build.mjs
+++ b/build.mjs
@@ -13,7 +13,13 @@ for (const plug of await readdir("./plugins")) {
try {
const bundle = await rollup({
input: `./plugins/${plug}/${manifest.main}`,
- onwarn: () => { },
+ onwarn: (warning) => {
+ ![
+ "UNRESOLVED_IMPORT",
+ "MISSING_NAME_OPTION_FOR_IIFE_EXPORT",
+ "CIRCULAR_DEPENDENCY"
+ ].includes(warning.code) && console.warn(warning);
+ },
plugins: [
nodeResolve(),
commonjs(),
diff --git a/package.json b/package.json
index 8017d32..abcfa29 100644
--- a/package.json
+++ b/package.json
@@ -1,13 +1,21 @@
{
"scripts": {
- "build": "node build.mjs"
+ "build": "node build.mjs",
+ "lint": "eslint plugins"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^24.0.1",
+ "@rollup/plugin-eslint": "^9.0.3",
"@rollup/plugin-node-resolve": "^15.0.1",
+ "@rollup/plugin-typescript": "^11.0.0",
+ "@typescript-eslint/eslint-plugin": "^5.51.0",
+ "@typescript-eslint/parser": "^5.51.0",
"esbuild": "^0.16.17",
+ "eslint": "^8.34.0",
+ "eslint-plugin-react": "^7.32.2",
"rollup": "^3.15.0",
"rollup-plugin-esbuild": "^5.0.0",
+ "typescript": "^4.9.5",
"vendetta-types": "^2.3.4"
}
}
diff --git a/plugins/HideGiftButton/src/index.ts b/plugins/HideGiftButton/src/index.ts
index 17e82d4..80df01e 100644
--- a/plugins/HideGiftButton/src/index.ts
+++ b/plugins/HideGiftButton/src/index.ts
@@ -1,7 +1,7 @@
import { logger } from "@vendetta";
import { findByDisplayName } from "@vendetta/metro";
-let origState: Boolean;
+let origState: boolean;
const ChatInput = findByDisplayName("ChatInput");
export default {
@@ -14,4 +14,4 @@ export default {
logger.log("Unloading HideGiftButton..");
ChatInput.defaultProps.hideGiftButton = origState;
}
-}
+};
diff --git a/plugins/Last.fm/src/index.ts b/plugins/Last.fm/src/index.ts
index af7c2e1..29de04e 100644
--- a/plugins/Last.fm/src/index.ts
+++ b/plugins/Last.fm/src/index.ts
@@ -1,23 +1,23 @@
import { plugin } from "@vendetta";
-import { findByProps, findByStoreName } from '@vendetta/metro';
-import { FluxDispatcher } from '@vendetta/metro/common';
+import { findByProps, findByStoreName } from "@vendetta/metro";
+import { FluxDispatcher } from "@vendetta/metro/common";
import Settings from "./Settings";
import { flush, initialize, patchActivityType } from "./utils";
export const global = {} as {
- stopped?: Boolean,
+ stopped?: boolean,
lastActivity?: Activity,
updateInterval?: NodeJS.Timer,
lastTrackUrl?: string,
activityTypeUnpatch?: () => boolean
-}
+};
export const currentSettings = { ...plugin.storage } as PluginSettings;
// Discord modules that we need
-export const UserStore = findByStoreName("UserStore")
-export const SET_ACTIVITY = findByProps('SET_ACTIVITY').SET_ACTIVITY;
+export const UserStore = findByStoreName("UserStore");
+export const SET_ACTIVITY = findByProps("SET_ACTIVITY").SET_ACTIVITY;
export const verboseLog = (...message: any) => currentSettings.verboseLogging && console.log(...message);
@@ -47,4 +47,4 @@ export default {
global.activityTypeUnpatch = null;
},
settings: Settings
-}
+};
diff --git a/plugins/Last.fm/src/settings.tsx b/plugins/Last.fm/src/settings.tsx
index 5e6afbc..c16b811 100644
--- a/plugins/Last.fm/src/settings.tsx
+++ b/plugins/Last.fm/src/settings.tsx
@@ -3,13 +3,14 @@ import { storage } from "@vendetta/plugin";
import { useProxy } from "@vendetta/storage";
import { getAssetIDByName } from "@vendetta/ui/assets";
import { Forms } from "@vendetta/ui/components";
+import { showToast } from "@vendetta/ui/toasts";
import { currentSettings } from ".";
import Constants from "./constants";
import { flush, initialize } from "./utils";
const { ScrollView, TouchableOpacity, Text } = ReactNative;
-const { FormInput, FormDivider, FormSwitchRow, FormText, FormIcon, FormTextColors } = Forms;
+const { FormInput, FormDivider, FormSwitchRow, FormText, FormIcon } = Forms;
export default function Settings() {
const settings = useProxy(storage) as PluginSettings;
@@ -17,8 +18,8 @@ export default function Settings() {
React.useEffect(() => {
navigation.setOptions({
- headerRight: () => (
- {
+ headerRight: () => {
+ async function onPressCallback() {
for (const key in storage) {
if (typeof storage[key] === "boolean" || storage[key]) {
currentSettings[key] = settings[key];
@@ -26,11 +27,15 @@ export default function Settings() {
}
console.log("Applying settings...");
- flush().then(() => initialize());
- }}>
- UPDATE
-
- )
+ await flush();
+ await initialize();
+ showToast("Settings updated!", getAssetIDByName("Check"));
+ }
+
+ return
+ {"UPDATE"}
+ ;
+ }
});
}, []);
@@ -77,5 +82,5 @@ export default function Settings() {
onValueChange={(value: boolean) => settings.verboseLogging = value}
/>
- )
+ );
}
diff --git a/plugins/Last.fm/src/types.ts b/plugins/Last.fm/src/types.ts
index aff6d5d..44c43e4 100644
--- a/plugins/Last.fm/src/types.ts
+++ b/plugins/Last.fm/src/types.ts
@@ -1,3 +1,4 @@
+/* eslint-disable @typescript-eslint/no-unused-vars */
type PluginSettings = {
/** Application's name */
appName: string;
diff --git a/plugins/Last.fm/src/utils.ts b/plugins/Last.fm/src/utils.ts
index 23de96e..01762fe 100644
--- a/plugins/Last.fm/src/utils.ts
+++ b/plugins/Last.fm/src/utils.ts
@@ -8,12 +8,12 @@ import Constants from "./constants";
/** Fetches the latest user's scrobble */
async function fetchLatestScrobble(): Promise