-
Notifications
You must be signed in to change notification settings - Fork 16
Linting produces false positives with .erb files #44
Comments
If this linter doesn't properly extract the text, it probably shouldn't be run on any script file... |
Good point. I'll change the title and description. |
You can turn this check off in an .htmlhintrc file. |
Turning it off won't help me if I have a special character outside of the ERB code that should produce an error. |
Have you tried the linter-erb plugin? |
No, but I will :) Thanks for the tip. So, this linter is really only meant for files that only contain html right? |
I use it regularly with angular, and handlebars tags. Others work ok too, but tags that are legit for the template are invalid html, so I usually disable that rule for those projects. It's nice that you can put a .htmlhintrc file and just disable it for one directory. While you loose that rule, the others still work. If there is a better one available, you should definitely use it, and linter-htmhint should not interfere with it. so please let me know if the liter-erb plugin does the job and I'll remove the erb files from the list of files. I don't want to remove it if linter-htmlhint does a better job (but I doubt it is). Of course you may find that running both is desirable, after disabling the rules that cause false positives in linter-htmlhint. Let me know. |
Right, so I already had linter-erb enabled but I wasn't seeing any output out of it. Went over to the repo and it seems that it isn't working due to changes in linter: AtomLinter/linter-erb#11 |
Ok, well I think we should leave erb files in, at least until If you would, please open another ticket when you feel |
So, here's the thing. With this package active I get a ton of incorrect warnings in So, what should the expected behavior be in this case? Maybe disable the |
If It's possible to have both running, but you would want to place a |
I don't understand why I have to provide custom rules. Is it expected behavior that by default if I have both linters installed I get a lot of incorrect errors reported? Is the linting done based on the language scope of each code block or is it per file? |
It's per file. |
Right. I don't know much about how What needs to happen so that I can have both |
+1 I have both htmlhint and linter-erb, and htmlhint drives me crazy |
@amingilani I feel your pain. On semi-good news I just became the maintainer of |
@ricardograca wooohoooo! Okay, thank you! |
@ricardograca The problem isn't with If you want to see the reasoning on why it still lists those scopes you might want to read though #52. Personally I feel this package should only list itself as compatible with pure HTML as that is all the base linter actually understands, but @johnwebbcole disagrees, and as there is some utility in having it run on other scopes I haven't pressed the matter. Perhaps it's time to revisit this discussion, what do people think about only listing HTML by default, but allowing entering of a list of custom additional scopes? That way anyone can have this run on any scope they want, but they should know then that what they are doing isn't really supported and they may have to do some configuration to work with it (such as ignoring errors that don't mean anything in the "extra" scopes). |
I know that the problem isn't on I totally agree that this package should only lint html. It's the html linter after all, not the html/erb/handlebars/whatevever linter, so it's a bit unexpected that it also lints other file formats. Besides unexpected it also causes a lot of issues as has been proved by the number of people complaining about this package interfering with linting in other scopes. I also agree with the optional additional scopes to those that need that kind of support, but it should not be the default. |
The last time we were asked about When I had a limited set of scopes (the ones I used), I got request after request to add more, and |
@johnwebbcole I encourage you to do the inverse by explicitly defining If you add a line in the |
@johnwebbcole Personally I think that linter packages should just work without any workarounds needed, and you mentioned that even in your use case you have to provide a workaround for the "annoying false positives". I'm sure no one likes to be annoyed when trying to get work done, so that's why defaulting to html only with the option to provide additional scopes seems like a reasonable compromise. I can provide a PR to disable all scopes except html, but I have no idea how to add something to the settings page. Also, ideally it should be possible to call the html linter for the html portions of other language's templates, but I also have no idea how that's done. I think this would be a great step towards ensuring that no one would need to ask the html linter to include support for templating languages. Finally for statistics here are the issues requesting templating languages to be included: And here are the issues caused by supporting templating languages: #41, #42, #43, #44, #47, #51, #73, #82, #94 There are others mentioning the "unexpected end of input" error, but it's not clear if it's due to being used on a templating language or not. I think it's pretty clear that there would be a lot less issues if this package just linted html and nothing else. |
Re: calling the linter on "the HTML portions" You would need some sort of extractor for every extra language that you wanted to support in this manner, as that doesn't exist for most of them this isn't really a viable method unfortunately. |
Ok, but specifically in the case of ERB files. When using When you say that an extractor would be required for every language, does that mean the extractor would be required in the template language linters or in the html linter package? Isn't it possible for a package to pass a string (or buffer or whatever) to another package? It would be super easy to remove all template specific code and leave only the html part of a file from the |
This package would need to have the extractor, as it would be the one needing the HTML contents. If ERB provides a simple way to get the HTML that's great... but I'm not sure how you would run |
I see. So, the final question is: shouldn't the scopes change according to the part of the file being analyzed instead of having a single scope per file? If I was designing a linting API that's what I'd aim for. That way each specific linter would deal with the parts of files that it knows, and wouldn't have to pass anything to other linters. That is, the base linter package would handle all that. |
The scope does change based on where you are in a file, assuming you are dealing with a file that can change scopes. The issue is that those should be marked as embedded source. This was a major problem we had with the default Markdown language package in Atom actually, as it was marking all embedded code blocks with the full scope. So for example if you did something like this: var foo = 42; And had your cursor inside that block of embedded JavaScript the Some languages (I believe ERB is like this) simply claim the entire file is their language, even if they are a template language. An extractor takes those blocks of "other" code and brings them out into a manner that the linter understands, then when it's done linting translates things like lines and columns back to where they should be in the original file. That's an interesting idea about having |
I suspected it wouldn't be easy, but I think it's important to get there eventually. Documenting already used scope names also seems important and I've seen some discussion about that in other issues. Seems like that part is still a bit in its early stages. Well, I'll stop complaining for now, but will come back to it later when it starts bothering me :) |
When html-linter tries to lint
erb
files, it incorrectly complains about<%
and<%=
.It will also complain that the file should have a doctype, which obviously isn't needed in an
erb
view or partial.The text was updated successfully, but these errors were encountered: