eslint-plugin-diff icon indicating copy to clipboard operation
eslint-plugin-diff copied to clipboard

Help - Diff Plugin not compatible with new flat config

Open mlwyatt opened this issue 3 years ago • 5 comments

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

mlwyatt avatar Apr 21 '23 20:04 mlwyatt

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

paleite avatar Oct 10 '23 13:10 paleite

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

mlwyatt avatar Oct 16 '23 15:10 mlwyatt

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'),
];

alexeyr-ci avatar Dec 25 '23 14:12 alexeyr-ci

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

Lucasgb7 avatar Jul 11 '24 13:07 Lucasgb7