Skip to content
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

djLint should not attempt to lint HTML files in non-Django projects #736

Closed
gotofritz opened this issue May 14, 2024 · 9 comments
Closed

Comments

@gotofritz
Copy link

Only a few projects I work on are django, and there I install djlint (locally in the project's venv) and all is well. The problem is all the other projects.

DJLint insists on trying to lint those, and it gives me the annoying toaster message every time I save a file (I don't have it installed globally, or in some of the machine I share the settings with). VSCode correctly recognise the file as HTML (not django-html). It all boils down to this setting. I think the [html] one shouldn't be there. There is a reason why the [django-html] association exists, it's to keep the two separate. IMHO It's up to those devs who only ever work with Django to change the file association so that all *.html files are treated as django-html. But that should be an override, not the standard. Happy to submit a PR

  "[django-html]": {
    "djlint.enableLinting": true
  },
  "[html]": {
    "djlint.enableLinting": true
  },
@monosans
Copy link
Member

As a Django user, I agree with the proposed changes. But in this situation, you need to take into account that someone may use djLint for regular HTML or simply do not have an extension installed for the template language used. What do you think?

@gotofritz
Copy link
Author

I am pretty sure everyone uses prettier for that, it's the industry standard. Does anyone who isn't a Django dev even know DJlint exists? I only came across it when I was searching for something like that specifically, never heard of it before. Just my two cents!

@lucaspar
Copy link

Would this change disable djlint for plain html files entirely?

I also use prettier for HTML, but I think the user should be given the choice of which linter to use. If djlint handles plain HTML, it should be listed as an option for the language.

@gotofritz
Copy link
Author

gotofritz commented Jun 18, 2024

"Listed" - where?

There is no list you can look up. There is only one handler per file type. If djlint sets itself as the linter for html (instead of just django-html, which is what it should do) then you won't know there are others. Likewise if prettier is the one being installed last and taking over html. IMHO djlint should be a good citizen and just do what it's designed to do, django-html, and leave the rest alone.

Regardless, it seems pretty clear by now that the developer has no interest in this topic

@lucaspar
Copy link

lucaspar commented Jun 18, 2024

when there are multiple formatters available, VS Code enables this option

image

The autocompletion in settings.json is also smart to pick up the formatters compatible with the entry you're editing.

Multiple formatters for a language is not exactly a new thing or exclusive to HTML/Jinja.

@gotofritz
Copy link
Author

gotofritz commented Jun 19, 2024

I see. I would expect more people would have 'format on save' rather than go through the tedious step of format each individual document manually. And those (few?) people can add djlint manuallyb to that list, we are not talking about preventing them from doing so, but simply not having it as default.

@lucaspar
Copy link

lucaspar commented Jun 19, 2024

right, we don't have to [choose it manually] once it's configured in the settings.json: you can choose the default formatter by programming language there and the autocomplete will pick up their names.

https://stackoverflow.com/a/66647648/2848528

people can add djlint manuallyb to that list

I'm not sure this is possible if VS Code doesn't see djlint as a valid formatter for plain HTML. Only compatible formatters are listed there, and the proposed change seems to unlist plain HTML from the valid languages.

@monosans
Copy link
Member

djLint does not and has never set itself as the default formatter for any language, so it does not conflict with Prettier or anything else.

Linting is enabled by default because I believe the user doesn't have to do any additional customization to enable it. I would also like to point out that linting does not conflict with any other extensions.

As for the "djLint is not installed" error, we can easily fix it by adding some button like "Don't show again". What do you think?

@gotofritz
Copy link
Author

Dunno, to my mind a plugin for Django templates should focus on [django-html] and leave [html] alone, but what do I know. But a "Don't show again" could be useful, I guess

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants