Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mitchchn opened this issue May 3, 2021 · 0 comments
Open

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

mitchchn opened this issue May 3, 2021 · 0 comments

Comments

@mitchchn
Copy link

mitchchn commented May 3, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant