eslint-plugin-prettier icon indicating copy to clipboard operation
eslint-plugin-prettier copied to clipboard

Issue when upgrading prettier to 3.3.3 - parenthesis added from prettier break eslint

Open rbpimenta opened this issue 4 months ago • 0 comments

I'm using the following command as a "pretest" on my build CI eslint . --fix && prettier --write ./src ./resource. After upgrading to prettier 3.3.3 I'm receiving the following message on my CI code.

Error:   22:9   error  Insert `(`  prettier/prettier
Error:   23:39  error  Insert `)`  prettier/prettier

It seems that the code is been transformed from this

this.foo = message.method
      ? anotherMethod(bar) ??
        value1
      : value2

to this (it's adding parenthesis on the code )

this.foo = message.method
      ? (anotherMethod(bar) ??
        value1)
      : value2

I believe that the problem is somehow related with the changes on the new prettier 3.3.3 version. More specific these two PRs

  • https://github.com/prettier/prettier/pull/16391
  • https://github.com/prettier/prettier/pull/16458

What version of eslint are you using? 8.57.0

What version of prettier are you using? 3.3.3

What version of eslint-plugin-prettier are you using? 5.2.1

Please paste any applicable config files that you're using (e.g. .prettierrc or .eslintrc files) .prettierrc.json

{
  "semi": false,
  "tabWidth": 2,
  "useTabs": false,
  "printWidth": 120,
  "singleQuote": true,
  "trailingComma": "none"
}

.eslintrc.json

{
  "env": {
    "commonjs": true,
    "es2021": true,
    "node": true,
    "jest/globals": true
  },
  "extends": [
    "standard",
    "plugin:import/errors",
    "plugin:import/warnings",
    "plugin:jest/recommended",
    "plugin:n/recommended",
    "plugin:prettier/recommended",
    "plugin:promise/recommended"
  ],
  "plugins": [
    "jest",
    "prettier"
  ],
  "parserOptions": {
    "ecmaVersion": 12
  },
  "rules": {
    "space-before-function-paren": 0
  },
  "ignorePatterns": [
    "resource/**"
  ]
}

What source code are you linting?

this.foo = message.method
      ? anotherMethod(bar) ??
        value1
      : value2

What did you expect to happen?

I'd expect the code to pass on CI.

What actually happened?

eslint error

Error:   22:9   error  Insert `(`  prettier/prettier
Error:   23:39  error  Insert `)`  prettier/prettier

rbpimenta avatar Oct 17 '24 14:10 rbpimenta