import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
import prettier from "eslint-plugin-prettier";
import esLintImport from "eslint-plugin-import";
import comments from "eslint-plugin-eslint-comments";

export default [
    { files: ["**/*.{js,mjs,cjs,ts}"] },
    { languageOptions: { globals: globals.browser } },
    pluginJs.configs.recommended,
    ...tseslint.configs.recommended,
    {
        plugins: {
            prettier,
            import: esLintImport,
            comments,
        },
    },
    {
        rules: {
            "prettier/prettier": ["warn"],
            "linebreak-style": ["warn", "unix"],
            "default-case": ["error"],
            quotes: ["warn", "double", { avoidEscape: true }],
            eqeqeq: ["warn", "always"],
            "@typescript-eslint/array-type": ["warn", { default: "array" }],
            "@typescript-eslint/no-namespace": "off",
            "@typescript-eslint/no-unused-vars": ["warn"],
            "@typescript-eslint/no-non-null-assertion": ["warn"],
            "prefer-const": ["warn", { destructuring: "any", ignoreReadBeforeAssign: false }],
            "import/prefer-default-export": ["warn", { target: "single" }],
            "no-else-return": ["warn"],
            "no-duplicate-imports": ["warn"],
            "object-shorthand": ["warn", "always"],
            "max-depth": ["warn", 3],
            "no-template-curly-in-string": ["warn"],
            "no-useless-concat": ["warn"],
            "comma-dangle": ["warn", "always-multiline"],
            "no-empty-pattern": ["warn", { allowObjectPatternsAsParameters: true }],
            "@typescript-eslint/ban-ts-comment": [
                "warn",
                {
                    "ts-expect-error": "allow-with-description",
                    "ts-ignore": true,
                    "ts-nocheck": true,
                    "ts-check": false,
                    minimumDescriptionLength: 30,
                },
            ],
            "comments/no-restricted-disable": ["warn", "@typescript-eslint/ban-ts-comment"],
        },
    },
];
