a2ui-project / a2ui-project/a2ui

Enforce 1P-compatible coding standards via Linting and TS Config

Aperta
#1,667 1 commento 0 reazioni 1 assegnatario Assegnata a @josemontespg Vedi su GitHub
component: lit renderer P2 type: feature/enhancement
Lingua principale
TypeScript
Stelle
16.4k
Fork
1.3k
Merge medio
3g 15h
PR unite (30g)
134

Descrizione

To prevent new code from inadvertently breaking the Google 1P import process, we need to add several automated checks (formatting/linting) to our CI pipeline. This work should be completed following the merge of PR #1655.

### 1. Enforce `override` keyword (TypeScript)
We need to enable the `"noImplicitOverride": true` compiler option in our TypeScript configuration (e.g., `renderers/lit/tsconfig.json`).
* **Why**: This will force the compiler to throw an error if a developer overrides a method (such as Lit's `render()` or `updated()`) or a property (`static styles`) without explicitly providing the `override` keyword, maintaining compatibility with Google3's strict TypeScript compilation rules.

### 2. Prevent External Imports Inside Packages (ESLint)
We need to add the `no-restricted-imports` rule to our ESLint configuration (`eslint.preset.mjs` or package-specific configs).
* **Why**: To explicitly forbid importing from `@a2ui/lit/*` (or similar package names) from within that package's own source directories. This will enforce the use of relative imports (`../` or `./`) for internal file resolution, which is required for monorepo environments.

### 3. Enforce Strict Component Property Typing (TypeScript / ESLint)
We need to enhance our type strictness, either via `tsconfig.json` (`strict: true`) or specific ESLint rules like `@typescript-eslint/typedef`.
* **Why**: This ensures that properties (like input `type`s in `TextField`) are explicitly typed (e.g., `'text' | 'number' | 'password'`) rather than relying on loose string inference, preventing mismatched types downstream in Google3.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Il lavoro comporta tre modifiche di configurazione distinte. Innanzitutto, individua il file di configurazione TypeScript (ad esempio, `renderers/lit/tsconfig.json`) per aggiungere `"noImplicitOverride": true`. In secondo luogo, trova la configurazione ESLint (`eslint.preset.mjs`) per aggiungere una regola `no-restricted-imports` per gli import di pacchetti interni. In terzo luogo, esamina i file `tsconfig.json` esistenti per assicurarti che `strict: true` sia impostato oppure aggiungi le regole ESLint pertinenti. Controlla la configurazione della pipeline CI per assicurarti che questi controlli vengano eseguiti. «Fatto» significa che la CI passa con queste nuove regole applicate alla codebase.

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

Valutazione

Stack tecnologico
eslint, typescript
Ambito
build-system, ci-cd, tooling
Tipo di issue
Refactoring
Difficoltà
3/5
Tempo stimato
1-2 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.