Conversation
Add politicalContext, policyImplications, keyTakeaways, thematicAnalysis, legislativePipeline, oppositionStrategy, coalitionDynamics, whatThisMeans, whyItMatters, committeeBreakdown, propsBreakdown, motionsBreakdown to the newKeys array to ensure comprehensive validation across all 14 languages. Co-authored-by: pethers <[email protected]>
Co-authored-by: pethers <[email protected]>
…adata coverage - Add explicit switch cases for month-ahead, weekly-review, monthly-review, breaking - Enhance generateGenericContent with key takeaways and policy significance sections - Add generateMetadata coverage for weekly-review, monthly-review, month-ahead, breaking - Add 8 new tests for enhanced generic content, metadata, and multi-language support Co-authored-by: pethers <[email protected]>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
Co-authored-by: pethers <[email protected]>
- Fix 2 TypeScript errors (MockArticlePayload missing organ in documents type) - Fix 26 ESLint warnings (unused variables/args/catch bindings) - Add caughtErrorsIgnorePattern to ESLint config - Fix 34 HTMLHint errors (unclosed spans, unescaped special chars) - Remove unused path import from vite.config.js Co-authored-by: pethers <[email protected]>
The original file contains only a JSDoc documentation block with no executable code, so the TypeScript version is identical. Co-authored-by: Copilot <[email protected]>
Add TypeScript version of the CIA schema validator script with: - Proper type annotations for all variables, parameters, and return types - ValidationResult and ValidationReport interfaces - ESM imports using node: protocol - unknown catch bindings with proper casting - Class property declarations - Strict mode compatible annotations Co-authored-by: Copilot <[email protected]>
… code lines) Co-authored-by: pethers <[email protected]>
Add scripts/validate-translations.ts with: - Interfaces for ColorCodes, LanguageConfig, ValidationSuccess, ValidationError, ValidationResult, and ValidationChecks - Proper type annotations for all variables, parameters, return types - Discriminated union type for validation results - unknown catch binding with (error as Error).message cast - ESM import syntax preserved - Strict TypeScript compliance verified Co-authored-by: Copilot <[email protected]>
Add scripts/sync-cia-schemas.ts with full type annotations, interfaces for data structures, proper error handling with unknown catch bindings, and node: protocol imports. Original .js file is preserved. Co-authored-by: Copilot <[email protected]>
Add TypeScript version with: - Interfaces for SchemaHashResult, SchemaUpdate, SchemaError, UpdateReport - Typed class properties with access modifiers - Proper return type annotations on all methods - unknown catch bindings with (error as Error).message - ESM imports from node: protocol - readonly modifier on CIA_SCHEMAS array Co-authored-by: Copilot <[email protected]>
Add TypeScript version with: - Proper type annotations for all variables, parameters, return types - ESM import syntax with node: protocol - Interfaces for FailedGeneration and GenerationResults - Class property declarations with access modifiers - unknown error catch bindings with (error as Error).message casts - Strict mode compatible Co-authored-by: Copilot <[email protected]>
Add TypeScript version with: - Interfaces for ViewportSize, ValidationConfig, ScreenshotInfo, ValidationCheckResult, ArticleValidationResult, ValidationSummary, ValidationResults, and AccessibilityNode - Full type annotations on all variables, parameters, and return types - ESM imports from node: protocol - Typed Playwright imports (Browser, Page) - unknown catch bindings with (error as Error).message casts - Record<string, ScreenshotInfo[]> for grouped screenshots Original .js file preserved. Co-authored-by: Copilot <[email protected]>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
There was a problem hiding this comment.
Pull request overview
This pull request migrates JavaScript files in the scripts/ directory to TypeScript and resolves all static analysis errors across ESLint (26→0 warnings), TypeScript (2→0 errors), and HTMLHint (34→0 errors). The migration includes 9 scripts with comprehensive type annotations, while fixing HTML validation issues and updating configuration files.
Changes:
- Converted 9
scripts/*.jsfiles to TypeScript with full type safety (coalition-dashboard, committees-dashboard, validate-translations, validate-articles-playwright, validate-against-cia-schemas, sync-cia-schemas, check-cia-schema-updates, generate-types-from-cia-schemas, back-to-top) - Fixed ESLint warnings by prefixing unused variables with
_and addingcaughtErrorsIgnorePatternto eslint.config.js - Fixed TypeScript errors by adding missing
organproperty to MockArticlePayload.documents interface - Fixed 34 HTMLHint errors: closed unclosed
<span class="separator">tags across 26 news files, escaped HTML entities (>as>,"as") in meta attributes - Updated package.json scripts to use
npx tsxfor TypeScript execution - Removed empty
take-screenshot.js/.ts(159 lines JSDoc, 0 executable lines) - Extended data-transformers.ts to support new article types (month-ahead, weekly-review, monthly-review, breaking)
Reviewed changes
Copilot reviewed 58 out of 59 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| eslint.config.js | Added caughtErrorsIgnorePattern: '^_' to ignore caught errors prefixed with underscore |
| vitest.config.js | Updated coverage excludes to reference .ts extensions for migrated dashboard scripts |
| tsconfig.scripts.json | Updated excludes to reference .ts extensions for browser-loaded scripts |
| vite.config.js | Removed unused path import |
| package.json | Updated script commands to use npx tsx for TypeScript execution |
| scripts/*.ts (9 files) | Full TypeScript migration with comprehensive interface definitions and type annotations |
| tests/*.test.js | Fixed ESLint warnings by prefixing unused variables; added missing organ property to MockArticlePayload |
| news/*.html (26+ files) | Fixed unclosed <span> tags and escaped special characters in meta attributes |
| scripts/data-transformers.ts | Added support for month-ahead, weekly-review, monthly-review, breaking article types |
Comments suppressed due to low confidence (1)
scripts/validate-against-cia-schemas.ts:1
- The shebang line has been changed from
#!/usr/bin/env nodeto#!/usr/bin/env npx tsx. This change is inconsistent with the sync-cia-schemas.ts file (line 1) which still uses#!/usr/bin/env node.
For TypeScript files executed with tsx via package.json scripts (npx tsx scripts/...), the shebang should remain #!/usr/bin/env node for portability and convention. The tsx execution is already handled by the npm script commands in package.json. Using #!/usr/bin/env npx tsx in the shebang creates unnecessary indirection and may cause issues in environments where npx behaves differently.
| /** | ||
| * @module Infrastructure/Accessibility | ||
| * @category Infrastructure | ||
| * | ||
| * @title Back-to-Top Navigation Utility - Accessibility & User Experience | ||
| * | ||
| * @description | ||
| * Provides a "back to top" button that scrolls long-form political intelligence | ||
| * articles to the top with accessibility support (WCAG 2.1 AA). | ||
| * | ||
| * @author Hack23 AB (Accessibility & User Experience) | ||
| * @license Apache-2.0 | ||
| * @version 1.0.0 | ||
| * @since 2024-06-20 | ||
| */ | ||
| (function (): void { | ||
| 'use strict'; | ||
|
|
||
| const maybeButton: HTMLElement | null = document.getElementById('back-to-top'); | ||
|
|
||
| if (!maybeButton) return; | ||
|
|
||
| const backToTopButton: HTMLElement = maybeButton; | ||
|
|
||
| // Show/hide button based on scroll position | ||
| function toggleButtonVisibility(): void { | ||
| if (window.pageYOffset > 300) { | ||
| backToTopButton.classList.add('visible'); | ||
| } else { | ||
| backToTopButton.classList.remove('visible'); | ||
| } | ||
| } | ||
|
|
||
| // Scroll to top with accessibility support | ||
| function scrollToTop(): void { | ||
| // Check if user prefers reduced motion | ||
| const prefersReducedMotion: boolean = window.matchMedia('(prefers-reduced-motion: reduce)').matches; | ||
|
|
||
| window.scrollTo({ | ||
| top: 0, | ||
| behavior: prefersReducedMotion ? 'auto' : 'smooth' | ||
| }); | ||
| } | ||
|
|
||
| // Add event listeners | ||
| window.addEventListener('scroll', toggleButtonVisibility); | ||
| backToTopButton.addEventListener('click', scrollToTop); | ||
|
|
||
| // Initial check | ||
| toggleButtonVisibility(); | ||
| })(); |
There was a problem hiding this comment.
All news article HTML files (over 300 occurrences) still reference ../scripts/back-to-top.js, but this file has been migrated to TypeScript (.ts).
Browser-loaded TypeScript files need to be compiled to JavaScript before they can be referenced in HTML <script> tags. Either:
- The HTML files need to be updated to reference
back-to-top.jsafter build (if Vite compiles it), or - The TypeScript files need to remain as
.jsfor browser loading, or - A build step needs to compile
.tsbrowser scripts to.jsand output them with.jsextensions
Currently, the PR description states "HTML <script> refs to back-to-top.js in news articles need updating" as remaining work, confirming this is incomplete.
There was a problem hiding this comment.
Fixed in 52265f3. Updated all 399 news HTML files from <script src="../scripts/back-to-top.js"> to <script type="module" src="../scripts/back-to-top.ts"> — Vite handles .ts files natively in HTML when using type="module". Also updated article-template.ts so future generated articles use the correct reference.
vitest.config.js
Outdated
| 'scripts/sync-cia-schemas.js', | ||
| 'scripts/check-cia-schema-updates.js', | ||
| 'scripts/generate-types-from-cia-schemas.js', | ||
| 'scripts/generate-news-backport.js', | ||
| 'scripts/load-cia-stats.js', | ||
| 'scripts/update-stats-from-cia.js', | ||
| 'scripts/validate-against-cia-schemas.js', | ||
| 'scripts/validate-against-cia-schemas.ts', | ||
| // CLI validation script (not importable, uses process.exit) | ||
| 'scripts/validate-translations.js', |
There was a problem hiding this comment.
The vitest.config.js coverage excludes still reference .js extensions for files that have been migrated to TypeScript. Lines 70-72 and 78 should be updated to reflect the TypeScript migration:
scripts/sync-cia-schemas.js→scripts/sync-cia-schemas.tsscripts/check-cia-schema-updates.js→scripts/check-cia-schema-updates.tsscripts/generate-types-from-cia-schemas.js→scripts/generate-types-from-cia-schemas.tsscripts/validate-translations.js→scripts/validate-translations.ts
These files are still listed with .js extensions in the exclude patterns even though they've been converted to TypeScript.
There was a problem hiding this comment.
Fixed in 52265f3. Updated all 4 remaining .js coverage excludes to .ts: sync-cia-schemas, check-cia-schema-updates, generate-types-from-cia-schemas, and validate-translations.
| <p>Opposition motions speak directly to these swing segments. For Center voters uncomfortable with SD cooperation: preventive detention motions highlight civil liberties conflicts, positioning C as coalition's conscience. For SD soft supporters queasy about radicalism: procurement labor standards motions emphasize workers' rights, appealing to nationalist-but-not-fascist sentiments. For S-to-M defectors: corporate taxation motions remind former social democrats why they historically supported progressive economics. Each motion calibrated for specific persuasion target.</p> | ||
|
|
||
| <p>The parliamentary arithmetic projections show campaign's electoral stakes. Current seat distribution: S: 100, M: 68, SD: 73, C: 25, V: 24, KD: 19, MP: 18, L: 16 (343 contested seats; 6 adjustment seats allocated by national vote). September 2026 scenarios: Scenario A (Left bloc gains): S: 105, M: 65, SD: 70, C: 20, V: 26, KD: 18, MP: 20, L: 15 = Left majority (S+V+MP+C: 171 seats > 175 majority threshold). Scenario B (Tidö holds): S: 98, M: 70, SD: 75, C: 18, V: 22, KD: 20, MP: 16, L: 16 = Tidö maintains narrow majority (M+SD+KD+L: 181 seats). Scenario C (Hung parliament): S: 102, M: 68, SD: 72, C: 22, V: 24, KD: 19, MP: 18, L: 16 = No clear majority, extended coalition negotiations.</p> | ||
| <p>The parliamentary arithmetic projections show campaign's electoral stakes. Current seat distribution: S: 100, M: 68, SD: 73, C: 25, V: 24, KD: 19, MP: 18, L: 16 (343 contested seats; 6 adjustment seats allocated by national vote). September 2026 scenarios: Scenario A (Left bloc gains): S: 105, M: 65, SD: 70, C: 20, V: 26, KD: 18, MP: 20, L: 15 = Left majority (S+V+MP+C: 171 seats > 175 majority threshold). Scenario B (Tidö holds): S: 98, M: 70, SD: 75, C: 18, V: 22, KD: 20, MP: 16, L: 16 = Tidö maintains narrow majority (M+SD+KD+L: 181 seats). Scenario C (Hung parliament): S: 102, M: 68, SD: 72, C: 22, V: 24, KD: 19, MP: 18, L: 16 = No clear majority, extended coalition negotiations.</p> |
There was a problem hiding this comment.
The HTML entity escaping is correct here. The > character (greater-than) must be escaped as > in HTML meta attribute values. However, for consistency and readability, consider also escaping the comparison context: the sentence "171 seats > 175 majority threshold" is slightly confusing since 171 is not greater than 175. This appears to be a logic error in the content itself (not the HTML encoding).
The correct comparison should likely be checking if the sum exceeds some threshold, but the numbers don't support the stated "Left majority" claim since 171 < 175.
There was a problem hiding this comment.
Good catch on the logic error. Fixed in 52265f3 — changed "Left majority (S+V+MP+C: 171 seats > 175 majority threshold)" to "Left bloc short of majority (S+V+MP+C: 171 seats < 175 majority threshold)" since 171 is indeed less than 175.
|
@copilot apply changes based on the comments in this thread |
…ludes, content logic - Update 399 news HTML files: back-to-top.js → back-to-top.ts with type=module - Update article-template.ts to generate correct script reference - Fix vitest.config.js: update 4 remaining .js excludes to .ts - Fix content logic error: 171 seats < 175 threshold (was incorrectly >) Co-authored-by: pethers <[email protected]>
All three review comments addressed in
|
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
…t not installed) The script uses playwright which is not a project dependency. Exclude it from tsconfig.scripts.json, matching the pattern used for other browser- specific scripts (coalition-dashboard.ts, committees-dashboard.ts, back-to-top.ts). Co-authored-by: pethers <[email protected]>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
…narrowing - Exclude validate-articles-playwright.ts from tsconfig.typedoc.json (playwright not a dependency) - Fix type narrowing in validate-translations.ts:405 (use `as` cast after error check) Co-authored-by: pethers <[email protected]>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
CI failing on typedoc TS errors (
playwrightmodule not found, discriminated union narrowing), 26 ESLint warnings, 34 HTMLHint errors, and 2 tsc errors. Also migrates remaining JS scripts to TypeScript for codebase consistency.Static analysis fixes
_, addcaughtErrorsIgnorePattern: '^_'to configorgantoMockArticlePayload.documentstest fixture<span class="separator">in 26 news files, escape>and"in meta attributesvalidate-articles-playwright.tsfrom typedoc tsconfig (playwright not a dep), fixValidationSuccessnarrowing with explicit castTypeScript migration
Converted 9
scripts/*.js→.tswith full type annotations:coalition-dashboardPartyNode extends d3.SimulationNodeDatum,CoalitionLinkcommittees-dashboardCommitteeData,NetworkNode,HeatMapCellvalidate-against-cia-schemasValidationResult,ValidationReportvalidate-translationsValidationChecks, discriminated unionValidationResultsync-cia-schemasSyncResults,SchemaVersionEntryback-to-topDeleted empty
take-screenshot.js/.ts(159 lines JSDoc, 0 executable code). Updatedpackage.jsontotsx, excluded browser scripts fromtsconfig.scripts.jsonandtsconfig.typedoc.json.Article generation improvements
generateArticleContentswitch cases formonth-ahead,weekly-review,monthly-review,breaking(previously fell to default)generateGenericContentwith key takeaways and policy significance sectionsgenerateMetadatato all 8 article typesReference updates
<script>refs:back-to-top.js→back-to-top.tswithtype="module"article-template.tsfor future article generationvitest.config.jscoverage excludes.js→.ts💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.