cdn-and-caching-strategy: any firebase.json counts as a web-serving surface, also one with no hosting

Aperta Adatta ai principianti
#547 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
firebase, typescript
Ambito
performance

Direzione di ricerca

La lista dei file si trova in src/laws/performance/cdn-caching-strategy.ts: WEB_SURFACE_FILES alla riga 18 include firebase.json, e hasWebAssets, intorno alle righe 33-36, restituisce true ogni volta che quel file esiste. Modifica il controllo in modo che firebase.json conti solo quando il JSON analizzato contiene una chiave hosting. È completato quando un progetto il cui firebase.json contiene solo impostazioni firestore viene segnalato come non applicabile, e uno con hosting continua a eseguire la legge.

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

Descrizione

bug

Version: 8.0.1 (tag v8.0.1)
Law: cdn-and-caching-strategy (CDN and Caching Strategy), CdnCachingStrategyLaw.hasWebAssets

What happens

WEB_SURFACE_FILES (src/laws/performance/cdn-caching-strategy.ts:18) lists firebase.json, and hasWebAssets (:33-36) returns true when the file exists. The law then judges the project for CDN configuration, browser caching headers and service-worker caching.

firebase.json configures several products. Only its hosting key declares something served to browsers; firestore, functions, storage and emulators do not.

Reproduction

A Python API (pyproject.toml, api/main.py with FastAPI) whose firebase.json is { "firestore": { "rules": "firestore.rules", "indexes": "firestore.indexes.json" } }, laws.enabled { "CDN and Caching Strategy": true }:

1. CDN and Caching Strategy [5 violations] (Score: 0/100)
   • CDN configuration not implemented
   • Browser caching headers not configured
   • Service worker caching not implemented

Without firebase.json the same project gets "Not applicable — no web assets to serve".

What I ruled out

No other web-surface file and no JS/TS sources in the fixture: firebase.json alone switches the law on.

Why it matters

The law asks a JSON API for a service worker. The only ways out are a waiver or deleting a config the project needs for its database.

Suggested direction

  1. Count firebase.json as a web surface only when it has a hosting key.
  2. Apply the same idea to other multi-purpose configs in the list where a key decides it (for example wrangler.toml with [site] / assets).
Lingua principale
TypeScript
Stelle
0
Fork
0
Merge medio
2h 36m
PR unite (30g)
168

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Rule-Of-Code/RoC

Tutte le issue di Rule-Of-Code/RoC

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.