Next.js Discord

Discord Forum

disable unused-vars from nextjs when running npm run build

Unanswered
Briard posted this in #help-forum
Open in Discord
BriardOP
i added those options in my eslint.config.mjs but i still get those errors
./src/app/auth/forgot-password/page.tsx
15:72  Error: `'` can be escaped with `'`, `‘`, `'`, `’`.  react/no-unescaped-entities

./src/features/users/components/EmployeesTable.tsx
52:10  Error: 'toggle' is assigned a value but never used.  @typescript-eslint/no-unused-vars


import { dirname } from "path";
import { fileURLToPath } from "url";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const compat = new FlatCompat({
  baseDirectory: __dirname,
  rules: {
    "react/no-unescaped-entities": "off",
    "@next/next/no-page-custom-font": "off",
    "@typescript-eslint/no-explicit-any": "error",
    "no-console": "warn",
    "no-unused-vars": "off",
    "@typescript-eslint/no-unused-vars": "warn",
  },
});

const eslintConfig = [
  ...compat.config({
    extends: ["next/core-web-vitals", "next/typescript"],
  }),
];

export default eslintConfig;

3 Replies

Move the custom *rules *from the FlatCompat config object to the eslintConfig array as a separate object.

// ... prev code
const compat = new FlatCompat({
  baseDirectory: __dirname,
  // remove rules from here
});

const eslintConfig = [
  ...compat.extends("next/core-web-vitals", "next/typescript"),
  {
    rules: {
      "react/no-unescaped-entities": "off",
      "@next/next/no-page-custom-font": "off",
      "@typescript-eslint/no-explicit-any": "error",
      "no-console": "warn",
      "no-unused-vars": "off",
      "@typescript-eslint/no-unused-vars": "warn",
    },
  },
];

export default eslintConfig;
@Briard solved?
BriardOP
yes thanks