a2ui-project / a2ui-project/a2ui

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

Đang mở
#1,667 1 bình luận 0 reaction 1 người được giao Được giao cho @josemontespg Xem trên GitHub
component: lit renderer P2 type: feature/enhancement
Ngôn ngữ chính
TypeScript
Star
16.4k
Fork
1.3k
Merge trung bình
3 ngày 15 giờ
Pull request đã merge (30 ngày)
134

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Công việc bao gồm ba thay đổi cấu hình riêng biệt. Trước tiên, tìm tệp cấu hình TypeScript (ví dụ: `renderers/lit/tsconfig.json`) để thêm `"noImplicitOverride": true`. Thứ hai, tìm cấu hình ESLint (`eslint.preset.mjs`) để thêm quy tắc `no-restricted-imports` cho các import package nội bộ. Thứ ba, xem xét các tệp `tsconfig.json` hiện có để đảm bảo `strict: true` được thiết lập hoặc thêm các quy tắc ESLint liên quan. Kiểm tra cấu hình pipeline CI để đảm bảo các bước kiểm tra này được chạy. “Hoàn tất” có nghĩa là CI vượt qua với các quy tắc mới này được áp dụng cho codebase.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
eslint, typescript
Lĩnh vực
build-system, ci-cd, tooling
Loại issue
Tái cấu trúc
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
55/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.