Merge pull request #1232 from dank074/patch/eslintConfig

This commit is contained in:
Madeline 2024-11-14 16:02:00 +11:00 committed by GitHub
commit 841b36112f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 54 additions and 30 deletions

View File

@ -1,7 +0,0 @@
node_modules
dist
README.md
COPYING
src/webrtc
scripts/
assets

View File

@ -1,14 +0,0 @@
{
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"root": true,
"rules": {
"no-mixed-spaces-and-tabs": "off",
"@typescript-eslint/no-inferrable-types": "off", // Required by typeorm
"@typescript-eslint/no-var-requires": "off" // Sometimes requred by typeorm to resolve circular deps
},
"env": {
"node": true
}
}

47
eslint.config.mjs Normal file
View File

@ -0,0 +1,47 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
export default [{
ignores: [
"**/node_modules",
"**/dist",
"**/README.md",
"**/COPYING",
"src/webrtc",
"**/scripts/",
"**/assets",
],
}, ...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"), {
plugins: {
"@typescript-eslint": typescriptEslint,
},
languageOptions: {
globals: {
...globals.node,
},
parser: tsParser,
},
rules: {
"no-mixed-spaces-and-tabs": "off",
"@typescript-eslint/no-inferrable-types": "off", // Required by typeorm
"@typescript-eslint/no-var-requires": "off", // Sometimes requred by typeorm to resolve circular deps
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/no-unused-vars": "off",
},
}];

BIN
package-lock.json generated

Binary file not shown.

View File

@ -38,6 +38,8 @@
},
"homepage": "https://spacebar.chat",
"devDependencies": {
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.14.0",
"@types/amqplib": "^0.10.5",
"@types/bcrypt": "^5.0.2",
"@types/body-parser": "^1.19.5",
@ -61,6 +63,7 @@
"@typescript-eslint/parser": "^8.12.2",
"eslint": "^9.13.0",
"express": "^4.21.1",
"globals": "^15.12.0",
"husky": "^9.1.6",
"prettier": "^3.3.3",
"pretty-quick": "^4.0.0",

View File

@ -108,7 +108,6 @@ export async function Authentication(
req.rights = new Rights(Number(user.rights));
return next();
} catch (error) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return next(new HTTPError(error!.toString(), 400));
}
}

View File

@ -72,7 +72,6 @@ router.post(
await User.update({ id: user.id }, data);
// come on, the user has to have an email to reset their password in the first place
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
await Email.sendPasswordChanged(user, user.email!);
res.json({ token: await generateToken(user.id) });

View File

@ -171,7 +171,6 @@ export async function onIdentify(this: WebSocket, data: Payload) {
// but we do want almost everything from guild.
// How do you do that without just enumerating the guild props?
guild: Object.fromEntries(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
getDatabase()!
.getMetadata(Guild)
.columns.map((x) => [x.propertyName, true]),

View File

@ -214,7 +214,6 @@ async function subscribeToMemberEvents(this: WebSocket, user_id: string) {
export async function onLazyRequest(this: WebSocket, { d }: Payload) {
// TODO: check data
check.call(this, LazyRequestSchema, d);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { guild_id, typing, channels, activities, members } =
d as LazyRequestSchema;

View File

@ -99,7 +99,6 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) {
voiceState.token = genVoiceToken();
voiceState.session_id = this.session_id;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { id, ...newObj } = voiceState;
await Promise.all([

View File

@ -46,7 +46,7 @@ export class BaseClassWithoutId extends BaseEntity {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
toJSON(): any {
return Object.fromEntries(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/no-non-null-assertion
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
this.metadata!.columns // @ts-ignore
.map((x) => [x.propertyName, this[x.propertyName]])
.concat(

View File

@ -69,7 +69,6 @@ export interface MessageCreateSchema {
}
// TypeScript complains once this is used above
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface PollCreationSchema {
question: PollMedia;
answers: PollAnswer[];

View File

@ -18,4 +18,5 @@
import { Team } from "@spacebar/util";
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface TeamListResponse extends Array<Team> {}

View File

@ -70,7 +70,6 @@ export function enableAutoUpdate(opts: {
});
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async function download(url: string, dir: string) {
try {
// TODO: use file stream instead of buffer (to prevent crash because of high memory usage for big files)

View File

@ -100,6 +100,7 @@ export async function listenEvent(
};
const listener = (msg: ProcessEvent) => {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
msg.type === "event" &&
msg.id === event &&
callback({ ...msg.event, cancel });

View File

@ -117,7 +117,7 @@ export const Sentry = {
Integrations.setupExpressErrorHandler(app);
// The typings for this are broken?
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-explicit-any
app.use(function onError(err: any, req: any, res: any, next: any) {
res.statusCode = 500;
res.end(res.sentry + "\n");