I’m trying to use prettier
to fix Javascript/HTML code formatting. Unfortunately the final Javascript/HTML is generated from a Cheetah template, so there are many lines that start with #
characters. Those are throwing errors that prevent Prettier from fixing the rest of the code. Is there a quick way to fix/lint code while ignoring those lines, or do I have to comment every one of those lines, fix the file, then uncomment them again?
Asked
Active
Viewed 53 times
3

user2597451
- 1,903
- 2
- 12
- 10
-
Which cheetah version? Cheetah 3, a fork or the original [repo](https://github.com/cheetahtemplate/cheetah)? Links pls – Pranav Kasetti Feb 16 '21 at 13:52
-
I don't think you can use a linter that doesn't understand Cheetah syntax. Is you JavaScript code static or generated with Cheetah? – phd Feb 16 '21 at 14:05
-
Using Cheetah 3.2.5. This is a project that’s part of weewx, the personal weather software. Javascript is mostly static but various sections are added or removed based on conditionals written in Cheetah code. `prettier` seems to be able to handle the $tags okay, but it’s the lines that start with `#` that are causing the problem. – user2597451 Feb 16 '21 at 14:27
-
My advice is twofold: either run the linter before Cheetah and outside template or run the linter after Cheetah on the generated file. – phd Feb 16 '21 at 15:26
-
1The issue is that if I run the linter on the generated file, the changes are lost the next time the file is regenerated from the template. Running it before Cheetah fails because the linter cannot interpret the Cheetah commands. Is there any way to just set `prettier` to ignore lines that start with `#`? That would solve all the problems. – user2597451 Feb 16 '21 at 16:24