Skip to content
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

Merged
merged 1 commit into from Oct 2, 2017
Merged

Conversation

fatfisz
Copy link
Contributor

@fatfisz fatfisz commented Aug 5, 2017

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

  • documentation

@jsf-clabot
Copy link

jsf-clabot commented Aug 5, 2017

CLA assistant check
All committers have signed the CLA.

@eslintbot
Copy link

Thanks for the pull request, @fatfisz! I took a look to make sure it's ready for merging and found some changes are needed:

  • The commit summary needs to begin with a tag (such as Fix: or Update:). Please check out our guide for how to properly format your commit summary and update it on this pull request.

Can you please update the pull request to address these?

(More information can be found in our pull request guide.)

@mention-bot
Copy link

@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.

@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

@platinumazure
Copy link
Member

Is this cross-platform (i.e., would this work on Windows)?

@fatfisz
Copy link
Contributor Author

fatfisz commented Aug 5, 2017

I'm working on Windows (it works), will check on Ubuntu.

@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

@fatfisz
Copy link
Contributor Author

fatfisz commented Aug 5, 2017

Actually fs.writeFileSync did not work as I expected on Ubuntu, but fs.writeSync works just fine on both Windows and Ubuntu - I've pushed the changes.

@kaicataldo kaicataldo added core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion tsc agenda This issue will be discussed by ESLint's TSC at the next meeting labels Aug 5, 2017
@not-an-aardvark
Copy link
Member

not-an-aardvark commented Aug 5, 2017

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):

  • What does it mean to write to file descriptor 3? How would this typically be used in practice (edit: e.g. on the command line)?
  • Is the output just a JSON version of the result object? If so, it seems like we don't actually need to send the output to a file descriptor -- we can just remove the restriction on using --fix with --stdin, and then an integration could use the JSON formatter and handle the output from stdout.

@fatfisz
Copy link
Contributor Author

fatfisz commented Aug 5, 2017

@not-an-aardvark I've created the issue (sorry for not doing this before the PR...).

@not-an-aardvark
Copy link
Member

Removing this from the TSC agenda because the corresponding issue is also on the TSC agenda and has more up-to-date information.

@not-an-aardvark not-an-aardvark removed the tsc agenda This issue will be discussed by ESLint's TSC at the next meeting label Aug 14, 2017
@not-an-aardvark not-an-aardvark added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Aug 21, 2017
Copy link
Member

@not-an-aardvark not-an-aardvark left a 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.

@fatfisz fatfisz changed the title Enable the fix flag for stdio Add the fix-dry-run flag Aug 22, 2017
@eslintbot
Copy link

LGTM

@fatfisz
Copy link
Contributor Author

fatfisz commented Aug 22, 2017

I've added the --fix-dry-run flag instead and updated the PR.

@not-an-aardvark
Copy link
Member

Hi again, just checking in to see if you've had a chance to work on this.

@fatfisz
Copy link
Contributor Author

fatfisz commented Sep 11, 2017

Hi, I came back not too long ago, will take a look soon.

@eslintbot
Copy link

LGTM

fatfisz added a commit to fatfisz/eslint that referenced this pull request Sep 27, 2017
@eslintbot
Copy link

LGTM

@fatfisz
Copy link
Contributor Author

fatfisz commented Sep 27, 2017

@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 ;)

fatfisz added a commit to fatfisz/eslint that referenced this pull request Sep 27, 2017
@eslintbot
Copy link

LGTM

Copy link
Member

@not-an-aardvark not-an-aardvark left a 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.
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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?

fatfisz added a commit to fatfisz/eslint that referenced this pull request Sep 29, 2017
@eslintbot
Copy link

LGTM

@fatfisz
Copy link
Contributor Author

fatfisz commented Sep 29, 2017

I fixed the docs based on your suggestions!

fatfisz added a commit to fatfisz/eslint that referenced this pull request Sep 29, 2017
@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

Copy link
Member

@not-an-aardvark not-an-aardvark left a 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!

@not-an-aardvark
Copy link
Member

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.

@fatfisz
Copy link
Contributor Author

fatfisz commented Sep 30, 2017

That's awesome, thanks for your time & help!

@not-an-aardvark not-an-aardvark merged commit 4567ab1 into eslint:master Oct 2, 2017
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Apr 1, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Apr 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants