Repository navigation
refactor: split lint.ts into 10 focused modules - #46
Conversation
Review Summary by QodoRefactor: Split monolithic lint.ts into 10 focused modules
WalkthroughsDescription• Split monolithic src/lint.ts (4878 lines) into 10 focused, maintainable modules under src/lint/ directory • **Core modules**: index.ts (orchestrator), shared.ts (971 lines of utilities, type definitions, severity styling), categories.ts (804 lines), details.ts (530 lines), translations.ts (929 lines) • **Specialized modules**: icons.ts (icon validation), metadata.ts (metadata validation), strictMetrics.ts (entity count validation), htmlValidation.ts (HTML/dialog validation), svgValidation.ts (SVG size validation) • Maintained full GAS compatibility: zero import/export statements, all functions remain globally accessible • Updated src/dialog.ts reference path to point to new ./lint/htmlValidation.ts module • Pure refactoring with zero behavior changes, improving code navigation and reducing merge conflict risk Diagramflowchart LR
A["src/lint.ts<br/>4878 lines"] -->|split| B["src/lint/index.ts<br/>Orchestrator"]
A -->|split| C["src/lint/shared.ts<br/>971 lines<br/>Utilities & Styling"]
A -->|split| D["src/lint/categories.ts<br/>804 lines"]
A -->|split| E["src/lint/details.ts<br/>530 lines"]
A -->|split| F["src/lint/translations.ts<br/>929 lines"]
A -->|split| G["src/lint/icons.ts<br/>Icon Validation"]
A -->|split| H["src/lint/metadata.ts<br/>Metadata Validation"]
A -->|split| I["src/lint/strictMetrics.ts<br/>Entity Counts"]
A -->|split| J["src/lint/htmlValidation.ts<br/>HTML Validation"]
A -->|split| K["src/lint/svgValidation.ts<br/>SVG Validation"]
B -->|uses| C
D -->|uses| C
E -->|uses| C
F -->|uses| C
G -->|uses| C
H -->|uses| C
I -->|uses| C
J -->|uses| C
K -->|uses| C
L["src/dialog.ts"] -->|references| J
File Changes1. src/lint/shared.ts
|
Code Review by Qodo
1. driveIconInfoCache stores cross-run state
|
Pure file reorganization — no behavior changes. Modules created under src/lint/: - index.ts (224 lines) — orchestrator: lintAllSheets, lintSheet - categories.ts (804 lines) — category lint rules - details.ts (530 lines) — detail lint rules - translations.ts (929 lines) — translation lint rules - icons.ts (304 lines) — icon sheet lint rules - metadata.ts (242 lines) — metadata lint rules - shared.ts (971 lines) — shared helpers, colors, whitespace - strictMetrics.ts (462 lines) — strict metric checks - htmlValidation.ts (332 lines) — HTML/dialog validation - svgValidation.ts (84 lines) — inline SVG size validation Also updated dialog.ts reference path from ./lint.ts to ./lint/htmlValidation.ts. GAS global scope preserved: no import/export statements added. Closes #34
Apply scoped logger migration to the split lint module files. Replaces console.log/warn/error/time with getScopedLogger() calls across 6 files (73 replacements total). Test functions intentionally preserved. This makes PR #43 (fix/35-lint-scoped-logger) redundant since the logger migration is now included in the lint split.
6078f09 to
328ebbb
Compare
- translations.ts: guard getRange against translationRowCount=1 crash when sourceRowCount>1 (would throw invalid dimensions error) - categories.ts: use case-insensitive comparison for duplicate category ID detection, matching details.ts behavior (was case-sensitive)
Boots the concatenated TypeScript sources in a vm context and runs onOpen() to catch Apps Script's alphabetical file-load-order bugs (the class the previous commit's fallback-language and field-type fixes were papering over). Wired into the plugin CI workflow. Also updates context docs to reflect the src/lint.ts -> src/lint/ module split and refreshes the generated version banner.
checkDuplicateCategoryIds() lowercased IDs before comparing, so valid distinct IDs like "Foo" and "foo" were flagged as hard-error duplicates. The package writer (package/src/writer.js) dedupes categories with an exact-case Map and SAFE_ID_REGEX permits mixed case, so those are two legitimate, non-colliding IDs. Switch to exact-case duplicate detection (error) and demote case-only collisions to a non-blocking warning. Unlike categories, field IDs genuinely are looked up case-insensitively elsewhere in the builder (payloadBuilder.ts's fieldNameToId map), so checkDuplicateDetailIds() is intentionally left untouched. test(ci): run lint parity tests in CI, gate deploy on Plugin checks - Extract the GAS-boot vm harness (mock APIs, file collection, transpile) out of check-gas-boot.cjs into gasSimHarness.cjs so it can be reused. - Add check-lint-parity.cjs, which boots the full source tree (including src/test/, unlike the boot probe) and runs runLintParityTests(). Wire it into the Plugin workflow as `test:lint-parity`. This was previously only runnable manually from the Apps Script editor, so it never ran in CI — exactly how the category ID bug above went uncaught. - Fix two stale assertions in testLint.ts uncovered by actually running the suite: a severity check expecting "warning" where production now (and correctly) emits "error", and a duplicate-primaryLanguage message substring that didn't match current wording. Both were drift from the message/severity text changing without the test being updated. - Gate deploy.yml on the Plugin workflow succeeding via workflow_run instead of triggering independently on the same push, so clasp push can no longer race ahead of failing or in-progress checks. Pin checkout to workflow_run's head_sha since it doesn't default to the triggering commit.
github.ref resolves to the repo's default branch (main) on workflow_run events, not the branch that triggered the upstream Plugin run. The Deploy Script step's `github.ref == 'refs/heads/main'` guard (added in the previous commit's workflow_run gating fix) would therefore evaluate true for a develop-branch Plugin run too, running clasp deploy where only clasp push was intended. Check event.workflow_run.head_branch for that event type instead; github.ref stays reliable for workflow_dispatch and release, which aren't affected. Found by a second gpt-5.6-sol Codex readiness pass on commit 33c94dc, verified against GitHub's documented workflow_run context behavior before applying.
workflow_run runs in the base repo's privileged context (full CLASP secrets) regardless of what triggered the upstream Plugin run, and the branches: [main, develop] filter matches on head_branch — which a fork can set by simply naming its own branch "main" or "develop". Without further checks, a pull_request-triggered Plugin run from such a fork branch would satisfy the gate and let deploy check out and `clasp deploy` attacker-controlled code using this repo's secrets (the classic GitHub Actions "pwn request" pattern). Require the upstream run's underlying event to be 'push' and its head repository to match this repository, closing both the fork-PR path and the branch-name-spoofing path. workflow_dispatch and release triggers are unaffected (no workflow_run context to check). Found by a fourth gpt-5.6-sol Codex readiness pass on commit 6dd881f; verified as a real, well-documented risk class (GitHub Security Lab's "pwn request" writeup, GitHub's secure-use docs) before applying.
Problem
src/lint.tswas 4878 lines — a monolith handling all linting concerns. Hard to navigate, high merge conflict risk, difficult to review.Changes
Pure file reorganization. No behavior changes. Split into
src/lint/directory:index.tslintAllSheets(),lintSheet()categories.tsdetails.tstranslations.tsicons.tsmetadata.tsshared.tsstrictMetrics.tshtmlValidation.tssvgValidation.tsGAS compatibility
import/exportstatements (GAS global scope)dialog.tsreference path to./lint/htmlValidation.tsCloses #34
Greptile Summary
This PR splits the lint monolith into focused Google Apps Script modules. The main changes are:
src/lint/.Confidence Score: 5/5
This looks safe to merge.
This looks safe to merge.
What T-Rex did
Important Files Changed
Reviews (12): Last reviewed commit: "chore: refresh version banner" | Re-trigger Greptile