| In short: it's more comfortable and more versatile. 1. Sometimes there's already a comment on the preceding line commenting the logic, and the new comment explaining ESLint would have to go awkwardly in-between. 2. Sometimes it's just complicated to word the comment if it can't be on the same line. 3. Sometimes eslint-disable-line is in a place where it would be ugly to have a comment above. Here are two examples from my current project, both from cases where the disable is right after a closing curly brace: } as any // eslint-disable-line @typescript-eslint/no-explicit-any
}, [map]); // eslint-disable-line react-hooks/exhaustive-deps
Other cases can be found in the issues:Feature request #1: https://github.com/eslint/eslint/issues/11298 Feature request #2: https://github.com/eslint/eslint/issues/11806 RFC: https://github.com/eslint/rfcs/tree/master/designs/2019-desc... Next up: an ESLint rule that makes the comment obligatory for disable directives. |