mysticatea / eslint-plugin-eslint-comments

Additional ESLint rules for directive comments of ESLint.
https://mysticatea.github.io/eslint-plugin-eslint-comments/
MIT License
354 stars 44 forks source link

Cannot disable eslint-comments/no-unused-disable with comment #50

Open nwalters512 opened 3 years ago

nwalters512 commented 3 years ago

Thanks for the awesome plugin! We're running into a bit of a tricky issue in our repo. We have some files with certain lint rules that are expected to sometimes fail and sometimes not. Specifically, we have files in the root of our repo that re-export transpiled files from dist:

module.exports = require('./dist/transpiled-file');

Depending on if the build process has been run or not, ./dist/transpiled-file may or may not exist, and we don't want the non-existence of it at that particular moment to be an error in the import/no-unresolved rule. Before adopting this plugin, we had the following to ensure import/no-unresolved wouldn't error:

// eslint-disable-next-line import/no-unresolved
module.exports = require('./dist/transpiled-file');

However, with this plugin, that eslint-disable-next-line directive is itself reported as failing if the build process was run already (and thus ./dist/transpiled-file exists). I tried to disabled the eslint-comments/no-unused-disable rule itself as follows:

/* eslint-disable eslint-comments/no-unused-disable */
// eslint-disable-next-line import/no-unresolved
module.exports = require('./dist/transpiled-file');

However, disabling that rule doesn't disable it for either the line itself, or for the following line that it should actually apply to:

file.js
  1:19  error  'eslint-comments/no-unused-disable' rule is disabled but never reported  eslint-comments/no-unused-disable
  2:29  error  'import/no-unresolved' rule is disabled but never reported               eslint-comments/no-unused-disable

The first error is incorrect, because the rule is reported on the next line, and the second error is also incorrect, because the first line should be disabling that rule for the file.

I understand this is a bit of a weird case, but for this specific file I want to be able to opt out of both rules entirely in this file because I know what I'm doing, and I don't even have the ability to do that at the moment.

runspired commented 2 years ago

70 and #69 are roughly duplicates of this issue but broken out into the two steps I feel need to be taken here.

MichaelDeBoey commented 8 months ago

Hi @nwalters512!

Since this repo is unmaintained, you might want to re-open this issue in the @eslint-community fork https://github.com/eslint-community/eslint-plugin-eslint-comments

For more info about why we created this organization, you can read https://eslint.org/blog/2023/03/announcing-eslint-community-org