Files
puaros/eslint.config.mjs
imfozilbek a34ca85241 chore: refactor hardcoded values to constants (v0.5.1)
Major internal refactoring to eliminate hardcoded values and improve
maintainability. Guardian now fully passes its own quality checks!

Changes:
- Extract all RepositoryViolation messages to domain constants
- Extract all framework leak template strings to centralized constants
- Extract all layer paths to infrastructure constants
- Extract all regex patterns to IMPORT_PATTERNS constant
- Add 30+ new constants for better maintainability

New files:
- src/infrastructure/constants/paths.ts (layer paths, patterns)
- src/domain/constants/Messages.ts (25+ repository messages)
- src/domain/constants/FrameworkCategories.ts (framework categories)
- src/shared/constants/layers.ts (layer names)

Impact:
- Reduced hardcoded values from 37 to 1 (97% improvement)
- Guardian passes its own src/ directory checks with 0 violations
- All 292 tests still passing (100% pass rate)
- No breaking changes - fully backwards compatible

Test results:
- 292 tests passing (100% pass rate)
- 96.77% statement coverage
- 83.82% branch coverage
2025-11-24 20:12:08 +05:00

160 lines
5.8 KiB
JavaScript

// @ts-check
import eslint from '@eslint/js';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import globals from 'globals';
import tseslint from 'typescript-eslint';
export default tseslint.config(
{
ignores: [
'eslint.config.mjs',
'**/dist/**',
'**/node_modules/**',
'**/coverage/**',
'**/.puaros/**',
'**/build/**',
],
},
eslint.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
eslintPluginPrettierRecommended,
{
languageOptions: {
globals: {
...globals.node,
...globals.jest,
...globals.es2021,
},
sourceType: 'commonjs',
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
rules: {
// ========================================
// TypeScript Best Practices
// ========================================
'@typescript-eslint/no-explicit-any': 'warn', // Warn about 'any' usage
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-call': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/explicit-function-return-type': [
'warn',
{
allowExpressions: true,
allowTypedFunctionExpressions: true,
allowHigherOrderFunctions: true,
},
],
'@typescript-eslint/explicit-module-boundary-types': 'warn',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
'@typescript-eslint/prefer-optional-chain': 'warn',
'@typescript-eslint/prefer-readonly': 'warn',
'@typescript-eslint/promise-function-async': 'warn',
'@typescript-eslint/require-await': 'warn',
'@typescript-eslint/no-unnecessary-condition': 'warn',
'@typescript-eslint/no-non-null-assertion': 'warn',
// ========================================
// Code Quality & Best Practices
// ========================================
'no-console': ['warn', { allow: ['warn', 'error'] }],
'no-debugger': 'error',
'no-alert': 'error',
'no-var': 'error',
'prefer-const': 'error',
'prefer-arrow-callback': 'warn',
'prefer-template': 'warn',
'no-nested-ternary': 'warn',
'no-unneeded-ternary': 'error',
'no-else-return': 'warn',
eqeqeq: ['error', 'always'],
curly: ['error', 'all'],
'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 0 }],
'no-trailing-spaces': 'error',
'comma-dangle': ['error', 'always-multiline'],
// ========================================
// Code Style (handled by Prettier mostly)
// ========================================
indent: 'off', // Let Prettier handle this
'@typescript-eslint/indent': 'off', // Let Prettier handle this
quotes: ['error', 'double', { avoidEscape: true }],
semi: ['error', 'never'],
// ========================================
// Prettier Integration
// ========================================
'prettier/prettier': [
'error',
{
tabWidth: 4,
endOfLine: 'auto',
},
],
// ========================================
// Complexity & Maintainability
// ========================================
complexity: ['warn', 15],
'max-depth': ['warn', 4],
'max-lines-per-function': ['warn', { max: 100, skipBlankLines: true, skipComments: true }],
'max-params': ['warn', 5],
// ========================================
// Imports & Dependencies
// ========================================
'no-duplicate-imports': 'error',
'sort-imports': [
'warn',
{
ignoreCase: true,
ignoreDeclarationSort: true,
},
],
// ========================================
// Comments
// ========================================
'no-inline-comments': 'off',
'line-comment-position': 'off',
'spaced-comment': [
'error',
'always',
{
markers: ['/'],
exceptions: ['-', '+', '*', '='],
block: {
balanced: true,
},
},
],
'multiline-comment-style': ['warn', 'starred-block'],
'no-warning-comments': [
'warn',
{
terms: ['todo', 'fixme', 'hack', 'xxx'],
location: 'start',
},
],
},
},
);