Opinionated eslint config that I use for Next application.
Install @khuibeom/eslint-config-next
npm i -D @khuibeom/eslint-config-next
# or
pnpm i -D @khuibeom/eslint-config-next
# or
yarn add -D @khuibeom/eslint-config-next
Extend it in .eslintrc
{
"extends": "@khuibeom/next"
}
If you want to auto fix code on save, add the following in .vscode/settings.json
.
Make sure ESLint extension is installed.
{
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
This is a wrapper around eslint config from Next-js-Boilerplate. I made some changes to the original config, including:
- Removing prettier. I was influenced by this article
- Allowing
var
and removingprefer-const
. You can read about it here - Removing jest/cypress related configs.
You can always change the eslint config tailored to your need. For instance, you can use following config for adding back jest/cypress config from Next-js-Boilerplate that I removed:
.eslintrc
{
"extends": "@khuibeom/next",
"overrides": [
{
"files": ["**/*.test.ts", "**/*.test.tsx"],
"plugins": ["jest", "jest-formatting", "testing-library", "jest-dom"],
"extends": [
"plugin:jest/recommended",
"plugin:jest-formatting/recommended",
"plugin:testing-library/react",
"plugin:jest-dom/recommended"
]
},
{
"files": ["cypress/**/*.ts"],
"plugins": ["cypress"],
"extends": ["plugin:cypress/recommended"],
"parserOptions": {
"project": "./cypress/tsconfig.json"
}
}
]
}
Make sure to install the necessary plugins:
npm i -D eslint-plugin-jest eslint-plugin-jest-dom eslint-plugin-jest-formatting eslint-plugin-testing-library eslint-plugin-cypress