// SPDX-FileCopyrightText: 2025 Johannes Loher
//
// SPDX-License-Identifier: MIT

// @ts-check

import eslint from "@eslint/js";
import eslintConfigPrettier from "eslint-config-prettier";
import tseslint from "typescript-eslint";
import globals from "globals";

const foundryGlobals = {
  ActiveEffect: false,
  ActiveEffectConfig: false,
  Actor: false,
  ActorSheet: false,
  canvas: false,
  Canvas: false,
  ChatMessage: false,
  CONFIG: false,
  DocumentSheetConfig: false,
  game: false,
  Game: false,
  Hooks: false,
  Item: false,
  ItemSheet: false,
  Macro: false,
  Notifications: false,
  ui: false,
  loadTemplates: false,
  foundry: false,
  Dialog: false,
  renderTemplate: false,
  TokenDocument: false,
  Roll: false,
  TextEditor: false,
  CONST: false,
  getProperty: false,
  fromUuid: false,
};

export default tseslint.config(
  {
    ignores: ["dist/**", "client", "common"],
  },
  eslint.configs.recommended,
  tseslint.configs.recommended,
  {
    languageOptions: {
      parserOptions: {
        ecmaVersion: 2020,
        sourceType: "module",
      },
      globals: { ...globals.browser, ...globals.jquery, ...foundryGlobals },
    },
  },
  {
    files: ["tools/**", "*"],
    languageOptions: {
      parserOptions: {},
      globals: globals.node,
    },
  },
  eslintConfigPrettier,
);