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 --fix-dry-run option #665

Closed
wants to merge 6 commits into from

Conversation

jopemachine
Copy link

@jopemachine jopemachine commented May 14, 2022

Fixes #663.

Eslint doesn't expose fixDryRun option in programmatic API.
fixDryRun is internally translated to fix option and don't call ESLint.outputFixes.
(Ref: eslint/eslint#15877)

So I think xo could handle this option similarly.
fixDryRun is translated to fix option before passing to ESLint constructor, and xo.outputFixes would not be called since
the fix option is false.

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

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?"

Copy link
Author

@jopemachine jopemachine May 30, 2022

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.

Copy link

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"?

Suggested change
--fix-dry-run Automatically fix problems without saving the changes to the file system
--fix-dry-run Preview fixed file contents

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support --fix-dry-run flag
3 participants