-
Notifications
You must be signed in to change notification settings - Fork 141
Determine fix results based on exit code #777
Conversation
577b5d7
to
913d0e1
Compare
Hm, I just noticed that this change will cause It's nice to get the warning in the manual case, but I think saving a file should not show that message if the |
OK, the latest commit should help. We will no longer attempt to perform a |
} | ||
return 'Linter-ESLint: Fix attempt complete, but linting errors remain.' |
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.
"linting issues" maybe? The remaining messages aren't necessarily errors.
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.
Actually, to get an error code other than 0
, means there are errors. If there are only warnings, eslint will exit with a 0
.
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.
Ah, didn't know that. errors
works just fine then!
// Do not try to fix if linting should be disabled | ||
const fileDir = Path.dirname(filePath) | ||
const configPath = getConfigPath(fileDir) | ||
if (configPath === null && atom.config.get('linter-eslint.disableWhenNoEslintConfig')) return |
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 setting should be observed instead of retrieved every time.
Perhaps in the past ESLint threw an error if `--fix` did not fix all of the errors in a file. Or, maybe this logic was flawed from the start. Either way, this change just looks at the exit code (`0` if there are no linting errors left, `1` if there are), and returns an appropriate string. Both cases are really success messages, there were no errors. If there was an error for some reason, we need to print the `err.message` string, because `addWarning` expects a string, not an error object.
If `disableWhenNoEslintConfig` is disabling linting, we should also not be trying to perform an autofix.
a7e073d
to
d7ef6d4
Compare
OK, @Arcanemagus, I made the fix you asked for, and rebased on master. I think this is ready-to-go. |
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.
LGTM, merge at will @IanVS 😉
Fixes #511
Description
This adjusts the response of running
Linter eslint: fix
or fixing automatically on save, so that unexpected runtime errors are correctly printed in a notification.This PR also no longer treats an incomplete
fix
as requiring a warning. A success message is given whether the fix is total or partial, with only the wording being altered to reflect the result. As I mention in the commit message details, I believeeslint.execute
used to throw when autofix did not fix all of the errors in a file. It no longer does, so we need to rely on the exit code instead.This change is