Ctrl K
ComunidadGuías…

eslint.config.mjs

Rama main · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
import { defineConfig, globalIgnores } from "eslint/config";
import nextVitals from "eslint-config-next/core-web-vitals";
import nextTs from "eslint-config-next/typescript";

const eslintConfig = defineConfig([
  ...nextVitals,
  ...nextTs,
  {
    rules: {
      "@typescript-eslint/no-unused-vars": ["warn", {
        argsIgnorePattern: "^_",
        varsIgnorePattern: "^_",
        destructuredArrayIgnorePattern: "^_",
      }],
    },
  },
  // eslint-plugin-react-hooks 7 (pulled in by eslint-config-next) ships new
  // React Compiler-powered rules at error severity. ~33 legacy components
  // predate them; refactoring those effects is behavior-sensitive work that
  // happens per component, not in a lint sweep. Same pattern as no-console
  // below: warn (not error) until the legacy sites are migrated, then flip
  // each rule back to "error" so the floor is enforced. New violations still
  // surface as warnings in every lint run and PR review.
  {
    rules: {
      "react-hooks/set-state-in-effect": "warn",
      "react-hooks/static-components": "warn",
      "react-hooks/purity": "warn",
      "react-hooks/preserve-manual-memoization": "warn",
    },
  },
  // No raw console.* in lib/ or app/api/. Use createLogger from @/lib/logger
  // so log lines carry requestId + structured context. lib/logger.ts and
  // app/api/log/route.ts are the two intentional exemptions because they ARE
  // the logger plumbing.
  {
    files: ["src/lib/**/*.ts", "src/lib/**/*.tsx", "src/app/api/**/*.ts", "src/app/api/**/*.tsx"],
    ignores: [
      "src/lib/logger.ts",
      "src/app/api/log/route.ts",
      // Test files have legitimate console use for assertions / debugging.
      "**/__tests__/**",
      "**/*.test.ts",
      "**/*.bench.test.ts",
      "**/*.pg.test.ts",
    ],
    rules: {
      // warn (not error) until the remaining ~20 routes/lib files migrate.
      // Flip to "error" once the count drops to zero so the floor is enforced.
      "no-console": "warn",
    },
  },
  // The Skatteverket extension handles redovisare and arbetsgivare ids, which
  // for an enskild firma are the owner's personnummer, plus declaration
  // payloads. Raw console.* skips the redacting logger, so here it is an error.
  {
    files: ["src/extensions/general/skatteverket/**/*.ts", "src/extensions/general/skatteverket/**/*.tsx"],
    ignores: ["**/__tests__/**", "**/*.test.ts", "**/*.pg.test.ts"],
    rules: {
      "no-console": "error",
    },
  },
  globalIgnores([
    ".next/**",
    "out/**",
    "build/**",
    "next-env.d.ts",
    // Claude Code session worktrees are full repo copies: without this,
    // local `npm run lint` / `check:lint` walks them (and their node_modules
    // siblings), inflating the report until the ratchet's JSON parse fails.
    ".claude/worktrees/**",
  ]),
]);

export default eslintConfig;