A2UI icon indicating copy to clipboard operation
A2UI copied to clipboard

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

Open josemontespg opened this issue 5 months ago • 1 comments

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 types in TextField) are explicitly typed (e.g., 'text' | 'number' | 'password') rather than relying on loose string inference, preventing mismatched types downstream in Google3.

josemontespg avatar Jun 15 '26 23:06 josemontespg

Approved as P2. Assigned to @josemontespg and @Varun-S10. Please proceed with implementation now that PR #1655 has been merged.

gspencergoog avatar Jun 25 '26 01:06 gspencergoog