academia/docs/entregables/03-configuracion/DV-006-herramientas-calidad.md

3.4 KiB

DV-006: Herramientas de Calidad

Proyecto: Sistema de Registro de Estudiantes Fecha: 2026-01-07


1. Backend (.NET 10)

.editorconfig

root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{cs,csx}]
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_prefer_braces = true:warning
dotnet_sort_system_directives_first = true

Directory.Build.props (Analyzers)

<Project>
  <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
    <AnalysisLevel>latest</AnalysisLevel>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" PrivateAssets="all" />
  </ItemGroup>
</Project>

Comandos

# Formatear código
dotnet format

# Verificar sin cambiar
dotnet format --verify-no-changes

# Build con warnings
dotnet build -warnaserror

2. Frontend (Angular 21)

ESLint

# Instalar
ng add @angular-eslint/schematics
// .eslintrc.json
{
  "root": true,
  "overrides": [
    {
      "files": ["*.ts"],
      "extends": [
        "eslint:recommended",
        "plugin:@typescript-eslint/recommended",
        "plugin:@angular-eslint/recommended"
      ],
      "rules": {
        "@angular-eslint/component-selector": ["error", {
          "prefix": "app",
          "style": "kebab-case",
          "type": "element"
        }],
        "@typescript-eslint/no-unused-vars": "error",
        "no-console": "warn"
      }
    }
  ]
}

Prettier

// .prettierrc
{
  "singleQuote": true,
  "trailingComma": "es5",
  "tabWidth": 2,
  "semi": true,
  "printWidth": 100
}
// .prettierignore
node_modules
dist
coverage
.angular

3. Pre-commit Hooks (Husky)

# Instalar
npm install -D husky lint-staged
npx husky init
// package.json
{
  "lint-staged": {
    "*.ts": ["eslint --fix", "prettier --write"],
    "*.html": ["prettier --write"],
    "*.scss": ["prettier --write"]
  }
}
# .husky/pre-commit
npm run lint-staged
cd ../backend && dotnet format --verify-no-changes

4. Scripts package.json

{
  "scripts": {
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "format": "prettier --write \"src/**/*.{ts,html,scss}\"",
    "format:check": "prettier --check \"src/**/*.{ts,html,scss}\"",
    "codegen": "graphql-codegen",
    "prepare": "husky"
  }
}

5. CI Checks

# .github/workflows/ci.yml (ejemplo)
jobs:
  backend:
    steps:
      - run: dotnet format --verify-no-changes
      - run: dotnet build -warnaserror
      - run: dotnet test

  frontend:
    steps:
      - run: npm ci
      - run: npm run lint
      - run: npm run format:check
      - run: npm run build
      - run: npm test -- --watch=false

6. Checklist de Calidad

Verificación Backend Frontend
Formato código dotnet format prettier
Linting Roslyn Analyzers ESLint
Tipos Nullable enabled TypeScript strict
Tests xUnit Jasmine/Jest
Pre-commit dotnet format lint-staged