Main: add ESLint
This commit is contained in:
parent
b6d46a160a
commit
4ab72b8dd9
10 changed files with 96 additions and 35 deletions
41
.eslintrc.json
Normal file
41
.eslintrc.json
Normal file
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
@ -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(),
|
||||
|
|
|
|||
10
package.json
10
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"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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: () => (
|
||||
<TouchableOpacity onPress={() => {
|
||||
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());
|
||||
}}>
|
||||
<FormText style={{ marginRight: 12 }}>UPDATE</FormText>
|
||||
</TouchableOpacity>
|
||||
)
|
||||
await flush();
|
||||
await initialize();
|
||||
showToast("Settings updated!", getAssetIDByName("Check"));
|
||||
}
|
||||
|
||||
return <TouchableOpacity onPress={onPressCallback}>
|
||||
<FormText style={{ marginRight: 12 }}>{"UPDATE"}</FormText>
|
||||
</TouchableOpacity>;
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
|
|
@ -77,5 +82,5 @@ export default function Settings() {
|
|||
onValueChange={(value: boolean) => settings.verboseLogging = value}
|
||||
/>
|
||||
</ScrollView>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
type PluginSettings = {
|
||||
/** Application's name */
|
||||
appName: string;
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ import Constants from "./constants";
|
|||
/** Fetches the latest user's scrobble */
|
||||
async function fetchLatestScrobble(): Promise<Track> {
|
||||
const params = new URLSearchParams({
|
||||
'method': 'user.getrecenttracks',
|
||||
'user': currentSettings.username,
|
||||
'api_key': Constants.LFM_API_KEY,
|
||||
'format': 'json',
|
||||
'limit': '1',
|
||||
'extended': '1'
|
||||
"method": "user.getrecenttracks",
|
||||
"user": currentSettings.username,
|
||||
"api_key": Constants.LFM_API_KEY,
|
||||
"format": "json",
|
||||
"limit": "1",
|
||||
"extended": "1"
|
||||
}).toString();
|
||||
|
||||
const info = await fetch(`https://ws.audioscrobbler.com/2.0/?${params}`).then(x => {
|
||||
|
|
@ -24,12 +24,12 @@ async function fetchLatestScrobble(): Promise<Track> {
|
|||
return {
|
||||
name: lastTrack.name,
|
||||
artist: lastTrack.artist.name,
|
||||
album: lastTrack.album['#text'],
|
||||
albumArt: handleAlbumCover(lastTrack.image[3]['#text']),
|
||||
album: lastTrack.album["#text"],
|
||||
albumArt: handleAlbumCover(lastTrack.image[3]["#text"]),
|
||||
url: lastTrack.url,
|
||||
date: lastTrack.date?.['#text'] ?? 'now',
|
||||
nowPlaying: Boolean(lastTrack['@attr']?.nowplaying),
|
||||
loved: lastTrack.loved === '1',
|
||||
date: lastTrack.date?.["#text"] ?? "now",
|
||||
nowPlaying: Boolean(lastTrack["@attr"]?.nowplaying),
|
||||
loved: lastTrack.loved === "1",
|
||||
} as Track;
|
||||
}
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ export async function update() {
|
|||
activity.assets = {
|
||||
large_image: lastTrack.albumArt,
|
||||
large_text: `on ${lastTrack.album}`
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const response = await sendRequest(activity).catch(async function (err) {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ export default {
|
|||
logger.error("Failed to start call", e);
|
||||
}
|
||||
},
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,4 +17,4 @@ export default {
|
|||
logger.log("Disabling NoIdle..");
|
||||
unpatch?.();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue