Skip to content

ESLint with nextjs

Course: ESLint, Prettier and Pre-commit hooks - chapter 7

  • Create a next application (Select yes on ESLint)
npx create-next-app
  • Check the default config
{
"extends": ["next/core-web-vitals"]
}
  • Add .vscode/settings.json
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
  • Add airbnb config
yarn add eslint-config-airbnb eslint-config-airbnb-typescript @typescript-eslint/dot-notation eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-import
  • Update the eslint config
{
"extends": ["next/core-web-vitals", "airbnb", "airbnb/hooks"]
}
  • Run npm run lint

  • Fix some automatically

yarn lint --fix