nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
22.63k stars 2.26k forks source link

conflict with semicolons between prettier and typescript/javascript eslint confg #22599

Open arrocke opened 3 months ago

arrocke commented 3 months ago

Current Behavior

Using plugin:@nx/javascript or plugin:@nx/typescript in my eslint configuration along with prettier configured to remove semicolons results an @typescript-eslint/no-extra-semi error on the following code

function test() {
  ;[1,2].forEach(console.log)
}

Expected Behavior

This rule is disabled by default when extending the prettier eslint config because prettier inserts semicolons in places where this rule errors if they are present. In this case, prettier is being overprotective in inserting the semicolon, but we can't change prettier behavior.

GitHub Repo

No response

Steps to Reproduce

  1. Set up a project with the default eslint config for javascript or typescript.
  2. Configure prettier to remove semicolons.
  3. Add the following code. Prettier will always insert a semicolon before this line
    function test() {
    ;[1,2].forEach(console.log)
    }
  4. Try to lint the project

Nx Report

Node   : 18.18.2
OS     : darwin-x64
npm    : 9.8.1

nx (global)        : 17.1.2
nx                 : 18.2.1
@nx/js             : 18.2.1
@nx/jest           : 18.2.1
@nx/linter         : 18.2.1
@nx/eslint         : 18.2.1
@nx/workspace      : 18.2.1
@nx/cypress        : 18.2.1
@nx/devkit         : 18.2.1
@nx/eslint-plugin  : 18.2.1
@nx/node           : 18.2.1
@nx/playwright     : 18.2.1
@nx/rollup         : 18.2.1
@nx/storybook      : 18.2.1
@nrwl/tao          : 18.2.1
@nx/vite           : 18.2.1
@nx/vue            : 18.2.1
@nx/web            : 18.2.1
@nx/webpack        : 18.2.1
typescript         : 5.0.4

Failure Logs

No response

Package Manager Version

No response

Operating System

Additional Information

I think this line in the typescript config (and the corresponding line in the javascript config) should be conditionally set based on isPrettierAvailable. If isPrettierAvailable is true, the the @typescript-eslint/no-extra-semi rule should be turned off.

I'm happy to open a PR to fix this. For now, we can override this ourselves in our config

veniodev commented 1 month ago

Having the same issue after the new version upgrade:

Node   : 20.14.0
OS     : win32-x64
npm    : 10.7.0

nx (global)        : 19.1.1
nx                 : 19.1.1
@nx/js             : 19.1.1
@nx/jest           : 19.1.1
@nx/linter         : 19.1.1
@nx/eslint         : 19.1.1
@nx/workspace      : 19.1.1
@nx/angular        : 19.1.1
@nx/cypress        : 19.1.1
@nx/devkit         : 19.1.1
@nx/eslint-plugin  : 19.1.1
@nrwl/tao          : 19.1.1
@nx/web            : 19.1.1
@nx/webpack        : 19.1.1
nx-cloud           : 19.0.0
typescript         : 5.4.5
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
---------------------------------------
Community plugins:
@ngrx/component-store                : 17.0.1
@ngrx/effects                        : 17.0.1
@ngrx/entity                         : 17.0.1
@ngrx/router-store                   : 17.0.1
@ngrx/schematics                     : 17.0.1
@ngrx/store                          : 17.0.1
@ngrx/store-devtools                 : 17.0.1

@arrocke until this fix, what would be the workaround?

arrocke commented 1 month ago

We manually set this rule in our eslint config:

"@typescript-eslint/no-extra-semi": "off"