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

Question: On Lint on Save and the breaking of Templater scripts #994

Closed
zanodor opened this issue Jan 13, 2024 · 5 comments
Closed

Question: On Lint on Save and the breaking of Templater scripts #994

zanodor opened this issue Jan 13, 2024 · 5 comments
Labels
question Further information is requested

Comments

@zanodor
Copy link

zanodor commented Jan 13, 2024

Hey there,

My question is about the purpose of ignored folders and lint on save.

Not for the first time -- probably about the 3rd or 4th time -- I inadvertently linted Templater files. Which means I had YAML created with date modified key and value and soft line breaks on each line. Neither are very beneficial, to say the least. It breaks one's template (I'm using Templater js to carry out small daily janitor jobs, so these are not really templates, but bits of code).

Last time around, I probably hit CNTRL + S or linted one of my templates I was editing and had the offending changes happening.

Then I realized that -- after having had to switch off 'lint file change' as you may remember the other thread -- I'd be better off switching off 'lint on save' as well.
As a workaround, I added the hotkey CNTRL + S for 'lint current file unless ignored'.
Goes without saying the template folder is among those on the list of ignored folders.

At this point, my question actually turns into a suggestion: would you consider adding support for:

  1. turning 'lint on save' to 'lint on save unless ignored' (or adding the new one as a second option one could tick);
  2. providing some other means of security for people using Templater in some way?

I'm guessing No 1. would be more feasible to achieve.

Thanks a lot

Regards,
Z.

@zanodor zanodor added the question Further information is requested label Jan 13, 2024
@pjkaufman
Copy link
Collaborator

I am not 100% sure what is happening here since I have used this plugin for years now and have not hit the issue where I have linted Templater files since I added them to my ignore path.

So I would like to better understand the problem since I believe that, except for manually telling a file to be linted, it should be checking that the file is a markdown file and that it is not ignored.

How are you currently able to lint your Templater files if they are in your ignored path? It may be a bug in the Linter unless you are using the rule/logic that is meant to bypass that.

@pjkaufman
Copy link
Collaborator

pjkaufman commented Jan 14, 2024

I did double check the logic and there is some logic in place to make sure that lint on file change does not run on ignored files. So if it is running on them, that would be a bug that needs fixing.
Edit: this comment is unrelated.

@pjkaufman
Copy link
Collaborator

Note: Lint on save is checking that the file is a markdown file and that it is ignored.

I am not sure how you are linting ignored folders (not sure if that is where your Templater scripts live), but if they do, a reproducible example would help greatly in getting to the bottom of this.

Thanks!

@zanodor
Copy link
Author

zanodor commented Jan 14, 2024

Turns out the command I was using with the key combo was actually a Commander macro (with the same name) that contained the single command 'lint the current file' -- probably I needed that on mobile where I cannot press key combinations...?

Indeed, when one lints on save, the ignored folders are respected.

Sorry about the trouble.

Cheers

@zanodor zanodor closed this as completed Jan 14, 2024
@pjkaufman
Copy link
Collaborator

No worries. The commander macro can use lint unless ignored and that should take care of it.

I am glad this is fixed for you!

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

No branches or pull requests

2 participants