gbu-accessibility-package 3.4.0 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,75 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.8.0] - 2025-10-03
9
+
10
+ ### Added
11
+ - **Separated Link and Resource Checking**: Split link validation into individual specialized functions
12
+ - `--broken-links`: Check only external HTTP/HTTPS links for 404, 500, timeout errors
13
+ - `--404-resources`: Check only local resources (images, CSS, JS, etc.) for missing files
14
+ - `--links-check`: Comprehensive mode checking both external links and local resources
15
+ - **Enhanced Link Validation**: Improved external link checking with better error handling
16
+ - **Resource Path Validation**: Better detection of missing local files with relative/absolute path support
17
+ - **Individual Command Scripts**: Added npm scripts for `broken-links` and `404-resources`
18
+
19
+ ### Enhanced
20
+ - **CLI Options**: Added new command-line options for granular link/resource checking
21
+ - **Mode-Based Analysis**: Intelligent filtering based on external vs local resource types
22
+ - **Error Messages**: More specific error messages for different types of link/resource issues
23
+ - **Documentation**: Updated README.md and README-vi.md with new separated features
24
+
25
+ ### Fixed
26
+ - **Duplicate Method Issues**: Resolved conflicts from duplicate `checkBrokenLinks` methods
27
+ - **CLI Parsing Logic**: Fixed individual mode detection for new options
28
+ - **Mode Parameter Passing**: Proper mode parameter handling in analysis methods
29
+
30
+ ### Improved
31
+ - **Performance**: Faster processing by checking only relevant resource types per mode
32
+ - **User Experience**: Clearer separation of concerns for different validation needs
33
+ - **Backward Compatibility**: Maintained `--links-check` for comprehensive checking
34
+
35
+ ## [3.6.0] - 2025-01-08
36
+
37
+ ### Added
38
+ - **Advanced Heading Structure Rules**: Enhanced heading structure validation with strict rules
39
+ - Only one `<h1>` element per page (converts extra h1 to h2)
40
+ - Proper heading hierarchy without level skipping (h2 → h3 → h4...)
41
+ - No duplicate headings in the same section/block
42
+ - Automatic empty heading text generation based on context
43
+ - **Section-Aware Duplicate Detection**: Detects duplicate headings within the same section context
44
+ - **Context-Based Text Generation**: Generates meaningful text for empty headings using surrounding content
45
+ - **Comprehensive Heading Analysis**: Detailed analysis of heading structure issues with specific suggestions
46
+
47
+ ### Enhanced
48
+ - **Heading Auto-Fix Logic**: More intelligent heading level corrections
49
+ - **Section Context Detection**: Better detection of section boundaries for duplicate checking
50
+ - **Error Reporting**: More detailed heading issue descriptions and suggestions
51
+
52
+ ### Fixed
53
+ - **Heading Level Skipping**: Automatic correction of improper heading hierarchies
54
+ - **Multiple H1 Elements**: Converts extra h1 elements to appropriate levels
55
+ - **Empty Headings**: Fills empty headings with contextually relevant text
56
+ - **Duplicate Headings**: Makes duplicate headings unique within sections
57
+
58
+ ## [3.5.0] - 2025-01-08
59
+
60
+ ### Added
61
+ - **Enhanced Heading Structure Auto-Fix**: Automatic fixing of heading hierarchy issues with `--auto-fix-headings` option
62
+ - **Improved Nested Controls Detection**: Better detection and fixing of nested interactive controls
63
+ - **Advanced Test Cases**: New comprehensive test files for heading structure and nested controls
64
+ - **Enhanced Alt Text Quality**: Improved context-aware alt text generation with better vocabulary support
65
+
66
+ ### Enhanced
67
+ - **Heading Analysis**: More comprehensive detection of heading issues including empty headings, level skipping, and duplicates
68
+ - **Interactive Controls**: Better handling of complex nested control scenarios
69
+ - **Test Coverage**: Expanded demo files for better testing and validation
70
+ - **Performance**: Optimized processing for large files and complex HTML structures
71
+
72
+ ### Fixed
73
+ - **Heading Level Corrections**: Automatic correction of improper heading hierarchies
74
+ - **Empty Heading Detection**: Better identification and handling of empty headings
75
+ - **Control Nesting Issues**: Improved resolution of nested interactive control conflicts
76
+
8
77
  ## [3.2.0] - 2024-07-28
9
78
 
10
79
  ### Added
package/README-vi.md CHANGED
@@ -18,8 +18,13 @@
18
18
  - 🔘 **Button Names** - Sửa buttons rỗng và input buttons không có tên
19
19
  - 🔗 **Link Names** - Sửa links rỗng và phát hiện text generic
20
20
  - 🏛️ **Landmarks** - Thêm main và navigation landmarks thiếu
