gbu-accessibility-package 3.8.3 → 3.8.6
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/README-vi.md +1 -0
- package/README.md +1 -1
- package/cli.js +7 -2
- package/lib/fixer.js +27 -7
- package/package.json +1 -1
package/README-vi.md
CHANGED
|
@@ -362,6 +362,7 @@ await fixer.checkFileSizes('./src');
|
|
|
362
362
|
### Tối ưu hóa dự án
|
|
363
363
|
|
|
364
364
|
- **File không sử dụng** → Phát hiện file không được tham chiếu ở đâu trong toàn bộ dự án
|
|
365
|
+
- **File types được kiểm tra**: Hình ảnh, CSS, SCSS/Sass, JavaScript, JSX, TypeScript, Vue, PHP, JSON, Markdown, XML, PDF, Video, Audio files (không bao gồm HTML)
|
|
365
366
|
- **Quét toàn diện**: Phân tích từ project root, không giới hạn thư mục hiện tại
|
|
366
367
|
- **Cross-reference detection**: Tìm tham chiếu từ HTML, CSS, JavaScript, JSON, và các file khác
|
|
367
368
|
- **Multiple path formats**: Hỗ trợ relative paths, absolute paths, imports, requires
|
package/README.md
CHANGED
|
@@ -349,7 +349,7 @@ await fixer.checkFileSizes('./src');
|
|
|
349
349
|
|
|
350
350
|
### Project Optimization
|
|
351
351
|
- **Unused Files** → Detect files not referenced anywhere in the project
|
|
352
|
-
- Images, CSS, JavaScript,
|
|
352
|
+
- Images, CSS, SCSS/Sass, JavaScript, JSX, TypeScript, Vue, PHP, JSON, Markdown, XML, PDF, Video, Audio files
|
|
353
353
|
- Local file references analysis
|
|
354
354
|
- Heuristic detection with manual review recommendations
|
|
355
355
|
- **Dead Code Analysis** → Find unused CSS rules and JavaScript functions
|
package/cli.js
CHANGED
|
@@ -572,9 +572,14 @@ async function main() {
|
|
|
572
572
|
// Check unused files only (no fixes, no cleanup)
|
|
573
573
|
console.log(chalk.blue('🗂️ Running unused files check only...'));
|
|
574
574
|
const unusedResults = await fixer.checkUnusedFiles(options.directory);
|
|
575
|
-
const totalUnusedFiles = unusedResults.
|
|
575
|
+
const totalUnusedFiles = unusedResults.unusedCount;
|
|
576
576
|
|
|
577
|
-
|
|
577
|
+
if (totalUnusedFiles === 0) {
|
|
578
|
+
console.log(chalk.green(`\n✅ No unused files found! All ${unusedResults.totalFiles} files are properly referenced.`));
|
|
579
|
+
} else {
|
|
580
|
+
console.log(chalk.green(`\n✅ Analysis complete: Found ${totalUnusedFiles} unused files out of ${unusedResults.totalFiles} total files`));
|
|
581
|
+
console.log(chalk.gray(`📊 ${unusedResults.referencedFiles} files are referenced, ${totalUnusedFiles} potentially unused`));
|
|
582
|
+
}
|
|
578
583
|
console.log(chalk.gray('💡 Unused file detection is heuristic - manual review recommended'));
|
|
579
584
|
|
|
580
585
|
showCompletionMessage(options, 'Unused files check');
|
package/lib/fixer.js
CHANGED
|
@@ -5684,6 +5684,8 @@ class AccessibilityFixer {
|
|
|
5684
5684
|
const relativePath = path.relative(scanDirectory, file);
|
|
5685
5685
|
const isReferenced = this.isFileReferenced(file, relativePath, referencedFiles, scanDirectory);
|
|
5686
5686
|
|
|
5687
|
+
|
|
5688
|
+
|
|
5687
5689
|
if (!isReferenced) {
|
|
5688
5690
|
const stats = await require('fs').promises.stat(file);
|
|
5689
5691
|
const fileSize = this.formatFileSize(stats.size);
|
|
@@ -5755,10 +5757,22 @@ class AccessibilityFixer {
|
|
|
5755
5757
|
}
|
|
5756
5758
|
}
|
|
5757
5759
|
|
|
5758
|
-
// Check for partial matches (for dynamic imports)
|
|
5759
|
-
const
|
|
5760
|
+
// Check for partial matches (for dynamic imports) - match only specific patterns
|
|
5761
|
+
const fullFileName = path.basename(filePath);
|
|
5762
|
+
|
|
5760
5763
|
for (const ref of referencedFiles) {
|
|
5761
|
-
|
|
5764
|
+
// Match full relative path first (most accurate)
|
|
5765
|
+
if (ref === relativePath || ref === './' + relativePath || ref === '/' + relativePath) {
|
|
5766
|
+
return true;
|
|
5767
|
+
}
|
|
5768
|
+
|
|
5769
|
+
// Match filename only if it appears in a relative path context (not absolute paths)
|
|
5770
|
+
if (ref.includes('/') && ref.endsWith('/' + fullFileName) && !path.isAbsolute(ref)) {
|
|
5771
|
+
return true;
|
|
5772
|
+
}
|
|
5773
|
+
|
|
5774
|
+
// Match filename only if it's the exact reference (not just substring)
|
|
5775
|
+
if (ref === fullFileName) {
|
|
5762
5776
|
return true;
|
|
5763
5777
|
}
|
|
5764
5778
|
}
|
|
@@ -5768,7 +5782,8 @@ class AccessibilityFixer {
|
|
|
5768
5782
|
|
|
5769
5783
|
async findAllProjectFiles(directory) {
|
|
5770
5784
|
const files = [];
|
|
5771
|
-
|
|
5785
|
+
// Check all relevant file types except HTML files
|
|
5786
|
+
const extensions = ['.css', '.scss', '.sass', '.js', '.jsx', '.ts', '.tsx', '.vue', '.php', '.json', '.md', '.xml', '.jpg', '.jpeg', '.png', '.gif', '.svg', '.webp', '.ico', '.pdf', '.mp4', '.webm', '.mp3', '.wav'];
|
|
5772
5787
|
|
|
5773
5788
|
const scan = async (dir) => {
|
|
5774
5789
|
try {
|
|
@@ -6057,15 +6072,15 @@ class AccessibilityFixer {
|
|
|
6057
6072
|
shouldSkipUnusedCheck(filePath) {
|
|
6058
6073
|
const fileName = path.basename(filePath);
|
|
6059
6074
|
const dirName = path.basename(path.dirname(filePath));
|
|
6075
|
+
const relativePath = path.relative(process.cwd(), filePath);
|
|
6060
6076
|
|
|
6061
|
-
// Skip certain file types and patterns
|
|
6077
|
+
// Skip certain file types and patterns - but only in root directory
|
|
6062
6078
|
const skipPatterns = [
|
|
6063
|
-
// Common files that might not be directly referenced
|
|
6079
|
+
// Common files that might not be directly referenced - only in root
|
|
6064
6080
|
/^(index|main|app)\.(html|js|css)$/i,
|
|
6065
6081
|
/^(readme|license|changelog)/i,
|
|
6066
6082
|
/^package\.json$/i,
|
|
6067
6083
|
/^\.gitignore$/i,
|
|
6068
|
-
/^favicon\.(ico|png)$/i,
|
|
6069
6084
|
/^robots\.txt$/i,
|
|
6070
6085
|
/^sitemap\.xml$/i,
|
|
6071
6086
|
// Backup files
|
|
@@ -6074,6 +6089,11 @@ class AccessibilityFixer {
|
|
|
6074
6089
|
/test|spec|__tests__/i
|
|
6075
6090
|
];
|
|
6076
6091
|
|
|
6092
|
+
// Only skip favicon in root directory, not in assets folders
|
|
6093
|
+
if (/^favicon\.(ico|png)$/i.test(fileName) && !relativePath.includes('/')) {
|
|
6094
|
+
return true;
|
|
6095
|
+
}
|
|
6096
|
+
|
|
6077
6097
|
return skipPatterns.some(pattern =>
|
|
6078
6098
|
pattern.test(fileName) || pattern.test(dirName)
|
|
6079
6099
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gbu-accessibility-package",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.6",
|
|
4
4
|
"description": "Comprehensive accessibility fixes and project optimization for HTML files. Smart context-aware alt text generation, form labels, button names, link names, landmarks, heading analysis, WCAG-compliant role attributes, unused files detection, dead code analysis, broken external links detection, and missing local resources detection. Covers major axe DevTools issues with individual fix modes.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|