module.exports = {
  env: {
    node: true,
    es2021: true,
  },
  extends: [
    'eslint:recommended',
  ],
  parserOptions: {
    ecmaVersion: 12,
    sourceType: 'module',
  },
  plugins: ['boundaries'],
  settings: {
    'boundaries/elements': [
      {
        type: 'controller',
        pattern: 'src/api/controllers/*',
      },
      {
        type: 'service',
        pattern: 'src/services/*',
      },
      {
        type: 'repository',
        pattern: 'src/repositories/*',
      },
    ],
  },
  rules: {
    'boundaries/element-types': [
      'error',
      {
        default: 'disallow',
        rules: [
          {
            from: 'controller',
            allow: ['service'], // Controller 只能调 Service
          },
          {
            from: 'service',
            allow: ['repository'], // Service 可以调 Repository
          },
          {
            from: 'repository',
            allow: [], // Repository 不允许调用任何业务层
          },
        ],
      },
    ],
  },
};