21
- - 📑 **Phân tích Heading** - Phân tích cấu trúc heading với gợi ý (không tự động sửa)
22
- - 🔍 **Broken Links Detection** - Phát hiện liên kết bị hỏng tài nguyên 404
21
+ - 📑 **Phân tích và Sửa Heading** - Phân tích cấu trúc heading với tùy chọn tự động sửa `--auto-fix-headings`
22
+ - 🎯 **Nested Controls Detection** - Phát hiện sửa các control tương tác lồng nhau
23
+ - 🔍 **Broken Links Detection** - Phát hiện liên kết external bị hỏng
24
+ - 📁 **404 Resources Detection** - Phát hiện tài nguyên local bị thiếu (hình ảnh, CSS, JS, v.v.)
25
+ - 🗂️ **Unused Files Detection** - Tìm file không được tham chiếu ở đâu trong dự án
26
+ - ☠️ **Dead Code Analysis** - Phát hiện CSS rules và JavaScript functions không sử dụng
27
+ - 📏 **File Size Analysis** - Kiểm tra dung lượng file và đề xuất tối ưu hóa
23
28
  - 🧹 **Dọn dẹp Duplicate** - Loại bỏ role attributes trùng lặp
24
29
 
25
30
  ### 🚀 **Tính năng Enhanced Alt Attribute (Đã tích hợp!)**
@@ -148,8 +153,14 @@ Chế độ sửa lỗi:
148
153
  --buttons-only Sửa button names + dọn dẹp
149
154
  --links-only Sửa link names + dọn dẹp
150
155
  --landmarks-only Sửa landmarks + dọn dẹp
151
- --headings-only Phân tích cấu trúc heading (không tự động sửa)
152
- --links-check Kiểm tra liên kết bị hỏng và tài nguyên 404
156
+ --headings-only Phân tích cấu trúc heading với tùy chọn tự động sửa
157
+ --auto-fix-headings Bật tự động sửa lỗi heading structure
158
+ --links-check Kiểm tra liên kết bị hỏng và tài nguyên 404 (toàn diện, không tự động sửa)
159
+ --broken-links Chỉ kiểm tra liên kết external bị hỏng (không tự động sửa)
160
+ --404-resources Chỉ kiểm tra tài nguyên local bị thiếu (không tự động sửa)
161
+ --unused-files Kiểm tra file không sử dụng trong dự án
162
+ --dead-code Kiểm tra dead code trong CSS và JavaScript
163
+ --file-size, --size-check Kiểm tra dung lượng file và đề xuất tối ưu hóa
153
164
  --cleanup-only Chỉ dọn dẹp role attributes trùng lặp
154
165
 
155
166
  Tùy chọn Enhanced Alt:
@@ -178,7 +189,14 @@ gbu-a11y -l en ./public
178
189
  gbu-a11y --alt-only # Sửa alt attributes + dọn dẹp
179
190
  gbu-a11y --forms-only # Sửa form labels + dọn dẹp
180
191
  gbu-a11y --buttons-only # Sửa button names + dọn dẹp
181
- gbu-a11y --links-check # Kiểm tra liên kết bị hỏng + dọn dẹp
192
+ gbu-a11y --headings-only # Phân tích heading structure
193
+ gbu-a11y --headings-only --auto-fix-headings # Tự động sửa heading structure
194
+ gbu-a11y --links-check # Kiểm tra liên kết bị hỏng và tài nguyên thiếu + dọn dẹp
195
+ gbu-a11y --broken-links # Chỉ kiểm tra liên kết external bị hỏng + dọn dẹp
196
+ gbu-a11y --404-resources # Chỉ kiểm tra tài nguyên local bị thiếu + dọn dẹp
197
+ gbu-a11y --unused-files # Kiểm tra file không sử dụng trong dự án
198
+ gbu-a11y --dead-code # Kiểm tra dead CSS và JavaScript code
199
+ gbu-a11y --file-size # Kiểm tra dung lượng file và đề xuất tối ưu hóa
182
200
 
183
201
  # Tính năng enhanced alt attribute
184
202
  gbu-a11y --enhanced-alt # Chế độ enhanced cơ bản
@@ -279,6 +297,15 @@ await fixer.fixEmptyAltAttributes("./src");
279
297
  // Không cần import thêm class riêng biệt
280
298
  const results = await fixer.fixAllAccessibilityIssues("./src");
281
299
  console.log("Hoàn thành sửa lỗi với enhanced features:", results);
300
+
301
+ // Mới: Kiểm tra file không sử dụng
302
+ await fixer.checkUnusedFiles('./src');
303
+
304
+ // Mới: Kiểm tra dead code
305
+ await fixer.checkDeadCode('./src');
306
+
307
+ // Mới: Kiểm tra dung lượng file
308
+ await fixer.checkFileSizes('./src');
282
309
  ```
283
310
 
284
311
  ## 🎯 Những gì được sửa
@@ -308,15 +335,41 @@ console.log("Hoàn thành sửa lỗi với enhanced features:", results);
308
335
 
309
336
  - **Lang attributes thiếu** → Phát hiện ngôn ngữ tự động
310
337
  - **Landmark thiếu** → Main và navigation landmarks
311
- - **Cấu trúc heading** → Phân tích và khuyến nghị
338
+ - **Cấu trúc heading** → Phân tích và tự động sửa với `--auto-fix-headings`
339
+ - Sửa multiple h1 elements
340
+ - Sửa heading level skipping (h2 → h4)
341
+ - Thêm text cho empty headings
342
+ - Sửa duplicate headings
343
+ - **Nested interactive controls** → Phát hiện và sửa controls lồng nhau
312
344
  - **Role attributes** → Gán role tuân thủ WCAG
313
345
 
314
346
  ### Kiểm tra liên kết
315
347
 
316
- - **Liên kết bị hỏng** → Phát hiện HTTP 404, 500, timeout
317
- - **Tài nguyên không tồn tại**Kiểm tra file local thiếu
318
- - **URL không hợp lệ** Phát hiện định dạng URL sai
319
- - **Liên kết chậm** Cảnh báo timeoutphản hồi chậm
348
+ - **Liên kết External bị hỏng** → Phát hiện HTTP 404, 500, timeout trên URL external
349
+ - URL không hợp lệPhát hiện định dạng URL sai
350
+ - Liên kết chậmCảnh báo timeout phản hồi chậm
351
+ - Lỗi mạngKết nối thất bại host không thể tiếp cận
352
+ - **Tài nguyên 404 bị thiếu** → Kiểm tra file local bị thiếu
353
+ - Hình ảnh (img src), file CSS (link href), file JavaScript (script src)
354
+ - Video/audio sources, tài nguyên local khác
355
+ - Kiểm tra đường dẫn relative và absolute
356
+
357
+ ### Tối ưu hóa dự án
358
+
359
+ - **File không sử dụng** → Phát hiện file không được tham chiếu ở đâu trong dự án
360
+ - Hình ảnh, CSS, JavaScript, HTML files
361
+ - Phân tích tham chiếu file local
362
+ - Phát hiện heuristic với khuyến nghị xem xét thủ công
363
+ - **Phân tích Dead Code** → Tìm CSS rules và JavaScript functions không sử dụng
364
+ - CSS selectors không được sử dụng trong HTML
365
+ - JavaScript functions không bao giờ được gọi
366
+ - Variables được khai báo nhưng không sử dụng
367
+ - Smart skipping các patterns động
368
+ - **Phân tích dung lượng file** → Kiểm tra kích thước file và đề xuất tối ưu hóa
369
+ - Phát hiện file lớn vượt ngưỡng khuyến nghị
370
+ - Đề xuất tối ưu hóa theo từng loại file (hình ảnh, CSS, JS, v.v.)
371
+ - Thống kê dung lượng theo loại file
372
+ - Top 10 file có dung lượng lớn nhất
320
373
 
321
374
  ## 🔧 Quản lý Package
322
375
 
package/README.md CHANGED
@@ -17,8 +17,13 @@
17
17
  - 🔘 **Button Names** - Fix empty buttons and input buttons without names
18
18
  - 🔗 **Link Names** - Fix empty links and detect generic link text
19
19
  - 🏛️ **Landmarks** - Add missing main and navigation landmarks
20
- - 📑 **Heading Analysis** - Analyze heading structure with suggestions (no auto-fix)
21
- - 🔍 **Broken Links Detection** - Detect broken links and 404 resources
20
+ - 📑 **Heading Analysis & Auto-Fix** - Analyze heading structure with optional auto-fix using `--auto-fix-headings`
21
+ - 🎯 **Nested Controls Detection** - Detect and fix nested interactive controls
22
+ - 🔍 **Broken Links Detection** - Detect broken external links
23
+ - 📁 **404 Resources Detection** - Detect missing local resources (images, CSS, JS, etc.)
24
+ - 🗂️ **Unused Files Detection** - Find files not referenced anywhere in the project
25
+ - ☠️ **Dead Code Analysis** - Detect unused CSS rules and JavaScript functions
26
+ - 📏 **File Size Analysis** - Check file sizes and suggest optimizations
22
27
  - 🧹 **Duplicate Cleanup** - Remove duplicate role attributes
23
28
 
24
29
  ### 🚀 **Enhanced Alt Attribute Features (Integrated!)**
@@ -145,8 +150,14 @@ Fix Modes:
145
150
  --buttons-only Fix button names + cleanup
146
151
  --links-only Fix link names + cleanup
147
152
  --landmarks-only Fix landmarks + cleanup
148
- --headings-only Analyze heading structure (no auto-fix)
149
- --links-check Check for broken links and 404 resources
153
+ --headings-only Analyze heading structure with optional auto-fix
154
+ --auto-fix-headings Enable automatic heading structure fixes
155
+ --links-check Check for broken links and 404 resources (comprehensive, no auto-fix)
156
+ --broken-links Check for broken external links only (no auto-fix)
157
+ --404-resources Check for missing local resources only (no auto-fix)
158
+ --unused-files Check for unused files in project
159
+ --dead-code Check for dead code in CSS and JavaScript
160
+ --file-size, --size-check Check file sizes and suggest optimizations
150
161
  --cleanup-only Only cleanup duplicate role attributes
151
162
 
152
163
  Enhanced Alt Options:
@@ -175,7 +186,14 @@ gbu-a11y -l en ./public
175
186
  gbu-a11y --alt-only # Fix alt attributes + cleanup
176
187
  gbu-a11y --forms-only # Fix form labels + cleanup
177
188
  gbu-a11y --buttons-only # Fix button names + cleanup
178
- gbu-a11y --links-check # Check broken links + cleanup
189
+ gbu-a11y --headings-only # Analyze heading structure
190
+ gbu-a11y --headings-only --auto-fix-headings # Auto-fix heading structure
191
+ gbu-a11y --links-check # Check broken links and missing resources + cleanup
192
+ gbu-a11y --broken-links # Check broken external links only + cleanup
193
+ gbu-a11y --404-resources # Check missing local resources only + cleanup
194
+ gbu-a11y --unused-files # Check for unused files in project
195
+ gbu-a11y --dead-code # Check for dead CSS and JavaScript code
196
+ gbu-a11y --file-size # Check file sizes and suggest optimizations
179
197
 
180
198
  # Enhanced alt attribute features
181
199
  gbu-a11y --enhanced-alt # Basic enhanced mode
@@ -273,6 +291,15 @@ await fixer.fixEmptyAltAttributes('./src');
273
291
  // No need to import separate classes
274
292
  const results = await fixer.fixAllAccessibilityIssues('./src');
275
293
  console.log('Accessibility fixes completed with enhanced features:', results);
294
+
295
+ // New: Check for unused files
296
+ await fixer.checkUnusedFiles('./src');
297
+
298
+ // New: Check for dead code
299
+ await fixer.checkDeadCode('./src');
300
+
301
+ // New: Check file sizes
302
+ await fixer.checkFileSizes('./src');
276
303
  ```
277
304
 
278
305
  ## 🎯 What Gets Fixed
@@ -298,14 +325,39 @@ console.log('Accessibility fixes completed with enhanced features:', results);
298
325
  ### Document Structure
299
326
  - **Missing lang attributes** → Automatic language detection
300
327
  - **Missing landmarks** → Main and navigation landmarks
301
- - **Heading structure** → Analysis and recommendations
328
+ - **Heading structure** → Analysis and auto-fix with `--auto-fix-headings`
329
+ - Fix multiple h1 elements
330
+ - Fix heading level skipping (h2 → h4)
331
+ - Add text to empty headings
332
+ - Fix duplicate headings
333
+ - **Nested interactive controls** → Detect and fix nested controls
302
334
  - **Role attributes** → WCAG-compliant role assignments
303
335
 
304
336
  ### Link Validation
305
- - **Broken links** → Detect HTTP 404, 500, timeout errors
306
- - **Missing resources**Check for missing local files
307
- - **Invalid URLs**Detect malformed URL formats
308
- - **Slow links**Warn about timeouts and slow responses
337
+ - **Broken External Links** → Detect HTTP 404, 500, timeout errors on external URLs
338
+ - Invalid URLsDetect malformed URL formats
339
+ - Slow linksWarn about timeouts and slow responses
340
+ - Network errorsConnection failures and unreachable hosts
341
+ - **404 Missing Resources** → Check for missing local files
342
+ - Images (img src), CSS files (link href), JavaScript files (script src)
343
+ - Video/audio sources, other local assets
344
+ - Relative and absolute path checking
345
+
346
+ ### Project Optimization
347
+ - **Unused Files** → Detect files not referenced anywhere in the project
348
+ - Images, CSS, JavaScript, HTML files
349
+ - Local file references analysis
350
+ - Heuristic detection with manual review recommendations
351
+ - **Dead Code Analysis** → Find unused CSS rules and JavaScript functions
352
+ - CSS selectors not used in HTML
353
+ - JavaScript functions never called
354
+ - Variables declared but never used
355
+ - Smart skipping of dynamic patterns
356
+ - **File Size Analysis** → Check file sizes and suggest optimizations
357
+ - Detect large files exceeding recommended thresholds
358
+ - Type-specific optimization suggestions (images, CSS, JS, etc.)
359
+ - File size breakdown by type
360
+ - Top 10 largest files reporting
309
361
 
310
362
  ## 🔧 Package Management
311
363
 
package/cli.js CHANGED
@@ -28,12 +28,19 @@ const options = {
28
28
  linksOnly: false,
29
29
  landmarksOnly: false,
30
30
  headingsOnly: false,
31
+ dlOnly: false,
31
32
  brokenLinksOnly: false,
33
+ unusedFilesOnly: false,
34
+ deadCodeOnly: false,
35
+ fileSizeOnly: false,
32
36
  // Enhanced alt options
33
37
  enhancedAlt: false,
34
38
  altCreativity: 'balanced', // conservative, balanced, creative
35
39
  includeEmotions: false,
36
- strictAltChecking: false
40
+ strictAltChecking: false,
41
+ // Advanced features options
42
+ autoFixHeadings: false,
43
+ fixDescriptionLists: true
37
44
  };
38
45
 
39
46
  // Parse arguments
@@ -96,10 +103,35 @@ for (let i = 0; i < args.length; i++) {
96
103
  case '--headings-only':
97
104
  options.headingsOnly = true;
98
105
  break;
106
+ case '--dl-only':
107
+ options.dlOnly = true;
108
+ break;
99
109
  case '--links-check':
110
+ options.linksCheckOnly = true;
111
+ break;
100
112
  case '--broken-links':
101
113
  options.brokenLinksOnly = true;
102
114
  break;
115
+ case '--404-resources':
116
+ case '--missing-resources':
117
+ options.missingResourcesOnly = true;
118
+ break;
119
+ case '--unused-files':
120
+ options.unusedFilesOnly = true;
121
+ break;
122
+ case '--dead-code':
123
+ options.deadCodeOnly = true;
124
+ break;
125
+ case '--file-size':
126
+ case '--size-check':
127
+ options.fileSizeOnly = true;
128
+ break;
129
+ case '--auto-fix-headings':
130
+ options.autoFixHeadings = true;
131
+ break;
132
+ case '--no-fix-dl':
133
+ options.fixDescriptionLists = false;
134
+ break;
103
135
  case '--enhanced-alt':
104
136
  options.enhancedAlt = true;
105
137
  break;
@@ -143,6 +175,11 @@ Options:
143
175
  --landmarks-only Fix landmarks + cleanup
144
176
  --headings-only Analyze heading structure (no auto-fix)
145
177
  --links-check Check for broken links and 404 resources (no auto-fix)
178
+ --broken-links Check for broken external links only (no auto-fix)
179
+ --404-resources Check for missing local resources only (no auto-fix)
180
+ --unused-files Check for unused files in project (no auto-fix)
181
+ --dead-code Check for dead code in CSS and JavaScript (no auto-fix)
182
+ --file-size, --size-check Check file sizes and suggest optimizations (no auto-fix)
146
183
  --enhanced-alt Use enhanced alt attribute analysis and generation
147
184
  --alt-creativity <mode> Alt text creativity: conservative, balanced, creative (default: balanced)
148
185
  --include-emotions Include emotional descriptors in alt text
@@ -173,6 +210,11 @@ Examples:
173
210
  node cli.js --landmarks-only # Fix landmarks + cleanup
174
211
  node cli.js --headings-only # Analyze heading structure only
175
212
  node cli.js --links-check # Check for broken links and 404s
213
+ node cli.js --broken-links # Check for broken external links only
214
+ node cli.js --404-resources # Check for missing local resources only
215
+ node cli.js --unused-files # Check for unused files in project
216
+ node cli.js --dead-code # Check for dead CSS and JavaScript code
217
+ node cli.js --file-size # Check file sizes and suggest optimizations
176
218
  node cli.js --cleanup-only # Only cleanup duplicate roles
177
219
  node cli.js ./src # Fix src directory (comprehensive)
178
220
  node cli.js -l en --dry-run ./dist # Preview comprehensive fixes in English
@@ -225,14 +267,16 @@ async function main() {
225
267
  enhancedAltMode: options.enhancedAlt,
226
268
  altCreativity: options.altCreativity,
227
269
  includeEmotions: options.includeEmotions,
228
- strictAltChecking: options.strictAltChecking
270
+ strictAltChecking: options.strictAltChecking,
271
+ autoFixHeadings: options.autoFixHeadings,
272
+ fixDescriptionLists: options.fixDescriptionLists
229
273
  });
230
274
 
231
275
  try {
232
276
  // Handle different modes - All modes now include cleanup
233
277
  if (options.cleanupOnly || options.altOnly || options.langOnly || options.roleOnly ||
234
278
  options.formsOnly || options.nestedOnly || options.buttonsOnly || options.linksOnly || options.landmarksOnly ||
235
- options.headingsOnly || options.brokenLinksOnly) {
279
+ options.headingsOnly || options.dlOnly || options.linksCheckOnly || options.brokenLinksOnly || options.missingResourcesOnly || options.unusedFilesOnly || options.deadCodeOnly || options.fileSizeOnly) {
236
280
  // Individual modes - handle each separately, then run cleanup
237
281
  } else {
238
282
  // Default mode: Run comprehensive fix (all fixes including cleanup)
@@ -410,27 +454,120 @@ async function main() {
410
454
  return;
411
455
 
412
456
  } else if (options.headingsOnly) {
413
- // Analyze headings only (no fixes, no cleanup)
414
- console.log(chalk.blue('📑 Running heading analysis only...'));
415
- const headingResults = await fixer.analyzeHeadings(options.directory);
416
- const totalSuggestions = headingResults.reduce((sum, r) => sum + (r.issues || 0), 0);
457
+ // Fix heading structure + cleanup
458
+ console.log(chalk.blue('📑 Running heading structure fixes + cleanup...'));
459
+ const headingResults = await fixer.fixHeadingStructure(options.directory);
460
+ const headingFixed = headingResults.filter(r => r.status === 'fixed').length;
461
+ const totalHeadingIssues = headingResults.reduce((sum, r) => sum + (r.issues || 0), 0);
462
+ const totalHeadingFixes = headingResults.reduce((sum, r) => sum + (r.fixes || 0), 0);
463
+
464
+ console.log(chalk.green(`\n✅ Processed headings in ${headingResults.length} files (${totalHeadingIssues} issues found)`));
465
+ if (options.autoFixHeadings) {
466
+ console.log(chalk.green(`✅ Fixed ${totalHeadingFixes} heading issues automatically`));
467
+ } else {
468
+ console.log(chalk.gray('💡 Use --auto-fix-headings to enable automatic heading fixes'));
469
+ }
470
+
471
+ // Run cleanup
472
+ console.log(chalk.blue('\n🧹 Running cleanup for duplicate role attributes...'));
473
+ const cleanupResults = await fixer.cleanupDuplicateRoles(options.directory);
474
+ const cleanupFixed = cleanupResults.filter(r => r.status === 'fixed').length;
475
+ console.log(chalk.green(`✅ Cleaned duplicate roles in ${cleanupFixed} files`));
476
+
477
+ showCompletionMessage(options, 'Heading structure fixes + cleanup');
478
+ return;
479
+
480
+ } else if (options.dlOnly) {
481
+ // Fix description lists + cleanup
482
+ console.log(chalk.blue('📋 Running description list fixes + cleanup...'));
483
+ const dlResults = await fixer.fixDescriptionLists(options.directory);
484
+ const dlFixed = dlResults.filter(r => r.status === 'fixed').length;
485
+ const totalDlIssues = dlResults.reduce((sum, r) => sum + (r.issues || 0), 0);
486
+
487
+ console.log(chalk.green(`\n✅ Fixed description lists in ${dlFixed} files (${totalDlIssues} issues)`));
488
+
489
+ // Run cleanup
490
+ console.log(chalk.blue('\n🧹 Running cleanup for duplicate role attributes...'));
491
+ const cleanupResults = await fixer.cleanupDuplicateRoles(options.directory);
492
+ const cleanupFixed = cleanupResults.filter(r => r.status === 'fixed').length;
493
+ console.log(chalk.green(`✅ Cleaned duplicate roles in ${cleanupFixed} files`));
494
+
495
+ showCompletionMessage(options, 'Description list fixes + cleanup');
496
+ return;
497
+
498
+ } else if (options.linksCheckOnly) {
499
+ // Check broken links and 404 resources (backward compatibility)
500
+ console.log(chalk.blue('🔗 Running comprehensive links and resources check...'));
501
+ const linkResults = await fixer.checkBrokenLinks(options.directory);
502
+ const resourceResults = await fixer.check404Resources(options.directory);
503
+ const totalLinkIssues = linkResults.reduce((sum, r) => sum + (r.issues || 0), 0);
504
+ const totalResourceIssues = resourceResults.reduce((sum, r) => sum + (r.issues || 0), 0);
417
505
 
418
- console.log(chalk.green(`\n✅ Analyzed headings in ${headingResults.length} files (${totalSuggestions} suggestions)`));
419
- console.log(chalk.gray('💡 Heading issues require manual review and cannot be auto-fixed'));
506
+ console.log(chalk.green(`\n✅ Checked links in ${linkResults.length} files (${totalLinkIssues} link issues found)`));
507
+ console.log(chalk.green(`✅ Checked resources in ${resourceResults.length} files (${totalResourceIssues} resource issues found)`));
508
+ console.log(chalk.gray('💡 Link and resource issues require manual review and cannot be auto-fixed'));
420
509
 
421
- showCompletionMessage(options, 'Heading analysis');
510
+ showCompletionMessage(options, 'Links and resources check');
422
511
  return;
423
512
 
424
513
  } else if (options.brokenLinksOnly) {
425
- // Check broken links only (no fixes, no cleanup)
426
- console.log(chalk.blue('🔗 Running broken links check only...'));
514
+ // Check broken external links only
515
+ console.log(chalk.blue('🔗 Running broken external links check only...'));
427
516
  const linkResults = await fixer.checkBrokenLinks(options.directory);
428
517
  const totalBrokenLinks = linkResults.reduce((sum, r) => sum + (r.issues || 0), 0);
429
518
 
430
- console.log(chalk.green(`\n✅ Checked links in ${linkResults.length} files (${totalBrokenLinks} issues found)`));
519
+ console.log(chalk.green(`\n✅ Checked external links in ${linkResults.length} files (${totalBrokenLinks} issues found)`));
431
520
  console.log(chalk.gray('💡 Broken link issues require manual review and cannot be auto-fixed'));
432
521
 
433
- showCompletionMessage(options, 'Broken links check');
522
+ showCompletionMessage(options, 'Broken external links check');
523
+ return;
524
+
525
+ } else if (options.missingResourcesOnly) {
526
+ // Check 404 resources only (missing local files)
527
+ console.log(chalk.blue('📁 Running missing resources check only...'));
528
+ const resourceResults = await fixer.check404Resources(options.directory);
529
+ const totalMissingResources = resourceResults.reduce((sum, r) => sum + (r.issues || 0), 0);
530
+
531
+ console.log(chalk.green(`\n✅ Checked local resources in ${resourceResults.length} files (${totalMissingResources} issues found)`));
532
+ console.log(chalk.gray('💡 Missing resource issues require manual review and cannot be auto-fixed'));
533
+
534
+ showCompletionMessage(options, 'Missing resources check');
535
+ return;
536
+
537
+ } else if (options.unusedFilesOnly) {
538
+ // Check unused files only (no fixes, no cleanup)
539
+ console.log(chalk.blue('🗂️ Running unused files check only...'));
540
+ const unusedResults = await fixer.checkUnusedFiles(options.directory);
541
+ const totalUnusedFiles = unusedResults.length;
542
+
543
+ console.log(chalk.green(`\n✅ Checked project files (${totalUnusedFiles} unused files found)`));
544
+ console.log(chalk.gray('💡 Unused file detection is heuristic - manual review recommended'));
545
+
546
+ showCompletionMessage(options, 'Unused files check');
547
+ return;
548
+
549
+ } else if (options.deadCodeOnly) {
550
+ // Check dead code only (no fixes, no cleanup)
551
+ console.log(chalk.blue('☠️ Running dead code check only...'));
552
+ const deadCodeResults = await fixer.checkDeadCode(options.directory);
553
+ const totalDeadCode = deadCodeResults.length;
554
+
555
+ console.log(chalk.green(`\n✅ Checked for dead code (${totalDeadCode} potential issues found)`));
556
+ console.log(chalk.gray('💡 Dead code analysis is heuristic - manual review recommended'));
557
+
558
+ showCompletionMessage(options, 'Dead code check');
559
+ return;
560
+
561
+ } else if (options.fileSizeOnly) {
562
+ // Check file sizes only (no fixes, no cleanup)
563
+ console.log(chalk.blue('📏 Running file size analysis only...'));
564
+ const sizeResults = await fixer.checkFileSizes(options.directory);
565
+ const totalLargeFiles = sizeResults.largeFiles.length;
566
+
567
+ console.log(chalk.green(`\n✅ Analyzed ${sizeResults.totalFiles} files (${totalLargeFiles} large files found)`));
568
+ console.log(chalk.gray('💡 File size analysis is based on common best practices'));
569
+
570
+ showCompletionMessage(options, 'File size analysis');
434
571
  return;
435
572
  }
436
573
 
Binary file
@@ -1,5 +1,5 @@
1
1
  <!DOCTYPE html>
2
- <html>
2
+ <html lang="ja">
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
5
  <title>Advanced Accessibility Test</title>
@@ -9,22 +9,22 @@
9
9
 
10
10
  <!-- Form issues -->
11
11
  <form>
12
- <input type="text" placeholder="Name">
13
- <input type="email" id="email">
14
- <input type="password">
12
+ <input type="text" placeholder="Name" aria-label="Name" title="Name" id="text_019747">
13
+ <input type="email" id="email" aria-label="メールアドレス" title="メールアドレス">
14
+ <input type="password" aria-label="パスワード" title="パスワード" id="password_019747">
15
15
  <input type="submit">
16
16
  </form>
17
17
 
18
18
  <!-- Button issues -->
19
- <button></button>
20
- <button onclick="alert('test')"></button>
19
+ <button aria-label="ボタン" title="ボタン"></button>
20
+ <button onclick="alert('test')" role="button" aria-label="ボタン" title="ボタン"></button>
21
21
  <input type="button">
22
22
 
23
23
  <!-- Link issues -->
24
- <a href="/home"></a>
25
- <a href="/more">Click here</a>
26
- <a href="/read">Read more</a>
27
- <a href="/image"><img src="icon.png"></a>
24
+ <a href="/home" role="link" aria-label="リンク" title="リンク"></a>
25
+ <a href="/more" role="link">Click here</a>
26
+ <a href="/read" role="link">Read more</a>
27
+ <a href="/image" role="link" aria-label="リンク" title="リンク"><img src="icon.png" alt="Skipped h2" role="img" aria-label="Skipped h2"></a>
28
28
 
29
29
  <!-- Heading issues -->
30
30
  <h3>Skipped h2</h3>
@@ -36,9 +36,9 @@
36
36
  <p>Main content without landmark</p>
37
37
  </div>
38
38
 
39
- <ul class="navigation">
40
- <li><a href="/home">Home</a></li>
41
- <li><a href="/about">About</a></li>
39
+ <ul class="navigation" role="menubar">
40
+ <li><a href="/home" role="link">Home</a></li>
41
+ <li><a href="/about" role="link">About</a></li>
42
42
  </ul>
43
43
  </body>
44
44
  </html>
@@ -15,10 +15,10 @@
15
15
  <img src="test2.jpg" alt="Test image 2" aria-label="Custom label" role="img">
16
16
 
17
17
  <!-- Test case 3: Image with empty alt (should not add aria-label) -->
18
- <img src="test3.jpg" alt="" role="img">
18
+ <img src="test3.jpg" alt="Aria Label Test Cases" role="img" aria-label="Aria Label Test Cases">
19
19
 
20
20
  <!-- Test case 4: Image without alt (should generate alt and aria-label) -->
21
- <img src="logo.png" role="img">
21
+ <img src="logo.png" role="img" alt="ロゴ" aria-label="ロゴ">
22
22
 
23
23
  <!-- Test case 5: Picture with role and img with alt -->
24
24
  <picture>
@@ -12,30 +12,30 @@
12
12
  <h1>Broken Links Test</h1>
13
13
 
14
14
  <!-- Working local link -->
15
- <a href="advanced-test.html">Working local link</a>
15
+ <a href="advanced-test.html" role="link">Working local link</a>
16
16
 
17
17
  <!-- Broken local link -->
18
- <a href="non-existent-page.html">Broken local link</a>
18
+ <a href="non-existent-page.html" role="link">Broken local link</a>
19
19
 
20
20
  <!-- Working external link -->
21
- <a href="https://www.google.com">Working external link</a>
21
+ <a href="https://www.google.com" role="link">Working external link</a>
22
22
 
23
23
  <!-- Broken external link -->
24
- <a href="https://this-domain-does-not-exist-12345.com">Broken external link</a>
24
+ <a href="https://this-domain-does-not-exist-12345.com" role="link">Broken external link</a>
25
25
 
26
26
  <!-- Working image -->
27
- <img src="advanced-test.html" alt="Working image reference">
27
+ <img src="advanced-test.html" alt="Working image reference" role="img" aria-label="Working image reference">
28
28
 
29
29
  <!-- Broken image -->
30
- <img src="missing-image.jpg" alt="Broken image">
30
+ <img src="missing-image.jpg" alt="Broken image" role="img" aria-label="Broken image">
31
31
 
32
32
  <!-- Broken script -->
33
33
  <script src="missing-script.js"></script>
34
34
 
35
35
  <!-- Skip patterns -->
36
- <a href="#anchor">Anchor link (should skip)</a>
37
- <a href="mailto:test@example.com">Email link (should skip)</a>
38
- <a href="tel:+1234567890">Phone link (should skip)</a>
39
- <a href="javascript:void(0)">JavaScript link (should skip)</a>
36
+ <a href="#anchor" role="link">Anchor link (should skip)</a>
37
+ <a href="mailto:test@example.com" role="link">Email link (should skip)</a>
38
+ <a href="tel:+1234567890" role="link">Phone link (should skip)</a>
39
+ <a href="javascript:void(0)" role="link">JavaScript link (should skip)</a>
40
40
  </body>
41
41
  </html>