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

export default [
  {
    ignores: ["node_modules/**", "data/**", "releases/**", "android/**", "web/translations/**"],
  },
  js.configs.recommended,
  {
    // Browser-side single-page app served by the bridge. Loaded as a classic
    // (non-module) script, so all top-level functions/vars share one global scope.
    files: ["web/**/*.js"],
    languageOptions: {
      ecmaVersion: 2022,
      sourceType: "script",
      globals: {
        ...globals.browser,
      },
    },
    rules: {
      // Top-level functions/vars are intentional globals invoked from inline
      // HTML handlers, so only flag unused *local* bindings, not globals.
      "no-unused-vars": ["warn", { vars: "local", args: "none" }],
      // Empty catch blocks are used intentionally to swallow non-critical errors.
      "no-empty": ["error", { allowEmptyCatch: true }],
    },
  },
  prettier,
];
