@fulldecent/nice-checkers-plugin 0.1.1 → 0.2.1
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.md +149 -252
- package/dist/index.cjs +506 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +506 -5
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
# :cherry_blossom: Nice Checkers
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@fulldecent/nice-checkers)
|
|
4
|
-
|
|
5
3
|
[](https://github.com/fulldecent/html-validate-nice-checkers/actions/workflows/ci.yml)
|
|
6
4
|
|
|
7
5
|
An opinionated collection of essential HTML validation rules that promote best practices™ for web development. Use this plugin with [HTML-validate](https://html-validate.org/).
|
|
8
6
|
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- :white_check_mark: **Turnkey validation**: 7 rules covering SEO, security, accessibility, and best practices
|
|
10
|
+
- :white_check_mark: **TypeScript**: full type definitions included
|
|
11
|
+
- :warning: **Dual module support**: works with both ESM (`import`) and CJS (`require`) (known issue: ESM and CommonJS builds are [sometimes not building correctly](https://github.com/fulldecent/html-validate-nice-checkers/issues/6))
|
|
12
|
+
- :white_check_mark: **Tree shakeable**: import only what you need
|
|
13
|
+
- :white_check_mark: **Modern tooling**: [built with tsup](https://github.com/fulldecent/html-validate-nice-checkers/blob/main/tsup.config.ts), [tested with Vitest](https://github.com/fulldecent/html-validate-nice-checkers/blob/main/vitest.config.ts), [good IDE hinting](https://github.com/fulldecent/html-validate-nice-checkers/blob/main/tsconfig.json) and [enforced style checking](https://github.com/fulldecent/html-validate-nice-checkers/blob/main/.prettierrc)
|
|
14
|
+
- :white_check_mark: **Comprehensive testing**: high test coverage with realistic fixtures
|
|
15
|
+
|
|
9
16
|
## Installation
|
|
10
17
|
|
|
11
|
-
These instructions assume you
|
|
18
|
+
These instructions assume you will use Nice Checkers as part of a web test suite running Node (20+) and [HTML-validate](https://html-validate.org/). See [GitHub Pages Template](https://github.com/fulldecent/github-pages-template) for an end-to-end example, including GitHub Actions continuous integration, testing and GitHub Pages deployment for all modern best practices.
|
|
12
19
|
|
|
13
20
|
### Add package dev dependency
|
|
14
21
|
|
|
15
|
-
|
|
22
|
+
_Nice Checkers is a **dev** dependency for you because you need it to test your website, not to deploy it._
|
|
16
23
|
|
|
17
24
|
```sh
|
|
18
25
|
# Using Yarn
|
|
@@ -22,94 +29,46 @@ yarn add -D html-validate-nice-checkers
|
|
|
22
29
|
npm install --dev html-validate-nice-checkers
|
|
23
30
|
```
|
|
24
31
|
|
|
25
|
-
Update your
|
|
32
|
+
### Update your HTML-validate configuration
|
|
26
33
|
|
|
27
|
-
|
|
28
|
-
{
|
|
29
|
-
"plugins": ["dist"],
|
|
30
|
-
- "extends": ["htmlvalidate:recommended"]
|
|
31
|
-
+ "extends": ["htmlvalidate:recommended", "nice-checkers-plugin:recommended"]
|
|
32
|
-
}
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### Usage and configuration
|
|
36
|
-
|
|
37
|
-
You can configure individual rules:
|
|
34
|
+
This example assumes you are using the .htmlvalidate.mjs configuration flavor. HTML-validate also [supports other configuration flavors](https://html-validate.org/usage/index.html#configuration).
|
|
38
35
|
|
|
39
|
-
```
|
|
40
|
-
{
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"skipUrlPatterns": ["example.com", "localhost"],
|
|
49
|
-
"cacheExpiryFoundSeconds": 2592000
|
|
50
|
-
}
|
|
51
|
-
],
|
|
52
|
-
"nice-checkers/https-links": "warn",
|
|
53
|
-
"nice-checkers/internal-links": [
|
|
54
|
-
"error",
|
|
55
|
-
{
|
|
56
|
-
"webRoot": "./dist",
|
|
57
|
-
"alternativeExtensions": [".html"]
|
|
58
|
-
}
|
|
59
|
-
],
|
|
60
|
-
"nice-checkers/latest-packages": "warn",
|
|
61
|
-
"nice-checkers/mailto-awesome": [
|
|
62
|
-
"error",
|
|
63
|
-
{
|
|
64
|
-
"requiredParameters": ["subject", "body"]
|
|
65
|
-
}
|
|
66
|
-
],
|
|
67
|
-
"nice-checkers/no-jquery": "error"
|
|
68
|
-
}
|
|
69
|
-
}
|
|
36
|
+
```diff
|
|
37
|
+
import { defineConfig } from "html-validate";
|
|
38
|
+
+ import { NiceCheckersPlugin } from "@fulldecent/nice-checkers-plugin"
|
|
39
|
+
|
|
40
|
+
export default defineConfig({
|
|
41
|
+
- "extends": ["htmlvalidate:recommended"]
|
|
42
|
+
+ "plugins": [NiceCheckersPlugin],
|
|
43
|
+
+ "extends": ["htmlvalidate:recommended", "nice-checkers-plugin:recommended"]
|
|
44
|
+
});
|
|
70
45
|
```
|
|
71
46
|
|
|
72
47
|
## Rules
|
|
73
48
|
|
|
74
|
-
All rules are enabled by default when you extend from `nice-checkers-plugin:recommended`.
|
|
49
|
+
All rules are enabled by default when you extend from `nice-checkers-plugin:recommended`. Find introductions and configuration options for each rule below.
|
|
75
50
|
|
|
76
51
|
### `nice-checkers/canonical-link`
|
|
77
52
|
|
|
78
|
-
Ensures that each HTML document contains a single canonical link element pointing to the preferred URL for that page.
|
|
79
|
-
|
|
80
|
-
**Bad:**
|
|
81
|
-
|
|
82
|
-
```html
|
|
83
|
-
<!doctype html>
|
|
84
|
-
<html lang="en">
|
|
85
|
-
<head>
|
|
86
|
-
<meta charset="utf-8" />
|
|
87
|
-
<title>My first website about horses</title>
|
|
88
|
-
<!-- Missing canonical link -->
|
|
89
|
-
</head>
|
|
90
|
-
ody>
|
|
91
|
-
This page is missing a required canonical link element in the head.
|
|
92
|
-
</body>
|
|
93
|
-
</html>
|
|
94
|
-
```
|
|
53
|
+
Ensures that each HTML document contains a single canonical link element pointing to the preferred URL for that page. This rule helps with SEO by preventing duplicate content issues and clarifies the primary URL for search engines.
|
|
95
54
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
```
|
|
99
|
-
<!doctype html>
|
|
100
|
-
<html lang="en">
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
</html>
|
|
55
|
+
Also this rule enforces that your public URL does not end with a file extension (e.g. `.html`) or an index (`/index`). Each character in your URL is valuable real estate and you should not expose such implementation details in your URL.
|
|
56
|
+
|
|
57
|
+
```diff
|
|
58
|
+
<!doctype html>
|
|
59
|
+
<html lang="en">
|
|
60
|
+
<head>
|
|
61
|
+
<meta charset="utf-8" />
|
|
62
|
+
<title>My first website about horses</title>
|
|
63
|
+
+ <link rel="canonical" href="https://example.com/horses" />
|
|
64
|
+
</head>
|
|
65
|
+
<body>
|
|
66
|
+
This page is missing a required canonical link element in the head.
|
|
67
|
+
</body>
|
|
68
|
+
</html>
|
|
110
69
|
```
|
|
111
70
|
|
|
112
|
-
|
|
71
|
+
### Configuration
|
|
113
72
|
|
|
114
73
|
```json
|
|
115
74
|
{
|
|
@@ -119,34 +78,20 @@ Ensures that each HTML document contains a single canonical link element pointin
|
|
|
119
78
|
}
|
|
120
79
|
```
|
|
121
80
|
|
|
122
|
-
|
|
81
|
+
### Configuration options
|
|
123
82
|
|
|
124
|
-
|
|
125
|
-
- Canonical URL has file extension (`.html`, `.php`, etc.)
|
|
126
|
-
- Canonical URL ends with `/index`
|
|
83
|
+
This rule has no configurable options.
|
|
127
84
|
|
|
128
85
|
### `nice-checkers/external-links`
|
|
129
86
|
|
|
130
|
-
Validates that all external links are live and accessible.
|
|
87
|
+
Validates that all external links are live and accessible. This rule helps maintain website quality by catching broken external links before they go live, improving user experience and SEO.
|
|
131
88
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
<!-- Broken external link -->
|
|
136
|
-
<a href="https://example.com/nonexistent-page">This link is broken</a>
|
|
137
|
-
|
|
138
|
-
<!-- Link that redirects -->
|
|
139
|
-
<a href="http://old-domain.example.com/page">This redirects</a>
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
**Good:**
|
|
143
|
-
|
|
144
|
-
```html
|
|
145
|
-
<!-- Working external link -->
|
|
146
|
-
<a href="https://example.com/working-page">This link works</a>
|
|
89
|
+
```diff
|
|
90
|
+
- <a href="https://wrong-subdomain.example.com">This link is broken</a>
|
|
91
|
+
+ <a href="https://example.com/nonexistent-page">This link works</a>
|
|
147
92
|
```
|
|
148
93
|
|
|
149
|
-
|
|
94
|
+
### Configuration
|
|
150
95
|
|
|
151
96
|
```json
|
|
152
97
|
{
|
|
@@ -155,7 +100,7 @@ Validates that all external links are live and accessible. Uses caching to avoid
|
|
|
155
100
|
"error",
|
|
156
101
|
{
|
|
157
102
|
"proxyUrl": "",
|
|
158
|
-
"
|
|
103
|
+
"skipRegexes": ["://example.com", "://localhost"],
|
|
159
104
|
"cacheExpiryFoundSeconds": 2592000,
|
|
160
105
|
"cacheExpiryNotFoundSeconds": 259200,
|
|
161
106
|
"timeoutSeconds": 5,
|
|
@@ -167,37 +112,30 @@ Validates that all external links are live and accessible. Uses caching to avoid
|
|
|
167
112
|
}
|
|
168
113
|
```
|
|
169
114
|
|
|
170
|
-
|
|
115
|
+
### Configuration options
|
|
171
116
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
117
|
+
| Option | Type | Default | Description |
|
|
118
|
+
| ---------------------------- | ---------- | --------------------------------------------------------- | ------------------------------------------------------- |
|
|
119
|
+
| `proxyUrl` | `string` | `""` | Proxy URL to use for HTTP requests |
|
|
120
|
+
| `skipRegexes` | `string[]` | `[]` | Array of regex patterns for URLs to skip checking |
|
|
121
|
+
| `cacheExpiryFoundSeconds` | `number` | `2592000` | Cache duration for successful checks (default: 30 days) |
|
|
122
|
+
| `cacheExpiryNotFoundSeconds` | `number` | `259200` | Cache duration for failed checks (default: 3 days) |
|
|
123
|
+
| `timeoutSeconds` | `number` | `5` | Request timeout in seconds |
|
|
124
|
+
| `cacheDatabasePath` | `string` | `"cache/external-links.db"` | Path to the cache database file |
|
|
125
|
+
| `userAgent` | `string` | `"Mozilla/5.0 (compatible; html-validate-nice-checkers)"` | User agent string for HTTP requests |
|
|
176
126
|
|
|
177
127
|
### `nice-checkers/https-links`
|
|
178
128
|
|
|
179
|
-
Reports insecure HTTP links that are accessible via HTTPS, encouraging the use of secure connections.
|
|
180
|
-
|
|
181
|
-
**Bad:**
|
|
129
|
+
Reports insecure HTTP links that are accessible via HTTPS, encouraging the use of secure connections. This rule promotes security best practices by identifying opportunities to upgrade to HTTPS.
|
|
182
130
|
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
<
|
|
186
|
-
<
|
|
131
|
+
```diff
|
|
132
|
+
- <a href="http://example.com/page">Should use HTTPS</a>
|
|
133
|
+
- <img src="http://cdn.example.com/image.webp" alt="Image" />
|
|
134
|
+
+ <a href="https://example.com/page">Uses HTTPS</a>
|
|
135
|
+
+ <img src="https://cdn.example.com/image.webp" alt="Image" />
|
|
187
136
|
```
|
|
188
137
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
``tml
|
|
192
|
-
|
|
193
|
-
<!-- HTTPS link -->
|
|
194
|
-
|
|
195
|
-
<a href="https://secure-site.com/page">Uses HTTPS</a>
|
|
196
|
-
<img src="https://cdn.example.com/image.jpg" alt="Image" />
|
|
197
|
-
|
|
198
|
-
````
|
|
199
|
-
|
|
200
|
-
**Configuration:**
|
|
138
|
+
### Configuration
|
|
201
139
|
|
|
202
140
|
```json
|
|
203
141
|
{
|
|
@@ -213,33 +151,29 @@ Reports insecure HTTP links that are accessible via HTTPS, encouraging the use o
|
|
|
213
151
|
]
|
|
214
152
|
}
|
|
215
153
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
### `nice-checkers/internal-links`
|
|
219
|
-
|
|
220
|
-
Validates that all internal links point to existing files in your project.
|
|
221
|
-
|
|
222
|
-
**Bad:**
|
|
154
|
+
```
|
|
223
155
|
|
|
224
|
-
|
|
225
|
-
<!-- Link to non-existent page -->
|
|
226
|
-
<a href="/nonexistent-page">Broken internal link</a>
|
|
156
|
+
### Configuration options
|
|
227
157
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
158
|
+
| Option | Type | Default | Description |
|
|
159
|
+
| ---------------------------- | -------- | ------------------------------- | ------------------------------------------------------------- |
|
|
160
|
+
| `cacheExpiryFoundSeconds` | `number` | `2592000` | Cache duration for successful HTTPS checks (default: 30 days) |
|
|
161
|
+
| `cacheExpiryNotFoundSeconds` | `number` | `259200` | Cache duration for failed HTTPS checks (default: 3 days) |
|
|
162
|
+
| `timeoutSeconds` | `number` | `10` | Request timeout in seconds |
|
|
163
|
+
| `cacheDatabasePath` | `string` | `"cache/https-availability.db"` | Path to the cache database file |
|
|
231
164
|
|
|
232
|
-
|
|
165
|
+
### `nice-checkers/internal-links`
|
|
233
166
|
|
|
234
|
-
|
|
235
|
-
<!-- Link to existing page -->
|
|
236
|
-
<a href="/about">About page</a>
|
|
167
|
+
Validates that all internal links point to existing files in your project. This rule prevents broken internal navigation and missing resource references.
|
|
237
168
|
|
|
238
|
-
|
|
239
|
-
<
|
|
169
|
+
```diff
|
|
170
|
+
- <a href="/nonexistent-page">Broken internal link</a>
|
|
171
|
+
- <img src="../images/missing.webp" alt="Missing image" />
|
|
172
|
+
+ <a href="/about">Working internal link</a>
|
|
173
|
+
+ <img src="../images/logo.webp" alt="Company logo" />
|
|
240
174
|
```
|
|
241
175
|
|
|
242
|
-
|
|
176
|
+
### Configuration
|
|
243
177
|
|
|
244
178
|
```json
|
|
245
179
|
{
|
|
@@ -256,43 +190,30 @@ Validates that all internal links point to existing files in your project.
|
|
|
256
190
|
}
|
|
257
191
|
```
|
|
258
192
|
|
|
259
|
-
|
|
193
|
+
### Configuration options
|
|
260
194
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
195
|
+
| Option | Type | Default | Description |
|
|
196
|
+
| ----------------------- | ---------- | -------------- | ------------------------------------------- |
|
|
197
|
+
| `webRoot` | `string` | `"./build"` | Root directory for resolving absolute links |
|
|
198
|
+
| `alternativeExtensions` | `string[]` | `[".html"]` | Extensions to check for extensionless links |
|
|
199
|
+
| `indexFile` | `string` | `"index.html"` | Default file to look for in directory links |
|
|
264
200
|
|
|
265
201
|
### `nice-checkers/latest-packages`
|
|
266
202
|
|
|
267
|
-
Ensures that package assets loaded from CDNs (like jsDelivr) are using the latest version and have proper SRI attributes.
|
|
203
|
+
Ensures that package assets loaded from CDNs (like jsDelivr) are using the latest version and have proper SRI attributes. This rule promotes security and ensures you're using up-to-date packages.
|
|
268
204
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
<!--
|
|
273
|
-
<script
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
/>`` **Good:** ```html
|
|
280
|
-
<!-- Latest package with SRI -->
|
|
281
|
-
<script
|
|
282
|
-
src="https://cdn.jsdelivr.net/npm/bootstrap@latest/dist/js/bootstrap.min.js"
|
|
283
|
-
integrity="sha384-..."
|
|
284
|
-
crossorigin="anonymous"
|
|
285
|
-
></script>
|
|
286
|
-
|
|
287
|
-
<link
|
|
288
|
-
rel="stylesheet"
|
|
289
|
-
href="https://cdn.jsdelivr.net/npm/bootstrap@latest/dist/css/bootstrap.min.css"
|
|
290
|
-
integrity="sha384-..."
|
|
291
|
-
crossorigin="anonymous"
|
|
292
|
-
/>
|
|
293
|
-
````
|
|
205
|
+
```diff
|
|
206
|
+
- <!-- Outdated package without SRI -->
|
|
207
|
+
- <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.min.js"></script>
|
|
208
|
+
+ <!-- Latest package with SRI -->
|
|
209
|
+
+ <script
|
|
210
|
+
+ src="https://cdn.jsdelivr.net/npm/bootstrap@.../dist/js/bootstrap.min.js"
|
|
211
|
+
+ integrity="sha384-..."
|
|
212
|
+
+ crossorigin="anonymous"
|
|
213
|
+
+ ></script>
|
|
214
|
+
```
|
|
294
215
|
|
|
295
|
-
|
|
216
|
+
### Configuration
|
|
296
217
|
|
|
297
218
|
```json
|
|
298
219
|
{
|
|
@@ -310,29 +231,25 @@ Ensures that package assets loaded from CDNs (like jsDelivr) are using the lates
|
|
|
310
231
|
}
|
|
311
232
|
```
|
|
312
233
|
|
|
313
|
-
###
|
|
314
|
-
|
|
315
|
-
Enforces that mailto links contain specific parameters to improve user experience.
|
|
234
|
+
### Configuration options
|
|
316
235
|
|
|
317
|
-
|
|
236
|
+
| Option | Type | Default | Description |
|
|
237
|
+
| -------------------- | ---------- | ---------------------------- | ----------------------------------------------------------- |
|
|
238
|
+
| `cacheExpirySeconds` | `number` | `172800` | Cache duration for package version checks (default: 2 days) |
|
|
239
|
+
| `timeoutSeconds` | `number` | `10` | Request timeout in seconds |
|
|
240
|
+
| `cacheDatabasePath` | `string` | `"cache/latest-packages.db"` | Path to the cache database file |
|
|
241
|
+
| `skipUrlPatterns` | `string[]` | `[]` | Array of URL patterns to skip checking |
|
|
318
242
|
|
|
319
|
-
|
|
320
|
-
<!-- Mailto without required parameters -->
|
|
321
|
-
<a href="mailto:contact@example.com">Send email</a>
|
|
322
|
-
```
|
|
243
|
+
### `nice-checkers/mailto-awesome`
|
|
323
244
|
|
|
324
|
-
|
|
245
|
+
Enforces that `mailto:` links contain specific parameters to improve user experience. This rule ensures email links provide helpful context to users.
|
|
325
246
|
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
<a
|
|
329
|
-
href="mailto:contact@example.com?subject=Website%20Inquiry&body=Hello,%20I%20would%20like%20to..."
|
|
330
|
-
>
|
|
331
|
-
Send email
|
|
332
|
-
</a>
|
|
247
|
+
```diff
|
|
248
|
+
- <a href="mailto:contact@example.com">Send email</a>
|
|
249
|
+
+ <a href="mailto:contact@example.com?subject=Website%20Inquiry&body=Hello,%20I%20would%20like%20to...">Send email</a>
|
|
333
250
|
```
|
|
334
251
|
|
|
335
|
-
|
|
252
|
+
### Configuration
|
|
336
253
|
|
|
337
254
|
```json
|
|
338
255
|
{
|
|
@@ -347,37 +264,42 @@ Enforces that mailto links contain specific parameters to improve user experienc
|
|
|
347
264
|
}
|
|
348
265
|
```
|
|
349
266
|
|
|
350
|
-
|
|
267
|
+
### Configuration options
|
|
351
268
|
|
|
352
|
-
|
|
269
|
+
| Option | Type | Default | Description |
|
|
270
|
+
| -------------------- | ---------- | ------- | ---------------------------------------------------------------------------- |
|
|
271
|
+
| `requiredParameters` | `string[]` | `[]` | Array of parameters that must be present (e.g., `["subject", "body", "cc"]`) |
|
|
353
272
|
|
|
354
273
|
### `nice-checkers/no-jquery`
|
|
355
274
|
|
|
356
|
-
|
|
275
|
+
If you are still using jQuery after 2022, please try to open your favorite chatbot and ask how to replace it with vanilla JavaScript. Your page will run faster. And it is very possible that your chatbot can do this entire operation in one go without interactive back-and-forth.
|
|
357
276
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
<!-- jQuery script tag -->
|
|
362
|
-
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
|
363
|
-
<script src="../js/jquery.min.js"></script>
|
|
277
|
+
```diff
|
|
278
|
+
- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
|
279
|
+
- <script src="../js/jquery.min.js"></script>
|
|
364
280
|
```
|
|
365
281
|
|
|
366
|
-
|
|
282
|
+
### Configuration
|
|
367
283
|
|
|
368
|
-
|
|
284
|
+
```json
|
|
285
|
+
{
|
|
286
|
+
"rules": {
|
|
287
|
+
"nice-checkers/no-jquery": "error"
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
```
|
|
369
291
|
|
|
370
|
-
|
|
371
|
-
<script src="https://unpkg.com/htmx.org@1.8.4"></script>
|
|
372
|
-
<script src="../js/vanilla-app.js"></script>
|
|
292
|
+
### Configuration options
|
|
373
293
|
|
|
374
|
-
|
|
294
|
+
This rule has no configurable options.
|
|
375
295
|
|
|
376
296
|
## Development
|
|
377
297
|
|
|
378
|
-
This package is built with TypeScript and supports both ESM and CommonJS module systems.
|
|
298
|
+
This package is built with TypeScript and supports both ESM and CommonJS module systems. Thank you for contributing improvements to this project!
|
|
379
299
|
|
|
380
|
-
|
|
300
|
+
:warning: Known issue: ESM and CommonnJS builds are [sometimes not building correctly](https://github.com/fulldecent/html-validate-nice-checkers/issues/6).
|
|
301
|
+
|
|
302
|
+
### Install
|
|
381
303
|
|
|
382
304
|
```sh
|
|
383
305
|
# Clone the repository
|
|
@@ -392,7 +314,7 @@ corepack enable
|
|
|
392
314
|
|
|
393
315
|
# Install dependencies
|
|
394
316
|
yarn install
|
|
395
|
-
|
|
317
|
+
```
|
|
396
318
|
|
|
397
319
|
### Hint: VS Code setup for Yarn Berry
|
|
398
320
|
|
|
@@ -402,55 +324,30 @@ These notes are [from the Yarn project](https://yarnpkg.com/getting-started/edit
|
|
|
402
324
|
yarn dlx @yarnpkg/sdks vscode
|
|
403
325
|
```
|
|
404
326
|
|
|
405
|
-
and YES use workspace TypeScript version.
|
|
327
|
+
and YES, use workspace TypeScript version.
|
|
406
328
|
|
|
407
|
-
### Development
|
|
329
|
+
### [Development scripts](https://github.com/fulldecent/html-validate-nice-checkers/blob/main/package.json)
|
|
408
330
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
yarn
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
yarn
|
|
415
|
-
|
|
416
|
-
# Run tests in watch mode
|
|
417
|
-
yarn test:watch
|
|
418
|
-
|
|
419
|
-
# Run tests with coverage
|
|
420
|
-
yarn test:coverage
|
|
421
|
-
|
|
422
|
-
# Type checking
|
|
423
|
-
yarn lint
|
|
331
|
+
- `yarn build` builds the package
|
|
332
|
+
- `yarn build:watch` builds the package in watch mode
|
|
333
|
+
- `yarn test` runs the tests once
|
|
334
|
+
- `yarn test:watch` runs the tests in watch mode
|
|
335
|
+
- `yarn test:coverage` runs the tests and generates a coverage report
|
|
336
|
+
- `yarn lint` runs TypeScript type checking
|
|
337
|
+
- `yarn format` formats all source files with Prettier
|
|
424
338
|
|
|
425
|
-
|
|
426
|
-
yarn build:watch
|
|
427
|
-
```
|
|
428
|
-
|
|
429
|
-
## Publishing
|
|
430
|
-
|
|
431
|
-
The package uses GitHub Actions for CI/CD:
|
|
339
|
+
## Publishing to [npm registry](https://www.npmjs.com/package/@fulldecent/nice-checkers-plugin)
|
|
432
340
|
|
|
433
|
-
|
|
434
|
-
2. **Package validation** tests ESM/CJS imports
|
|
435
|
-
3. **Publishing** to npm on tagged releases
|
|
341
|
+
@fulldecent will periodically create a GitHub release and this triggers [the npm publish workflow](https://github.com/fulldecent/html-validate-nice-checkers/blob/main/.github/workflows/publish.yml).
|
|
436
342
|
|
|
437
|
-
##
|
|
343
|
+
## Maintenance
|
|
438
344
|
|
|
439
|
-
-
|
|
440
|
-
- ✅ **TypeScript**: Full type definitions included
|
|
441
|
-
- ✅ **Tree Shakeable**: Import only what you need
|
|
442
|
-
- ✅ **Zero Dependencies**: No runtime dependencies
|
|
443
|
-
- ✅ **Modern Tooling**: Built with tsup, tested with Vitest
|
|
444
|
-
- ✅ **Comprehensive Testing**: High test coverage with realistic fixtures
|
|
345
|
+
Periodically, load schemaorg-current-https.jsonld file from <https://schema.org/docs/developers.html> and save to src/vendor/schemaorg-current-https.jsonld. Ideally, the sponsors of Schema.org: Google, Inc., Yahoo, Inc., Microsoft Corporation and Yandex should maintain a NPM package for this file that we can depend on. This would allow our package manager to handle updates.
|
|
445
346
|
|
|
446
347
|
## Browser support
|
|
447
348
|
|
|
448
|
-
This is a Node.js library designed for build-time HTML validation. For browser usage, ensure your bundler supports the module format you're using.
|
|
349
|
+
This is a Node.js library designed for build-time HTML validation. For browser usage, ensure your bundler supports the module format you're using. Some of our rules use `cURL` which will not work in the browser. We would like to switch to `fetch()` but [are limited by](https://gitlab.com/html-validate/html-validate/-/issues/317) HTML-validate.
|
|
449
350
|
|
|
450
351
|
## Contributing
|
|
451
352
|
|
|
452
|
-
Ensure your changes pass `yarn
|
|
453
|
-
|
|
454
|
-
## Deploying
|
|
455
|
-
|
|
456
|
-
@fulldecent will deploy by making GitHub releases, this triggers the release workflow.
|
|
353
|
+
Ensure your changes pass `yarn format && yarn lint && yarn test`.
|