-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
no-unused-disable
autofixing does not properly work
#21
Comments
Thank you for the report. Looks like intentional behavior. This means, in the following case, because /* eslint max-nested-callbacks: [error, {max: 1}] */
'use strict'
var values = [1, 2]
/* eslint-disable max-nested-callbacks */
values.map(function(value) {
return values.map(function(otherValue) {
return value + otherValue
})
})
/* eslint-enable max-nested-callbacks */ However, in the following case, because /* eslint max-nested-callbacks: [error, {max: 2}] */
'use strict'
var values = [1, 2]
/* eslint-disable max-nested-callbacks */
values.map(function(value) {
return values.map(function(otherValue) {
return value + otherValue
})
})
/* eslint-enable max-nested-callbacks */ |
Hi @mysticatea, One problem is that the related Another problem is that |
I managed to reproduce it (it took me a while :) ). 'use strict'
// eslint-disable-next-line max-params
module.exports = function(context, type, promise, secondPromiseValue) {
return true
} Fixing produces: 'use strict'
module.exports = function(context, type, promise, secondPromiseValue) {
return true
} My plugins: [eslint-comments]
rules:
eslint-comments/no-unused-disable: 2
max-params: 2 What's odd is that I can only reproduce this when fixing through const { CLIEngine } = require('eslint')
const eslintConfig = {
rules: { 'eslint-comments/no-unused-disable': 2, 'max-params': [ 'off' ] },
plugins: [ 'eslint-comments' ],
fix: true,
useEslintrc: false,
}
const engine = new CLIEngine(eslintConfig)
const text = `'use strict'
// eslint-disable-next-line max-params
module.exports = function(context, type, promise, secondPromiseValue) {
return true
}`
const report = engine.executeOnText(text)
console.log(report.results[0].output) For information |
Okay, now I understand your problem. Please write both the actual behavior and the expected behavior to report bugs in the future. So, this is correct behavior for now, because
Your |
My original problem is this: in VS Code, I have some files that remove ESLint comments when I save them. However those ESLint comments are followed by lines that actually report ESLint errors. I.e. removing those comments make ESLint report those lines. There is definitely an issue there, this is not the expected behavior, and it started appearing with the This is hard to debug because VS Code uses I tried to reduce the original problem to a simpler problem to make the GitHub issue easier to fix, but it turns out I'm having a hard time reducing it to the actual problem. Now based on your comment above I think I've boiled it down to the following problem: I don't think this is an issue with
// eslint-disable-next-line no-empty-function
module.exports = function () {}
plugins: [eslint-comments]
rules:
eslint-comments/no-unused-disable: 2
no-empty-function: 2 Running module.exports = function () {} But the expected output is: // eslint-disable-next-line no-empty-function
module.exports = function () {} Same versions as above. |
That is the problem. |
I think they might have some legitimate reasons to do so, i.e. if I open a GitHub issue to the Would there be a way to make |
The result of I'd like to recommend to use |
Using For VS Code users reading this issue: This conflict makes it impossible to code (it creates quite a difficult developer experience) without either disabling |
I'm under considering. |
After considering, I have determined to revert that autofix feature.
It was reverted in 3cd7256. |
This problem appeared in
3.1.0
, i.e. was introduced by #13.Input:
Then
eslint --fix file.js
. Output:Note that the following works:
.eslintrc.yml
:Versions:
The text was updated successfully, but these errors were encountered: