web-audit-helper 1.0.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/LICENSE +21 -0
- package/README.md +318 -0
- package/dist/index.d.mts +42 -0
- package/dist/index.mjs +1263 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 NDuranC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
# WAH โ Web Audit Helper ๐ง
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/web-audit-helper)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
|
|
7
|
+
WAH is a **framework-agnostic JavaScript/TypeScript library** that helps developers audit web pages for accessibility, SEO, semantic HTML, responsive design, security, quality, performance, and form validation.
|
|
8
|
+
|
|
9
|
+
It provides **real-time DOM analysis**, a **floating visual overlay**, **console diagnostics**, and **exportable reports** without any runtime dependencies.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## โจ Features
|
|
14
|
+
|
|
15
|
+
- โฟ **60+ Accessibility checks** (WCAG AA/AAA, font size, alt text, labels, contrast, ARIA, skip links)
|
|
16
|
+
- ๐งฑ **Semantic HTML analysis** (proper elements, H1 hierarchy, main/nav/section structure)
|
|
17
|
+
- ๐ **SEO best practices** (title, meta description, viewport, canonical, Open Graph, Twitter Cards)
|
|
18
|
+
- ๐ฑ **Responsive design heuristics** (viewport meta, fixed-width, 100vh issues, overflow)
|
|
19
|
+
- ๐ **Security checks** (target=_blank, tabnabbing, unsafe patterns)
|
|
20
|
+
- โจ **Code quality patterns** (inline styles, semantic IDs/classes, deprecated elements)
|
|
21
|
+
- โก **Performance optimization** (image optimization, lazy loading, async decode, script placement, caching, render-blocking resources)
|
|
22
|
+
- ๐ **Form validation** (proper types, autocomplete, required indicators, label association)
|
|
23
|
+
- ๐จ **Interactive overlay** with drag, hide, category filters, and issue focus
|
|
24
|
+
- ๐ **5 scoring modes** (strict/normal/moderate/soft/custom) with auto-calibration
|
|
25
|
+
- ๐ค **Export reports** (JSON, TXT, HTML) with complete metadata
|
|
26
|
+
- ๐งฉ **Framework-agnostic** (works with vanilla JS, React, Vue, Angular, etc.)
|
|
27
|
+
- ๐งน **Zero runtime dependencies** (only dev dependencies)
|
|
28
|
+
- โณ **Temporary hide system** (hide overlay for X minutes or until next refresh)
|
|
29
|
+
- ๐ง **Console diagnostics** with issue focusing and timestamps
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## ๐ Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install web-audit-helper
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## ๐ Quick Start
|
|
42
|
+
|
|
43
|
+
### Browser (via CDN)
|
|
44
|
+
|
|
45
|
+
```html
|
|
46
|
+
<script type="module">
|
|
47
|
+
import { runWAH } from 'https://unpkg.com/web-audit-helper@1.0.0/dist/index.js';
|
|
48
|
+
|
|
49
|
+
// Run with default configuration
|
|
50
|
+
await runWAH();
|
|
51
|
+
</script>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Node.js / Module Bundler
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
import { runWAH } from 'web-audit-helper';
|
|
58
|
+
|
|
59
|
+
// Default configuration (recommended for development)
|
|
60
|
+
await runWAH();
|
|
61
|
+
|
|
62
|
+
// Custom configuration
|
|
63
|
+
await runWAH({
|
|
64
|
+
logs: true,
|
|
65
|
+
logLevel: 'full',
|
|
66
|
+
issueLevel: 'all',
|
|
67
|
+
accessibility: {
|
|
68
|
+
minFontSize: 12,
|
|
69
|
+
contrastLevel: 'AA'
|
|
70
|
+
},
|
|
71
|
+
overlay: {
|
|
72
|
+
enabled: true,
|
|
73
|
+
position: 'bottom-right',
|
|
74
|
+
hide: 0
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## โ๏ธ Configuration
|
|
82
|
+
|
|
83
|
+
WAH supports extensive configuration options for customization:
|
|
84
|
+
|
|
85
|
+
| Option | Type | Default | Description |
|
|
86
|
+
| ----------------------------- | ----------------------------------- | ---------------- | -------------------------------------------------------------- |
|
|
87
|
+
| `logs` | `boolean` | `true` | Enable console logging |
|
|
88
|
+
| `logLevel` | `'full' \| 'summary' \| 'none'` | `'full'` | Console verbosity level |
|
|
89
|
+
| `issueLevel` | `'critical' \| 'warnings' \| 'all'` | `'all'` | Filter which issues to report |
|
|
90
|
+
| `accessibility.minFontSize` | `number` | `12` | Minimum font size in pixels |
|
|
91
|
+
| `accessibility.contrastLevel` | `'AA' \| 'AAA'` | `'AA'` | WCAG contrast requirement level |
|
|
92
|
+
| `overlay.enabled` | `boolean` | `true` | Show visual overlay interface |
|
|
93
|
+
| `overlay.position` | `string` | `'bottom-right'` | Overlay position (bottom-left/bottom-right/top-left/top-right) |
|
|
94
|
+
| `overlay.hide` | `number` | `0` | Hide overlay for X milliseconds on load |
|
|
95
|
+
|
|
96
|
+
**For complete configuration documentation**, see [Configuration Guide](docs/configuration.md).
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## ๐ Scoring System
|
|
101
|
+
|
|
102
|
+
WAH calculates a score from **0-100** with letter grades **A-F**:
|
|
103
|
+
|
|
104
|
+
### Scoring Modes
|
|
105
|
+
|
|
106
|
+
- **strict** (25/10/5): Most aggressive penalties โ catches all issues
|
|
107
|
+
- **normal** (20/8/4): Balanced default โ recommended for general use
|
|
108
|
+
- **moderate** (20/8/0): Ignores recommendations โ focuses on critical/warnings
|
|
109
|
+
- **soft** (20/0/0): Only critical issues โ strictest scope
|
|
110
|
+
- **custom**: User-controlled filters with auto-calibrated multipliers
|
|
111
|
+
|
|
112
|
+
### Custom Filters
|
|
113
|
+
|
|
114
|
+
Enable custom mode to filter by:
|
|
115
|
+
- **Severities**: critical, warning, recommendation
|
|
116
|
+
- **Categories**: accessibility, seo, semantic, responsive, security, quality, performance, form
|
|
117
|
+
|
|
118
|
+
Multipliers automatically calibrate based on active categories:
|
|
119
|
+
- 1 category: 4x reduction
|
|
120
|
+
- 2 categories: 2x reduction
|
|
121
|
+
- 3-4 categories: 1.33x reduction
|
|
122
|
+
- 5+ categories: no reduction
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## ๐ฏ Audit Rules (+60 Total)
|
|
127
|
+
|
|
128
|
+
WAH implements comprehensive audit rules across **8 categories**:
|
|
129
|
+
|
|
130
|
+
### Accessibility
|
|
131
|
+
Font size, alt text, labels, links, buttons, ARIA, skip links, headings, focus, contrast, line-height, etc.
|
|
132
|
+
|
|
133
|
+
### Semantic HTML
|
|
134
|
+
H1 hierarchy, semantic elements (strong/em), main, nav, canonical structure
|
|
135
|
+
|
|
136
|
+
### SEO
|
|
137
|
+
Title, meta description, viewport, canonical, Open Graph, Twitter Cards, charset, robots
|
|
138
|
+
|
|
139
|
+
### Responsive Design
|
|
140
|
+
Viewport meta, fixed widths, overflow, fixed elements, 100vh issues
|
|
141
|
+
|
|
142
|
+
### Security
|
|
143
|
+
Target=_blank security (tabnabbing prevention)
|
|
144
|
+
|
|
145
|
+
### Quality
|
|
146
|
+
Inline styles, dummy links, semantic naming
|
|
147
|
+
|
|
148
|
+
### Performance
|
|
149
|
+
Image optimization, lazy loading, async decode, script placement, fonts, caching, render-blocking CSS
|
|
150
|
+
|
|
151
|
+
### Forms
|
|
152
|
+
Submit buttons, required indicators, input types, autocomplete
|
|
153
|
+
|
|
154
|
+
**For complete rules reference**, see [Rules Documentation](docs/rules.md).
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## ๐ฎ Console Commands
|
|
159
|
+
|
|
160
|
+
WAH exposes global commands for interaction:
|
|
161
|
+
|
|
162
|
+
### `__WAH_FOCUS_ISSUE__(index)`
|
|
163
|
+
Highlights a specific issue element in the DOM and logs its details.
|
|
164
|
+
```javascript
|
|
165
|
+
__WAH_FOCUS_ISSUE__(0) // Focus on first issue
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### `__WAH_RESET_HIDE__()`
|
|
169
|
+
Clears hide settings and reloads the overlay.
|
|
170
|
+
```javascript
|
|
171
|
+
__WAH_RESET_HIDE__() // Restore overlay immediately
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### `__WAH_RERUN__()`
|
|
175
|
+
Re-runs the audit after DOM changes without page reload.
|
|
176
|
+
```javascript
|
|
177
|
+
__WAH_RERUN__() // Refresh audit
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## ๐ค Export Reports
|
|
183
|
+
|
|
184
|
+
Run WAH with logging enabled to export reports to the console:
|
|
185
|
+
|
|
186
|
+
```javascript
|
|
187
|
+
await runWAH({
|
|
188
|
+
logs: true,
|
|
189
|
+
logLevel: 'full'
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// Reports are printed to console as:
|
|
193
|
+
// - Table format (filtered by category and severity)
|
|
194
|
+
// - JSON export
|
|
195
|
+
// - TXT export (with detailed formatting)
|
|
196
|
+
// - HTML export (full report with styling)
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Reports include:
|
|
200
|
+
- Overall score and grade
|
|
201
|
+
- Score by category
|
|
202
|
+
- Detailed issue list with CSS selectors
|
|
203
|
+
- Applied filters and scoring mode
|
|
204
|
+
- Viewport and user agent info
|
|
205
|
+
- Timestamp and WAH version
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## ๐จ Overlay & Interface
|
|
210
|
+
|
|
211
|
+
<!-- TODO: Add screenshots of overlay at different positions, popover components -->
|
|
212
|
+
<!-- Screenshots should show:
|
|
213
|
+
- Overlay positioned bottom-right with score badge
|
|
214
|
+
- Overlay positioned top-left
|
|
215
|
+
- Popover expanded showing filters
|
|
216
|
+
- Popover showing export options
|
|
217
|
+
- Popover showing settings
|
|
218
|
+
- Console table with issues
|
|
219
|
+
-->
|
|
220
|
+
|
|
221
|
+
The overlay provides a floating interface with:
|
|
222
|
+
|
|
223
|
+
- **Score badge**: Displays overall score and grade
|
|
224
|
+
- **Category breakdown**: Shows individual category scores
|
|
225
|
+
- **Issue list**: Filterable by severity (critical/warning/recommendation) and category
|
|
226
|
+
- **Issue focus**: Click to highlight elements in the DOM
|
|
227
|
+
- **Filters**: Toggle severities and categories to customize scoring
|
|
228
|
+
- **Settings**: Configure min font size, contrast level, scoring mode
|
|
229
|
+
- **Export**: Download audit reports in JSON, TXT, or HTML format
|
|
230
|
+
- **Hide**: Temporarily hide overlay for X minutes or until next refresh
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## ๐๏ธ Architecture
|
|
235
|
+
|
|
236
|
+
WAH is organized into clear modules:
|
|
237
|
+
|
|
238
|
+
- **`core/`**: Audit engine with 60+ rules across 8 categories
|
|
239
|
+
- **`overlay/`**: Visual UI components (Overlay, Popover, filters, drag)
|
|
240
|
+
- **`reporters/`**: Export formats (JSON, TXT, HTML) with metadata
|
|
241
|
+
- **`utils/`**: Shared utilities (console logging, DOM helpers)
|
|
242
|
+
|
|
243
|
+
**For architecture details**, see [Architecture Guide](docs/architecture.md).
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## ๐ง API Reference
|
|
248
|
+
|
|
249
|
+
### `runWAH(userConfig?: Partial<WAHConfig>): Promise<AuditResult>`
|
|
250
|
+
|
|
251
|
+
Main entry point to run the audit.
|
|
252
|
+
|
|
253
|
+
**Parameters:**
|
|
254
|
+
- `userConfig` (optional): Partial configuration object to override defaults
|
|
255
|
+
|
|
256
|
+
**Returns:**
|
|
257
|
+
- `AuditResult`: Object containing issues array and overall score
|
|
258
|
+
|
|
259
|
+
**Example:**
|
|
260
|
+
```javascript
|
|
261
|
+
const result = await runWAH({ logLevel: 'summary' });
|
|
262
|
+
console.log(`Score: ${result.score}%`);
|
|
263
|
+
console.log(`Issues: ${result.issues.length}`);
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
**For complete API documentation**, see [API Reference](docs/api.md).
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## ๐งช Testing
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
npm run test # Run tests once
|
|
274
|
+
npm run test:watch # Watch mode
|
|
275
|
+
npm run test:ui # Interactive UI
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## ๐ค Contributing
|
|
281
|
+
|
|
282
|
+
We welcome contributions! Please read [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on:
|
|
283
|
+
- Reporting issues
|
|
284
|
+
- Submitting pull requests
|
|
285
|
+
- Adding new rules
|
|
286
|
+
- Code style and conventions
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## ๐ Roadmap
|
|
291
|
+
|
|
292
|
+
### v1.0.0 (Current)
|
|
293
|
+
- 60+ audit rules implemented
|
|
294
|
+
- Visual overlay with filtering and export
|
|
295
|
+
- 5 scoring modes with auto-calibration
|
|
296
|
+
- Console diagnostics and commands
|
|
297
|
+
- Zero runtime dependencies
|
|
298
|
+
|
|
299
|
+
### v1.1.0 (Planned)
|
|
300
|
+
- 10+ additional rules (obsolete elements, ARIA, touch targets, etc.)
|
|
301
|
+
- Extended testing framework
|
|
302
|
+
- Comprehensive documentation
|
|
303
|
+
- Performance improvements
|
|
304
|
+
|
|
305
|
+
### v2.0.0 (Future)
|
|
306
|
+
- CLI tool for CI/CD integration
|
|
307
|
+
- Framework plugins (React, Vue, Angular)
|
|
308
|
+
- Advanced performance profiling
|
|
309
|
+
- DevTools integration
|
|
310
|
+
- Custom rule registration
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## ๐ License
|
|
315
|
+
|
|
316
|
+
MIT โ See [LICENSE](LICENSE) for details
|
|
317
|
+
|
|
318
|
+
---
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
type Severity = "critical" | "warning" | "recommendation";
|
|
2
|
+
type LogLevel = "full" | "summary" | "none";
|
|
3
|
+
type IssueLevel = "critical" | "warnings" | "all";
|
|
4
|
+
type IssueCategory = "accessibility" | "semantic" | "seo" | "responsive" | "security" | "quality" | "performance" | "form";
|
|
5
|
+
type ContrastLevel = "AA" | "AAA";
|
|
6
|
+
interface AuditIssue {
|
|
7
|
+
rule: string;
|
|
8
|
+
message: string;
|
|
9
|
+
severity: Severity;
|
|
10
|
+
category?: IssueCategory;
|
|
11
|
+
selector?: string;
|
|
12
|
+
element?: HTMLElement;
|
|
13
|
+
}
|
|
14
|
+
interface AuditResult {
|
|
15
|
+
issues: AuditIssue[];
|
|
16
|
+
score: number;
|
|
17
|
+
}
|
|
18
|
+
interface WAHConfig {
|
|
19
|
+
logs: boolean;
|
|
20
|
+
logLevel?: LogLevel;
|
|
21
|
+
issueLevel: IssueLevel;
|
|
22
|
+
accessibility: {
|
|
23
|
+
minFontSize: number;
|
|
24
|
+
contrastLevel: ContrastLevel;
|
|
25
|
+
minContrastRatio?: number;
|
|
26
|
+
minLineHeight?: number;
|
|
27
|
+
};
|
|
28
|
+
quality?: {
|
|
29
|
+
inlineStylesThreshold?: number;
|
|
30
|
+
};
|
|
31
|
+
overlay: {
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
position: "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
34
|
+
theme: "dark" | "light";
|
|
35
|
+
};
|
|
36
|
+
reporters?: ("console" | "json" | "text")[];
|
|
37
|
+
breakpoints: Record<string, number>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare function runWAH(userConfig?: Partial<WAHConfig>): Promise<AuditResult | undefined>;
|
|
41
|
+
|
|
42
|
+
export { runWAH };
|