invalid-directive
Flags a rafiki: comment that rafiki can’t read, like a
rafiki: ignore with a typo in it.
Why
A directive with a mistake in it does nothing, so a finding it was meant to hide is still reported and the comment looks like it should work.
What it flags
- A word after
rafiki:that isn’t a known directive rafiki: fmtwithoutofforonafter it- A
rafiki: fmt offorrafiki: fmt onthat shares its line with code, or arafiki: fmt offwith no declaration or statement after it, which the formatter leaves as a plain comment - A
rafiki: fmt onwith norafiki: fmt offbefore it in the same block, or arafiki: fmt offwhen formatting is already off - A rule name that doesn’t exist
- A missing
[or], or an empty rule list - A
file-ignoreafter the first line of code unused-ignoreorinvalid-directivein a rule list, since these can’t be silenced with a comment
Example
// rafiki: ignore[bool-comparisons]
var ready = isReady == true;
bool-comparisons is flagged, since the rule is called bool-comparison. There’s
no fix, since rafiki can’t know what was meant.