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

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

オープン
#172 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

enhancement tooling
主要言語
TypeScript
スター
146
フォーク
46
平均マージ
3日 10時間
マージ済み PR(30日)
24

説明

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:

#!/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)

// 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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

eslint.config.mjs と cli/src/bin/bgagent.ts から始め、次に PR #171 と、shebang に関する eslint-plugin-license-header の動作を確認します。プラグインが許可されたプリアンブルをサポートしているか確認し、サポートしていない場合は upstream-fix、custom-rule、alternative-plugin の各オプションを比較します。完了の条件は、shebang を含むファイルで実行可能ヘッダーが維持され、その直後にライセンスヘッダーが引き続き適用され、空行が最大 1 行であることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
eslint, typescript
領域
developer-experience, tooling
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。