html-validate 1.13.0 → 1.16.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 +36 -0
- package/build/cli/cli.d.ts +8 -0
- package/build/cli/cli.js +10 -0
- package/build/cli/html-validate.js +41 -13
- package/build/cli/init.d.ts +9 -0
- package/build/cli/init.js +90 -0
- package/build/config/config.js +2 -2
- package/build/dom/attribute.d.ts +2 -2
- package/build/dom/domnode.d.ts +3 -3
- package/build/dom/htmlelement.d.ts +7 -7
- package/build/dom/text.d.ts +3 -3
- package/build/engine/engine.js +0 -1
- package/build/htmlvalidate.d.ts +11 -1
- package/build/htmlvalidate.js +23 -3
- package/build/matchers.d.ts +1 -1
- package/build/meta/element.d.ts +1 -1
- package/build/rule.d.ts +1 -1
- package/build/rules/deprecated-rule.js +0 -1
- package/build/rules/input-missing-label.js +7 -0
- package/build/shim.d.ts +4 -3
- package/build/shim.js +3 -0
- package/package.json +26 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# html-validate changelog
|
|
2
2
|
|
|
3
|
+
# [1.16.0](https://gitlab.com/html-validate/html-validate/compare/v1.15.0...v1.16.0) (2019-11-09)
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
- **cli:** fix `--init` not creating configuration unless overwriting ([9098529](https://gitlab.com/html-validate/html-validate/commit/90985293bf941c54055c93b35a6c6f865a2f65e6))
|
|
8
|
+
- **config:** use `readFile` to prevent unintended caching ([4864bfa](https://gitlab.com/html-validate/html-validate/commit/4864bfa26edaf77b7bf7b0f551ffe7469a803c42))
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
- **shim:** expose version number in shim ([890d122](https://gitlab.com/html-validate/html-validate/commit/890d12269cfbfff7ce6b4e49e1876bb51ca7ccdd))
|
|
13
|
+
|
|
14
|
+
# [1.15.0](https://gitlab.com/html-validate/html-validate/compare/v1.14.1...v1.15.0) (2019-11-03)
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
- **cli:** `--help` does not take an argument ([e22293f](https://gitlab.com/html-validate/html-validate/commit/e22293fc3257f6ba9732016d2be44214299e23c2))
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
- **cli:** add `--dump-source` to debug transformers ([4d32a0d](https://gitlab.com/html-validate/html-validate/commit/4d32a0d6fc8e3caaa62107affa94fe0fe16aab1f))
|
|
23
|
+
- **cli:** add `--init` to create initial configuration ([6852d30](https://gitlab.com/html-validate/html-validate/commit/6852d30dcbccc5ebed3267c6dd181146156646f0))
|
|
24
|
+
|
|
25
|
+
## [1.14.1](https://gitlab.com/html-validate/html-validate/compare/v1.14.0...v1.14.1) (2019-10-27)
|
|
26
|
+
|
|
27
|
+
### Bug Fixes
|
|
28
|
+
|
|
29
|
+
- input hidden should not have label ([66cf13d](https://gitlab.com/html-validate/html-validate/commit/66cf13d489cbb641fabe83121fa0f135440875f8)), closes [#53](https://gitlab.com/html-validate/html-validate/issues/53)
|
|
30
|
+
|
|
31
|
+
# [1.14.0](https://gitlab.com/html-validate/html-validate/compare/v1.13.0...v1.14.0) (2019-10-20)
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
- **shim:** expose more types ([86bb78d](https://gitlab.com/html-validate/html-validate/commit/86bb78d))
|
|
36
|
+
- enable typescript strict mode (excect strict null) ([5d2b45e](https://gitlab.com/html-validate/html-validate/commit/5d2b45e))
|
|
37
|
+
- **htmlvalidate:** support passing filename to `validateString` ([c2e09a2](https://gitlab.com/html-validate/html-validate/commit/c2e09a2))
|
|
38
|
+
|
|
3
39
|
# [1.13.0](https://gitlab.com/html-validate/html-validate/compare/v1.12.0...v1.13.0) (2019-10-13)
|
|
4
40
|
|
|
5
41
|
### Features
|
package/build/cli/cli.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import HtmlValidate from "../htmlvalidate";
|
|
2
2
|
import { Report } from "../reporter";
|
|
3
3
|
import { ExpandOptions } from "./expand-files";
|
|
4
|
+
import { InitResult } from "./init";
|
|
4
5
|
export interface CLIOptions {
|
|
5
6
|
configFile?: string;
|
|
6
7
|
rules?: string | string[];
|
|
@@ -17,6 +18,13 @@ export declare class CLI {
|
|
|
17
18
|
constructor(options?: CLIOptions);
|
|
18
19
|
expandFiles(patterns: string[], options?: ExpandOptions): string[];
|
|
19
20
|
getFormatter(formatters: string): (report: Report) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Initialize project with a new configuration.
|
|
23
|
+
*
|
|
24
|
+
* A new `.htmlvalidate.json` file will be placed in the path provided by
|
|
25
|
+
* `cwd`.
|
|
26
|
+
*/
|
|
27
|
+
init(cwd: string): Promise<InitResult>;
|
|
20
28
|
/**
|
|
21
29
|
* Get HtmlValidate instance with configuration based on options passed to the
|
|
22
30
|
* constructor.
|
package/build/cli/cli.js
CHANGED
|
@@ -9,6 +9,7 @@ const error_1 = require("../error");
|
|
|
9
9
|
const htmlvalidate_1 = __importDefault(require("../htmlvalidate"));
|
|
10
10
|
const expand_files_1 = require("./expand-files");
|
|
11
11
|
const formatter_1 = require("./formatter");
|
|
12
|
+
const init_1 = require("./init");
|
|
12
13
|
class CLI {
|
|
13
14
|
/**
|
|
14
15
|
* Create new CLI helper.
|
|
@@ -26,6 +27,15 @@ class CLI {
|
|
|
26
27
|
getFormatter(formatters) {
|
|
27
28
|
return formatter_1.getFormatter(formatters);
|
|
28
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Initialize project with a new configuration.
|
|
32
|
+
*
|
|
33
|
+
* A new `.htmlvalidate.json` file will be placed in the path provided by
|
|
34
|
+
* `cwd`.
|
|
35
|
+
*/
|
|
36
|
+
init(cwd) {
|
|
37
|
+
return init_1.init(cwd);
|
|
38
|
+
}
|
|
29
39
|
/**
|
|
30
40
|
* Get HtmlValidate instance with configuration based on options passed to the
|
|
31
41
|
* constructor.
|
|
@@ -13,15 +13,23 @@ const cli_1 = require("./cli");
|
|
|
13
13
|
var Mode;
|
|
14
14
|
(function (Mode) {
|
|
15
15
|
Mode[Mode["LINT"] = 0] = "LINT";
|
|
16
|
-
Mode[Mode["
|
|
17
|
-
Mode[Mode["
|
|
18
|
-
Mode[Mode["
|
|
19
|
-
Mode[Mode["
|
|
16
|
+
Mode[Mode["INIT"] = 1] = "INIT";
|
|
17
|
+
Mode[Mode["DUMP_EVENTS"] = 2] = "DUMP_EVENTS";
|
|
18
|
+
Mode[Mode["DUMP_TOKENS"] = 3] = "DUMP_TOKENS";
|
|
19
|
+
Mode[Mode["DUMP_TREE"] = 4] = "DUMP_TREE";
|
|
20
|
+
Mode[Mode["DUMP_SOURCE"] = 5] = "DUMP_SOURCE";
|
|
21
|
+
Mode[Mode["PRINT_CONFIG"] = 6] = "PRINT_CONFIG";
|
|
20
22
|
})(Mode || (Mode = {}));
|
|
21
23
|
function getMode(argv) {
|
|
24
|
+
if (argv.init) {
|
|
25
|
+
return Mode.INIT;
|
|
26
|
+
}
|
|
22
27
|
if (argv["dump-events"]) {
|
|
23
28
|
return Mode.DUMP_EVENTS;
|
|
24
29
|
}
|
|
30
|
+
if (argv["dump-source"]) {
|
|
31
|
+
return Mode.DUMP_SOURCE;
|
|
32
|
+
}
|
|
25
33
|
if (argv["dump-tokens"]) {
|
|
26
34
|
return Mode.DUMP_TOKENS;
|
|
27
35
|
}
|
|
@@ -60,6 +68,9 @@ function dump(files, mode) {
|
|
|
60
68
|
case Mode.DUMP_TREE:
|
|
61
69
|
lines = files.map((filename) => htmlvalidate.dumpTree(filename));
|
|
62
70
|
break;
|
|
71
|
+
case Mode.DUMP_SOURCE:
|
|
72
|
+
lines = files.map((filename) => htmlvalidate.dumpSource(filename));
|
|
73
|
+
break;
|
|
63
74
|
default:
|
|
64
75
|
throw new Error(`Unknown mode "${mode}"`);
|
|
65
76
|
}
|
|
@@ -79,16 +90,18 @@ const argv = minimist_1.default(process.argv.slice(2), {
|
|
|
79
90
|
"ext",
|
|
80
91
|
"f",
|
|
81
92
|
"formatter",
|
|
82
|
-
"h",
|
|
83
|
-
"help",
|
|
84
93
|
"max-warnings",
|
|
85
94
|
"rule",
|
|
86
95
|
"stdin-filename",
|
|
87
96
|
],
|
|
88
97
|
boolean: [
|
|
98
|
+
"init",
|
|
89
99
|
"dump-events",
|
|
100
|
+
"dump-source",
|
|
90
101
|
"dump-tokens",
|
|
91
102
|
"dump-tree",
|
|
103
|
+
"h",
|
|
104
|
+
"help",
|
|
92
105
|
"print-config",
|
|
93
106
|
"stdin",
|
|
94
107
|
"version",
|
|
@@ -122,17 +135,19 @@ Common options:
|
|
|
122
135
|
--stdin process markup from stdin.
|
|
123
136
|
--stdin-filename=STRING specify filename to report when using stdin
|
|
124
137
|
|
|
125
|
-
Debugging options:
|
|
126
|
-
--dump-events output events during parsing.
|
|
127
|
-
--dump-tokens output tokens from lexing stage.
|
|
128
|
-
--dump-tree output nodes from the dom tree.
|
|
129
|
-
|
|
130
138
|
Miscellaneous:
|
|
131
139
|
-c, --config=STRING use custom configuration file.
|
|
140
|
+
--init initialize project with a new configuration
|
|
132
141
|
--print-config output configuration for given file.
|
|
133
142
|
-h, --help show help.
|
|
134
143
|
--version show version.
|
|
135
144
|
|
|
145
|
+
Debugging options:
|
|
146
|
+
--dump-events output events during parsing.
|
|
147
|
+
--dump-source output post-transformed source data.
|
|
148
|
+
--dump-tokens output tokens from lexing stage.
|
|
149
|
+
--dump-tree output nodes from the dom tree.
|
|
150
|
+
|
|
136
151
|
Formatters:
|
|
137
152
|
|
|
138
153
|
Multiple formatters can be specified with a comma-separated list,
|
|
@@ -152,7 +167,7 @@ if (argv.version) {
|
|
|
152
167
|
showVersion();
|
|
153
168
|
process.exit();
|
|
154
169
|
}
|
|
155
|
-
if (argv.help || argv._.length === 0) {
|
|
170
|
+
if (argv.help || (argv._.length === 0 && !argv.init)) {
|
|
156
171
|
showUsage();
|
|
157
172
|
process.exit();
|
|
158
173
|
}
|
|
@@ -174,7 +189,7 @@ const extensions = (argv.ext || "html").split(",").map((cur) => {
|
|
|
174
189
|
return cur[0] === "." ? cur.slice(1) : cur;
|
|
175
190
|
});
|
|
176
191
|
const files = cli.expandFiles(argv._, { extensions });
|
|
177
|
-
if (files.length === 0) {
|
|
192
|
+
if (files.length === 0 && mode !== Mode.INIT) {
|
|
178
193
|
console.error("No files matching patterns", argv._);
|
|
179
194
|
process.exit(1);
|
|
180
195
|
}
|
|
@@ -192,6 +207,19 @@ try {
|
|
|
192
207
|
}
|
|
193
208
|
process.exit(result.valid ? 0 : 1);
|
|
194
209
|
}
|
|
210
|
+
else if (mode === Mode.INIT) {
|
|
211
|
+
cli
|
|
212
|
+
.init(process.cwd())
|
|
213
|
+
.then(result => {
|
|
214
|
+
console.log(`Configuration written to "${result.filename}"`);
|
|
215
|
+
})
|
|
216
|
+
.catch(err => {
|
|
217
|
+
if (err) {
|
|
218
|
+
console.error(err);
|
|
219
|
+
}
|
|
220
|
+
process.exit(1);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
195
223
|
else if (mode === Mode.PRINT_CONFIG) {
|
|
196
224
|
const config = htmlvalidate.getConfigFor(files[0]);
|
|
197
225
|
const json = JSON.stringify(config.get(), null, 2);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
9
|
+
var Frameworks;
|
|
10
|
+
(function (Frameworks) {
|
|
11
|
+
Frameworks["angularjs"] = "AngularJS";
|
|
12
|
+
Frameworks["vuejs"] = "Vue.js";
|
|
13
|
+
Frameworks["markdown"] = "Markdown";
|
|
14
|
+
})(Frameworks = exports.Frameworks || (exports.Frameworks = {}));
|
|
15
|
+
const frameworkConfig = {
|
|
16
|
+
[Frameworks.angularjs]: {
|
|
17
|
+
transform: {
|
|
18
|
+
"^.*\\.js$": "html-validate-angular/js",
|
|
19
|
+
"^.*\\.html$": "html-validate-angular/html",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
[Frameworks.vuejs]: {
|
|
23
|
+
elements: ["html-validate-vue/elements"],
|
|
24
|
+
transform: {
|
|
25
|
+
"^.*\\.vue$": "html-validate-vue",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
[Frameworks.markdown]: {
|
|
29
|
+
transform: {
|
|
30
|
+
"^.*\\.md$": "html-validate-markdown",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
function addFrameworks(src, frameworks) {
|
|
35
|
+
let config = src;
|
|
36
|
+
for (const framework of frameworks) {
|
|
37
|
+
config = deepmerge_1.default(config, frameworkConfig[framework]);
|
|
38
|
+
}
|
|
39
|
+
return config;
|
|
40
|
+
}
|
|
41
|
+
function writeConfig(dst, config) {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
fs_1.default.writeFile(dst, JSON.stringify(config, null, 2), err => {
|
|
44
|
+
if (err)
|
|
45
|
+
reject(err);
|
|
46
|
+
resolve();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
async function init(cwd) {
|
|
51
|
+
const filename = `${cwd}/.htmlvalidate.json`;
|
|
52
|
+
const exists = fs_1.default.existsSync(filename);
|
|
53
|
+
const initialConfig = {
|
|
54
|
+
elements: ["html5"],
|
|
55
|
+
extends: ["htmlvalidate:recommended"],
|
|
56
|
+
};
|
|
57
|
+
const when = /* istanbul ignore next */ (answers) => {
|
|
58
|
+
return !exists || answers.write;
|
|
59
|
+
};
|
|
60
|
+
const questions = [
|
|
61
|
+
{
|
|
62
|
+
name: "write",
|
|
63
|
+
type: "confirm",
|
|
64
|
+
default: false,
|
|
65
|
+
when: exists,
|
|
66
|
+
message: "A .htmlvalidate.json file already exists, do you want to overwrite it?",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "frameworks",
|
|
70
|
+
type: "checkbox",
|
|
71
|
+
choices: [Frameworks.angularjs, Frameworks.vuejs, Frameworks.markdown],
|
|
72
|
+
message: "Support additional frameworks?",
|
|
73
|
+
when,
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
/* prompt user for questions */
|
|
77
|
+
const answers = await inquirer_1.default.prompt(questions);
|
|
78
|
+
/* dont overwrite configuration unless explicitly requested */
|
|
79
|
+
if (exists && !answers.write) {
|
|
80
|
+
return Promise.reject();
|
|
81
|
+
}
|
|
82
|
+
/* write configuration to file */
|
|
83
|
+
let config = initialConfig;
|
|
84
|
+
config = addFrameworks(config, answers.frameworks);
|
|
85
|
+
await writeConfig(filename, config);
|
|
86
|
+
return {
|
|
87
|
+
filename,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
exports.init = init;
|
package/build/config/config.js
CHANGED
|
@@ -35,8 +35,8 @@ function mergeInternal(base, rhs) {
|
|
|
35
35
|
function loadFromFile(filename) {
|
|
36
36
|
let json;
|
|
37
37
|
try {
|
|
38
|
-
|
|
39
|
-
json =
|
|
38
|
+
const data = fs_1.default.readFileSync(filename, "utf-8");
|
|
39
|
+
json = JSON.parse(data);
|
|
40
40
|
}
|
|
41
41
|
catch (err) {
|
|
42
42
|
throw new error_2.ConfigError(`Failed to read configuration from "${filename}"`, err);
|
package/build/dom/attribute.d.ts
CHANGED
|
@@ -26,11 +26,11 @@ export declare class Attribute {
|
|
|
26
26
|
/**
|
|
27
27
|
* Flag set to true if the attribute value is static.
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
get isStatic(): boolean;
|
|
30
30
|
/**
|
|
31
31
|
* Flag set to true if the attribute value is dynamic.
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
get isDynamic(): boolean;
|
|
34
34
|
/**
|
|
35
35
|
* Test attribute value.
|
|
36
36
|
*
|
package/build/dom/domnode.d.ts
CHANGED
|
@@ -25,19 +25,19 @@ export declare class DOMNode {
|
|
|
25
25
|
/**
|
|
26
26
|
* Get the text (recursive) from all child nodes.
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
get textContent(): string;
|
|
29
29
|
append(node: DOMNode): void;
|
|
30
30
|
isRootElement(): boolean;
|
|
31
31
|
/**
|
|
32
32
|
* Returns a DOMNode representing the first direct child node or `null` if the
|
|
33
33
|
* node has no children.
|
|
34
34
|
*/
|
|
35
|
-
|
|
35
|
+
get firstChild(): DOMNode;
|
|
36
36
|
/**
|
|
37
37
|
* Returns a DOMNode representing the last direct child node or `null` if the
|
|
38
38
|
* node has no children.
|
|
39
39
|
*/
|
|
40
|
-
|
|
40
|
+
get lastChild(): DOMNode;
|
|
41
41
|
/**
|
|
42
42
|
* Disable a rule for this node.
|
|
43
43
|
*/
|
|
@@ -28,7 +28,7 @@ export declare class HtmlElement extends DOMNode {
|
|
|
28
28
|
/**
|
|
29
29
|
* Similar to childNodes but only elements.
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
get childElements(): HtmlElement[];
|
|
32
32
|
/**
|
|
33
33
|
* Find the first ancestor matching a selector.
|
|
34
34
|
*
|
|
@@ -52,7 +52,7 @@ export declare class HtmlElement extends DOMNode {
|
|
|
52
52
|
/**
|
|
53
53
|
* Get a list of all attributes on this node.
|
|
54
54
|
*/
|
|
55
|
-
|
|
55
|
+
get attributes(): Attribute[];
|
|
56
56
|
hasAttribute(key: string): boolean;
|
|
57
57
|
/**
|
|
58
58
|
* Get attribute.
|
|
@@ -96,11 +96,11 @@ export declare class HtmlElement extends DOMNode {
|
|
|
96
96
|
* Return a list of all known classes on the element. Dynamic values are
|
|
97
97
|
* ignored.
|
|
98
98
|
*/
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
get classList(): DOMTokenList;
|
|
100
|
+
get id(): string;
|
|
101
|
+
get siblings(): HtmlElement[];
|
|
102
|
+
get previousSibling(): HtmlElement;
|
|
103
|
+
get nextSibling(): HtmlElement;
|
|
104
104
|
getElementsByTagName(tagName: string): HtmlElement[];
|
|
105
105
|
querySelector(selector: string): HtmlElement;
|
|
106
106
|
querySelectorAll(selector: string): HtmlElement[];
|
package/build/dom/text.d.ts
CHANGED
|
@@ -18,13 +18,13 @@ export declare class TextNode extends DOMNode {
|
|
|
18
18
|
/**
|
|
19
19
|
* Get the text from node.
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
get textContent(): string;
|
|
22
22
|
/**
|
|
23
23
|
* Flag set to true if the attribute value is static.
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
get isStatic(): boolean;
|
|
26
26
|
/**
|
|
27
27
|
* Flag set to true if the attribute value is dynamic.
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
get isDynamic(): boolean;
|
|
30
30
|
}
|
package/build/engine/engine.js
CHANGED
package/build/htmlvalidate.d.ts
CHANGED
|
@@ -24,10 +24,11 @@ declare class HtmlValidate {
|
|
|
24
24
|
* Parse and validate HTML from string.
|
|
25
25
|
*
|
|
26
26
|
* @param str - Text to parse.
|
|
27
|
+
* @param filename - If set configuration is loaded for given filename.
|
|
27
28
|
* @param hooks - Optional hooks (see [[Source]]) for definition.
|
|
28
29
|
* @returns Report output.
|
|
29
30
|
*/
|
|
30
|
-
validateString(str: string, hooks?: SourceHooks): Report;
|
|
31
|
+
validateString(str: string, filename?: string, hooks?: SourceHooks): Report;
|
|
31
32
|
/**
|
|
32
33
|
* Parse and validate HTML from [[Source]].
|
|
33
34
|
*
|
|
@@ -77,6 +78,15 @@ declare class HtmlValidate {
|
|
|
77
78
|
* @param filename - Filename to dump DOM tree from.
|
|
78
79
|
*/
|
|
79
80
|
dumpTree(filename: string): string[];
|
|
81
|
+
/**
|
|
82
|
+
* Transform filename and output source data.
|
|
83
|
+
*
|
|
84
|
+
* Using CLI this is enabled with `--dump-source`. Mostly useful for
|
|
85
|
+
* debugging.
|
|
86
|
+
*
|
|
87
|
+
* @param filename - Filename to dump source from.
|
|
88
|
+
*/
|
|
89
|
+
dumpSource(filename: string): string[];
|
|
80
90
|
/**
|
|
81
91
|
* Get contextual documentation for the given rule.
|
|
82
92
|
*
|
package/build/htmlvalidate.js
CHANGED
|
@@ -25,14 +25,15 @@ class HtmlValidate {
|
|
|
25
25
|
* Parse and validate HTML from string.
|
|
26
26
|
*
|
|
27
27
|
* @param str - Text to parse.
|
|
28
|
+
* @param filename - If set configuration is loaded for given filename.
|
|
28
29
|
* @param hooks - Optional hooks (see [[Source]]) for definition.
|
|
29
30
|
* @returns Report output.
|
|
30
31
|
*/
|
|
31
|
-
validateString(str, hooks) {
|
|
32
|
+
validateString(str, filename, hooks) {
|
|
32
33
|
const source = {
|
|
33
34
|
column: 1,
|
|
34
35
|
data: str,
|
|
35
|
-
filename: "inline",
|
|
36
|
+
filename: filename || "inline",
|
|
36
37
|
line: 1,
|
|
37
38
|
hooks,
|
|
38
39
|
};
|
|
@@ -45,7 +46,7 @@ class HtmlValidate {
|
|
|
45
46
|
* @returns Report output.
|
|
46
47
|
*/
|
|
47
48
|
validateSource(source) {
|
|
48
|
-
const config = this.getConfigFor(
|
|
49
|
+
const config = this.getConfigFor(source.filename);
|
|
49
50
|
const engine = new engine_1.Engine(config, parser_1.Parser);
|
|
50
51
|
return engine.lint([source]);
|
|
51
52
|
}
|
|
@@ -113,6 +114,25 @@ class HtmlValidate {
|
|
|
113
114
|
const engine = new engine_1.Engine(config, parser_1.Parser);
|
|
114
115
|
return engine.dumpTree(source);
|
|
115
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Transform filename and output source data.
|
|
119
|
+
*
|
|
120
|
+
* Using CLI this is enabled with `--dump-source`. Mostly useful for
|
|
121
|
+
* debugging.
|
|
122
|
+
*
|
|
123
|
+
* @param filename - Filename to dump source from.
|
|
124
|
+
*/
|
|
125
|
+
dumpSource(filename) {
|
|
126
|
+
const config = this.getConfigFor(filename);
|
|
127
|
+
const sources = config.transform(filename);
|
|
128
|
+
return sources.reduce((result, source) => {
|
|
129
|
+
result.push(`Source ${source.filename}@${source.line}:${source.column}`);
|
|
130
|
+
result.push("---");
|
|
131
|
+
result = result.concat(source.data.split("\n"));
|
|
132
|
+
result.push("---");
|
|
133
|
+
return result;
|
|
134
|
+
}, []);
|
|
135
|
+
}
|
|
116
136
|
/**
|
|
117
137
|
* Get contextual documentation for the given rule.
|
|
118
138
|
*
|
package/build/matchers.d.ts
CHANGED
package/build/meta/element.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export interface MetaData {
|
|
|
35
35
|
}
|
|
36
36
|
export interface MetaElement extends MetaData {
|
|
37
37
|
tagName: string;
|
|
38
|
-
[key: string]: boolean | PropertyExpression | Permitted | PermittedOrder | PermittedAttribute | RequiredAncestors;
|
|
38
|
+
[key: string]: undefined | boolean | PropertyExpression | Permitted | PermittedOrder | PermittedAttribute | RequiredAncestors;
|
|
39
39
|
}
|
|
40
40
|
export interface MetaDataTable {
|
|
41
41
|
[tagName: string]: MetaData;
|
package/build/rule.d.ts
CHANGED
|
@@ -12,6 +12,13 @@ class InputMissingLabel extends rule_1.Rule {
|
|
|
12
12
|
this.on("dom:ready", (event) => {
|
|
13
13
|
const root = event.document;
|
|
14
14
|
for (const elem of root.querySelectorAll("input, textarea, select")) {
|
|
15
|
+
/* <input type="hidden"> should not have label */
|
|
16
|
+
if (elem.is("input")) {
|
|
17
|
+
const type = elem.getAttributeValue("type");
|
|
18
|
+
if (type && type.toLowerCase() === "hidden") {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
15
22
|
/* try to find label by id */
|
|
16
23
|
if (findLabelById(root, elem.id)) {
|
|
17
24
|
continue;
|
package/build/shim.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { default as HtmlValidate } from "./htmlvalidate";
|
|
2
2
|
export { AttributeData } from "./parser";
|
|
3
3
|
export { CLI } from "./cli/cli";
|
|
4
|
-
export { Config, ConfigData, ConfigLoader } from "./config";
|
|
4
|
+
export { Config, ConfigData, ConfigLoader, Severity } from "./config";
|
|
5
5
|
export { DynamicValue, HtmlElement } from "./dom";
|
|
6
6
|
export { Rule } from "./rule";
|
|
7
|
-
export { Source } from "./context";
|
|
8
|
-
export { Reporter } from "./reporter";
|
|
7
|
+
export { Source, Location } from "./context";
|
|
8
|
+
export { Reporter, Message, Result } from "./reporter";
|
|
9
9
|
export { TemplateExtractor } from "./transform/template";
|
|
10
|
+
export declare const version: any;
|
package/build/shim.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.CLI = cli_1.CLI;
|
|
|
8
8
|
var config_1 = require("./config");
|
|
9
9
|
exports.Config = config_1.Config;
|
|
10
10
|
exports.ConfigLoader = config_1.ConfigLoader;
|
|
11
|
+
exports.Severity = config_1.Severity;
|
|
11
12
|
var dom_1 = require("./dom");
|
|
12
13
|
exports.DynamicValue = dom_1.DynamicValue;
|
|
13
14
|
exports.HtmlElement = dom_1.HtmlElement;
|
|
@@ -17,3 +18,5 @@ var reporter_1 = require("./reporter");
|
|
|
17
18
|
exports.Reporter = reporter_1.Reporter;
|
|
18
19
|
var template_1 = require("./transform/template");
|
|
19
20
|
exports.TemplateExtractor = template_1.TemplateExtractor;
|
|
21
|
+
const pkg = require("../package.json");
|
|
22
|
+
exports.version = pkg.version;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-validate",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "html linter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"html",
|
|
@@ -108,45 +108,47 @@
|
|
|
108
108
|
"eslint": "^6.0.0",
|
|
109
109
|
"espree": "^6.0.0",
|
|
110
110
|
"glob": "^7.1.3",
|
|
111
|
+
"inquirer": "^7.0.0",
|
|
111
112
|
"json-merge-patch": "^0.2.3",
|
|
112
113
|
"minimist": "^1.2.0"
|
|
113
114
|
},
|
|
114
115
|
"devDependencies": {
|
|
115
|
-
"@babel/core": "7.
|
|
116
|
-
"@babel/preset-env": "7.
|
|
116
|
+
"@babel/core": "7.7.2",
|
|
117
|
+
"@babel/preset-env": "7.7.1",
|
|
117
118
|
"@commitlint/cli": "8.2.0",
|
|
118
119
|
"@commitlint/config-conventional": "8.2.0",
|
|
119
|
-
"@semantic-release/changelog": "3.0.
|
|
120
|
-
"@semantic-release/exec": "3.3.
|
|
121
|
-
"@semantic-release/git": "7.0.
|
|
122
|
-
"@semantic-release/gitlab": "4.0.
|
|
123
|
-
"@semantic-release/npm": "5.
|
|
124
|
-
"@semantic-release/release-notes-generator": "7.3.
|
|
120
|
+
"@semantic-release/changelog": "3.0.5",
|
|
121
|
+
"@semantic-release/exec": "3.3.8",
|
|
122
|
+
"@semantic-release/git": "7.0.18",
|
|
123
|
+
"@semantic-release/gitlab": "4.0.4",
|
|
124
|
+
"@semantic-release/npm": "5.3.4",
|
|
125
|
+
"@semantic-release/release-notes-generator": "7.3.2",
|
|
125
126
|
"@types/babel__code-frame": "7.0.1",
|
|
126
127
|
"@types/estree": "0.0.39",
|
|
127
128
|
"@types/glob": "7.1.1",
|
|
128
|
-
"@types/
|
|
129
|
+
"@types/inquirer": "6.5.0",
|
|
130
|
+
"@types/jest": "24.0.22",
|
|
129
131
|
"@types/json-merge-patch": "0.0.4",
|
|
130
132
|
"@types/minimist": "1.2.0",
|
|
131
|
-
"@types/node": "11.
|
|
132
|
-
"@typescript-eslint/eslint-plugin": "2.
|
|
133
|
-
"@typescript-eslint/parser": "2.
|
|
134
|
-
"autoprefixer": "9.
|
|
133
|
+
"@types/node": "11.15.2",
|
|
134
|
+
"@typescript-eslint/eslint-plugin": "2.6.1",
|
|
135
|
+
"@typescript-eslint/parser": "2.6.1",
|
|
136
|
+
"autoprefixer": "9.7.1",
|
|
135
137
|
"babelify": "10.0.0",
|
|
136
138
|
"bootstrap-sass": "3.4.1",
|
|
137
139
|
"canonical-path": "1.0.0",
|
|
138
140
|
"cssnano": "4.1.10",
|
|
139
141
|
"dgeni": "0.4.12",
|
|
140
142
|
"dgeni-packages": "0.28.1",
|
|
141
|
-
"eslint-config-prettier": "6.
|
|
143
|
+
"eslint-config-prettier": "6.5.0",
|
|
142
144
|
"eslint-config-sidvind": "1.3.2",
|
|
143
145
|
"eslint-plugin-array-func": "3.1.3",
|
|
144
146
|
"eslint-plugin-import": "2.18.2",
|
|
145
|
-
"eslint-plugin-jest": "
|
|
147
|
+
"eslint-plugin-jest": "23.0.3",
|
|
146
148
|
"eslint-plugin-node": "10.0.0",
|
|
147
149
|
"eslint-plugin-prettier": "3.1.1",
|
|
148
150
|
"eslint-plugin-security": "1.4.0",
|
|
149
|
-
"eslint-plugin-sonarjs": "0.
|
|
151
|
+
"eslint-plugin-sonarjs": "0.5.0",
|
|
150
152
|
"font-awesome": "4.7.0",
|
|
151
153
|
"grunt": "1.0.4",
|
|
152
154
|
"grunt-browserify": "5.3.0",
|
|
@@ -155,24 +157,24 @@
|
|
|
155
157
|
"grunt-contrib-copy": "1.0.0",
|
|
156
158
|
"grunt-postcss": "0.9.0",
|
|
157
159
|
"grunt-sass": "3.1.0",
|
|
158
|
-
"highlight.js": "9.
|
|
159
|
-
"husky": "3.0.
|
|
160
|
+
"highlight.js": "9.16.2",
|
|
161
|
+
"husky": "3.0.9",
|
|
160
162
|
"jest": "24.9.0",
|
|
161
163
|
"jest-diff": "24.9.0",
|
|
162
|
-
"jest-junit": "
|
|
164
|
+
"jest-junit": "9.0.0",
|
|
163
165
|
"jquery": "3.4.1",
|
|
164
166
|
"lint-staged": "9.4.2",
|
|
165
167
|
"load-grunt-tasks": "5.1.0",
|
|
166
168
|
"minimatch": "3.0.4",
|
|
167
169
|
"prettier": "1.18.2",
|
|
168
|
-
"sass": "1.23.
|
|
169
|
-
"semantic-release": "15.13.
|
|
170
|
+
"sass": "1.23.3",
|
|
171
|
+
"semantic-release": "15.13.30",
|
|
170
172
|
"serve-static": "1.14.1",
|
|
171
173
|
"strip-ansi": "5.2.0",
|
|
172
174
|
"ts-jest": "24.1.0",
|
|
173
|
-
"tslint": "5.20.
|
|
175
|
+
"tslint": "5.20.1",
|
|
174
176
|
"tslint-config-prettier": "1.18.0",
|
|
175
|
-
"typescript": "3.
|
|
177
|
+
"typescript": "3.7.2"
|
|
176
178
|
},
|
|
177
179
|
"jest": {
|
|
178
180
|
"collectCoverage": true,
|