-
-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --fix-dry-run
option
#665
Conversation
@@ -13,6 +13,7 @@ const cli = meow(` | |||
|
|||
Options | |||
--fix Automagically fix issues | |||
--fix-dry-run Automatically fix problems without saving the changes to the file system |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like it's unclear to the user how this would even work. The user will ask themselves: "If it does not save to the file system, what's the point of it?"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--fix-dry-run Automatically fix problems without saving the changes to the file system.
Because the default formatter does not output the fixed code, you'll have to use another one (e.g. json)
This flag can be useful for integrations which need to autofix text from command line without saving it to the filesystem.
Note that `fix-dry-run` is mutually exclusive with the `fix` option.
How about the above one?
I'm worried about only this option's description looks too verbose because the other options' descriptions are all single lines.
These descriptions are copy-pasted from https://eslint.org/docs/user-guide/command-line-interface#--fix-dry-run without the last sentense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps "Preview fixed file contents" or "Print fixed file contents"?
--fix-dry-run Automatically fix problems without saving the changes to the file system | |
--fix-dry-run Preview fixed file contents |
lib/options-manager.js
Outdated
@@ -309,6 +309,13 @@ const buildESLintConfig = options => config => { | |||
}; | |||
} | |||
|
|||
// ESLint does not expose a `fixDryRun` option in the programmatic API. | |||
// Instead of using `fixDryRun` itself, the option is internally translated to `fix` option in ESLint's CLI module. | |||
// https://github.com/eslint/eslint/blob/901ce0f1e32ea1e9e10ce4d8b37c0d750007a3c5/lib/cli.js#L96 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not make it clear how it then manages to be a "dry-run". The important part is missing.
Fixes #663.
Eslint doesn't expose
fixDryRun
option in programmatic API.fixDryRun
is internally translated tofix
option and don't callESLint.outputFixes
.(Ref: eslint/eslint#15877)
So I think
xo
could handle this option similarly.fixDryRun
is translated tofix
option before passing to ESLint constructor, andxo.outputFixes
would not be called sincethe
fix
option is false.