-
Notifications
You must be signed in to change notification settings - Fork 141
Conversation
Should possibility of remote file checking be on our radar? |
For simple linters that just depend on the file contents it's certainly a possibility, but |
8854efe
to
df2841e
Compare
df2841e
to
38d13cb
Compare
I think treating remote files as a single file with no project context would be a reasonable trade-off. If we get an .eslintrc global fallback working, it seems quite reasonable to use that fallback on new files that have never been saved. We could then simply treat remote files as new/never-saved.. Worth thinking about at least I think. |
The most that could be done is ESLint's syntax check, and even then I'm not sure if reporting fixes back would even work as I don't know if the messages can be associated back to the file in any meaningful way.
Linter shouldn't even be triggering us on unsaved files in the first place 😉. |
Add several sanity checks before moving on to attempting to lint the file: * Check that the `TextEditor` is valid * Check that the path for the file is not empty * Check that the path isn't a remote path If a remote path is found, show a message to the user that linting isn't possible. Fixes #594.
38d13cb
to
fa3079d
Compare
A basic syntax check is still a very useful feature of having a linter handy. If I'm editing a remote or unsaved file and I have choice between linter only does basic syntax check or linter ignores the file, I would definitely take the syntax check. As for whether we can report the findings, that's I don't know about, but if there is a reasonable way it would be a good feature.
Yes. This statement was based on the premise of first having useful treatment for unsaved files, which we currently do not. I just think it's worth having this potential use-case in the back of our minds in case someone stumbles onto a good way to do it or wakes up from a dream about linting with the perfect solution. Hahaha |
There's a slim possibility a remote file would work, but as there is no path at all for an unsaved file there is no way to report messages to it (This is why
It's been over a year with no better solutions presented in that issue, so I went with the safest one 😉. |
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.
Personally, I think disabling for remote files is fine. If we try to support them, I think we're in for a bad time for the reasons @Arcanemagus has mentioned. It also doesn't sound like there's anyone clamoring for us to support that use case, so I think our time is better spent elsewhere.
I do waffle a bit about whether this should be an error or a warning. It's not like there's definitely anything wrong with the file, we just don't know, so an error seems a bit… harsh. What do you think about making a helpers.handleWarning
?
src/main.js
Outdated
if (filePath.includes('://')) { | ||
// If the path is a URL (Nuclide remote file) return a message | ||
// telling the user we are unable to work on remote files. | ||
const message = 'Remote file open, impossible to run ESLint.' |
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.
Perhaps a slightly-more-accurate message might be something like:
"Remote file open, linter-eslint is therefore disabled for this file."
Since it sounds like the Facebook folks have may their own eslint integration for remote files.
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.
Huh, it would have to be some sort of primitive LSP to work at all. They did start Nuclide before Microsoft published the LSP protocol.
@@ -188,11 +188,26 @@ module.exports = { | |||
scope: 'file', | |||
lintsOnChange: true, | |||
lint: async (textEditor) => { | |||
const text = textEditor.getText() | |||
if (text.length === 0) { | |||
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.
Question
Did you mean to remove this check?
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.
Hmmm, nope. I meant to move it down below the path checks along with the getText
call. 🐛
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.
Oh, actually, yes I did mean to remove it. With it in there we are saying that an empty file is completely valid, but we have no idea what a user's configuration is, or what plugins they have or rules they have enabled. We have no way of knowing whether an empty file is considered "valid" under their configuration so we should remove this optimization and do the full ESLint run even on an empty file.
Add a function to generate generic messages to send to the user, modify `handleError` to use this function and change the message dispalyed for remote files to a warning.
@IanVS fixed it up a bit 😉. |
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 pushed up a small commit to expand the jsdoc for generateUserMessage, but this all looks great.
Just for clarity, there's definitely no way we can lint projects inside atom in remote projects via Nuclide + Watchman? |
All that we have for files opened like that is the raw text, since ESLint depends on external configuration files which we have no way to access with these remote files there really isn't anything that could be done other than possibly a basic syntax check. Just because you can see the text in Atom doesn't mean the hacked together way that Nuclide has done that works for anything other than Nuclide. |
Even if there were some ssh tunnel to the remote project dir? |
You could use |
I guess running some kind of eslint server to report back linting results to atom from the remote project would be inadvisable as well? Linting on remote projects is a real pain, but I understand the limitation |
An ESLint Language Server is certainly possible, but none exists currently that I know of. From what I understand there is nothing that prevents a language server from running on a remote host, I don't think any of the current adapters into Atom work like that though. |
Ah, I see. Making an eslint-js language client seems like the only way something like this would integrate with atom super nicely. https://github.com/atom/atom-languageclient Thanks for the clarification |
Add several sanity checks before moving on to attempting to lint the file:
TextEditor
is validIf a remote path is found, show a message to the user that linting isn't possible.
Blocked on #1015 as it uses the Error handling functionality introduced in that branch. Just putting this up here so it can get reviewed.
Fixes #594.