Allow `eng-disable` comments to be placed above lines of code
mitchchn opened this issue · comments
Is your feature request related to a problem? Please describe.
eng-disable
comments must be placed on the same line as the relevant code, e.g.:
contents.on("will-navigate", (ev) => { /* eng-disable LIMIT_NAVIGATION_GLOBAL_CHECK */
ev.preventDefault();
});
This limitation poses a problem for Prettier and similar tools which autoformat code and comments based on line length and other criteria. For instance, Prettier will automatically re-format the above code like this:
contents.on("will-navigate", (ev) => {
/* eng-disable LIMIT_NAVIGATION_GLOBAL_CHECK */
ev.preventDefault();
});
Describe the solution you'd like
The ability to put the comment above the relevant line:
// eng-disable LIMIT_NAVIGATION_GLOBAL_CHECK
contents.on("will-navigate", (ev) => {
ev.preventDefault();
});
This approach is compatible with Prettier and follows a convention used by other tools including TypeScript (// ts-ignore
) and ESLint. It is resilient to future formatting changes. In my opinion, it is also more readable. :)
Describe alternatives you've considered
Sometimes code can be re-written to make Prettier happy:
contents.on("will-navigate", handlerCallback); /* eng-disable LIMIT_NAVIGATION_GLOBAL_CHECK */
But this is not always desirable or guaranteed to work due to line length restrictions.