more eslint
This commit is contained in:
parent
350e7b0a6a
commit
36f4478a4f
13 changed files with 39 additions and 19 deletions
|
@ -35,6 +35,26 @@
|
||||||
"no-constant-condition": ["error", { "checkLoops": false }],
|
"no-constant-condition": ["error", { "checkLoops": false }],
|
||||||
"no-duplicate-imports": "error",
|
"no-duplicate-imports": "error",
|
||||||
"no-extra-semi": "error",
|
"no-extra-semi": "error",
|
||||||
"consistent-return": ["error", { "treatUndefinedAsUnspecified": true }]
|
"consistent-return": ["warn", { "treatUndefinedAsUnspecified": true }],
|
||||||
|
"dot-notation": "error",
|
||||||
|
"no-useless-escape": "error",
|
||||||
|
"no-fallthrough": "error",
|
||||||
|
"for-direction": "error",
|
||||||
|
"no-async-promise-executor": "error",
|
||||||
|
"no-cond-assign": "error",
|
||||||
|
"no-dupe-else-if": "error",
|
||||||
|
"no-duplicate-case": "error",
|
||||||
|
"no-irregular-whitespace": "error",
|
||||||
|
"no-loss-of-precision": "error",
|
||||||
|
"no-misleading-character-class": "error",
|
||||||
|
"no-prototype-builtins": "error",
|
||||||
|
"no-regex-spaces": "error",
|
||||||
|
"no-shadow-restricted-names": "error",
|
||||||
|
"no-unexpected-multiline": "error",
|
||||||
|
"no-unsafe-optional-chaining": "error",
|
||||||
|
"no-useless-backreference": "error",
|
||||||
|
"use-isnan": "error",
|
||||||
|
"prefer-const": "error",
|
||||||
|
"prefer-spread": "error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ function question(question) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getMenuItem(installations) {
|
async function getMenuItem(installations) {
|
||||||
let menuItems = installations.map(info => ({
|
const menuItems = installations.map(info => ({
|
||||||
title: info.patched ? "[MODIFIED] " + info.location : info.location,
|
title: info.patched ? "[MODIFIED] " + info.location : info.location,
|
||||||
info,
|
info,
|
||||||
}));
|
}));
|
||||||
|
@ -126,7 +126,7 @@ function getWindowsDirs() {
|
||||||
.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 = [];
|
const versions = [];
|
||||||
let patched = false;
|
let patched = false;
|
||||||
|
|
||||||
for (const fqAppDir of appDirs) {
|
for (const fqAppDir of appDirs) {
|
||||||
|
@ -140,7 +140,7 @@ function getWindowsDirs() {
|
||||||
}
|
}
|
||||||
versions.push({
|
versions.push({
|
||||||
path: appDir,
|
path: appDir,
|
||||||
name: /app-([0-9\.]+)/.exec(fqAppDir)[1],
|
name: /app-([0-9.]+)/.exec(fqAppDir)[1],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ function getDarwinDirs() {
|
||||||
.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 = [];
|
const versions = [];
|
||||||
let patched = false;
|
let patched = false;
|
||||||
|
|
||||||
for (const resourceDir of appDirs) {
|
for (const resourceDir of appDirs) {
|
||||||
|
@ -248,7 +248,7 @@ function getLinuxDirs() {
|
||||||
.map(file => path.join(location, file.name));
|
.map(file => path.join(location, file.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
let versions = [];
|
const versions = [];
|
||||||
let patched = false;
|
let patched = false;
|
||||||
|
|
||||||
for (const resourceDir of appDirs) {
|
for (const resourceDir of appDirs) {
|
||||||
|
@ -260,7 +260,7 @@ function getLinuxDirs() {
|
||||||
patched = true;
|
patched = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const version = /app-([0-9\.]+)/.exec(resourceDir);
|
const version = /app-([0-9.]+)/.exec(resourceDir);
|
||||||
|
|
||||||
versions.push({
|
versions.push({
|
||||||
path: appDir,
|
path: appDir,
|
||||||
|
|
|
@ -18,7 +18,7 @@ export function SettingBooleanComponent({ option, pluginSettings, id, onChange,
|
||||||
];
|
];
|
||||||
|
|
||||||
function handleChange(newValue: boolean): void {
|
function handleChange(newValue: boolean): void {
|
||||||
let isValid = (option.isValid && option.isValid(newValue)) ?? true;
|
const isValid = (option.isValid && option.isValid(newValue)) ?? true;
|
||||||
if (typeof isValid === "string") setError(isValid);
|
if (typeof isValid === "string") setError(isValid);
|
||||||
else if (!isValid) setError("Invalid input provided.");
|
else if (!isValid) setError("Invalid input provided.");
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -18,7 +18,7 @@ export function SettingNumericComponent({ option, pluginSettings, id, onChange,
|
||||||
}, [error]);
|
}, [error]);
|
||||||
|
|
||||||
function handleChange(newValue) {
|
function handleChange(newValue) {
|
||||||
let isValid = (option.isValid && option.isValid(newValue)) ?? true;
|
const isValid = (option.isValid && option.isValid(newValue)) ?? true;
|
||||||
if (typeof isValid === "string") setError(isValid);
|
if (typeof isValid === "string") setError(isValid);
|
||||||
else if (!isValid) setError("Invalid input provided.");
|
else if (!isValid) setError("Invalid input provided.");
|
||||||
else if (option.type === OptionType.NUMBER && BigInt(newValue) >= MAX_SAFE_NUMBER) {
|
else if (option.type === OptionType.NUMBER && BigInt(newValue) >= MAX_SAFE_NUMBER) {
|
||||||
|
|
|
@ -13,7 +13,7 @@ export function SettingSelectComponent({ option, pluginSettings, onChange, onErr
|
||||||
}, [error]);
|
}, [error]);
|
||||||
|
|
||||||
function handleChange(newValue) {
|
function handleChange(newValue) {
|
||||||
let isValid = (option.isValid && option.isValid(newValue)) ?? true;
|
const isValid = (option.isValid && option.isValid(newValue)) ?? true;
|
||||||
if (typeof isValid === "string") setError(isValid);
|
if (typeof isValid === "string") setError(isValid);
|
||||||
else if (!isValid) setError("Invalid input provided.");
|
else if (!isValid) setError("Invalid input provided.");
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -20,7 +20,7 @@ export function SettingSliderComponent({ option, pluginSettings, id, onChange, o
|
||||||
}, [error]);
|
}, [error]);
|
||||||
|
|
||||||
function handleChange(newValue: number): void {
|
function handleChange(newValue: number): void {
|
||||||
let isValid = (option.isValid && option.isValid(newValue)) ?? true;
|
const isValid = (option.isValid && option.isValid(newValue)) ?? true;
|
||||||
if (typeof isValid === "string") setError(isValid);
|
if (typeof isValid === "string") setError(isValid);
|
||||||
else if (!isValid) setError("Invalid input provided.");
|
else if (!isValid) setError("Invalid input provided.");
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -11,7 +11,7 @@ export function SettingInputComponent({ option, pluginSettings, id, onChange, on
|
||||||
}, [error]);
|
}, [error]);
|
||||||
|
|
||||||
function handleChange(newValue) {
|
function handleChange(newValue) {
|
||||||
let isValid = (option.isValid && option.isValid(newValue)) ?? true;
|
const isValid = (option.isValid && option.isValid(newValue)) ?? true;
|
||||||
if (typeof isValid === "string") setError(isValid);
|
if (typeof isValid === "string") setError(isValid);
|
||||||
else if (!isValid) setError("Invalid input provided.");
|
else if (!isValid) setError("Invalid input provided.");
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -49,7 +49,7 @@ export default definePlugin({
|
||||||
|
|
||||||
anonymise(file: string) {
|
anonymise(file: string) {
|
||||||
let name = "image";
|
let name = "image";
|
||||||
const ext = file.match(/\..+$/g) ?? "";
|
const ext = file.match(/\..+$/g)?.[0] ?? "";
|
||||||
switch (Settings.plugins.AnonymiseFileNames.method) {
|
switch (Settings.plugins.AnonymiseFileNames.method) {
|
||||||
case Methods.Random:
|
case Methods.Random:
|
||||||
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
|
|
|
@ -30,7 +30,7 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
find: ".isStaff=function(){",
|
find: ".isStaff=function(){",
|
||||||
predicate: () => Settings.plugins["Experiments"].enableIsStaff === true,
|
predicate: () => Settings.plugins.Experiments.enableIsStaff === true,
|
||||||
replacement: [
|
replacement: [
|
||||||
{
|
{
|
||||||
match: /return\s*(\w+)\.hasFlag\((.+?)\.STAFF\)}/,
|
match: /return\s*(\w+)\.hasFlag\((.+?)\.STAFF\)}/,
|
||||||
|
|
|
@ -111,7 +111,7 @@ function countMatches(sourceString: string, pattern: RegExp) {
|
||||||
const customMoyaiRe = /<a?:\w*moy?ai\w*:\d{17,20}>/gi;
|
const customMoyaiRe = /<a?:\w*moy?ai\w*:\d{17,20}>/gi;
|
||||||
|
|
||||||
function getMoyaiCount(message: string) {
|
function getMoyaiCount(message: string) {
|
||||||
let count = countOccurrences(message, MOYAI)
|
const count = countOccurrences(message, MOYAI)
|
||||||
+ countMatches(message, customMoyaiRe);
|
+ countMatches(message, customMoyaiRe);
|
||||||
|
|
||||||
return Math.min(count, 10);
|
return Math.min(count, 10);
|
||||||
|
|
|
@ -38,7 +38,7 @@ async function bulkFetchPronouns(ids: string[]): Promise<PronounsResponse> {
|
||||||
params.append("ids", ids.join(","));
|
params.append("ids", ids.join(","));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const req = await fetch("https://pronoundb.org/api/v1/lookup-bulk?" + params, {
|
const req = await fetch("https://pronoundb.org/api/v1/lookup-bulk?" + params.toString(), {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
"Accept": "application/json"
|
"Accept": "application/json"
|
||||||
|
|
|
@ -31,14 +31,14 @@ function uwuify(message: string): string {
|
||||||
.split(" ")
|
.split(" ")
|
||||||
.map(w => {
|
.map(w => {
|
||||||
let owofied = false;
|
let owofied = false;
|
||||||
let lowerCase = w.toLowerCase();
|
const lowerCase = w.toLowerCase();
|
||||||
// return if the word is too short - uwuifying short words makes them unreadable
|
// return if the word is too short - uwuifying short words makes them unreadable
|
||||||
if (w.length < 4) {
|
if (w.length < 4) {
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
// replacing the words based on the array on line 29
|
// replacing the words based on the array on line 29
|
||||||
for (let [find, replace] of replacements) {
|
for (const [find, replace] of replacements) {
|
||||||
if (w.includes(find)) {
|
if (w.includes(find)) {
|
||||||
w = w.replace(find, replace);
|
w = w.replace(find, replace);
|
||||||
owofied = true;
|
owofied = true;
|
||||||
|
|
|
@ -49,7 +49,7 @@ export default definePlugin({
|
||||||
replace: (m, guild) => `_guild=${guild},${m}`
|
replace: (m, guild) => `_guild=${guild},${m}`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
match: /(?<=createElement\((.{1,5}),\{id:"leave-guild".{0,100}\,)(.{1,2}\.createElement)\((.{1,5}),null,(.{1,2})\)(?=\)\}function)/,
|
match: /(?<=createElement\((.{1,5}),\{id:"leave-guild".{0,100},)(.{1,2}\.createElement)\((.{1,5}),null,(.{1,2})\)(?=\)\}function)/,
|
||||||
replace: (_, menu, createElement, menuGroup, copyIdElement) =>
|
replace: (_, menu, createElement, menuGroup, copyIdElement) =>
|
||||||
`${createElement}(${menuGroup},null,[` +
|
`${createElement}(${menuGroup},null,[` +
|
||||||
`_guild.icon&&${createElement}(${menu},` +
|
`_guild.icon&&${createElement}(${menu},` +
|
||||||
|
|
Loading…
Reference in a new issue