I have a Next.js project that is configured to use Prettier & ESLint. I want to enable the Prettier rule "trailingComma"
by setting its value to "all"
, such that the .prettierrc
file contains the following:
// ".prettierrc"
{
"trailingComma": "all"
}
I am using an .eslintrc.json
file to configure ESLint, and I have it configured to apply a couple of plug-ins, and to extend a couple of the plug-in's rule-sets.
This is an image of my file:
{
"next",
"next/core-web-vitals",
"prettier",
"eslint:recommended",
"plugin:jsx-a11y/recommended",
"plugin:prettier/recommended",
"plugin:typescript-eslint/recommended",
}
The following ESLint rule is the rule ESLint uses to configure commas:
"comma-dangle": "off",
This rule is shown to affect the trailingComma rule, as it is mentioned in the error message:
"prettier/prettier": ["error", {}, { "usePrettierrc": true }],
Prettier seems to execute when I save, and the commas are added to the end of the list, but then I get the following error message (shown in the image).
I tried adding the "endOfLine" option both to .prettierrc
and .eslintrc.json
rule "prettier/prettier"
, someone said that it would fix the issue, but it didn't fix it.