eslint: `eslint-` comments cause `lines-around-comment` rule to error

  1. The version of ESLint you are using

    1.8.0

  2. What you did (the source code and ESLint configuration)

    /* eslint-disable no-underscore-dangle */
    this._values = values;
    this._values2 = true;
    /* eslint-enable no-underscore-dangle */
    

    with the following configuration:

    "lines-around-comment": [2, {
      "allowArrayStart": true,
      "allowBlockStart": true,
      "allowObjectStart": true,
      "beforeBlockComment": true,
      "beforeLineComment": true
    }],
    
  3. The actual ESLint output complete with numbers

    error Expected line before comment lines-around-comment

  4. What you expected to happen instead

    No error. I don’t think lines-around-comment should be enforced for eslint-enable/eslint-disable type comments. This follows with the fact that no-inline-comments ignores eslint-disable-line comments even when it’s enabled.

<bountysource-plugin>

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 2
  • Comments: 37 (33 by maintainers)

Commits related to this issue

Most upvoted comments

I’m working on this

Per TSC meeting, we decided that globally excluding comments has too many problems and we shouldn’t proceed down that path. We do think it’s useful to be able to exclude configuration comments from lines-around-comments, and have decided on adding an ignorePattern option to the rule that behaves the same as in https://github.com/eslint/eslint/issues/6077.

I feel like we just keep going round and round on this, so maybe the best solution is just not to make any changes. What we had now may be a bit weird, but it seems like any potential change to that behavior has some other weird side effect or implication.

I think ignorePattern should be made into helper method, so it can be reused across multiple rules, if necessary.