microsoft / vscode-eslint

VSCode extension to integrate eslint into VSCode
MIT License
1.73k stars 335 forks source link

eslint-disable comments removed on save when other lint error is present #1938

Open pfoedermayr opened 2 days ago

pfoedermayr commented 2 days ago

When a file with one or more eslint-disable comments is saved while there are other lint errors present the comments are automatically removed. I was able to reproduce it with a fresh project with just eslint and a javascript file. Only the extension dbaeumer.vscode-eslint in version 3.0.10 being enabled in VSCode.

eslint.config.mjs

export default [
  {
    linterOptions: {
      reportUnusedDisableDirectives: 'error'
    }
  },
  {
    rules: {
      'no-console': 'error',
      'quotes': ['error', 'single']
    }
  },
];

.vscode/settings.json

{
    "editor.codeActionsOnSave": {
      "source.fixAll.eslint": "explicit"
    },
    "eslint.codeActionsOnSave.rules": [
        "quotes"
    ]
}

When I save a file that looks like this for example

// eslint-disable-next-line no-console
console.log('test');

var a = "a"; // Lint error here

it results in:


console.log('test');

var a = 'a'; // Lint error here

Running just ESLint: Fix all auto-fixable Problems does fix the lint error in line 4 and keeps the eslint-disable comment in line 1.

dbaeumer commented 2 days ago

@pfoedermayr could you please provide me with a GitHub repository I can clone. That ensure we are using the identical setup when I try to reproduce this.

pfoedermayr commented 2 days ago

Hope this helps, let me know if I should change something or if you need anything else

https://github.com/pfoedermayr/vscode-eslint-1938