import js from "@eslint/js";
import json from "@eslint/json";
import markdown from "@eslint/markdown";
import eslintConfigPrettier from "eslint-config-prettier";
import prettierPlugin from "eslint-plugin-prettier";
import { defineConfig } from "eslint/config";
import globals from "globals";
import tseslint from "typescript-eslint";
export default defineConfig([
// Global ignores
{
ignores: [".github/**/*", "node_modules/**/*", "dist/**/*", "build/**/*"],
},
// Base config for all JavaScript and TypeScript files
{
files: ["**/*.{js,mjs,cjs,ts,mts,cts}"],
plugins: { js },
extends: ["js/recommended"],
},
{
files: ["**/*.{js,mjs,cjs,ts,mts,cts}"],
languageOptions: { globals: globals.node },
},
// TypeScript-specific configuration
{
files: ["**/*.{ts,mts,cts}"],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: "./tsconfig.dev.json",
ecmaVersion: "latest",
sourceType: "module",
},
},
plugins: {
"@typescript-eslint": tseslint.plugin,
},
rules: {
...tseslint.configs.recommended.rules,
// Add any custom TypeScript rules here
"@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-floating-promises": "off",
},
},
// JSON files
{
files: ["**/*.json"],
plugins: { json },
language: "json/json",
extends: ["json/recommended"],
},
// Markdown files
{
files: ["**/*.md"],
plugins: { markdown },
language: "markdown/gfm",
extends: ["markdown/recommended"],
},
// Prettier configuration (must be last to override other formatting rules)
{
files: ["**/*.{js,mjs,cjs,ts,mts,cts,json,md}"],
plugins: {
prettier: prettierPlugin,
},
rules: {
...eslintConfigPrettier.rules,
"prettier/prettier": "error",
// Turn off rules that might conflict with Prettier
"arrow-body-style": "off",
"prefer-arrow-callback": "off",
},
},
]);