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 the fix-dry-run flag #9073
Add the fix-dry-run flag #9073
Conversation
Thanks for the pull request, @fatfisz! I took a look to make sure it's ready for merging and found some changes are needed:
Can you please update the pull request to address these? (More information can be found in our pull request guide.) |
@fatfisz, thanks for your PR! By analyzing the history of the files in this pull request, we identified @nzakas, @mysticatea and @gyandeeps to be potential reviewers. |
d55baba
to
6a44794
Compare
LGTM |
6a44794
to
e79df3a
Compare
LGTM |
Is this cross-platform (i.e., would this work on Windows)? |
I'm working on Windows (it works), will check on Ubuntu. |
e79df3a
to
28745bc
Compare
LGTM |
28745bc
to
7cd53ae
Compare
LGTM |
Actually |
Thanks for the PR. May you please create an issue for this change? From our pull request guidelines, all pull requests that make changes to core require an issue. The idea is that having an issue makes it easier to understand what problem the proposal is trying to solve, and the team can make sure the proposal is the best solution to the problem. Also, I have a few questions about this approach (we can discuss it further on the issue):
|
@not-an-aardvark I've created the issue (sorry for not doing this before the PR...). |
Removing this from the TSC agenda because the corresponding issue is also on the TSC agenda and has more up-to-date information. |
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 marked this PR as accepted because the corresponding issue was approved by the TSC. However, the proposal has changed since it was implemented in this PR (there is now a new --fix-dry-run
flag), so this PR should also be updated to match that proposal.
7cd53ae
to
24ba1c6
Compare
LGTM |
I've added the |
Hi again, just checking in to see if you've had a chance to work on this. |
Hi, I came back not too long ago, will take a look soon. |
24ba1c6
to
ba90156
Compare
LGTM |
ba90156
to
3d74b95
Compare
LGTM |
@not-an-aardvark Sorry for the long wait, had to get myself together after the vacation + burn out. I've fixed everything, squashed, and force-pushed the commit. If you have any other change requests then I'll work on them much faster now ;) |
3d74b95
to
a27ef31
Compare
LGTM |
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 looks good to me aside from a broken link in the documentation, and a few small wording nitpicks.
|
||
This option has the same effect as `--fix` with one difference: the fixes are not being saved to the file system. This makes fixing the code from stdin possible. | ||
|
||
Because the default formatter does not output the fixed code, you'll have to use another one (e.g. `json`) to get the fixes. |
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 think it would be useful to have an example here, e.g.
getSomeText | eslint --stdin --fix-dry-run --format=json
|
||
#### `--fix-dry-run` | ||
|
||
This option has the same effect as `--fix` with one difference: the fixes are not being saved to the file system. This makes fixing the code from stdin possible. |
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.
Nitpick: I think the word "being" should be removed from the first sentence ("the fixes are not saved to the file system.")
|
||
#### `--fix-dry-run` | ||
|
||
This option has the same effect as `--fix` with one difference: the fixes are not being saved to the file system. This makes fixing the code from stdin possible. |
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.
Nitpick: I would modify the second sentence slightly:
This makes it possible to fix code from `stdin` (when used with the `--stdin` flag).
|
||
Because the default formatter does not output the fixed code, you'll have to use another one (e.g. `json`) to get the fixes. | ||
|
||
This flag was added with editor plugins in mind - in some cases they can only use stdio for linting. Without this option enabling autofixing in such tools is close to impossible. |
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 think this paragraph could be rephrased a bit. The main goal of the paragraph is to provide an example use case for the flag, so it doesn't seem useful to describe what editor plugins would be like if this flag didn't exist.
For example:
This flag can be useful for integrations (e.g. editor plugins) which need to autofix text from the command line without saving it to the filesystem.
@@ -361,6 +362,16 @@ This option instructs ESLint to try to fix as many issues as possible. The fixes | |||
1. This option throws an error when code is piped to ESLint. | |||
1. This option has no effect on code that uses processors. | |||
|
|||
If you want to fix code from stdin or otherwise want to get the fixes without actually writing them to the file, use the [`--fix-dry-run`](--fix-dry-run) option. |
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 think this link is broken -- should it go to #--fix-dry-run
instead of --fix-dry-run
?
a27ef31
to
7a68566
Compare
LGTM |
I fixed the docs based on your suggestions! |
7a68566
to
48313e9
Compare
LGTM |
48313e9
to
731a495
Compare
LGTM |
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.
Looks good to me. Thanks for contributing!
We just did a release on Friday, so we're waiting to merge PRs until we determine whether a patch release will be necessary on Monday (see the release issue for updates). So this will probably get merged sometime around Monday, assuming no one else requests changes on it. |
That's awesome, thanks for your time & help! |
What is the purpose of this pull request? (put an "X" next to item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[X] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
I've added the new flag, as discussed in #9076.
Is there anything you'd like reviewers to focus on?
Nothing in particular, the changes are rather small.
To do