gbu-accessibility-package 3.12.0 → 3.13.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 +17 -1
- package/QUICK_START.md +14 -157
- package/README-vi.md +104 -672
- package/README.md +105 -652
- package/bin/fix.js +1 -138
- package/cli.js +297 -535
- package/index.js +5 -2
- package/lib/checker.js +233 -0
- package/lib/fixer.js +325 -161
- package/package.json +14 -13
package/index.js
CHANGED
package/lib/checker.js
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
const AccessibilityFixer = require('./fixer.js');
|
|
2
|
+
|
|
3
|
+
class AccessibilityChecker extends AccessibilityFixer {
|
|
4
|
+
constructor(config = {}) {
|
|
5
|
+
super({
|
|
6
|
+
...config,
|
|
7
|
+
dryRun: true,
|
|
8
|
+
backupFiles: false,
|
|
9
|
+
autoFixHeadings: false
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
transformLogValue(value) {
|
|
14
|
+
if (typeof value !== 'string') {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return value
|
|
19
|
+
.replace(/Đang sửa/g, 'Đang kiểm tra')
|
|
20
|
+
.replace(/Fixing/g, 'Checking')
|
|
21
|
+
.replace(/✅ Fixed/g, '✅ Reported')
|
|
22
|
+
.replace(/Files fixed/g, 'Files with findings')
|
|
23
|
+
.replace(/files fixed/g, 'files with findings')
|
|
24
|
+
.replace(/Tự động sửa/g, 'Rà soát')
|
|
25
|
+
.replace(/Sử dụng --meta-fix để tự động sửa các lỗi này/g, 'Các lỗi meta cần được review và xử lý thủ công')
|
|
26
|
+
.replace(/Use without --dry-run to apply changes\./g, 'Source files are never modified.');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async withCheckOnlyLogging(task) {
|
|
30
|
+
const originalLog = console.log;
|
|
31
|
+
const originalError = console.error;
|
|
32
|
+
|
|
33
|
+
console.log = (...messages) => originalLog(...messages.map((message) => this.transformLogValue(message)));
|
|
34
|
+
console.error = (...messages) => originalError(...messages.map((message) => this.transformLogValue(message)));
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
return await task();
|
|
38
|
+
} finally {
|
|
39
|
+
console.log = originalLog;
|
|
40
|
+
console.error = originalError;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
normalizeSimulationResults(results = []) {
|
|
45
|
+
return results.map((result) => {
|
|
46
|
+
if (result.status === 'fixed') {
|
|
47
|
+
return {
|
|
48
|
+
...result,
|
|
49
|
+
status: 'issue-found',
|
|
50
|
+
rawStatus: result.status
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (result.status === 'no-change') {
|
|
55
|
+
return {
|
|
56
|
+
...result,
|
|
57
|
+
status: 'clean',
|
|
58
|
+
rawStatus: result.status
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return result;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async checkLang(directory = '.') {
|
|
67
|
+
return this.withCheckOnlyLogging(async () => this.normalizeSimulationResults(await super.fixHtmlLang(directory)));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async checkAltText(directory = '.') {
|
|
71
|
+
return this.withCheckOnlyLogging(async () => this.normalizeSimulationResults(await super.fixEmptyAltAttributes(directory)));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async checkRoles(directory = '.') {
|
|
75
|
+
return this.withCheckOnlyLogging(async () => this.normalizeSimulationResults(await super.fixRoleAttributes(directory)));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async checkAriaLabels(directory = '.') {
|
|
79
|
+
return this.withCheckOnlyLogging(async () => this.normalizeSimulationResults(await super.fixAriaLabels(directory)));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async checkForms(directory = '.') {
|
|
83
|
+
return this.withCheckOnlyLogging(async () => this.normalizeSimulationResults(await super.fixFormLabels(directory)));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async checkNestedControls(directory = '.') {
|
|
87
|
+
return this.withCheckOnlyLogging(async () => this.normalizeSimulationResults(await super.fixNestedInteractiveControls(directory)));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async checkButtons(directory = '.') {
|
|
91
|
+
return this.withCheckOnlyLogging(async () => this.normalizeSimulationResults(await super.fixButtonNames(directory)));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async checkLinks(directory = '.') {
|
|
95
|
+
return this.withCheckOnlyLogging(async () => this.normalizeSimulationResults(await super.fixLinkNames(directory)));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async checkLandmarks(directory = '.') {
|
|
99
|
+
return this.withCheckOnlyLogging(async () => this.normalizeSimulationResults(await super.fixLandmarks(directory)));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async checkHeadings(directory = '.') {
|
|
103
|
+
return this.withCheckOnlyLogging(async () => this.normalizeSimulationResults(await super.fixHeadingStructure(directory)));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async checkDescriptionLists(directory = '.') {
|
|
107
|
+
return this.withCheckOnlyLogging(async () => this.normalizeSimulationResults(await super.fixDescriptionLists(directory)));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async checkLinksAndResources(directory = '.') {
|
|
111
|
+
return this.withCheckOnlyLogging(async () => {
|
|
112
|
+
const [brokenLinks, missingResources] = await Promise.all([
|
|
113
|
+
this.checkBrokenLinks(directory),
|
|
114
|
+
this.check404Resources(directory)
|
|
115
|
+
]);
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
brokenLinks,
|
|
119
|
+
missingResources
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async previewUnusedFilesListRemoval(directory = '.', listFile = 'unused-files-list.txt') {
|
|
125
|
+
return this.withCheckOnlyLogging(async () => super.deleteUnusedFilesFromList(directory, listFile, { dryRun: true }));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async checkMetaTags(directory = '.') {
|
|
129
|
+
return this.withCheckOnlyLogging(async () => super.checkMetaTags(directory));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async checkUnusedFiles(directory = '.') {
|
|
133
|
+
return this.withCheckOnlyLogging(async () => super.checkUnusedFiles(directory));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async generateUnusedFilesList(directory = '.', listFile = 'unused-files-list.txt') {
|
|
137
|
+
return this.withCheckOnlyLogging(async () => super.generateUnusedFilesList(directory, listFile));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async checkDeadCode(directory = '.') {
|
|
141
|
+
return this.withCheckOnlyLogging(async () => super.checkDeadCode(directory));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async checkFileSizes(directory = '.') {
|
|
145
|
+
return this.withCheckOnlyLogging(async () => super.checkFileSizes(directory));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async checkGoogleTagManager(directory = '.') {
|
|
149
|
+
return this.withCheckOnlyLogging(async () => super.checkGoogleTagManager(directory));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async generateFullReport(directory = '.', outputPath = null) {
|
|
153
|
+
return this.withCheckOnlyLogging(async () => super.generateFullReport(directory, outputPath));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
async runComprehensiveChecks(directory = '.') {
|
|
157
|
+
const results = {};
|
|
158
|
+
|
|
159
|
+
results.lang = await this.checkLang(directory);
|
|
160
|
+
results.alt = await this.checkAltText(directory);
|
|
161
|
+
results.roles = await this.checkRoles(directory);
|
|
162
|
+
results.ariaLabels = await this.checkAriaLabels(directory);
|
|
163
|
+
results.forms = await this.checkForms(directory);
|
|
164
|
+
results.nestedControls = await this.checkNestedControls(directory);
|
|
165
|
+
results.buttons = await this.checkButtons(directory);
|
|
166
|
+
results.links = await this.checkLinks(directory);
|
|
167
|
+
results.landmarks = await this.checkLandmarks(directory);
|
|
168
|
+
results.headings = await this.checkHeadings(directory);
|
|
169
|
+
results.descriptionLists = await this.checkDescriptionLists(directory);
|
|
170
|
+
results.externalLinks = await this.withCheckOnlyLogging(async () => this.checkBrokenLinks(directory));
|
|
171
|
+
results.missingResources = await this.withCheckOnlyLogging(async () => this.check404Resources(directory));
|
|
172
|
+
|
|
173
|
+
return results;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async fixHtmlLang(directory = '.') {
|
|
177
|
+
return this.checkLang(directory);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
async fixEmptyAltAttributes(directory = '.') {
|
|
181
|
+
return this.checkAltText(directory);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
async fixRoleAttributes(directory = '.') {
|
|
185
|
+
return this.checkRoles(directory);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async fixAriaLabels(directory = '.') {
|
|
189
|
+
return this.checkAriaLabels(directory);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async fixFormLabels(directory = '.') {
|
|
193
|
+
return this.checkForms(directory);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
async fixNestedInteractiveControls(directory = '.') {
|
|
197
|
+
return this.checkNestedControls(directory);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
async fixButtonNames(directory = '.') {
|
|
201
|
+
return this.checkButtons(directory);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
async fixLinkNames(directory = '.') {
|
|
205
|
+
return this.checkLinks(directory);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
async fixLandmarks(directory = '.') {
|
|
209
|
+
return this.checkLandmarks(directory);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
async fixHeadingStructure(directory = '.') {
|
|
213
|
+
return this.checkHeadings(directory);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
async fixDescriptionLists(directory = '.') {
|
|
217
|
+
return this.checkDescriptionLists(directory);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
async fixMetaTags(directory = '.') {
|
|
221
|
+
return this.checkMetaTags(directory);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
async fixAllAccessibilityIssues(directory = '.') {
|
|
225
|
+
return this.runComprehensiveChecks(directory);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
async deleteUnusedFilesFromList(directory = '.', listFile = 'unused-files-list.txt') {
|
|
229
|
+
return this.previewUnusedFilesListRemoval(directory, listFile);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
module.exports = AccessibilityChecker;
|