Witam na mojej prywatnej stronie internetowej!
[If this is all Polish to you, click here: English]
Uwaga: z oczywistych powodów nie mogę zagwarantować swojej nieomylności, choć staram się o zgodność tego, co piszę, z Prawdą. Jest również oczywiste, że nie gwarantuję takiej zgodności w przypadku komentarzy. Umieszczenie linku do strony spoza niniejszego serwisu nie musi oznaczać, że podzielam poglądy autora tej strony, a jedynie, że uważam ją za wartościową z takich czy innych powodów.
Marcin ‘mbork’ Borkowski
When coding in JavaScript, I use Eslint like everybody else. (Let’s set the discussion about Eslint vs. Oxlint for another time.) One problem I have is that sometimes (rarely, but not never) I need to tell Eslint that I broke one of the rules intentionally and I don’t want it to nag me about it. The easiest way is to put a comment saying
// eslint-disable-next-line <name of the rule I broke>
directly above the offending line. Trouble is, I never remember the exact syntax of that line (is it eslint-disable-next-line? or disable-eslint-next-line, or maybe eslint-disable-line…?), not to mention the name of the rule. (Yes, it appears in the echo area. No, you can’t easily copy it from there. Well, you can say C-u C-x =, press RET on the [Show] button next to the flycheck-error property name. Or you can just head to the *Messages* buffer after seeing the rule name in the echo area and copy it from there. Either way, it’s not exactly convenient.)
I figured that having a function to add such a comment automatically would be pretty cool. Of course, I would have to dive in Flycheck internals. As usual in such cases, I decided to start with checking if such a function exists already. Also as usual, I was not disappointed! I have Tide installed, and it turns out that it defines a command tide-add-eslint-disable-next-line which does exactly what I need! One caveat is that the Eslint checker must be enabled in Flycheck for this to work.
That’s it for today, come next week for another post!
CategoryEnglish, CategoryBlog, CategoryEmacs, CategoryJavaScript