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

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

Open
nwalters512 opened this issue Jul 17, 2020 · 2 comments
Open

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

nwalters512 opened this issue Jul 17, 2020 · 2 comments

Comments

@nwalters512
Copy link

nwalters512 commented Jul 17, 2020

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
Copy link

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

ota-meshi pushed a commit to ota-meshi/eslint-plugin-eslint-comments that referenced this issue Sep 19, 2023
@MichaelDeBoey
Copy link

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

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

3 participants