-
Notifications
You must be signed in to change notification settings - Fork 178
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
allow linting of new yet unsaved files #1235
Comments
Just a thought, if this change would break many linters why not allow the linter to pass this information (whether it supports on-the-fly or not) to the base linter. |
@gliviu That's already how the linter providers work 😉. There is a All of the linters that I know of currently either use I'd be fine with this being a required situation to be able to handle in v2, as technically any v1 linter should already be able to handle this, it's just none were written well enough to do so that I know of 😛. |
As for actually implementing this I see a few options for linters that need a path to operate (for things like determining configurations):
For linters that don't need a path to operate (ie. they have no configuration) this isn't really an issue. I'd personally probably go with the second choice, since in the rare case that there are more than one projects open in the same window, I'd imagine they are related and would probably have the same configuration anyway. If not, then the configuration will be wrong and there might be some incorrect messages reported, at least until the file is saved. The technically correct result would be to just return What are people's thoughts on that? |
Some of the current on-the-fly linters already don't care about the
I can see A linter could also decide to return one message mentioning that the linter could not be run successful and that the file needs to be saved before. |
And that brings up an excellent problem with this... the v2 Message type currently requires a file in the location, this can never be available in this situation 😕. |
@Arcanemagus that is actually a very good point. If we allow this, we'll have to make providers associate |
If someone needs a few reasons on why |
Ouch, so we would have to have an active |
How about generating an "unsaved-file-path" for unsaved files, which get passed to the linter-provider? when a message file path matches the "unsaved-file-path" associate the message with said Buffer. So all this stuff discussed here would actually be done mostly in the Linter side and not in the providers, old providers would ignore this information so it wouldn't be a breaking change, everything else stays the same |
Previously we were simply exiting early during the error handling process if there was no filepath because the linter package requires a filepath in order to work. Now, we detect this early and instead send the error message to a popup so that the user still gets some feedback. See: steelbrain/linter#1235 Fixes #235
I'm late to the party, but I'd like to toss out the one case where I'd find this hugely useful. I often copy/paste JSON network responses into a new Atom file to format them for readability. I'll occasionally miss a leading/trailing character, or the JSON will be malformed to start with for some reason. If the linter could be run on this throw-away context to help me make the JSON valid so the pretty formatter can operate on it. Other similar quick linting on copy/pasted chunks of text without having to create temp files could be very useful for vanilla ES5, XML, etc. |
Created as a follow up of AtomLinter/linter-xmllint#68.
Currently when a user creates a new file (but doesn't save it yet) and selects a specific syntax for the editor no linter is being triggered. Some linters might not be able to work with an editor which doesn't have a path yet e.g. because they don't support on-the-fly linting or require relative resources. But some linters can perform their task in that case and they should be triggered.
This will require linters which can't handle this case to check the editors path and abort linting when the editor doesn't have a path yet.
The text was updated successfully, but these errors were encountered: