import path from "node:path"

// https://nextjs.org/docs/app/building-your-application/configuring/eslint#lint-staged
const buildEslintCommand = (filenames) =>
  `next lint --fix --max-warnings 0 --file ${filenames
    .map((f) => path.relative(process.cwd(), f))
    .join(" --file ")}`

const config = {
  "*.{js,jsx,ts,tsx}": [buildEslintCommand],
  "*.{ts,tsx}": () => "tsc -p tsconfig.json --noEmit",
  "*": "prettier --write",
}

export default config
