You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Saving the file will convert the var to a const, meaning that eslint --fix was run.
Adding the pragma comment at the top and saving again will also move the string literal to a new line, meaning that Prettier was run.
Problem description:
The idea I had of this tool was to use Prettier (in my case on save) to also run eslint --fix, which it does correctly. However, I would have expected it respect the pragma comments also when running eslint --fix.
This makes sense also because if we set "editor.formatOnSave": false,, neither Prettier nor eslint --fix are run.
This is a big problem for large codebases with un-pretty code which could prefer to slowly review and prettify the code while still being able to instantly prettify on newer files.
Suggested solution:
Do not run eslint --fix if prettier did not run, or add an option for respecting the pragma not only with prettier but also with eslint --fix.
The text was updated successfully, but these errors were encountered:
TiredFalcon
changed the title
Prettier runs even if requirePragma is set to true in .prettierrc
Prettier runs ESLint --fix even if requirePragma is set to true in .prettierrc
Feb 14, 2019
Versions:
prettier-eslint
version: Included in the latest version of the prettier-vscode extensionnode
version: 8.15.0npm
(oryarn
) version: 6.4.1Have you followed the debugging tips?
No
Relevant code or config
.prettierrc
and.eslintrc
in the example repository.settings.json
What I did:
I opened a file containing old, non-pretty JavaScript code and hit
Cmd+S
to save it.What happened:
The saving ran
eslint --fix
, even though no pragma comment was at the top of the file.The pragma comment would look like this (source):
Reproduction repository:
https://github.com/LambdaFalcon/h-prettier-eslint-bug
The file
test.js
shows the problem. It containsSaving the file will convert the
var
to aconst
, meaning thateslint --fix
was run.Adding the pragma comment at the top and saving again will also move the string literal to a new line, meaning that Prettier was run.
Problem description:
The idea I had of this tool was to use Prettier (in my case on save) to also run
eslint --fix
, which it does correctly. However, I would have expected it respect the pragma comments also when runningeslint --fix
.This makes sense also because if we set
"editor.formatOnSave": false,
, neither Prettier noreslint --fix
are run.This is a big problem for large codebases with un-pretty code which could prefer to slowly review and prettify the code while still being able to instantly prettify on newer files.
Suggested solution:
Do not run
eslint --fix
if prettier did not run, or add an option for respecting the pragma not only with prettier but also witheslint --fix
.The text was updated successfully, but these errors were encountered: