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
Enabling the fix flag for stdio #9076
Comments
Thanks for creating an issue. I'm 👍 for just removing the restriction on There is a slight potential for confusion if someone uses |
I'm not sure about this, because I don't know how we can easily display both the reported messages (remaining lint errors/warnings) and the fixed code, in an unambiguous way. I would be curious about having |
@platinumazure To clarify, proposal 2 only removes the restriction agains The
I'm not sure I like this idea because it seems like a surprising behavior switch. When no flags are used, or when (edit: added a response to the second paragraph) |
So to make sure I understand the proposal, would CLIEngine.outputFixes (or
an equivalent for stdin) be called at all?
I'm still not really seeing the utility of doing this since only certain
formatters would even provide useful output for this use case. My
preference would be for us to come up with a more well thought-out design
that doesn't depend on a third CLI option for its effectiveness.
…On Aug 5, 2017 10:49 PM, "Teddy Katz" ***@***.***> wrote:
I'm not sure about this, because I don't know how we can easily display
both the reported messages (remaining lint errors/warnings) and the fixed
code, in an unambiguous way.
@platinumazure <https://github.com/platinumazure> To clarify, proposal 2
*only* removes the restriction agains --fix --stdin, and makes no other
changes. Formatters that only display problems, such as stylish, would
continue to do so. On the other hand, formatters that can display both
problems and output, such as json, would be able to unambiguously do that
with the --stdin flag.
The output property is already passed to formatters when linting files
with --fix, but stylish ignores it.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9076 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AARWehKuTQqq0UPvojASr0Frhv7GcKQrks5sVTevgaJpZM4OulNy>
.
|
Right, it would not get called when the text comes from stdin. Admittedly, this would be a special case, which does seem undesirable.
The utility is for integrations that want to autofix text without writing it to the filesystem. I agree that only some formatters would be useful here -- my assumption is that integrations would use only the useful formatters for this use case. (Integrations that use the command-line interface typically use those formatters anyway, rather than the human-readable formatters.) |
Thanks @not-an-aardvark. I guess I'm worried about CLI end-user confusion if they try to use |
How about this proposal?
I like this proposal because it doesn't introduce any special cases, and seems like it obeys the principle of least astonishment. |
I'm not sure about I think the people most interested in this will be the plugin or the tool authors, so it should be sufficient to document the feature. Additionally, we could make a getter for |
I think you're misunderstanding the proposal somewhere; |
I'm addressing this - not everything is fixable, so if i wanted to get both the warnings/errors and the fixed output at the same time, I'd need to run ESLint twice. Or not? |
Could I use |
No -- to clarify, by "output" I mean the object that is usually passed to a formatter, which looks something like this: Result list[
{
"filePath": "/path/to/foo.js",
"messages": [
{
"ruleId": "no-undef",
"severity": 2,
"message": "'foo' is not defined.",
"line": 1,
"column": 1,
"nodeType": "Identifier",
"source": "foo;",
"endLine": 1,
"endColumn": 4
}
],
"errorCount": 1,
"warningCount": 0,
"fixableErrorCount": 0,
"fixableWarningCount": 0,
"output": "foo;\n"
}
] Note that this includes the autofix output in the
Yes, that's the idea. You wouldn't even need a custom formatter -- you could use the built-in |
I'll work on this during the weekend then. Unfortunately my time during the week is quite limited. |
Thanks! I should note that this proposal is still marked as "evaluating", so there is still a possibility that it will change again after more discussion (which would result in you having to reimplement it again.) If you want to be sure that you won't accidentally waste your time on an implementation that doesn't get used, you could also choose to wait until the proposal is marked as "accepted". |
I'll wait then! Please ping me when it gets changed, because there are no notifications for the labels. |
@platinumazure Any thoughts on the updated proposal in #9076 (comment)? If that proposal addresses your objections, then I'd like to add this to the TSC agenda for approval. Otherwise, we can discuss more to hopefully find the best solution. |
I'm okay with that proposal, yes. Thanks for following up. |
TSC Summary: This issue proposes adding a TSC Question: Should we accept this? |
This was approved in today's TSC meeting. cc @fatfisz |
Snap, I forgot about this - will do it tomorrow! |
The problem
I'm using SublimeLinter-contrib-eslint and I noticed that it operates on stdio. This is probably because the linter also works on non-yet-saved-files. I wanted to enable autofixing of the code, but it was not built-in and when manually passing the
--fix
flag I saw that ESLint just exits with an error message. I decided that enabling--fix
and--stdin
together was the right first step to autofixing with the linter plugin.The solution
Currently there are three proposed solutions:
--fix-dry-run
that can be used with--stdin
, but doesn't output fixes to the filesystem.I'd be happy to go with either of them, and frankly, the second one feels like a more convenient option to use.
(edited by @not-an-aardvark to add the third proposed solution)
The text was updated successfully, but these errors were encountered: