import { fixupPluginRules } from '@eslint/compat';
import storybookPlugin from 'eslint-plugin-storybook';
import filenamesPlugin from 'eslint-plugin-filenames';
import { importX as importPlugin } from 'eslint-plugin-import-x';
import storybookRules from '../rules/storybook.mjs';

export default [
  {
    plugins: {
      storybook: storybookPlugin,
      filenames: fixupPluginRules(filenamesPlugin),
      'import-x': importPlugin,
    },
    rules: {
      ...storybookRules,
      // storybook >7 requires default exports in stories
      'import-x/no-anonymous-default-export': 'off',
      'import-x/no-default-export': 'off',
      'import-x/no-extraneous-dependencies': ['error', { devDependencies: true }],
      'import-x/prefer-default-export': 'error',

      // the default export is always called `meta` so the filenames
      // will never match the exported name
      'filenames/match-exported': 'off',
    },
  },
];
