a2ui-project / a2ui-project/a2ui
Enforce 1P-compatible coding standards via Linting and TS Config
- 主要语言
- TypeScript
- 星标
- 16.4k
- 派生
- 1.3k
- 平均合并
- 3 天 15 小时
- 30 天内合并 PR
- 134
描述
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.
贡献指南
调研方向
这项工作涉及三项不同的配置更改。首先,找到 TypeScript 配置文件(例如 `renderers/lit/tsconfig.json`),添加 `"noImplicitOverride": true`。其次,找到 ESLint 配置(`eslint.preset.mjs`),为内部包的导入添加 `no-restricted-imports` 规则。第三,检查现有的 `tsconfig.json` 文件,确保已设置 `strict: true`,或者添加相关的 ESLint 规则。检查 CI 流水线配置,确保这些检查会运行。“完成”意味着在代码库中强制执行这些新规则后,CI 通过。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- eslint, typescript
- 领域
- build-system, ci-cd, tooling
- Issue 类型
- 重构
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 冷清
- 描述清晰度
- 描述清楚
- 新手友好度
- 55/100