#Adding Prettier to Next.js

1 messages · Page 1 of 1 (latest)

golden swan
#

With the official instruction on how to add Prettier to Next.js

const eslintConfig = [
  ...compat.config({
    extends: ['next', 'prettier'],
  }),
]

However, my files doesn't look the same, it is

const eslintConfig = [
  ...compat.extends("next/core-web-vitals", "next/typescript", "prettier"),
];

At this point. how do I prettify my code?

  1. What command do I need to run?
  2. Does it enforce prettier before git committing?

Learn how to use and configure the ESLint plugin to catch common issues and problems in a Next.js application.

mortal raptorBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

dull turret
#

You can just run prettier . and no it won't auto run before commiting. You can setup a pre-commit hook with husky and lint-staged however.

golden swan
dull turret
#

Thats is just to sort out the rules. so eslint doesn't clash with prettier etc.

tawny remnant
#

Hello, Chung

#

You will need to run "prettier --write ." manually

#

Or another way is to set up a pre-commit hook

mortal raptorBOT