...
 
Commits (28)
......@@ -68,7 +68,7 @@ Jest:
reports:
junit: temp/jest.xml
script:
- npm test -- src elements
- npm test -- src elements tests
TSLint:
stage: test
......
# html-validate changelog
# [2.17.0](https://gitlab.com/html-validate/html-validate/compare/v2.16.0...v2.17.0) (2020-02-17)
### Bug Fixes
- **elements:** `<img>` `srcset` attribute cannot be empty ([27699ad](https://gitlab.com/html-validate/html-validate/commit/27699ad08d4f9363b275449df3110f36f1b0ee9d))
- **jest:** typescript compatibility with [email protected] ([4efae54](https://gitlab.com/html-validate/html-validate/commit/4efae544dbe9cd499e352776edbde1ea03d83706))
- **rules:** add `aria-label` helper ([6d5d963](https://gitlab.com/html-validate/html-validate/commit/6d5d9630666bec57e70ea3ce563cbef558e2ab3b))
- **rules:** fix `deprecated-rule` missing location ([1156c1e](https://gitlab.com/html-validate/html-validate/commit/1156c1e8b6153ee8ac5691df8f3fdeddfb896255))
- change config merge order in `toHTMLValidate` ([204a8fa](https://gitlab.com/html-validate/html-validate/commit/204a8faac7cfe34b8e0fe2b834124b2b9502e231))
- **rules:** handle `aria-label` on links for WCAG H30 ([eb01542](https://gitlab.com/html-validate/html-validate/commit/eb01542abb0fbf4104672794e621b6bf5564903c)), closes [#67](https://gitlab.com/html-validate/html-validate/issues/67)
### Features
- **rules:** mark `void` as deprecated ([f6afc0f](https://gitlab.com/html-validate/html-validate/commit/f6afc0fd15877695b735754d0eca6dc013252abc)), closes [#58](https://gitlab.com/html-validate/html-validate/issues/58)
- **rules:** new rule `no-self-closing` ([d9c869b](https://gitlab.com/html-validate/html-validate/commit/d9c869b36e3c5c9c4027809417b535bcd565c5cc)), closes [#58](https://gitlab.com/html-validate/html-validate/issues/58)
- **rules:** new rule `script-element` ([48ad6da](https://gitlab.com/html-validate/html-validate/commit/48ad6da1b965d0299d022dbc27c25ebc0ed3ffc8))
- **rules:** new rule `script-type` ([a680f1d](https://gitlab.com/html-validate/html-validate/commit/a680f1d297100c92f08f5d5de2ac39ee27915c15))
- **rules:** new rule `void-content` ([c93c63b](https://gitlab.com/html-validate/html-validate/commit/c93c63b1a3609d90cc493a6cb448b071905926f0)), closes [#58](https://gitlab.com/html-validate/html-validate/issues/58)
- **rules:** new rule `void-style` ([f30de03](https://gitlab.com/html-validate/html-validate/commit/f30de03ea4f8caaf065047d5e3bd44417d0202ad)), closes [#58](https://gitlab.com/html-validate/html-validate/issues/58)
- allow configuration override when using `validate{String,Source}` ([6e62852](https://gitlab.com/html-validate/html-validate/commit/6e62852c88182defbe9b465ab5652f456310d07e))
# [2.16.0](https://gitlab.com/html-validate/html-validate/compare/v2.15.0...v2.16.0) (2020-02-12)
### Bug Fixes
......
......@@ -122,9 +122,9 @@ module.exports = new Package("html-validate-docs", [
docTypes: ["changelog"],
getPath: function(doc) {
const dirname = path.dirname(doc.fileInfo.relativePath);
return path.join(dirname, doc.fileInfo.baseName);
return path.join(dirname, doc.fileInfo.baseName, "index.html");
},
outputPathTemplate: "${path.toLowerCase()}/index.html",
outputPathTemplate: "${path.toLowerCase()}",
});
computePathsProcessor.pathTemplates.push({
......
......@@ -44,14 +44,14 @@ expect("<p></i>").toHTMLValidate({
```
By default configuration is also read from `.htmlvalidate.json` files where the test-case filename is used to match.
If you need to override this (perhaps because the test-case isn't in the same folder) you can pass in a custom filename as the third argument:
This means you can apply transformations using patterns such as `^.*\\.(spec|test).js$`.
If you need to override the filename (perhaps because the test-case isn't in the same folder) you can pass in a custom filename as the third argument:
```js
expect("<p></i>").toHTMLValidate(null, "path/to/my-file.html");
```
This can also be used to apply transformations to the markup.
Additionally, the `root` configuration property can be used to skip loading from `.htmlvalidate.json` but remember to actually include the rules you need:
```js
......
......@@ -124,8 +124,8 @@ Note the usage of a trailing `?`, this limits the allowed occurrences to 0 or 1
Default is to allow any number of occurrences.
Next it uses `permittedOrder` to declare that `<head>` must come before `<body>`.
`permittedOrder` doesnt have to list all the possible elements from `permittedContent` but for the items listed the order must be adhered to.
Contents groups such as `@flow` is allowed and unlisted elements can be used in any anywhere (even inbetween listed elements).
`permittedOrder` doesn't have to list all the possible elements from `permittedContent` but for the items listed the order must be adhered to.
Contents groups such as `@flow` is allowed and unlisted elements can be used in any anywhere (even between listed elements).
Lastly it uses `requiredContent` to declare that both `<head>` and `<body>` must be present.
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`docs/rules/no-self-closing.md inline validation: correct 1`] = `Array []`;
exports[`docs/rules/no-self-closing.md inline validation: foreign 1`] = `
Array [
Object {
"errorCount": 1,
"filePath": "inline",
"messages": Array [
Object {
"column": 5,
"context": "svg",
"line": 1,
"message": "<svg> must not be self-closed",
"offset": 4,
"ruleId": "no-self-closing",
"selector": "svg",
"severity": 2,
"size": 2,
},
],
"source": "<svg/>",
"warningCount": 0,
},
]
`;
exports[`docs/rules/no-self-closing.md inline validation: incorrect 1`] = `
Array [
Object {
"errorCount": 1,
"filePath": "inline",
"messages": Array [
Object {
"column": 5,
"context": "div",
"line": 1,
"message": "<div> must not be self-closed",
"offset": 4,
"ruleId": "no-self-closing",
"selector": "div",
"severity": 2,
"size": 2,
},
],
"source": "<div/>",
"warningCount": 0,
},
]
`;
exports[`docs/rules/no-self-closing.md inline validation: xml 1`] = `
Array [
Object {
"errorCount": 1,
"filePath": "inline",
"messages": Array [
Object {
"column": 12,
"context": "xi:include",
"line": 1,
"message": "<xi:include> must not be self-closed",
"offset": 11,
"ruleId": "no-self-closing",
"selector": "xi:include",
"severity": 2,
"size": 2,
},
],
"source": "<xi:include/>",
"warningCount": 0,
},
]
`;
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`docs/rules/script-element.md inline validation: correct 1`] = `Array []`;
exports[`docs/rules/script-element.md inline validation: incorrect 1`] = `
Array [
Object {
"errorCount": 1,
"filePath": "inline",
"messages": Array [
Object {
"column": 26,
"context": undefined,
"line": 1,
"message": "End tag for <script> must not be omitted",
"offset": 25,
"ruleId": "script-element",
"selector": "script",
"severity": 2,
"size": 2,
},
],
"source": "<script src=\\"myscript.js\\"/>",
"warningCount": 0,
},
]
`;
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`docs/rules/script-type.md inline validation: correct 1`] = `Array []`;
exports[`docs/rules/script-type.md inline validation: incorrect 1`] = `
Array [
Object {
"errorCount": 3,
"filePath": "inline",
"messages": Array [
Object {
"column": 9,
"context": undefined,
"line": 1,
"message": "\\"type\\" attribute is unnecessary for javascript resources",
"offset": 8,
"ruleId": "script-type",
"selector": "script",
"severity": 2,
"size": 4,
},
Object {
"column": 9,
"context": undefined,
"line": 2,
"message": "\\"type\\" attribute is unnecessary for javascript resources",
"offset": 34,
"ruleId": "script-type",
"selector": "script:nth-child(2)",
"severity": 2,
"size": 4,
},
Object {
"column": 9,
"context": undefined,
"line": 3,
"message": "\\"type\\" attribute is unnecessary for javascript resources",
"offset": 75,
"ruleId": "script-type",
"selector": "script:nth-child(3)",
"severity": 2,
"size": 4,
},
],
"source": "<script type=\\"\\"></script>
<script type=\\"text/javascript\\"></script>
<script type=\\"application/javascript\\"></script>",
"warningCount": 0,
},
]
`;
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`docs/rules/void-content.md inline validation: correct 1`] = `Array []`;
exports[`docs/rules/void-content.md inline validation: incorrect 1`] = `
Array [
Object {
"errorCount": 1,
"filePath": "inline",
"messages": Array [
Object {
"column": 7,
"context": "img",
"line": 1,
"message": "End tag for <img> must be omitted",
"offset": 6,
"ruleId": "void-content",
"selector": null,
"severity": 2,
"size": 4,
},
],
"source": "<img></img>",
"warningCount": 0,
},
]
`;
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`docs/rules/void-content.md inline validation: correct 1`] = `Array []`;
exports[`docs/rules/void-content.md inline validation: incorrect 1`] = `
Array [
Object {
"errorCount": 1,
"filePath": "inline",
"messages": Array [
Object {
"column": 7,
"context": "img",
"line": 1,
"message": "End tag for <img> must be omitted",
"offset": 6,
"ruleId": "void-content",
"selector": null,
"severity": 2,
"size": 4,
},
],
"source": "<img></img>
<div/>",
"warningCount": 0,
},
]
`;
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`docs/rules/void-style.md inline validation: correct 1`] = `Array []`;
exports[`docs/rules/void-style.md inline validation: incorrect 1`] = `
Array [
Object {
"errorCount": 1,
"filePath": "inline",
"messages": Array [
Object {
"column": 7,
"context": Object {
"style": 1,
"tagName": "input",
},
"line": 1,
"message": "Expected omitted end tag <input> instead of self-closing element <input/>",
"offset": 6,
"ruleId": "void-style",
"selector": "input",
"severity": 2,
"size": 2,
},
],
"source": "<input/>",
"warningCount": 0,
},
]
`;
import HtmlValidate from "../../../src/htmlvalidate";
const markup: { [key: string]: string } = {};
markup["incorrect"] = `<div/>`;
markup["correct"] = `<div></div>
<!-- foreign elements are ignored -->
<svg/>
<!-- elements with XML namespace are ignored -->
<xi:include/>`;
markup["foreign"] = `<svg/>`;
markup["xml"] = `<xi:include/>`;
describe("docs/rules/no-self-closing.md", () => {
it("inline validation: incorrect", () => {
const htmlvalidate = new HtmlValidate({"rules":{"no-self-closing":"error"}});
const report = htmlvalidate.validateString(markup["incorrect"]);
expect(report.results).toMatchSnapshot();
});
it("inline validation: correct", () => {
const htmlvalidate = new HtmlValidate({"rules":{"no-self-closing":"error"}});
const report = htmlvalidate.validateString(markup["correct"]);
expect(report.results).toMatchSnapshot();
});
it("inline validation: foreign", () => {
const htmlvalidate = new HtmlValidate({"rules":{"no-self-closing":["error",{"ignoreForeign":false}]}});
const report = htmlvalidate.validateString(markup["foreign"]);
expect(report.results).toMatchSnapshot();
});
it("inline validation: xml", () => {
const htmlvalidate = new HtmlValidate({"rules":{"no-self-closing":["error",{"ignoreXML":false}]}});
const report = htmlvalidate.validateString(markup["xml"]);
expect(report.results).toMatchSnapshot();
});
});
import HtmlValidate from "../../../src/htmlvalidate";
const markup: { [key: string]: string } = {};
markup["incorrect"] = `<script src="myscript.js"/>`;
markup["correct"] = `<script src="myscript.js"></script>`;
describe("docs/rules/script-element.md", () => {
it("inline validation: incorrect", () => {
const htmlvalidate = new HtmlValidate({"rules":{"script-element":"error"}});
const report = htmlvalidate.validateString(markup["incorrect"]);
expect(report.results).toMatchSnapshot();
});
it("inline validation: correct", () => {
const htmlvalidate = new HtmlValidate({"rules":{"script-element":"error"}});
const report = htmlvalidate.validateString(markup["correct"]);
expect(report.results).toMatchSnapshot();
});
});
import HtmlValidate from "../../../src/htmlvalidate";
const markup: { [key: string]: string } = {};
markup["incorrect"] = `<script type=""></script>
<script type="text/javascript"></script>
<script type="application/javascript"></script>`;
markup["correct"] = `<script></script>
<script type="module"></script>
<script type="text/plain"></script>
<script type="text/x-custom"></script>`;
describe("docs/rules/script-type.md", () => {
it("inline validation: incorrect", () => {
const htmlvalidate = new HtmlValidate({"rules":{"script-type":"error"}});
const report = htmlvalidate.validateString(markup["incorrect"]);
expect(report.results).toMatchSnapshot();
});
it("inline validation: correct", () => {
const htmlvalidate = new HtmlValidate({"rules":{"script-type":"error"}});
const report = htmlvalidate.validateString(markup["correct"]);
expect(report.results).toMatchSnapshot();
});
});
import HtmlValidate from "../../../src/htmlvalidate";
const markup: { [key: string]: string } = {};
markup["incorrect"] = `<img></img>`;
markup["correct"] = `<img>
<img/>`;
describe("docs/rules/void-content.md", () => {
it("inline validation: incorrect", () => {
const htmlvalidate = new HtmlValidate({"rules":{"void-content":"error"}});
const report = htmlvalidate.validateString(markup["incorrect"]);
expect(report.results).toMatchSnapshot();
});
it("inline validation: correct", () => {
const htmlvalidate = new HtmlValidate({"rules":{"void-content":"error"}});
const report = htmlvalidate.validateString(markup["correct"]);
expect(report.results).toMatchSnapshot();
});
});
import HtmlValidate from "../../../src/htmlvalidate";
const markup: { [key: string]: string } = {};
markup["incorrect"] = `<img></img>
<div/>`;
markup["correct"] = `<img>
<div></div>`;
describe("docs/rules/void-content.md", () => {
it("inline validation: incorrect", () => {
const htmlvalidate = new HtmlValidate({"rules":{"void-content":"error"}});
const report = htmlvalidate.validateString(markup["incorrect"]);
expect(report.results).toMatchSnapshot();
});
it("inline validation: correct", () => {
const htmlvalidate = new HtmlValidate({"rules":{"void-content":"error"}});
const report = htmlvalidate.validateString(markup["correct"]);
expect(report.results).toMatchSnapshot();
});
});
import HtmlValidate from "../../../src/htmlvalidate";
const markup: { [key: string]: string } = {};
markup["incorrect"] = `<input/>`;
markup["correct"] = `<input>`;
describe("docs/rules/void-style.md", () => {
it("inline validation: incorrect", () => {
const htmlvalidate = new HtmlValidate({"rules":{"void-style":"error"}});
const report = htmlvalidate.validateString(markup["incorrect"]);
expect(report.results).toMatchSnapshot();
});
it("inline validation: correct", () => {
const htmlvalidate = new HtmlValidate({"rules":{"void-style":"error"}});
const report = htmlvalidate.validateString(markup["correct"]);
expect(report.results).toMatchSnapshot();
});
});
---
docType: rule
name: no-self-closing
category: style
summary: Disallow self-closing elements
---
# Disallow self-closing elements (`no-self-closing`)
Require regular end tags for elements even if the element has no content, e.g. require `<div></div>` instead of `<div/>`.
This rule has no effect on void elements, see the related rule {@link void-style}.
## Rule details
Examples of **incorrect** code for this rule:
<validate name="incorrect" rules="no-self-closing">
<div/>
</validate>
Examples of **correct** code for this rule:
<validate name="correct" rules="no-self-closing">
<div></div>
<!-- foreign elements are ignored -->
<svg/>
<!-- elements with XML namespace are ignored -->
<xi:include/>
</validate>
## Options
This rule takes an optional object:
```json
{
"ignoreForeign": true,
"ignoreXML": true
}
```
### `ignoreForeign`
By default foreign elements are ignored by this rule.
By setting `ignoreForeign` to `false` foreign elements must not be self-closed either.
<validate name="foreign" rules="no-self-closing" no-self-closing='{"ignoreForeign": false}'>
<svg/>
</validate>
### `ignoreXML`
By default elements in XML namespaces are ignored by this rule.
By setting `ignoreXML` to `false` elements in XML namespaces must not be self-closed either.
<validate name="xml" rules="no-self-closing" no-self-closing='{"ignoreXML": false}'>
<xi:include/>
</validate>
---
docType: rule
name: script-element
category: content-model
summary: Require end tag for `<script>`
---
# Require end tag for `<script>` element (`script-element`)
For legacy reasons the `<script>` element must include a `</script>` end tag even when using the `src` attribute.
## Rule details
Examples of **incorrect** code for this rule:
<validate name="incorrect" rules="script-element">
<script src="myscript.js"/>
</validate>
Examples of **correct** code for this rule:
<validate name="correct" rules="script-element">
<script src="myscript.js"></script>
</validate>
---
docType: rule
name: script-type
summary: Require valid type for `<script>`
---
# Require valid type for `<script>` element (`script-type`)
The [HTML5 standard encourages][spec] omitting the `type` attribute when the script is a JavaScript resource and only use it to specify `module` or other non-javascript MIME types.
[spec]: https://html.spec.whatwg.org/multipage/scripting.html#attr-script-type
## Rule details
Examples of **incorrect** code for this rule:
<validate name="incorrect" rules="script-type">
<script type=""></script>
<script type="text/javascript"></script>
<script type="application/javascript"></script>
</validate>
Examples of **correct** code for this rule:
<validate name="correct" rules="script-type">
<script></script>
<script type="module"></script>
<script type="text/plain"></script>
<script type="text/x-custom"></script>
</validate>
---
docType: rule
name: void-content
category: content-model
summary: Disallow void element with content
---
# Disallows void element with content (`void-content`)
HTML [void elements](https://www.w3.org/TR/html5/syntax.html#void-contents)
cannot have any content and must not have an end tag.
## Rule details
Examples of **incorrect** code for this rule:
<validate name="incorrect" rules="void-content">
<img></img>
</validate>
Examples of **correct** code for this rule:
<validate name="correct" rules="void-content">
<img>
<img/>
</validate>
---
docType: rule
name: void-style
category: style
summary: Require a specific style for closing void elements
---
# Require a specific style for closing void elements (`void-style`)
HTML [void elements](https://www.w3.org/TR/html5/syntax.html#void-elements) are elements which cannot have content.
Void elements are implicitly closed (`<img>`) but may optionally be XML-style self-closed (`<img/>`).
This rules enforces usage of one of the two styles.
Default is to omit self-closing tag.
This rule has no effect on non-void elements, see the related rule {@link no-self-closing}.
## Rule details
Examples of **incorrect** code for this rule:
<validate name="incorrect" rules="void-style">
<input/>
</validate>
Examples of **correct** code for this rule:
<validate name="correct" rules="void-style">
<input>
</validate>
## Options
This rule takes an optional object:
```javascript
{
"style": "omit",
}
```
### Style
- `omit` requires end tag to be omitted and disallows self-closing
elements (default).
- `selfclosing` requests self-closing all void element.
......@@ -12,6 +12,8 @@ cannot have any content and must not have an end tag.
Foreign elements will always be ignored by this rule.
**Deprecated:** This rule is deprecated. It has been replaced by the rules {@link void-content}, {@link void-style} and {@link no-self-closing}.
## Rule details
Examples of **incorrect** code for this rule:
......
......@@ -3,7 +3,8 @@ import HtmlValidate from "../../../../src/htmlvalidate";
const markup: { [key: string]: string } = {};
markup["incorrect"] = `<a><img src="cat.gif"></a>`;
markup["correct"] = `<a>lorem ipsum</a>
<a><img src="cat.gif" alt="cat page"></a>`;
<a><img src="cat.gif" alt="cat page"></a>
<a aria-label="lorem ipsum"></a>`;
describe("docs/rules/wcag/h30.md", () => {
it("inline validation: incorrect", () => {
......
......@@ -16,6 +16,12 @@ links and determine whenever to follow the link or not. Assistive technology may
also present a list of links in which case the description is the only thing the
user will be presented with.
The rule recognizes the following patterns:
- Text (non-whitespace) inside the link
- Images with `alt` text (non-whitespace)
- `aria-label` either on the link or at least one descendant.
[1]: https://www.w3.org/WAI/WCAG21/Techniques/html/H30
## Rule details
......@@ -31,4 +37,5 @@ Examples of **correct** code for this rule:
<validate name="correct" rules="wcag/h30">
<a>lorem ipsum</a>
<a><img src="cat.gif" alt="cat page"></a>
<a aria-label="lorem ipsum"></a>
</validate>
......@@ -242,22 +242,22 @@ Array [
"messages": Array [
Object {
"column": 9,
"context": undefined,
"context": "area",
"line": 6,
"message": "End tag for <area> must be omitted",
"offset": 96,
"ruleId": "void",
"ruleId": "void-content",
"selector": null,
"severity": 2,
"size": 5,
},
Object {
"column": 3,
"context": undefined,
"context": "area",
"line": 11,
"message": "End tag for <area> must be omitted",
"offset": 168,
"ruleId": "void",
"ruleId": "void-content",
"selector": null,
"severity": 2,
"size": 5,
......@@ -568,11 +568,11 @@ Array [
},
Object {
"column": 8,
"context": undefined,
"context": "base",
"line": 7,
"message": "End tag for <base> must be omitted",
"offset": 109,
"ruleId": "void",
"ruleId": "void-content",
"selector": null,
"severity": 2,
"size": 5,
......@@ -827,11 +827,11 @@ Array [
"messages": Array [
Object {
"column": 6,
"context": undefined,
"context": "br",
"line": 2,
"message": "End tag for <br> must be omitted",
"offset": 39,
"ruleId": "void",
"ruleId": "void-content",
"selector": null,
"severity": 2,
"size": 3,
......@@ -1134,11 +1134,11 @@ Array [
},
Object {
"column": 9,
"context": undefined,
"context": "col",
"line": 9,
"message": "End tag for <col> must be omitted",
"offset": 134,
"ruleId": "void",
"ruleId": "void-content",
"selector": null,
"severity": 2,
"size": 4,
......@@ -1635,11 +1635,11 @@ Array [
"messages": Array [
Object {
"column": 45,
"context": undefined,
"context": "embed",
"line": 2,
"message": "End tag for <embed> must be omitted",
"offset": 91,
"ruleId": "void",
"ruleId": "void-content",
"selector": null,
"severity": 2,
"size": 6,
......@@ -2566,11 +2566,11 @@ Array [
"messages": Array [
Object {
"column": 6,
"context": undefined,
"context": "hr",
"line": 2,
"message": "End tag for <hr> must be omitted",
"offset": 39,
"ruleId": "void",
"ruleId": "void-content",
"selector": null,
"severity": 2,
"size": 3,
......@@ -2812,7 +2812,7 @@ exports[`HTML elements <iframe> valid markup 1`] = `Array []`;
exports[`HTML elements <img> invalid markup 1`] = `
Array [
Object {
"errorCount": 4,
"errorCount": 5,
"filePath": "test-files/elements/img-invalid.html",
"messages": Array [
Object {
......@@ -2848,12 +2848,30 @@ Array [
"size": 3,
},
Object {
"column": 21,
"context": undefined,
"column": 2,
"context": Object {
"allowed": Array [
/\\.\\+/,
],
"attribute": "srcset",
"element": "img",
"value": "",
},
"line": 8,
"message": "Attribute \\"srcset\\" has invalid value \\"\\"",
"offset": 120,
"ruleId": "attribute-allowed-values",
"selector": "img:nth-child(3)",
"severity": 2,
"size": 3,
},
Object {
"column": 21,
"context": "img",
"line": 11,
"message": "End tag for <img> must be omitted",
"offset": 139,
"ruleId": "void",
"offset": 204,
"ruleId": "void-content",
"selector": null,
"severity": 2,
"size": 4,
......@@ -2861,9 +2879,9 @@ Array [
Object {
"column": 3,
"context": undefined,
"line": 12,
"line": 15,
"message": "Element <img> is not permitted as descendant of <button>",
"offset": 219,
"offset": 284,
"ruleId": "element-permitted-content",
"selector": "button > img",
"severity": 2,
......@@ -2876,6 +2894,9 @@ Array [
<!-- src must be non-empty -->
<img src=\\"\\">
<!-- srcset must be non-empty -->
<img src=\\"foo.png\\" srcset=\\"\\">
<!-- should not allow end tag -->
<img src=\\"foo.png\\"></img>
......@@ -2899,11 +2920,11 @@ Array [
"messages": Array [
Object {
"column": 21,
"context": undefined,
"context": "input",
"line": 2,
"message": "End tag for <input> must be omitted",
"offset": 54,
"ruleId": "void",
"ruleId": "void-content",
"selector": null,
"severity": 2,
"size": 6,
......@@ -3266,11 +3287,11 @@ Array [
"messages": Array [
Object {
"column": 10,
"context": undefined,
"context": "keygen",
"line": 2,
"message": "End tag for <keygen> must be omitted",
"offset": 38,
"ruleId": "void",
"ruleId": "void-content",
"selector": null,
"severity": 2,
"size": 7,
......@@ -3418,11 +3439,11 @@ Array [
"messages": Array [
Object {
"column": 23,
"context": undefined,
"context": "link",
"line": 2,
"message": "End tag for <link> must be omitted",
"offset": 56,
"ruleId": "void",
"ruleId": "void-content",
"selector": null,
"severity": 2,
"size": 5,
......@@ -3762,11 +3783,11 @@ Array [
"messages": Array [
Object {
"column": 8,
"context": undefined,
"context": "meta",
"line": 2,
"message": "End tag for <meta> must be omitted",
"offset": 36,
"ruleId": "void",
"ruleId": "void-content",
"selector": null,
"severity": 2,
"size": 5,
......@@ -4344,11 +4365,11 @@ Array [
"messages": Array [
Object {
"column": 9,
"context": undefined,
"context": "param",
"line": 2,
"message": "End tag for <param> must be omitted",
"offset": 37,
"ruleId": "void",
"ruleId": "void-content",
"selector": null,
"severity": 2,
"size": 6,
......@@ -4838,7 +4859,7 @@ exports[`HTML elements <samp> valid markup 1`] = `Array []`;
exports[`HTML elements <script> invalid markup 1`] = `
Array [
Object {
"errorCount": 3,
"errorCount": 6,
"filePath": "test-files/elements/script-invalid.html",
"messages": Array [
Object {
......@@ -4863,21 +4884,54 @@ Array [
"column": 9,
"context": undefined,
"line": 5,
"message": "\\"type\\" attribute is unnecessary for javascript resources",
"offset": 132,
"ruleId": "script-type",
"selector": "script:nth-child(2)",
"severity": 2,
"size": 4,
},
Object {
"column": 9,
"context": undefined,
"line": 6,
"message": "\\"type\\" attribute is unnecessary for javascript resources",
"offset": 158,
"ruleId": "script-type",
"selector": "script:nth-child(3)",
"severity": 2,
"size": 4,
},
Object {
"column": 9,
"context": undefined,
"line": 9,
"message": "Attribute \\"language\\" is deprecated on <script> element",
"offset": 103,
"offset": 230,
"ruleId": "no-deprecated-attr",
"selector": "script:nth-child(2)",
"selector": "script:nth-child(4)",
"severity": 2,
"size": 8,
},
Object {
"column": 8,
"context": "script",
"line": 12,
"message": "<script> must not be self-closed",
"offset": 457,
"ruleId": "no-self-closing",
"selector": "script:nth-child(5)",
"severity": 2,
"size": 2,
},
Object {
"column": 8,
"context": undefined,
"line": 8,
"line": 12,
"message": "End tag for <script> must not be omitted",
"offset": 330,
"ruleId": "void",
"selector": "script:nth-child(3)",
"offset": 457,
"ruleId": "script-element",
"selector": "script:nth-child(5)",
"severity": 2,
"size": 2,
},
......@@ -4885,6 +4939,10 @@ Array [
"source": "<!-- src attribute cannot be empty -->
<script src=\\"\\"></script>
<!-- type attribute should be omitted when empty or js -->
<script type=\\"\\"></script>
<script type=\\"text/javascript\\"></script>
<!-- deprecated attribute -->
<script language=\\"vbscript\\"></script>
......@@ -5012,11 +5070,11 @@ Array [
"messages": Array [
Object {
"column": 11,
"context": undefined,
"context": "source",
"line": 3,
"message": "End tag for <source> must be omitted",
"offset": 47,
"ruleId": "void",
"ruleId": "void-content",
"selector": null,
"severity": 2,
"size": 7,
......@@ -5957,11 +6015,11 @@ Array [
"messages": Array [
Object {
"column": 10,
"context": undefined,
"context": "track",
"line": 3,
"message": "End tag for <track> must be omitted",
"offset": 46,
"ruleId": "void",
"ruleId": "void-content",
"selector": null,
"severity": 2,
"size": 6,
......@@ -6229,11 +6287,11 @@ Array [
"messages": Array [
Object {
"column": 7,
"context": undefined,
"context": "wbr",
"line": 2,
"message": "End tag for <wbr> must be omitted",
"offset": 35,
"ruleId": "void",
"ruleId": "void-content",
"selector": null,
"severity": 2,
"size": 4,
......
......@@ -458,7 +458,8 @@
"crossorigin": ["", "anonymous", "use-credentials"],
"decoding": ["sync", "async", "auto"],
"ismap": [],
"src": ["/.+/"]
"src": ["/.+/"],
"srcset": ["/.+/"]
},
"deprecatedAttributes": [
"datasrc",
......
......@@ -164,6 +164,9 @@ describe("HTML elements", () => {
* yield any errors */
"prefer-button": "off",
/* void is being deprecated */
void: "off",
/* none of the WCAG rules should trigger in these tests, they are tested
* separately and adds too much noise here */
"wcag/h32": "off",
......
This diff is collapsed.
{
"name": "html-validate",
"version": "2.16.0",
"version": "2.17.0",
"description": "html linter",
"keywords": [
"html",
......@@ -99,9 +99,9 @@
"@babel/preset-env": "7.8.4",
"@commitlint/cli": "8.3.5",
"@html-validate/commitlint-config": "1.0.1",
"@html-validate/eslint-config": "1.1.0",
"@html-validate/eslint-config": "1.1.2",
"@html-validate/prettier-config": "1.0.0",
"@html-validate/semantic-release-config": "1.0.8",
"@html-validate/semantic-release-config": "1.0.9",
"@types/babel__code-frame": "7.0.1",
"@types/estree": "0.0.42",
"@types/glob": "7.1.1",
......@@ -109,7 +109,7 @@
"@types/jest": "25.1.2",
"@types/json-merge-patch": "0.0.4",
"@types/minimist": "1.2.0",
"@types/node": "11.15.5",
"@types/node": "11.15.6",
"autoprefixer": "9.7.4",
"babelify": "10.0.0",
"bootstrap-sass": "3.4.1",
......@@ -117,7 +117,7 @@
"cssnano": "4.1.10",
"dgeni": "0.4.12",
"dgeni-front-matter": "1.0.2",
"dgeni-packages": "0.28.2",
"dgeni-packages": "0.28.3",
"eslint-plugin-array-func": "3.1.3",
"eslint-plugin-node": "11.0.0",
"eslint-plugin-security": "1.4.0",
......@@ -132,7 +132,7 @@
"grunt-postcss": "0.9.0",
"grunt-sass": "3.1.0",
"highlight.js": "9.18.1",
"husky": "4.2.1",
"husky": "4.2.3",
"jest": "25.1.0",
"jest-diff": "25.1.0",
"jest-junit": "10.0.0",
......@@ -143,7 +143,7 @@
"minimatch": "3.0.4",
"prettier": "1.19.1",
"sass": "1.25.0",
"semantic-release": "17.0.2",
"semantic-release": "17.0.3",
"serve-static": "1.14.1",
"stringmap": "0.2.2",
"strip-ansi": "6.0.0",
......@@ -179,7 +179,8 @@
"roots": [
"<rootDir>/docs",
"<rootDir>/elements",
"<rootDir>/src"
"<rootDir>/src",
"<rootDir>/tests"
],
"snapshotSerializers": [
"pretty-format/build/plugins/ConvertAnsi"
......
......@@ -6,10 +6,11 @@ Object {
"html-validate:recommended",
],
"plugins": Array [],
"root": true,
"rules": Object {
"deprecated": "error",
"element-permitted-content": "off",
"void": "error",
"no-self-closing": "error",
},
"transform": Object {},
}
......@@ -23,22 +24,22 @@ Array [
"messages": Array [
Object {
"column": 3,
"context": undefined,
"context": "i",
"line": 1,
"message": "End tag for <i> must not be omitted",
"message": "<i> must not be self-closed",
"offset": 2,
"ruleId": "void",
"ruleId": "no-self-closing",
"selector": "i",
"severity": 2,
"size": 2,
},
Object {
"column": 3,
"context": undefined,
"context": "i",
"line": 8,
"message": "End tag for <i> must not be omitted",
"offset": 190,
"ruleId": "void",
"message": "<i> must not be self-closed",
"offset": 212,
"ruleId": "no-self-closing",
"selector": "i:nth-child(4)",
"severity": 2,
"size": 2,
......@@ -46,11 +47,11 @@ Array [
],
"source": "<i/>Before disable, should trigger
<!-- [html-validate-disable void] -->
<!-- [html-validate-disable no-self-closing] -->
<i/>After disable, should not trigger
<i/>After disable, should not trigger
<!-- [html-validate-enable void] -->
<!-- [html-validate-enable no-self-closing] -->
<i/>Before after, should trigger
",
"warningCount": 0,
......@@ -64,10 +65,11 @@ Object {
"html-validate:recommended",
],
"plugins": Array [],
"root": true,
"rules": Object {
"deprecated": "error",
"element-permitted-content": "off",
"void": "error",
"no-self-closing": "error",
},
"transform": Object {},
}
......@@ -81,44 +83,44 @@ Array [
"messages": Array [
Object {
"column": 3,
"context": undefined,
"context": "i",
"line": 1,
"message": "End tag for <i> must not be omitted",
"message": "<i> must not be self-closed",
"offset": 2,
"ruleId": "void",
"ruleId": "no-self-closing",
"selector": "i",
"severity": 2,
"size": 2,
},
Object {
"column": 4,
"context": undefined,
"context": "i",
"line": 3,
"message": "End tag for <i> must not be omitted",
"message": "<i> must not be self-closed",
"offset": 43,
"ruleId": "void",
"ruleId": "no-self-closing",
"selector": "div > i",
"severity": 2,
"size": 2,
},
Object {
"column": 3,
"context": undefined,
"context": "i",
"line": 11,
"message": "End tag for <i> must not be omitted",
"offset": 324,
"ruleId": "void",
"message": "<i> must not be self-closed",
"offset": 335,
"ruleId": "no-self-closing",
"selector": "i:nth-child(3)",
"severity": 2,
"size": 2,
},
Object {
"column": 3,
"context": undefined,
"context": "i",
"line": 16,
"message": "End tag for <i> must not be omitted",
"offset": 417,
"ruleId": "void",
"message": "<i> must not be self-closed",
"offset": 439,
"ruleId": "no-self-closing",
"selector": "i:nth-child(5)",
"severity": 2,
"size": 2,
......@@ -127,7 +129,7 @@ Array [
"source": "<i/>Outside block, should trigger
<div>
<i/>Inside block, before directive, should trigger
<!-- [html-validate-disable-block void] -->
<!-- [html-validate-disable-block no-self-closing] -->
<i/>Inside block, after directive, shout not trigger
<div>
<i/>Inside block, after directive, shout not trigger
......@@ -137,11 +139,11 @@ Array [
<i/>Outside block, should trigger
<div>
<!-- [html-validate-disable-block void] -->
<!-- [html-validate-disable-block no-self-closing] -->
</div>
<i/>Outside block, should trigger
<!-- [html-validate-disable-block void] -->
<!-- [html-validate-disable-block no-self-closing] -->
Should handle when root element is parent but no children
",
"warningCount": 0,
......@@ -155,10 +157,11 @@ Object {
"html-validate:recommended",
],
"plugins": Array [],
"root": true,
"rules": Object {
"deprecated": "error",
"element-permitted-content": "off",
"void": "error",
"no-self-closing": "error",
},
"transform": Object {},
}
......@@ -183,11 +186,11 @@ Array [
},
Object {
"column": 7,
"context": undefined,
"context": "blink",
"line": 1,
"message": "End tag for <blink> must not be omitted",
"message": "<blink> must not be self-closed",
"offset": 6,
"ruleId": "void",
"ruleId": "no-self-closing",
"selector": "blink",
"severity": 2,
"size": 2,
......@@ -195,7 +198,7 @@ Array [
],
"source": "<blink/>
<div>
<!-- [html-validate-disable-block void, deprecated] -->
<!-- [html-validate-disable-block no-self-closing, deprecated] -->
<blink/>
</div>
",
......@@ -210,10 +213,11 @@ Object {
"html-validate:recommended",
],
"plugins": Array [],
"root": true,
"rules": Object {
"deprecated": "error",
"element-permitted-content": "off",
"void": "error",
"no-self-closing": "error",
},
"transform": Object {},
}
......@@ -227,22 +231,22 @@ Array [
"messages": Array [
Object {
"column": 3,
"context": undefined,
"context": "i",
"line": 1,
"message": "End tag for <i> must not be omitted",
"message": "<i> must not be self-closed",
"offset": 2,
"ruleId": "void",
"ruleId": "no-self-closing",
"selector": "i",
"severity": 2,
"size": 2,
},
Object {
"column": 3,
"context": undefined,
"context": "i",
"line": 5,
"message": "End tag for <i> must not be omitted",
"offset": 125,
"ruleId": "void",
"message": "<i> must not be self-closed",
"offset": 136,
"ruleId": "no-self-closing",
"selector": "i:nth-child(3)",
"severity": 2,
"size": 2,
......@@ -250,7 +254,7 @@ Array [
],
"source": "<i/>Before disable, should trigger
<!-- [html-validate-disable-next void] -->
<!-- [html-validate-disable-next no-self-closing] -->
<i/>First after disable, should not trigger
<i/>Second after disable, should trigger
",
......@@ -269,10 +273,11 @@ Object {
"html-validate:recommended",
],
"plugins": Array [],
"root": true,
"rules": Object {
"deprecated": "error",
"element-permitted-content": "error",
"void": "error",
"no-self-closing": "error",
},
"transform": Object {},
}
......@@ -327,10 +332,11 @@ Object {
"html-validate:recommended",
],
"plugins": Array [],
"root": true,
"rules": Object {
"deprecated": "error",
"element-permitted-content": "error",
"void": "error",
"no-self-closing": "error",
},
"transform": Object {},
}
......@@ -344,11 +350,11 @@ Array [
"messages": Array [
Object {
"column": 6,
"context": undefined,
"context": "br",
"line": 2,
"message": "End tag for <br> must be omitted",
"offset": 49,
"ruleId": "void",
"ruleId": "void-content",
"selector": null,
"severity": 2,
"size": 3,
......@@ -368,10 +374,11 @@ Object {
"html-validate:recommended",
],
"plugins": Array [],
"root": true,
"rules": Object {
"deprecated": "error",
"element-permitted-content": "error",
"void": "error",
"no-self-closing": "error",
},
"transform": Object {},
}
......@@ -385,11 +392,11 @@ Array [
"messages": Array [
Object {
"column": 6,
"context": undefined,
"context": "br",
"line": 2,
"message": "End tag for <br> must be omitted",
"offset": 42,
"ruleId": "void",
"ruleId": "void-content",
"selector": null,
"severity": 2,
"size": 3,
......@@ -409,10 +416,11 @@ Object {
"html-validate:recommended",