Eslint not working with create-next-app@latest
Answered
Wood Sandpiper posted this in #help-forum
Wood SandpiperOP
I notice eslint not catching any errors with
How to repro this issue:
1. Create a new next app
2. Add below to
ref: https://eslint.org/docs/latest/rules/no-const-assign
3. Run
I expected
Here is my package.json.
pnpm lint. Whats the right way to configure. ? https://nextjs.org/docs/app/building-your-application/configuring/eslintHow to repro this issue:
1. Create a new next app
% pnpm create next-app nextjs_playground. Answer yes to prompts. 2. Add below to
page.tsx const a = 0;
a = 1;ref: https://eslint.org/docs/latest/rules/no-const-assign
3. Run
pnpm lintI expected
pnpm lint complain this no-const-assign. But lint succeeded. nextjs_playground % pnpm lint
> nextjs_playground@0.1.0 lint user/.../ws/nextjs_playground
> next lint
✔ No ESLint warnings or errorsHere is my package.json.
{
"name": "nextjs_playground",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"react": "^18",
"react-dom": "^18",
"next": "14.1.0"
},
"devDependencies": {
"typescript": "^5",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"eslint": "^8",
"eslint-config-next": "14.1.0"
}
}Answered by Ray
you need to extend the rule for
no-const-assign in .eslintrc.json like so{
"extends": ["next/core-web-vitals", "eslint:recommended"]
}5 Replies
Wood SandpiperOP
Is there a guide on eslint , prettier / style setup for the project? Something that can guide us to setup prettier, eslint for new nextjs project will be helpful .
Wood SandpiperOP
Bump
@Wood Sandpiper Bump
you need to extend the rule for
no-const-assign in .eslintrc.json like so{
"extends": ["next/core-web-vitals", "eslint:recommended"]
}Answer
Wood SandpiperOP
wow! Thanks @Ray 🦸 . That fixed the issue!