/**
* ESLint Configuration for Email Checker Module
*
* Modern ESLint flat config for Node.js 20+ with ESM modules
*/
import js from '@eslint/js';
export default [
js.configs.recommended,
{
languageOptions: {
ecmaVersion: 2024,
sourceType: 'module',
globals: {
console: 'readonly',
process: 'readonly',
Buffer: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
global: 'readonly',
globalThis: 'readonly',
fetch: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
},
},
rules: {
// Error prevention
'no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
'no-undef': 'error',
'no-unreachable': 'error',
'no-constant-condition': 'error',
'no-duplicate-imports': 'error',
// Code style
indent: ['error', 2, { SwitchCase: 1 }],
quotes: ['error', 'single', { avoidEscape: true }],
semi: ['error', 'always'],
'comma-dangle': ['error', 'always-multiline'],
'object-curly-spacing': ['error', 'always'],
'array-bracket-spacing': ['error', 'never'],
'space-before-function-paren': [
'error',
{
anonymous: 'never',
named: 'never',
asyncArrow: 'always',
},
],
// Modern JavaScript
'prefer-const': 'error',
'prefer-arrow-callback': 'error',
'prefer-template': 'error',
'prefer-destructuring': [
'error',
{
array: false,
object: true,
},
],
'no-var': 'error',
'object-shorthand': 'error',
// Async/await
'prefer-promise-reject-errors': 'error',
'no-async-promise-executor': 'error',
'require-atomic-updates': 'error',
// Best practices
eqeqeq: ['error', 'always'],
'no-eval': 'error',
'no-implied-eval': 'error',
'no-new-func': 'error',
'no-return-assign': 'error',
'no-self-compare': 'error',
'no-throw-literal': 'error',
'no-unused-expressions': 'error',
radix: 'error',
yoda: 'error',
// Error handling
'no-promise-executor-return': 'error',
// Formatting
'max-len': [
'error',
{
code: 100,
ignoreUrls: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
},
],
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1 }],
'no-trailing-spaces': 'error',
'eol-last': 'error',
},
},
{
// Test-specific configuration
files: ['test/**/*.js', '**/*.test.js'],
languageOptions: {
globals: {
describe: 'readonly',
it: 'readonly',
before: 'readonly',
after: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly',
},
},
rules: {
// Allow longer lines in tests for readability
'max-len': ['error', { code: 120 }],
// Allow unused expressions in tests (for assertions)
'no-unused-expressions': 'off',
},
},
{
// Example files configuration
files: ['examples/**/*.js'],
rules: {
// Allow console.log in examples
'no-console': 'off',
// Allow longer lines in examples for readability
'max-len': ['error', { code: 120 }],
},
},
{
ignores: ['node_modules/**', 'dist/**', 'build/**', 'coverage/**', '*.min.js'],
},
];