aws-samples / aws-samples/serverless-full-stack-webapp-starter-kit

refactor(cdk): awscdk-lint (strict) を全ルール適用する(既存 stack name は disable コメントで例外化)

Aperta
#203 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
enhancement needs-triage
Lingua principale
TypeScript
Stelle
229
Fork
45
Merge medio
1m
PR unite (30g)
4

Descrizione

## 背景

[awscdk-lint](https://github.com/ren-yamanashi/awscdk-lint)(`oxlint-plugin-awscdk`)を
`apps/cdk` に適用する。strict 構成を全ルール有効で導入し、検出された指摘に対応する。

唯一リソース置換を伴う `no-construct-stack-suffix` は、既存の 2 つの stack name に対してのみ
inline disable コメントで例外化し、破壊的変更を回避する(新規コードには引き続き適用される)。

検証は type-aware モードで実施(`--type-aware` 必須。付けないと型情報必須ルールが
黙ってスキップされ false negative になる)。

## 方針

- `oxlint-plugin-awscdk` の `strict` 構成を全ルール有効で適用する。
- 検出された非破壊的な指摘(型注釈・readonly・未使用 Props 削除・コンストラクタ引数名・JSDoc)を修正する。
- **既存 stack name のみ例外化**: `bin/cdk.ts` の 2 箇所は disable コメントで抑制する。

## 対応する指摘(strict / type-aware、いずれも synth 出力不変)

| ルール | 件数 | 主な箇所 |
| ---------------------------------------------- | ---- | ----------------------------------------------------------------------------------------------- |
| `require-jsdoc` | 28 | 各 construct / props |
| `no-mutable-property-of-props-interface` | 27 | `webapp.ts`, `service.ts`, `bin/cdk.ts`, `us-east-1-stack.ts` ほか |
| `no-construct-in-public-property-of-construct` | 4 | `service.ts`(`urlParameter`), `event-bus/index.ts`(`api`), `auth/index.ts`(`userPool`,`client`) |
| `no-construct-in-interface` | 3 | `webapp.ts`(`accessLogBucket`), `service.ts`(`handler`,`accessLogBucket`) |
| `no-unused-props` | 2 | `service.ts`(`basicAuthUsername`,`basicAuthPassword`) |
| `require-props-default-doc` | 1 | オプショナル Props |
| `construct-constructor-property` | 1 | `database.ts` / `event-bus/index.ts` |

(`pascal-case-construct-id` / `no-parent-name-construct-id-match` /
`no-variable-construct-id` / `prevent-construct-id-collision` / `require-passing-this` は検出 0 件)

## 例外化する指摘(リソース置換を伴うため disable)

| ルール | 件数 | 箇所 | 対応 |
| --------------------------- | ---- | ------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `no-construct-stack-suffix` | 2 | `bin/cdk.ts`(`ServerlessWebappStarterKitStack`, `ServerlessWebappStarterKitUsEast1Stack`) | 直上に `// oxlint-disable-next-line awscdk/no-construct-stack-suffix` + 理由コメント。stack ID 変更 = スタックごと再作成(RETAIN の DSQL/Cognito が孤立)のため既存名を維持 |

## 完了条件

- [ ] `strict` 構成を全ルール有効で導入する
- [ ] 上記「対応する指摘」をすべて解消する
- [ ] `bin/cdk.ts` の 2 箇所を disable コメント + 理由コメントで例外化する
- [ ] `cdk synth` の diff がゼロ(logical ID・テンプレート不変)であることをスナップショットテストで確認
- [ ] `pnpm --filter @repo/cdk run lint:ci`(type-aware 前提)が pass する

## 補足

- 型情報必須ルールは素の `oxlint` ではスキップされる。CI 組込みには
`oxlint-tsgolint` + `--type-aware` が前提。既存の `lint:ci` スクリプトの更新が必要。
- プラグイン peer 依存は `oxlint >= 1.70`。現状リポジトリは `oxlint ^1`(要バージョン確認)。
- disable コメントが type-aware モードの JS プラグイン規則に効くことは検証済み。

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia in apps/cdk e ispeziona lo script lint:ci esistente, quindi esamina bin/cdk.ts e i file dei construct elencati, come webapp.ts, service.ts, database.ts ed event-bus/index.ts. Esegui prima il comando di lint consapevole dei tipi e i controlli degli snapshot CDK. È terminato quando tutti i rilievi non distruttivi sono stati corretti, le due eccezioni di stack-name mantengono le motivazioni, il lint passa e cdk synth non mostra differenze.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
aws, nodejs, typescript
Ambito
ci-cd, infrastructure, testing, tooling
Tipo di issue
Refactoring
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.