a2ui-project / a2ui-project/a2ui
Enforce 1P-compatible coding standards via Linting and TS Config
- Langage dominant
- TypeScript
- Étoiles
- 16.4k
- Forks
- 1.3k
- Merge moyen
- 3 j 15 h
- PR mergées (30 j)
- 134
Description
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.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Le travail comporte trois changements de configuration distincts. Premièrement, localisez le fichier de configuration TypeScript (par exemple, `renderers/lit/tsconfig.json`) pour y ajouter `"noImplicitOverride": true`. Deuxièmement, trouvez la configuration ESLint (`eslint.preset.mjs`) pour y ajouter une règle `no-restricted-imports` pour les imports de packages internes. Troisièmement, examinez les fichiers `tsconfig.json` existants afin de vérifier que `strict: true` est défini, ou ajoutez les règles ESLint pertinentes. Vérifiez la configuration du pipeline CI pour vous assurer que ces contrôles sont exécutés. « Terminé » signifie que la CI passe avec ces nouvelles règles appliquées à la base de code.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- eslint, typescript
- Domaine
- build-system, ci-cd, tooling
- Type d'issue
- Refactorisation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- Calme
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 55/100