0

I have created Next.js project uinsg npx create-next-app@latest, and I have unused imports in the pages.

npm run lint does not complaint the unused imports until I added eslint:recommended in .eslintrc.json

{
  "extends": ["next/core-web-vitals", "eslint:recommended"]
}

Is this the recommended way?

user3357926
  • 435
  • 1
  • 4
  • 13
  • You can add you own rule below. I think you need `unused-imports` plugin. Take a look at this answer: https://stackoverflow.com/a/68338238/2018591 – Jamadan Apr 28 '23 at 11:48
  • I guess `next/core-web-vitals` simply not include the rules to check unused imports. That is why we need `eslint:recommended` to detect the unused imports. It looks like `eslint-plugin-unused-imports` is needed only if we want ESLint to remove the unused imports automatically. – user3357926 Apr 29 '23 at 12:40
  • "is needed only if we want ESLint to remove the unused imports automatically" It should also highlight unused imports in your IDE and error if you run eslint – Jamadan Apr 29 '23 at 21:16
  • "is needed only if we want ESLint to remove the unused imports automatically" It should also highlight unused imports in your IDE and error if you run eslint – Jamadan Apr 29 '23 at 21:16

0 Answers0