/ eslint.config.js
eslint.config.js
  1  /**
  2   * ESLint Configuration for 333 Method Automation
  3   * Modern flat config format for ESM projects
  4   */
  5  
  6  import js from '@eslint/js';
  7  import globals from 'globals';
  8  import security from 'eslint-plugin-security';
  9  
 10  export default [
 11    // Base recommended rules
 12    js.configs.recommended,
 13  
 14    // Security plugin recommended rules
 15    security.configs.recommended,
 16  
 17    {
 18      languageOptions: {
 19        ecmaVersion: 2022,
 20        sourceType: 'module',
 21        globals: {
 22          ...globals.node,
 23          ...globals.es2021,
 24        },
 25      },
 26  
 27      rules: {
 28        // Error Prevention
 29        'no-unused-vars': [
 30          'warn',
 31          {
 32            argsIgnorePattern: '^_',
 33            varsIgnorePattern: '^_',
 34          },
 35        ],
 36        'no-console': 'off', // We use console for logging
 37        'no-debugger': 'warn',
 38        'no-unreachable': 'error',
 39  
 40        // Best Practices
 41        eqeqeq: ['error', 'always'],
 42        'no-var': 'error',
 43        'prefer-const': 'warn',
 44        'prefer-arrow-callback': 'warn',
 45        'no-throw-literal': 'error',
 46  
 47        // Code Quality
 48        'max-lines-per-function': ['warn', { max: 150, skipBlankLines: true, skipComments: true }],
 49        complexity: ['warn', 15],
 50        'max-depth': ['warn', 4],
 51        'max-params': ['warn', 5],
 52  
 53        // Modern JavaScript
 54        'prefer-template': 'warn',
 55        'prefer-destructuring': ['warn', { object: true, array: false }],
 56        'object-shorthand': 'warn',
 57  
 58        // Async/Await
 59        'no-async-promise-executor': 'error',
 60        'require-await': 'warn',
 61        'no-return-await': 'warn',
 62  
 63        // Security
 64        'no-eval': 'error',
 65        'no-implied-eval': 'error',
 66        'no-new-func': 'error',
 67      },
 68    },
 69  
 70    {
 71      // Test files - more relaxed rules
 72      files: ['**/*.test.js', '**/*.spec.js'],
 73      rules: {
 74        'max-lines-per-function': 'off',
 75        'no-unused-expressions': 'off',
 76        'no-empty': ['error', { allowEmptyCatch: true }],
 77      },
 78    },
 79  
 80    {
 81      // E2E tests run in a browser context (Playwright) — allow browser globals
 82      files: ['tests/e2e/**/*.js'],
 83      languageOptions: {
 84        globals: {
 85          ...globals.browser,
 86        },
 87      },
 88    },
 89    {
 90      // Ignore patterns
 91      ignores: [
 92        'node_modules/**',
 93        'db/**',
 94        '.venv/**',
 95        'coverage/**',
 96        '.quality-reports/**',
 97        '.security-reports/**',
 98        'dist/**',
 99        'extensions/**',
100        'workers/**',
101        'auditandfix.com/**',
102        '__quarantined_tests__/**',
103      ],
104    },
105  ];