|
| 1 | +import js from '@eslint/js'; |
| 2 | +import globals from 'globals'; |
| 3 | +import nodejs from 'eslint-plugin-n'; |
| 4 | + |
| 5 | +export default [ |
| 6 | + // Base configurations |
| 7 | + js.configs.recommended, |
| 8 | + nodejs.configs['flat/recommended'], |
| 9 | + |
| 10 | + // Global variables |
| 11 | + { |
| 12 | + languageOptions: { |
| 13 | + globals: { |
| 14 | + ...globals.node, |
| 15 | + ...globals.jest |
| 16 | + }, |
| 17 | + ecmaVersion: 2022, |
| 18 | + sourceType: 'module', |
| 19 | + } |
| 20 | + }, |
| 21 | + |
| 22 | + // File patterns and ignored files |
| 23 | + { |
| 24 | + ignores: [ |
| 25 | + 'node_modules/', |
| 26 | + 'coverage/', |
| 27 | + '.github/', |
| 28 | + 'dist/', |
| 29 | + 'build/', |
| 30 | + '**/*.min.js', |
| 31 | + 'jest.config.mjs' |
| 32 | + ] |
| 33 | + }, |
| 34 | + |
| 35 | + // Rules configuration |
| 36 | + { |
| 37 | + rules: { |
| 38 | + // Disable specific rules for this project |
| 39 | + 'no-undef': 'off', // Disable undefined variable checks (we have variables from outer scopes) |
| 40 | + // Error prevention |
| 41 | + 'no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }], |
| 42 | + 'no-console': 'off', |
| 43 | + 'no-constant-condition': 'warn', |
| 44 | + 'no-debugger': 'error', |
| 45 | + 'no-duplicate-case': 'error', |
| 46 | + 'no-empty': 'warn', |
| 47 | + 'no-extra-boolean-cast': 'warn', |
| 48 | + 'no-fallthrough': 'warn', |
| 49 | + 'no-irregular-whitespace': 'warn', |
| 50 | + 'no-prototype-builtins': 'warn', |
| 51 | + 'no-return-await': 'warn', |
| 52 | + 'no-var': 'error', |
| 53 | + 'prefer-const': 'warn', |
| 54 | + |
| 55 | + // Style |
| 56 | + 'camelcase': ['warn', { properties: 'never' }], |
| 57 | + 'semi': ['error', 'always'], |
| 58 | + 'indent': ['warn', 2, { SwitchCase: 1 }], |
| 59 | + 'quotes': ['warn', 'single', { allowTemplateLiterals: true, avoidEscape: true }], |
| 60 | + 'arrow-spacing': ['warn', { before: true, after: true }], |
| 61 | + 'block-spacing': ['warn', 'always'], |
| 62 | + 'brace-style': ['warn', '1tbs', { allowSingleLine: true }], |
| 63 | + 'comma-dangle': ['warn', 'only-multiline'], |
| 64 | + 'comma-spacing': ['warn', { before: false, after: true }], |
| 65 | + 'comma-style': ['warn', 'last'], |
| 66 | + 'eol-last': ['warn', 'always'], |
| 67 | + 'func-call-spacing': ['warn', 'never'], |
| 68 | + 'key-spacing': ['warn', { beforeColon: false, afterColon: true }], |
| 69 | + 'keyword-spacing': ['warn', { before: true, after: true }], |
| 70 | + 'linebreak-style': ['error', 'unix'], |
| 71 | + 'max-len': ['warn', { code: 120, ignoreUrls: true, ignoreStrings: true, ignoreTemplateLiterals: true }], |
| 72 | + 'no-multiple-empty-lines': ['warn', { max: 2, maxEOF: 1 }], |
| 73 | + 'no-trailing-spaces': 'warn', |
| 74 | + 'object-curly-spacing': ['warn', 'always'], |
| 75 | + 'padded-blocks': ['warn', 'never'], |
| 76 | + 'space-before-blocks': ['warn', 'always'], |
| 77 | + 'space-before-function-paren': ['warn', { anonymous: 'always', named: 'never', asyncArrow: 'always' }], |
| 78 | + 'space-in-parens': ['warn', 'never'], |
| 79 | + 'space-infix-ops': 'warn', |
| 80 | + |
| 81 | + // Node.js specific |
| 82 | + 'n/exports-style': ['error', 'module.exports'], |
| 83 | + 'n/file-extension-in-import': ['error', 'always', { '.js': 'never', '.mjs': 'always' }], |
| 84 | + 'n/prefer-global/buffer': ['error', 'always'], |
| 85 | + 'n/prefer-global/console': ['error', 'always'], |
| 86 | + 'n/prefer-global/process': ['error', 'always'], |
| 87 | + 'n/prefer-global/url-search-params': ['error', 'always'], |
| 88 | + 'n/prefer-global/url': ['error', 'always'], |
| 89 | + 'n/prefer-promises/dns': 'error', |
| 90 | + 'n/prefer-promises/fs': 'error', |
| 91 | + 'n/no-deprecated-api': 'warn', |
| 92 | + 'n/no-unpublished-require': 'off', |
| 93 | + 'n/no-missing-import': 'off', |
| 94 | + 'n/no-unpublished-import': 'off', |
| 95 | + 'n/no-unsupported-features/es-syntax': 'off', |
| 96 | + // Allow process.exit() in CLI applications |
| 97 | + 'n/no-process-exit': 'off' |
| 98 | + } |
| 99 | + } |
| 100 | +]; |
0 commit comments