adding eslint support to nextjs is definitely not as easy as the official claims!
what happened?
nextjs has supported eslint by default, then I thought "maybe a just need a .eslintrc file, how hard can it be?", then one afternoon of my life is ruined. I copied my .eslintrc file from my old project, and I promised I exactly followed nextjs migrate instruction
tldr, nextjs prompts you to extend "next" in your own .eslintrc.json
then nothing happened when I run "pnpm run lint", nextjs has no idea about my .eslintrc.json file.
After copying referring to many stackoverflow/github issues, I decided to screw that bullcrap next lint, I do it my self!
these are necessary dependencies, notice they are all devDependencies
then we will be okay...?
after eslint 9, .eslintrc files (js or json or whatever) are not supported, which means I have to make a eslint.config.mjs instead to let eslint cli know my config file
is breaking changes ths mainstream in javascript? am I right, Nextjs official?
Good news is, eslint official tells me how to migrate to the new version:
download...
actually we good,
eslint shouts, in the end.
setup prettier
eslint shouts when our rules are broken, but prettier fix our code (kind of)
to introduce some plugins I am using:
go to your .prettierrc,
run prettier write .
to format all the files in your project
why this command can run globally?
modify my commands
I am not getting used to the latest eslint config syntax, you can make your own's
don't forget to go to next.config.ts
since we run format
every time before build
so we don't need it anymore
currently I am making it into a git hook, I will write a new blog after I made it