From 044b3ac9015d73b65fb14659fd50d98d34172169 Mon Sep 17 00:00:00 2001 From: Taken Date: Thu, 3 Oct 2024 15:45:05 +0200 Subject: [PATCH] Added eslint fot drizzle --- eslint.config.mjs | 12 ++++++++++-- package.json | 1 + pnpm-lock.yaml | 12 ++++++++++++ src/commands/config.ts | 3 ++- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 17f9faf..d6b1b22 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -2,6 +2,7 @@ import { FlatCompat } from "@eslint/eslintrc" import js from "@eslint/js" import typescriptEslint from "@typescript-eslint/eslint-plugin" import tsParser from "@typescript-eslint/parser" +import drizzle from "eslint-plugin-drizzle" import globals from "globals" import path from "node:path" import { fileURLToPath } from "node:url" @@ -20,10 +21,11 @@ export default [ { ignores: ["**/node_modules", "**/dist", "**/dev"] }, - ...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"), + ...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:drizzle/all"), { plugins: { - "@typescript-eslint": typescriptEslint + "@typescript-eslint": typescriptEslint, + "drizzle": drizzle }, languageOptions: { @@ -87,6 +89,12 @@ export default [ "ts-ignore": "allow-with-description", "ts-nocheck": "allow-with-description", "ts-check": "allow-with-description" + }], + "drizzle/enforce-delete-with-where": ["error", { + "drizzleObjectName": ["db"] + }], + "drizzle/enforce-update-with-where": ["error", { + "drizzleObjectName": ["db"] }] } }, diff --git a/package.json b/package.json index 8281157..6bc26b1 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,7 @@ "dprint": "^0.47.2", "drizzle-kit": "^0.24.2", "eslint": "^9.11.1", + "eslint-plugin-drizzle": "^0.2.3", "globals": "^15.9.0", "sqlite3": "^5.1.7", "tsx": "^4.19.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c1bdfe1..fcd2d03 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -104,6 +104,9 @@ importers: eslint: specifier: ^9.11.1 version: 9.11.1 + eslint-plugin-drizzle: + specifier: ^0.2.3 + version: 0.2.3(eslint@9.11.1) globals: specifier: ^15.9.0 version: 15.9.0 @@ -1466,6 +1469,11 @@ packages: resolution: {integrity: sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==} engines: {node: '>=12'} + eslint-plugin-drizzle@0.2.3: + resolution: {integrity: sha512-BO+ymHo33IUNoJlC0rbd7HP9EwwpW4VIp49R/tWQF/d2E1K2kgTf0tCXT0v9MSiBr6gGR1LtPwMLapTKEWSg9A==} + peerDependencies: + eslint: '>=8.0.0' + eslint-scope@8.0.2: resolution: {integrity: sha512-6E4xmrTw5wtxnLA5wYL3WDfhZ/1bUBGOXV0zQvVRDOtrR8D0p6W7fs3JweNYhwRYeGvd/1CKX2se0/2s7Q/nJA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -3927,6 +3935,10 @@ snapshots: escape-string-regexp@5.0.0: {} + eslint-plugin-drizzle@0.2.3(eslint@9.11.1): + dependencies: + eslint: 9.11.1 + eslint-scope@8.0.2: dependencies: esrecurse: 4.3.0 diff --git a/src/commands/config.ts b/src/commands/config.ts index cac3046..d624fde 100644 --- a/src/commands/config.ts +++ b/src/commands/config.ts @@ -1,5 +1,6 @@ import { embedColor } from "config/options.js" import { InteractionContextType, PermissionFlagsBits, SlashCommandBuilder } from "discord.js" +import { eq } from "drizzle-orm" import { ICommand } from "interfaces" import db from "src/db/db.js" import { settings } from "src/db/schema.js" @@ -56,7 +57,7 @@ export default { } else { await db.update(settings).set({ value: value - }) + }).where(eq(settings.name, setting)) await interaction.editReply({ embeds: [{