1

The Story:

We are using ESLint with a set of different plugins. Long ago, in a specific JS-file (page object for Protractor) one of the rules was disabled via a comment at the top of the script:

/* eslint-disable protractor/no-by-xpath */

because there was an xpath() method used that violated the no-by-xpath and at that time we have not found a way to workaround it and we simply disabled the check.

The Problem:

Nowadays, the page object source code changed and there is no xpath() method used anymore. But, the rule is left disabled since the comment disabling it is still there.

The Question:

Our goal is to find the places in the source code where rules are disabled, but not violated. Does ESLint provide anything to report that? How would you approach the problem?

Would appreciate any insights and hints.

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • Honest question: Why not just search the code ? Because you have many `eslint-disable` ? – Denys Séguret Apr 27 '16 at 16:19
  • @DenysSéguret sorry, I meant to ask about a generic approach where we don't know what rule we are searching for. Basically, find all rules that are disabled, but actually not violated. The "no-by-xpath" is just an example. Thanks. – alecxe Apr 27 '16 at 16:21
  • @DenysSéguret hope the motivation is clear. We don't particularly like disabling the rules in specific places, but it happens from time to time. The goal is to keep the rules disabled only if it's really necessary, makes sense and actually does the job. Leaving the comments that disable rules in the source code might lead us to overlooking code violations because of accidentally left "obsolete" comments. Sorry, I am terrible at explaining things :) – alecxe Apr 27 '16 at 16:26
  • 1
    There's a [closed issue](https://github.com/eslint/eslint/issues/4971) asking for this, but it wasn't implemented. – btmills Apr 27 '16 at 19:47

1 Answers1

1

No, ESLint doesn't provide anything for this. This feature has been requested a few times, but was deemed unfit for ESLint core. Suggested way of doing something like that would be to create another tool that uses ESLint's Node API, and does two runs on all of the files, once with --no-inline-config flag on, and once with that flag off, then compare results and if files with inline eslint configs don't have any differences, then comments can be removed.

Ilya Volodin
  • 10,929
  • 2
  • 45
  • 48
  • Thanks so much, Ilya, the advice makes total sense - will try that out. A bit of the off-topic: please take a look at this question whenever you have time: http://stackoverflow.com/questions/36237874/making-all-plugin-specific-rules-strict. – alecxe Apr 29 '16 at 02:55