Skip to content

Allow eng-disable comments to be placed above lines of codeΒ #93

@mitchchn

Description

@mitchchn

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions