paleite / eslint-plugin-diff

Run ESLint on your changes only
https://npm.im/eslint-plugin-diff
MIT License
172 stars 13 forks source link

Help - Diff Plugin not compatible with new flat config #47

Open mlwyatt opened 1 year ago

mlwyatt commented 1 year ago

Either this plugin isn't compatible with ESLint's flat config file yet, or I'm not setting it up quite right.

Here's a simple example:

Config ```js import globals from 'globals'; import diff from 'eslint-plugin-diff'; export default [ { ...diff.configs.diff.overrides[0], plugins: { diff }, processor: diff.processors.diff, }, { rules: { 'no-console': ['error'], }, }, ]; ```
console.log(1);
+console.log(2);
console.log(3);
console.log(4);

Expected

  2:1  error  Unexpected console statement  no-console

Actual

  1:1  error  Unexpected console statement  no-console
  2:1  error  Unexpected console statement  no-console
  3:1  error  Unexpected console statement  no-console
  4:1  error  Unexpected console statement  no-console

Any help would be appreciated. Thanks in advance

paleite commented 11 months ago

Ah, that's interesting. Great find! Do you have a reproduction repository i could check?

mlwyatt commented 10 months ago

Unfortunately, I don't. I was migrating a couple of my work projects, one of which is written in TS, to the flat config but then came across this saying the TS plugin won't be updated until the flat config is almost finished. Once I found out that, I just dropped it and moved on

alexeyr-ci commented 8 months ago

I can say it appears to work for me. The only thing I needed to do is

const { FlatCompat } = require('@eslint/eslintrc');
const js = require('@eslint/js');

const compat = new FlatCompat({
  baseDirectory: __dirname,
  recommendedConfig: js.configs.recommended,
});

module.exports = [
  // what we had previously
  ...compat.extends('plugin:diff/diff'),
];
Lucasgb7 commented 1 month ago

Are there any updates about ESLint's flat config support?