gbu-accessibility-package 3.5.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 +50 -0
- package/README-vi.md +51 -7
- package/README.md +50 -7
- package/cli.js +97 -5
- package/demo/1mb-jpg-example-file.jpg +0 -0
- package/demo/advanced-test.html +13 -13
- package/demo/aria-label-test.html +2 -2
- package/demo/broken-links-test.html +10 -10
- package/demo/comprehensive-test.html +4 -4
- package/demo/dead-code-test.css +68 -0
- package/demo/dead-code-test.html +36 -0
- package/demo/dead-code-test.js +77 -0
- package/demo/duplicate-roles.html +15 -15
- package/demo/enhanced-alt-test.html +22 -22
- package/demo/form-labels-test.html +17 -17
- package/demo/heading-structure-test.html +14 -14
- package/demo/heading-structure-test.html.backup +60 -0
- package/demo/large-file-demo.css +213 -0
- package/demo/nested-controls-test.html +17 -17
- package/demo/sample.html +12 -12
- package/demo/test-external-links.html +26 -0
- package/demo/unused-files-test.html +31 -0
- package/demo/unused-image.png +1 -0
- package/demo/unused-page.html +11 -0
- package/demo/unused-script.js +12 -0
- package/demo/unused-style.css +10 -0
- package/demo/very-large-file.js +2 -0
- package/lib/fixer.js +1438 -97
- package/package.json +15 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,56 @@ 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
|
+
|
|
8
58
|
## [3.5.0] - 2025-01-08
|
|
9
59
|
|
|
10
60
|
### Added
|
package/README-vi.md
CHANGED
|
@@ -20,7 +20,11 @@
|
|
|
20
20
|
- 🏛️ **Landmarks** - Thêm main và navigation landmarks thiếu
|
|
21
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
22
|
- 🎯 **Nested Controls Detection** - Phát hiện và sửa các control tương tác lồng nhau
|
|
23
|
-
- 🔍 **Broken Links Detection** - Phát hiện liên kết bị hỏng
|
|
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
|
|
24
28
|
- 🧹 **Dọn dẹp Duplicate** - Loại bỏ role attributes trùng lặp
|
|
25
29
|
|
|
26
30
|
### 🚀 **Tính năng Enhanced Alt Attribute (Đã tích hợp!)**
|
|
@@ -151,7 +155,12 @@ Chế độ sửa lỗi:
|
|
|
151
155
|
--landmarks-only Sửa landmarks + dọn dẹp
|
|
152
156
|
--headings-only Phân tích cấu trúc heading với tùy chọn tự động sửa
|
|
153
157
|
--auto-fix-headings Bật tự động sửa lỗi heading structure
|
|
154
|
-
--links-check Kiểm tra liên kết bị hỏng và tài nguyên 404
|
|
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
|
|
155
164
|
--cleanup-only Chỉ dọn dẹp role attributes trùng lặp
|
|
156
165
|
|
|
157
166
|
Tùy chọn Enhanced Alt:
|
|
@@ -182,7 +191,12 @@ gbu-a11y --forms-only # Sửa form labels + dọn dẹp
|
|
|
182
191
|
gbu-a11y --buttons-only # Sửa button names + dọn dẹp
|
|
183
192
|
gbu-a11y --headings-only # Phân tích heading structure
|
|
184
193
|
gbu-a11y --headings-only --auto-fix-headings # Tự động sửa heading structure
|
|
185
|
-
gbu-a11y --links-check # Kiểm tra liên kết bị hỏng + dọn dẹp
|
|
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
|
|
186
200
|
|
|
187
201
|
# Tính năng enhanced alt attribute
|
|
188
202
|
gbu-a11y --enhanced-alt # Chế độ enhanced cơ bản
|
|
@@ -283,6 +297,15 @@ await fixer.fixEmptyAltAttributes("./src");
|
|
|
283
297
|
// Không cần import thêm class riêng biệt
|
|
284
298
|
const results = await fixer.fixAllAccessibilityIssues("./src");
|
|
285
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');
|
|
286
309
|
```
|
|
287
310
|
|
|
288
311
|
## 🎯 Những gì được sửa
|
|
@@ -322,10 +345,31 @@ console.log("Hoàn thành sửa lỗi với enhanced features:", results);
|
|
|
322
345
|
|
|
323
346
|
### Kiểm tra liên kết
|
|
324
347
|
|
|
325
|
-
- **Liên kết bị hỏng** → Phát hiện HTTP 404, 500, timeout
|
|
326
|
-
-
|
|
327
|
-
-
|
|
328
|
-
-
|
|
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ậm → Cảnh báo timeout và phản hồi chậm
|
|
351
|
+
- Lỗi mạng → Kết nối thất bại và 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
|
|
329
373
|
|
|
330
374
|
## 🔧 Quản lý Package
|
|
331
375
|
|
package/README.md
CHANGED
|
@@ -19,7 +19,11 @@
|
|
|
19
19
|
- 🏛️ **Landmarks** - Add missing main and navigation landmarks
|
|
20
20
|
- 📑 **Heading Analysis & Auto-Fix** - Analyze heading structure with optional auto-fix using `--auto-fix-headings`
|
|
21
21
|
- 🎯 **Nested Controls Detection** - Detect and fix nested interactive controls
|
|
22
|
-
- 🔍 **Broken Links Detection** - Detect broken links
|
|
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
|
|
23
27
|
- 🧹 **Duplicate Cleanup** - Remove duplicate role attributes
|
|
24
28
|
|
|
25
29
|
### 🚀 **Enhanced Alt Attribute Features (Integrated!)**
|
|
@@ -148,7 +152,12 @@ Fix Modes:
|
|
|
148
152
|
--landmarks-only Fix landmarks + cleanup
|
|
149
153
|
--headings-only Analyze heading structure with optional auto-fix
|
|
150
154
|
--auto-fix-headings Enable automatic heading structure fixes
|
|
151
|
-
|
|
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
|
|
152
161
|
--cleanup-only Only cleanup duplicate role attributes
|
|
153
162
|
|
|
154
163
|
Enhanced Alt Options:
|
|
@@ -179,7 +188,12 @@ gbu-a11y --forms-only # Fix form labels + cleanup
|
|
|
179
188
|
gbu-a11y --buttons-only # Fix button names + cleanup
|
|
180
189
|
gbu-a11y --headings-only # Analyze heading structure
|
|
181
190
|
gbu-a11y --headings-only --auto-fix-headings # Auto-fix heading structure
|
|
182
|
-
gbu-a11y --links-check # Check broken links + cleanup
|
|
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
|
|
183
197
|
|
|
184
198
|
# Enhanced alt attribute features
|
|
185
199
|
gbu-a11y --enhanced-alt # Basic enhanced mode
|
|
@@ -277,6 +291,15 @@ await fixer.fixEmptyAltAttributes('./src');
|
|
|
277
291
|
// No need to import separate classes
|
|
278
292
|
const results = await fixer.fixAllAccessibilityIssues('./src');
|
|
279
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');
|
|
280
303
|
```
|
|
281
304
|
|
|
282
305
|
## 🎯 What Gets Fixed
|
|
@@ -311,10 +334,30 @@ console.log('Accessibility fixes completed with enhanced features:', results);
|
|
|
311
334
|
- **Role attributes** → WCAG-compliant role assignments
|
|
312
335
|
|
|
313
336
|
### Link Validation
|
|
314
|
-
- **Broken
|
|
315
|
-
-
|
|
316
|
-
-
|
|
317
|
-
-
|
|
337
|
+
- **Broken External Links** → Detect HTTP 404, 500, timeout errors on external URLs
|
|
338
|
+
- Invalid URLs → Detect malformed URL formats
|
|
339
|
+
- Slow links → Warn about timeouts and slow responses
|
|
340
|
+
- Network errors → Connection 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
|
|
318
361
|
|
|
319
362
|
## 🔧 Package Management
|
|
320
363
|
|
package/cli.js
CHANGED
|
@@ -30,6 +30,9 @@ const options = {
|
|
|
30
30
|
headingsOnly: false,
|
|
31
31
|
dlOnly: false,
|
|
32
32
|
brokenLinksOnly: false,
|
|
33
|
+
unusedFilesOnly: false,
|
|
34
|
+
deadCodeOnly: false,
|
|
35
|
+
fileSizeOnly: false,
|
|
33
36
|
// Enhanced alt options
|
|
34
37
|
enhancedAlt: false,
|
|
35
38
|
altCreativity: 'balanced', // conservative, balanced, creative
|
|
@@ -104,9 +107,25 @@ for (let i = 0; i < args.length; i++) {
|
|
|
104
107
|
options.dlOnly = true;
|
|
105
108
|
break;
|
|
106
109
|
case '--links-check':
|
|
110
|
+
options.linksCheckOnly = true;
|
|
111
|
+
break;
|
|
107
112
|
case '--broken-links':
|
|
108
113
|
options.brokenLinksOnly = true;
|
|
109
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;
|
|
110
129
|
case '--auto-fix-headings':
|
|
111
130
|
options.autoFixHeadings = true;
|
|
112
131
|
break;
|
|
@@ -156,6 +175,11 @@ Options:
|
|
|
156
175
|
--landmarks-only Fix landmarks + cleanup
|
|
157
176
|
--headings-only Analyze heading structure (no auto-fix)
|
|
158
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)
|
|
159
183
|
--enhanced-alt Use enhanced alt attribute analysis and generation
|
|
160
184
|
--alt-creativity <mode> Alt text creativity: conservative, balanced, creative (default: balanced)
|
|
161
185
|
--include-emotions Include emotional descriptors in alt text
|
|
@@ -186,6 +210,11 @@ Examples:
|
|
|
186
210
|
node cli.js --landmarks-only # Fix landmarks + cleanup
|
|
187
211
|
node cli.js --headings-only # Analyze heading structure only
|
|
188
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
|
|
189
218
|
node cli.js --cleanup-only # Only cleanup duplicate roles
|
|
190
219
|
node cli.js ./src # Fix src directory (comprehensive)
|
|
191
220
|
node cli.js -l en --dry-run ./dist # Preview comprehensive fixes in English
|
|
@@ -247,7 +276,7 @@ async function main() {
|
|
|
247
276
|
// Handle different modes - All modes now include cleanup
|
|
248
277
|
if (options.cleanupOnly || options.altOnly || options.langOnly || options.roleOnly ||
|
|
249
278
|
options.formsOnly || options.nestedOnly || options.buttonsOnly || options.linksOnly || options.landmarksOnly ||
|
|
250
|
-
options.headingsOnly || options.dlOnly || options.brokenLinksOnly) {
|
|
279
|
+
options.headingsOnly || options.dlOnly || options.linksCheckOnly || options.brokenLinksOnly || options.missingResourcesOnly || options.unusedFilesOnly || options.deadCodeOnly || options.fileSizeOnly) {
|
|
251
280
|
// Individual modes - handle each separately, then run cleanup
|
|
252
281
|
} else {
|
|
253
282
|
// Default mode: Run comprehensive fix (all fixes including cleanup)
|
|
@@ -466,16 +495,79 @@ async function main() {
|
|
|
466
495
|
showCompletionMessage(options, 'Description list fixes + cleanup');
|
|
467
496
|
return;
|
|
468
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);
|
|
505
|
+
|
|
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'));
|
|
509
|
+
|
|
510
|
+
showCompletionMessage(options, 'Links and resources check');
|
|
511
|
+
return;
|
|
512
|
+
|
|
469
513
|
} else if (options.brokenLinksOnly) {
|
|
470
|
-
// Check broken links only
|
|
471
|
-
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...'));
|
|
472
516
|
const linkResults = await fixer.checkBrokenLinks(options.directory);
|
|
473
517
|
const totalBrokenLinks = linkResults.reduce((sum, r) => sum + (r.issues || 0), 0);
|
|
474
518
|
|
|
475
|
-
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)`));
|
|
476
520
|
console.log(chalk.gray('💡 Broken link issues require manual review and cannot be auto-fixed'));
|
|
477
521
|
|
|
478
|
-
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');
|
|
479
571
|
return;
|
|
480
572
|
}
|
|
481
573
|
|
|
Binary file
|
package/demo/advanced-test.html
CHANGED
|
@@ -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>
|
|
@@ -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>Comprehensive Test</title>
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
<h1>Comprehensive Test File</h1>
|
|
9
9
|
|
|
10
10
|
<!-- Missing alt -->
|
|
11
|
-
<img src="test.jpg">
|
|
11
|
+
<img src="test.jpg" alt="Comprehensive Test File" role="img" aria-label="Comprehensive Test File">
|
|
12
12
|
|
|
13
13
|
<!-- Missing role -->
|
|
14
|
-
<a href="/home">Home</a>
|
|
14
|
+
<a href="/home" role="link">Home</a>
|
|
15
15
|
|
|
16
16
|
<!-- Duplicate roles -->
|
|
17
|
-
<img src="dup.jpg" alt="Duplicate" role="img"
|
|
17
|
+
<img src="dup.jpg" alt="Duplicate" role="img" aria-label="Duplicate">
|
|
18
18
|
|
|
19
19
|
<p>This tests comprehensive mode as default.</p>
|
|
20
20
|
</body>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/* CSS file with mixed used and unused rules */
|
|
2
|
+
|
|
3
|
+
/* Used classes - these appear in HTML */
|
|
4
|
+
.header {
|
|
5
|
+
background-color: #333;
|
|
6
|
+
color: white;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.content {
|
|
10
|
+
padding: 20px;
|
|
11
|
+
margin: 0 auto;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* Unused classes - these don't appear in any HTML */
|
|
15
|
+
.sidebar {
|
|
16
|
+
width: 300px;
|
|
17
|
+
background: #f0f0f0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.popup {
|
|
21
|
+
position: fixed;
|
|
22
|
+
top: 50%;
|
|
23
|
+
left: 50%;
|
|
24
|
+
transform: translate(-50%, -50%);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.modal-overlay {
|
|
28
|
+
background: rgba(0, 0, 0, 0.5);
|
|
29
|
+
position: fixed;
|
|
30
|
+
top: 0;
|
|
31
|
+
left: 0;
|
|
32
|
+
right: 0;
|
|
33
|
+
bottom: 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* Used tag selectors */
|
|
37
|
+
h1 {
|
|
38
|
+
font-size: 2em;
|
|
39
|
+
margin-bottom: 1em;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
p {
|
|
43
|
+
line-height: 1.6;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Unused tag selectors */
|
|
47
|
+
article {
|
|
48
|
+
margin: 20px 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
aside {
|
|
52
|
+
float: right;
|
|
53
|
+
width: 250px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* Dynamic classes that should be skipped */
|
|
57
|
+
.active {
|
|
58
|
+
color: red;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.hidden {
|
|
62
|
+
display: none;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Pseudo-classes that should be skipped */
|
|
66
|
+
.button:hover {
|
|
67
|
+
background-color: #007bff;
|
|
68
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="ja">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Dead Code Test</title>
|
|
6
|
+
<link rel="stylesheet" href="dead-code-test.css">
|
|
7
|
+
<script src="dead-code-test.js"></script>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<!-- Uses .header and .content classes from CSS -->
|
|
11
|
+
<div class="header">
|
|
12
|
+
<h1>Dead Code Analysis Test</h1>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<div class="content">
|
|
16
|
+
<p>This page uses some CSS classes and JavaScript functions, but not all of them.</p>
|
|
17
|
+
|
|
18
|
+
<!-- Button that calls showAlert() function -->
|
|
19
|
+
<button onclick="showAlert()" role="button">Click me (uses showAlert function)</button>
|
|
20
|
+
|
|
21
|
+
<!-- Button with event handler -->
|
|
22
|
+
<button onclick="handleClick(event)" role="button">Handle Click</button>
|
|
23
|
+
|
|
24
|
+
<p>Run <code>gbu-a11y --dead-code</code> to analyze which CSS rules and JavaScript functions are unused.</p>
|
|
25
|
+
|
|
26
|
+
<!-- Note: The following are used:
|
|
27
|
+
CSS: .header, .content, h1, p (tag selectors)
|
|
28
|
+
JS: showAlert(), handleClick(), and their dependencies
|
|
29
|
+
|
|
30
|
+
The following should be detected as unused:
|
|
31
|
+
CSS: .sidebar, .popup, .modal-overlay, article, aside
|
|
32
|
+
JS: unusedFunction(), complexUnusedFunction(), unusedVariable, etc.
|
|
33
|
+
-->
|
|
34
|
+
</div>
|
|
35
|
+
</body>
|
|
36
|
+
</html>
|