Skip to content

Instantly share code, notes, and snippets.

@themouette
Last active April 1, 2022 21:56
Show Gist options
  • Save themouette/4a0c74b58c7e563cc7ddba28183f9b5c to your computer and use it in GitHub Desktop.
Save themouette/4a0c74b58c7e563cc7ddba28183f9b5c to your computer and use it in GitHub Desktop.
Having eslint and prettier to work together

It requires:

  • eslint-config-prettier to avoid collision with other eslint rules
  • eslint-plugin-prettier to add the eslint rules
  • prettier package

Install

yarn add --dev eslint-config-prettier eslint-plugin-prettier prettier

Configure

Add prettier to eslint configuration plugins section Add prettier last to eslint configuration extends section Add the prettier/prettier rule:

    "rules": {
        "prettier/prettier": [
            "error",
            {
                "endOfLine": "auto"
            }
        ]
    }
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"useJSXTextNode": true
},
"ecmaVersion": 2018,
"sourceType": "module",
"project": "./tsconfig.json"
},
"extends": [
"next/core-web-vitals",
"prettier"
],
"plugins": [
"prettier"
],
"rules": {
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment