Matías Baldanza

ESLint - False positive with no-unused-vars rule in Next.js

Problem

After installing adding an .eslintrc.json file to a Next.js project that uses ESLint, I started getting false positives from the no-unused-vars rule. This is how I fixed it.

The error I was getting looked like this:

ESLint error

See the red highlight on all those files? They're all false positives! Like in the PaginatedArticleList import, which is clearly used a few lines below.

Solution

The only thing required to fix this is to add "next" to the extends in .eslintrc.json.

{
  "extends": ["standard", "next"]
}