chore(all): Replace exceljs with write-excel-file - #2628
Conversation
- accessibility-checker: mocha test calling ACReporterXLSX.generateSummary() directly (no rule server needed); validates all 5 sheets and key cells - vitest-accessibility-checker: parallel Node forks test using same approach; vitest.node.config.mjs replaces the .js version (poolOptions removed for v4) - cypress-accessibility-checker: Cypress e2e test + adm-zip tasks in cypress.config.js; adds outputFilenameTimestamp: false to .achecker.yml Fix XLSX XML parser helpers in all three tests: - Sheet name lookup: extract r:id and name attrs independently (write-excel-file emits r:id before name, opposite of the old regex assumption) - Cell parsing: use attribute-order-independent regex that handles both self-closing <c .../> and full <c ...>...</c> forms; index rows by actual Excel row number (sparse array) so merged/skipped rows don't shift indices CI (test.yml): add mocha XLSX + vitest test:node steps to both Linux and Windows basic jobs; add npm install write-excel-file before each step
counts.elements can be 0 (or undefined) when a page has no elements to check. Dividing by zero produces NaN which write-excel-file writes as <v>NaN</v> — illegal OOXML that triggers Excel's corruption-repair dialog. Guard both percentage columns: return 0 when counts.elements is 0.
…n missing file - test.yml: add 'npm install write-excel-file' step for cypress-accessibility-checker (peerDependencies are not auto-installed by npm install) - cypress.config.js: guard readXlsxCell and xlsxSheetExists tasks against missing file so tests fail with a clear message instead of ADM-ZIP crash
achecker-xlsx.test.js imports ACReporterXLSX (CJS) and adm-zip — both Node-only. The default include pattern was picking it up in the Chromium browser run causing 'does not provide an export named ACReporterXLSX'. Explicitly exclude it from vitest.config.js; it runs separately via vitest.node.config.mjs (pool: forks).
… packages peerDependencies are not auto-installed by npm install, causing 'write-excel-file is not installed' warnings in CI for cypress and vitest. Move write-excel-file to regular dependencies in: - accessibility-checker - cypress-accessibility-checker - vitest-accessibility-checker Remove the now-redundant explicit 'npm install write-excel-file' CI steps.
…EADMEs Move write-excel-file (and adm-zip in common/module) from peerDependencies to regular dependencies in all remaining packages: - common/module - accessibility-checker/src (published package manifest) - vitest-accessibility-checker/src (published package manifest) - karma-accessibility-checker Update all four READMEs to remove the 'Optional: XLSX Report Format' install instructions — XLSX is now included automatically.
| "cypress": "^13.2.0 || ^15" | ||
| }, | ||
| "devDependencies": { | ||
| "adm-zip": "^0.5.9", |
There was a problem hiding this comment.
@tombrunet I have not explored cypress and karma package in detail, but should adm-zip be in direct dependencies, if we are generating report similar to extension, not sure about this though.
I used bob to check where it is used it gave back following result
karma-accessibility-checker — adm-zip is used only inside ACReporterXLSX.js at line 160. That file ships in the published package and runs when a user generates a report. adm-zip must be in dependencies. There are no test files in this package that use it independently.
cypress-accessibility-checker — adm-zip is used in two places:
src/lib/common/report/ACReporterXLSX.js — runtime report generation → needs dependencies
test/cypress.config.js — reading XLSX cells during tests → needs devDependencies
There was a problem hiding this comment.
Good catch. I think this is a leftover. It was originally a peer dependency because of the security vulnerabilities but we can move them now to regular dependencies
Summary
Replace the peer dependency (unmaintained) with across all packages. The XLSX report output is functionally equivalent — same five sheets, same column widths, same colour coding and cell styling.
Motivation
exceljshas not received meaningful maintenance. Switching towrite-excel-fileremoves the dependency on an unmaintained library and eliminates the'use strict'patching workaround that was required in the browser extension'spreprocess.js.Changes
Core logic —
common/module/src/report/ACReporterXLSX.tswrite-excel-file's data-array model.{ data, sheet, columns }object; all sheets are passed towriteExcelFile(sheets).toFile(filename)in one call."FF403151") to standard 6-digit hex ("#403151").write-excel-file/node; warning message updated accordingly.worksheet.commit()/workbook.commit()calls removed (not needed by the new library).Extension —
accessibility-checker-extension/package.json: replacedexceljsdirect dependency withwrite-excel-file.preprocess.js: removed thesedcommands that stripped'use strict'from the exceljs bundle (no longer needed).jest.config.js: removed stale comment referencing exceljs.E2E test helper —
accessibility-checker-extension/test/support/steps/steps_excel.ts: replacedexceljsWorkbookreader withread-excel-file/node; updated cell-address parsing to use the library's row/column array model.package.json: replacedexceljswithread-excel-file.package.jsonpeer / direct dependency updatesAll packages that declared
exceljsas a peer or direct dependency have been updated to declarewrite-excel-file@^4.1.1instead:accessibility-checker/package.jsonaccessibility-checker/src/package.jsoncypress-accessibility-checker/package.json+package/package.jsonvitest-accessibility-checker/package.json+src/package.json+package/package.jsonkarma-accessibility-checker/package.jsoncommon/module/package.jsonPre-built JS artefacts regenerated
All committed copies of
ACReporterXLSX.js(CJS + MJS outputs acrossaccessibility-checker,cypress-accessibility-checker,vitest-accessibility-checker,karma-accessibility-checker) were rebuilt from the new TypeScript source and committed.Testing checklist
XLSX report output (accessibility-checker Node.js)
accessibility-checkeragainst a page with violations and confirm a.xlsxfile is written to disk.#403151), summary counts (Violations / Needs review / Recommendations / Archived) are correct, and column widths are reasonable.outputFilenameTimestamp: falseand confirm the output file is namedresults.xlsx(not timestamped).write-excel-fileis not installed the warning"Warning: write-excel-file is not installed…"is printed and the process does not crash.Browser extension (accessibility-checker-extension)
npm run build:dev) — confirm it compiles without errors (no exceljs webpack error or'use strict'conflict).preprocess.jsno longer modifies anynode_modulesfiles on build.E2E tests (accessibility-checker-extension/test)
npm testinaccessibility-checker-extension/test— the Cucumber stepExcel Sheet "…" Cell "…" is "…"should pass usingread-excel-file.Downstream packages
cypress-accessibility-checker: runnpm run testand confirm XLSX output is produced correctly.vitest-accessibility-checker: runnpm run testand confirm XLSX output is produced correctly.karma-accessibility-checker: runnpm run buildwith no errors.