aws-samples / aws-samples/sample-autonomous-cloud-coding-agents

fix(eslint): support license headers in shebang files without disabling the rule

Abierto
#172 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

enhancement tooling
Lenguaje dominante
TypeScript
Estrellas
146
Forks
46
Merge medio
3 d 10 h
PR fusionados (30 d)
24

Descripción

## Summary

The `eslint-plugin-license-header` rule reports "Superfluous new lines before license header" on files that start with a shebang (`#!/usr/bin/env node`) followed by the license comment. The current workaround disables the rule entirely for `src/bin/**/*.ts` — this hides the problem instead of fixing it.

## Problem

`cli/src/bin/bgagent.ts` starts with:
```typescript
#!/usr/bin/env node

/**
* MIT No Attribution
* ...
*/
```

The license-header plugin expects the license comment at line 1. The shebang line + blank line before it triggers "superfluous new lines." The `--fix` option can't resolve this because removing the shebang would break the executable.

## Current workaround (PR #171)

```javascript
// eslint.config.mjs
{
files: ['src/bin/**/*.ts'],
rules: { 'license-header/header': 'off' },
}
```

This means shebang files have NO license header enforcement — a file could lose its header and ESLint wouldn't catch it.

## Desired behavior

The license-header rule should:
1. Recognize shebangs as valid preamble before the license header
2. Still enforce that the license header appears immediately after the shebang (with at most one blank line separator)

## Options

1. **Upstream fix**: File an issue/PR on `eslint-plugin-license-header` to support shebang-aware header detection
2. **Custom rule**: Write a project-local rule that handles shebangs (more maintenance)
3. **Different plugin**: Evaluate alternatives (e.g., `eslint-plugin-header`) that may already handle shebangs
4. **Plugin configuration**: Check if `eslint-plugin-license-header` has an option for allowed preamble patterns (shebangs, `@ts-check`, etc.)

## Related

- PR #171 — ESLint 10 migration (introduced the workaround)
- #169 — ESLint 10 upgrade issue

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Empieza con eslint.config.mjs y cli/src/bin/bgagent.ts; después revisa PR #171 y el comportamiento de eslint-plugin-license-header con respecto a los shebangs. Comprueba si el plugin admite un preámbulo permitido; de lo contrario, compara las opciones upstream-fix, custom-rule y alternative-plugin. Se considera terminado cuando los archivos con shebang conservan sus encabezados ejecutables y los encabezados de licencia siguen siendo obligatorios inmediatamente después, con como máximo una línea en blanco.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
eslint, typescript
Área
developer-experience, tooling
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
48/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.