Next.js Discord

Discord Forum

eslint-plugin-next with eslint.config.mjs (v9) throws error

Answered
Tomistoma posted this in #help-forum
Open in Discord
TomistomaOP
Solved
There was no problem in the first place, it was an issue with my editor not displaying errors correctly












## Expected

This code should throw error for @next/next/no-img-element eslint rule, but it doesn't.
export default function Home() {
  return <img/>;
}


eslint.config.mjs
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import next from "@next/eslint-plugin-next";

import { fixupPluginRules } from "@eslint/compat";

export default tseslint.config(
  eslint.configs.recommended,
  ...tseslint.configs.recommended,
  {
    languageOptions: {
      parserOptions: {
        project: true,
        tsconfigRootDir: import.meta.dirname,
      },
    },
    plugins: {
      "@next/next": fixupPluginRules(next),
    },
    rules: {
      ...next.configs.recommended.rules,
    },
  },
);

The regular eslint/recommended and @typescript-eslint/recommended work correctly.

Package versions:

"next": "14.2.5",
"eslint": "^9.9.0",
"@next/eslint-plugin-next": "^14.2.5",
"@eslint/compat": "^1.1.1",


## Tried
Not using @eslint/compat:
plugins: {
   "@next/next": next,
},

got error:
Could not parse linter output due to:
Expected value but found invalid token at character 1

output: TypeError: context.getAncestors is not a function
Rule: "@next/next/no-duplicate-head"
Answered by Tomistoma
Solved
There was no problem in the first place, it was an issue with my editor not displaying errors correctly
View full answer

1 Reply

TomistomaOP
Solved
There was no problem in the first place, it was an issue with my editor not displaying errors correctly
Answer