nx
nx copied to clipboard
conflict with semicolons between prettier and typescript/javascript eslint confg
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
- Set up a project with the default eslint config for javascript or typescript.
- Configure prettier to remove semicolons.
- Add the following code. Prettier will always insert a semicolon before this line
function test() {
;[1,2].forEach(console.log)
}
- 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
- [X] macOS
- [ ] Linux
- [ ] Windows
- [ ] Other (Please specify)
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