eslint.config.js•1.65 kB
// eslint.config.js
import { defineConfig, globalIgnores } from "eslint/config";
import { fileURLToPath } from "url";
import { dirname, resolve } from "path";
import tsPlugin from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import prettierPlugin from "eslint-plugin-prettier";
import markdownPlugin from "@eslint/markdown";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
export default defineConfig([
// 1️⃣ Global ignores
globalIgnores([
"node_modules/",
"dist/",
"build/",
".git/",
]),
// 2️⃣ TypeScript + Prettier for code files
{
files: ["**/*.{ts,tsx}"], // only TypeScript files
languageOptions: {
parser: tsParser,
parserOptions: {
project: resolve(__dirname, "./tsconfig.json"),
tsconfigRootDir: __dirname,
sourceType: "module",
},
},
plugins: {
"@typescript-eslint": tsPlugin,
prettier: prettierPlugin, // 👈 MUST be defined here
},
rules: {
"prettier/prettier": ["error", { singleQuote: true, semi: true }],
},
},
{
files: ["**/*.js"],
languageOptions: {
parserOptions: { sourceType: "module" }, // no TS project needed
},
rules: { /* JS-specific rules */ },
},
// 3️⃣ Markdown override
{
files: ["**/*.md"],
plugins: {
markdown: markdownPlugin,
prettier: prettierPlugin, // 👈 Prettier plugin must also be defined here
},
processor: "markdown/markdown",
rules: {
"prettier/prettier": ["error", { singleQuote: true, semi: true }],
},
},
]);