Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
AshyBoxy committed Nov 1, 2024
1 parent 3c90a80 commit f1cb716
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 152 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

123 changes: 0 additions & 123 deletions .eslintrc.json

This file was deleted.

135 changes: 135 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import js from "@eslint/js";
import stylistic from "@stylistic/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import globals from "globals";
import ts from "typescript-eslint";


const tsConfigMain = ts.configs.recommended.map((config) => ({
...config, files: ["**/*.ts"]
}));
const tsConfigStylistic = ts.configs.stylistic.map((config) => ({
...config, files: ["**/*.ts"]
}));


export default [
{
ignores: [
"**/dist", "**/node_modules"
]
},
js.configs.recommended,
{
plugins: {
"@typescript-eslint": ts.plugin,
"@stylistic": stylistic
},

languageOptions: {
globals: {
...globals.node
},
parser: tsParser,
ecmaVersion: 2022,
sourceType: "module"
},

rules: {
"no-console": "error",

"no-extra-boolean-cast": [
"error", {
enforceForLogicalOperands: true
}
],

"no-template-curly-in-string": "error",
"no-unreachable-loop": "error",
curly: [
"error", "multi"
],
"default-case-last": "error",
"default-case": "error",
"dot-notation": "error",
eqeqeq: "error",
"no-empty-function": "error",
"no-lone-blocks": "error",
"require-await": "error",
yoda: "error",

"array-bracket-newline": [
"error", {
minItems: 2
}
],

camelcase: "error",
"comma-dangle": [
"error", "never"
],
"comma-style": [
"error", "last"
],
"linebreak-style": [
"error", "unix"
],
"new-parens": "error",
"no-trailing-spaces": "error",
"no-unneeded-ternary": "error",
"no-whitespace-before-property": "error",
"operator-assignment": "error",
"arrow-body-style": [
"error", "as-needed"
],
"arrow-parens": "error",
"no-var": "error",

"prefer-const": [
"error", {
destructuring: "any"
}
],

"prefer-template": "error",
"template-curly-spacing": "error",

"quote-props": [
"error", "as-needed", {
numbers: true
}
],

"comma-spacing": "off",
quotes: "off"
}
},
...tsConfigMain,
...tsConfigStylistic,
{
files: ["**/*.ts"],

rules: {
"@typescript-eslint/explicit-function-return-type": "error",
"@stylistic/comma-spacing": "error",

"@stylistic/quotes": [
"error", "double", {
avoidEscape: true
}
],

"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-namespace": "off",
"no-shadow": "off",
"@typescript-eslint/no-shadow": ["error"],

"@typescript-eslint/consistent-type-assertions": [
"error", {
assertionStyle: "angle-bracket",
objectLiteralTypeAssertions: "never"
}
]
}
}
];
2 changes: 2 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// bun doesn't seem to look for package.json for relative path imports
export * from "./src";
18 changes: 10 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 11 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,21 @@
"author": "AshyBoxy <[email protected]>",
"license": "MIT",
"dependencies": {
"discord.js": "^14.13.0",
"discord.js": "^14.16.3",
"leveldown": "^6.1.1",
"levelup": "^5.1.1",
"resolve": "^1.22.8"
},
"devDependencies": {
"@types/leveldown": "^4.0.4",
"@types/levelup": "^5.1.3",
"@types/node": "^20.12.7",
"@typescript-eslint/eslint-plugin": "^6.6.0",
"@typescript-eslint/parser": "^6.6.0",
"eslint": "^8.48.0",
"typescript": "^5.2.2"
"@types/leveldown": "^4.0.6",
"@types/levelup": "^5.1.5",
"@types/node": "^22.8.6",
"eslint": "^9.14.0",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.14.0",
"@stylistic/eslint-plugin": "^2.10.1",
"globals": "^15.11.0",
"typescript": "^5.6.3",
"typescript-eslint": "^8.12.2"
}
}
9 changes: 6 additions & 3 deletions src/Classes/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class MapDB<valueType> implements IDatabase<valueType> {
close = (): Promise<void> => new Promise((r) => r());
}

const validFileRegex = /\.[tj]s$/;
const fileSplitRegex = /\.[tj]s/;

// using true here basically makes typescript assume the bot is ready
// meaning it won't enforce type checking
// this probably shouldn't be left like this(?)
Expand Down Expand Up @@ -81,7 +84,7 @@ class BreadClient<Databases extends Record<string, IDatabase<any>> = Record<stri
const eventFiles: eventFile[] = [
...this.config.eventsPath ? readdirSync(this.config.eventsPath).map((x) => ({ path: x, dir: <string>this.config.eventsPath })) : [],
...readdirSync(BreadClient.BuiltInEventPath).map((x) => ({ path: x, dir: BreadClient.BuiltInEventPath }))
].filter((x: eventFile) => x.path.endsWith(".js"));
].filter((x: eventFile) => validFileRegex.test(x.path));

for (let i = 0; i < eventFiles.length; i++) {
const event: EventHandler<keyof ClientEvents> = (await import(path.join(eventFiles[i].dir, eventFiles[i].path))).default;
Expand All @@ -103,13 +106,13 @@ class BreadClient<Databases extends Record<string, IDatabase<any>> = Record<stri
});

for (let i = 0; i < this.modules.length; i++) {
const cmdFiles = readdirSync(path.join(this.modules[i].path.startsWith("/") ? "" : this.config.commandsPath || "", this.modules[i].path)).filter((x: string) => x.endsWith(".js"));
const cmdFiles = readdirSync(path.join(this.modules[i].path.startsWith("/") ? "" : this.config.commandsPath || "", this.modules[i].path)).filter((x: string) => validFileRegex.test(x));

const commands: string[] = [];
for (let x = 0; x < cmdFiles.length; x++) {
const cmd: Command = (await import(path.join(this.modules[i].path.startsWith("/") ? "" : this.config.commandsPath || "", this.modules[i].path, cmdFiles[x]))).default;
if (!cmd?.run || !cmd?.name) {
warnings.push(strings.get("bread_framework.classes.breadclient.commandwarning", cmdFiles[x].split(".js")[0], this.modules[i].name));
warnings.push(strings.get("bread_framework.classes.breadclient.commandwarning", cmdFiles[x].split(fileSplitRegex)[0], this.modules[i].name));
continue;
}
cmd.module = this.modules[i];
Expand Down
Loading

0 comments on commit f1cb716

Please sign in to comment.