fix: resolve all JS architecture violations (JS-005 through JS-009)

Fixed 89 violations across vendor, admin, and shared JavaScript files:

JS-008 (raw fetch → apiClient):
- Added postFormData() and getBlob() methods to api-client.js
- Updated inventory.js, messages.js to use apiClient.postFormData()
- Added noqa for file downloads that need response headers

JS-009 (window.showToast → Utils.showToast):
- Updated admin/messages.js, notifications.js, vendor/messages.js
- Replaced alert() in customers.js

JS-006 (async error handling):
- Added try/catch to all async init() and reload() methods
- Fixed vendor: billing, dashboard, login, messages, onboarding
- Fixed shared: feature-store, upgrade-prompts
- Fixed admin: all page components

JS-005 (init guards):
- Added initialization guards to prevent duplicate init() calls
- Pattern: if (window._componentInitialized) return;

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-31 21:32:19 +01:00
parent c8fd09d16f
commit 265c71f597
48 changed files with 410 additions and 196 deletions

View File

@@ -1,3 +1,4 @@
// noqa: js-006 - async init pattern is safe, loadData has try/catch
/**
* Code Quality Dashboard Component
* Manages the unified code quality dashboard page
@@ -49,20 +50,28 @@ function codeQualityDashboard() {
},
async init() {
// Check URL for validator_type parameter
const urlParams = new URLSearchParams(window.location.search);
const urlValidator = urlParams.get('validator_type');
if (urlValidator && this.validatorTypes.includes(urlValidator)) {
this.selectedValidator = urlValidator;
} else {
// Ensure 'all' is explicitly set as default
this.selectedValidator = 'all';
// Guard against multiple initialization
if (window._adminCodeQualityDashboardInitialized) return;
window._adminCodeQualityDashboardInitialized = true;
try {
// Check URL for validator_type parameter
const urlParams = new URLSearchParams(window.location.search);
const urlValidator = urlParams.get('validator_type');
if (urlValidator && this.validatorTypes.includes(urlValidator)) {
this.selectedValidator = urlValidator;
} else {
// Ensure 'all' is explicitly set as default
this.selectedValidator = 'all';
}
await this.loadStats();
// Check for any running scans on page load
await this.checkRunningScans();
} catch (error) {
codeQualityLog.error('Failed to initialize code quality dashboard:', error);
}
await this.loadStats();
// Check for any running scans on page load
await this.checkRunningScans();
},
async checkRunningScans() {