Configure the Prettier
Edson Junior de Andrade

Edson Junior de Andrade @edsonjuniornarvaes

About: Front-end developer, Web e Mobile

Location:
Umuarama-PR, Brasil
Joined:
Apr 26, 2021

Configure the Prettier

Publish Date: Sep 21 '21
1 0

Here we will install two dependencies to configure Prettier along with ESLint, the first disables the conflicting rules between Prettier and ESLint and the second transforms Prettier and its settings into ESLint rules, so we can integrate the two, come on:

If you don't have ESLint installed, check out the step-by-step guide (here).

yarn add -D prettier eslint-config-prettier eslint-plugin-prettier
Enter fullscreen mode Exit fullscreen mode

Now let's update our .eslintrc file again, let's leave our keysextends, plugins and rules, in the example below I'll be configuring with react:

extends: [
  "eslint:recommended",
  "prettier/react",
  "airbnb",
  "plugin:react/recommended",
  "plugin:prettier/recommended"
],
plugins: ['react', 'prettier'],
rules: {'prettier/prettier':  'error'}
Enter fullscreen mode Exit fullscreen mode

Finally, create a .prettierrc.json file and configure it as follows:

{
  "trailingComma": "es5",
  "tabWidth": 2,
  "semi": true,
  "singleQuote": true,
  "jsxSingleQuote": true
}
Enter fullscreen mode Exit fullscreen mode

Comments 0 total

    Add comment