Commits (36)
image: node:latest
include:
- template: License-Scanning.gitlab-ci.yml
- template: Security/Dependency-Scanning.gitlab-ci.yml
- template: Security/License-Scanning.gitlab-ci.yml
stages:
- prepare
......@@ -17,10 +18,13 @@ NPM:
name: ${CI_PROJECT_PATH_SLUG}-${CI_PIPELINE_ID}-npm
paths:
- node_modules/
reports:
dependency_scanning: gl-dependency-scanning.json
script:
- node --version
- npm --version
- npm ci
- npm audit --json --production | npx gitlab-npm-audit-parser -o gl-dependency-scanning.json || true
Build:
stage: build
......
# html-validate changelog
## [4.6.0](https://gitlab.com/html-validate/html-validate/compare/v4.5.0...v4.6.0) (2021-02-13)
### Features
- **parser:** add DOCTYPE tag to `DoctypeEvent` ([8c53d40](https://gitlab.com/html-validate/html-validate/commit/8c53d40b8ed3bbf8f5016cf58c63e75a09e4964e))
- **parser:** new event `token` emitted for each lexer token ([f9d44d6](https://gitlab.com/html-validate/html-validate/commit/f9d44d665c0c5f5522f9220ac8940c1d285b339e))
- **rules:** allow rules to unregister event listeners ([8b1a6bc](https://gitlab.com/html-validate/html-validate/commit/8b1a6bc3ce2c38d7ff6a68b8ea54a6b2784a6e45))
- **rules:** new rule `attr-spacing` requiring attributes to be separated by whitespace ([7734dc6](https://gitlab.com/html-validate/html-validate/commit/7734dc6855bb1fccbb0e66ddc7684c6ba997912a)), closes [#105](https://gitlab.com/html-validate/html-validate/issues/105)
- **rules:** new rule `doctype-style` requiring doctype to be specific case ([e94f819](https://gitlab.com/html-validate/html-validate/commit/e94f8191c6da0acf02b1322d140ff8afa3a8c33f))
- **rules:** new rule `no-utf8-bom` disallowing usage of UTF-8 BOM ([7a2d264](https://gitlab.com/html-validate/html-validate/commit/7a2d264f6ff805740a2c1ed3988327cd96441682))
### Bug Fixes
- **lexer:** handle CRLF after xml declaration ([97fd77d](https://gitlab.com/html-validate/html-validate/commit/97fd77de1467a9e97cc80fd1a4643b88701cbdb0))
- **lexer:** handle doctype with mixed case ([a40e28e](https://gitlab.com/html-validate/html-validate/commit/a40e28e2c115ae3382ef6b63827fdf1685134692))
- **lexer:** handle html comment before doctype ([6c1b830](https://gitlab.com/html-validate/html-validate/commit/6c1b830898534cbfed2adb5cb6b06abfdeaede1b))
- **lexer:** handle unicode bom ([97506b1](https://gitlab.com/html-validate/html-validate/commit/97506b1a8b143c9e686538fa02d349091b9076a3))
## [4.5.0](https://gitlab.com/html-validate/html-validate/compare/v4.4.0...v4.5.0) (2021-02-05)
### Features
......
......@@ -18,6 +18,18 @@ title: Events
Emitted after after configuration is ready but before DOM is initialized.
### `token`
```typescript
interface TokenEvent {
location: Location;
type: TokenType;
data?: any;
}
```
Emitted for each lexer token during parsing.
## Document
### `dom:load`
......@@ -43,18 +55,18 @@ Emitted after the parsing has finished loading the DOM tree.
### `doctype`
```typescript
{
location: Location,
value: string,
valueLocation: Location,
interface DoctypeEvent {
location: Location;
tag: string;
value: string;
valueLocation: Location;
}
```
Emitted when a doctype is encountered. `value` is the doctype (without
`<doctype` and `>`).
Emitted when a DOCTYPE is encountered.
`tag` is the tag used to open and `value` is the doctype value (without `<!doctype` and `>`).
`location` refers to the doctype opening tag and `valueLocation` to the value
(as described above)
`location` refers to the doctype opening tag and `valueLocation` to the value (as described above)
## DOM Nodes
......
......@@ -3,6 +3,7 @@
</p>
<div class="inline-validation">
{# <!-- [html-validate-disable-next attr-spacing: endfor is not part of the next attribute ] --> #}
<div class="markup"
{%- for attrName, attrValue in doc.validate.attributes %}{{ attrName }}="{{ attrValue }}"{% endfor %}>
<pre><code class="hljs lang-html">{{ doc.validate.markup | highlight('html') }}</code></pre>
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`docs/rules/attr-spacing.md inline validation: correct 1`] = `Array []`;
exports[`docs/rules/attr-spacing.md inline validation: incorrect 1`] = `
Array [
Object {
"errorCount": 1,
"filePath": "inline",
"messages": Array [
Object {
"column": 21,
"context": undefined,
"line": 1,
"message": "No space between attributes",
"offset": 20,
"ruleId": "attr-spacing",
"selector": null,
"severity": 2,
"size": 5,
},
],
"source": "<input type=\\"submit\\"class=\\"foo\\">",
"warningCount": 0,
},
]
`;
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`docs/rules/doctype-style.md inline validation: correct 1`] = `Array []`;
exports[`docs/rules/doctype-style.md inline validation: incorrect 1`] = `
Array [
Object {
"errorCount": 1,
"filePath": "inline",
"messages": Array [
Object {
"column": 1,
"context": Object {
"style": "uppercase",
},
"line": 1,
"message": "DOCTYPE should be uppercase",
"offset": 0,
"ruleId": "doctype-style",
"selector": null,
"severity": 2,
"size": 10,
},
],
"source": "<!Doctype html>",
"warningCount": 0,
},
]
`;
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`docs/rules/no-utf8-bom.md inline validation: correct 1`] = `Array []`;
exports[`docs/rules/no-utf8-bom.md inline validation: incorrect 1`] = `Array []`;
import HtmlValidate from "../../../src/htmlvalidate";
const markup: { [key: string]: string } = {};
markup["incorrect"] = `<input type="submit"class="foo">`;
markup["correct"] = `<input type="submit" class="foo">`;
describe("docs/rules/attr-spacing.md", () => {
it("inline validation: incorrect", () => {
expect.assertions(1);
const htmlvalidate = new HtmlValidate({"rules":{"attr-spacing":"error"}});
const report = htmlvalidate.validateString(markup["incorrect"]);
expect(report.results).toMatchSnapshot();
});
it("inline validation: correct", () => {
expect.assertions(1);
const htmlvalidate = new HtmlValidate({"rules":{"attr-spacing":"error"}});
const report = htmlvalidate.validateString(markup["correct"]);
expect(report.results).toMatchSnapshot();
});
});
import HtmlValidate from "../../../src/htmlvalidate";
const markup: { [key: string]: string } = {};
markup["incorrect"] = `<!Doctype html>`;
markup["correct"] = `<!DOCTYPE html>`;
describe("docs/rules/doctype-style.md", () => {
it("inline validation: incorrect", () => {
expect.assertions(1);
const htmlvalidate = new HtmlValidate({"rules":{"doctype-style":"error"}});
const report = htmlvalidate.validateString(markup["incorrect"]);
expect(report.results).toMatchSnapshot();
});
it("inline validation: correct", () => {
expect.assertions(1);
const htmlvalidate = new HtmlValidate({"rules":{"doctype-style":"error"}});
const report = htmlvalidate.validateString(markup["correct"]);
expect(report.results).toMatchSnapshot();
});
});
import HtmlValidate from "../../../src/htmlvalidate";
const markup: { [key: string]: string } = {};
markup["incorrect"] = `<!DOCTYPE html>`;
markup["correct"] = `<!DOCTYPE html>`;
describe("docs/rules/no-utf8-bom.md", () => {
it("inline validation: incorrect", () => {
expect.assertions(1);
const htmlvalidate = new HtmlValidate({"rules":{"no-utf8-bom":"error"}});
const report = htmlvalidate.validateString(markup["incorrect"]);
expect(report.results).toMatchSnapshot();
});
it("inline validation: correct", () => {
expect.assertions(1);
const htmlvalidate = new HtmlValidate({"rules":{"no-utf8-bom":"error"}});
const report = htmlvalidate.validateString(markup["correct"]);
expect(report.results).toMatchSnapshot();
});
});
---
docType: rule
name: attr-spacing
summary: Require attributes to be separated by whitespace
---
# Require attributes to be separated by whitespace (`attr-spacing`)
In HTML attributes must be separated by whitespace (commonly a regular space).
## Rule details
Examples of **incorrect** code for this rule:
<validate name="incorrect" rules="attr-spacing">
<input type="submit"class="foo">
</validate>
Examples of **correct** code for this rule:
<validate name="correct" rules="attr-spacing">
<input type="submit" class="foo">
</validate>
---
docType: rule
name: doctype-style
category: style
summary: Require a specific case for DOCTYPE
---
# Require a specific case for DOCTYPE (`doctype-style`)
While DOCTYPE is case-insensitive in the standard this rule requires it to be a specific style.
The standard consistently uses uppercase which is the default style for this rule.
Mixed case it not supported.
## Rule details
Examples of **incorrect** code for this rule:
<validate name="incorrect" rules="doctype-style">
<!Doctype html>
</validate>
Examples of **correct** code for this rule:
<validate name="correct" rules="doctype-style">
<!DOCTYPE html>
</validate>
## Options
This rule takes an optional object:
```javascript
{
"style": "uppercase",
}
```
### `style`
- `uppercase` requires DOCTYPE to be uppercase.
- `lowercase` requires DOCTYPE to be lowercase.
---
docType: rule
name: no-utf8-bom
category: document
summary: Disallow documents from having UTF-8 BOM
---
# Disallow documents from having UTF-8 BOM (`no-utf8-bom`)
A unicode byte order mark (BOM) is needed in UTF-16 and UTF-32 to determine endiannes but for UTF-8 it has no meaning.
Browsers are required to handle the BOM under all circumstances but tooling might not handle it properly and is therefor best left out.
Instead the document should be served with the `Content-Type: application/javascript; charset=utf-8` header and/or the `<meta charset="utf-8">` meta-tag.
This diff is collapsed.
{
"name": "html-validate",
"version": "4.5.0",
"version": "4.6.0",
"description": "html linter",
"keywords": [
"html",
......@@ -47,27 +47,20 @@
"eslint": "eslint .",
"eslint:fix": "eslint --fix .",
"htmlvalidate": "./bin/html-validate.js",
"prepare": "scripts/prepare.sh",
"prepare": "scripts/prepare",
"prettier:check": "prettier --check .",
"prettier:write": "prettier --write .",
"semantic-release": "semantic-release",
"start": "grunt connect",
"test": "jest --ci"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-push": "./scripts/pre-push"
}
},
"commitlint": {
"extends": [
"@html-validate"
]
},
"lint-staged": {
"*.{ts,js,json,html,md,scss}": "prettier --write"
"*.{ts,js,json,html,md,scss,yml}": "prettier --write"
},
"prettier": "@html-validate/prettier-config",
"jest": {
......@@ -105,8 +98,8 @@
"prompts": "^2.0.0"
},
"devDependencies": {
"@babel/core": "7.12.13",
"@babel/preset-env": "7.12.13",
"@babel/core": "7.12.16",
"@babel/preset-env": "7.12.16",
"@commitlint/cli": "11.0.0",
"@html-validate/commitlint-config": "1.2.0",
"@html-validate/eslint-config": "3.1.0",
......@@ -144,26 +137,26 @@
"grunt-contrib-connect": "3.0.0",
"grunt-contrib-copy": "1.0.0",
"grunt-sass": "3.1.0",
"highlight.js": "10.5.0",
"husky": "4.3.8",
"highlight.js": "10.6.0",
"husky": "5.0.9",
"jest": "26.6.3",
"jest-diff": "26.6.2",
"jquery": "3.5.1",
"lint-staged": "10.5.3",
"lint-staged": "10.5.4",
"load-grunt-tasks": "5.1.0",
"marked": "1.2.9",
"marked": "2.0.0",
"minimatch": "3.0.4",
"npm-pkg-lint": "1.3.0",
"postcss": "8.2.4",
"postcss": "8.2.6",
"prettier": "2.2.1",
"pretty-format": "26.6.2",
"sass": "1.32.6",
"semantic-release": "17.3.7",
"sass": "1.32.7",
"semantic-release": "17.3.8",
"serve-static": "1.14.1",
"stringmap": "0.2.2",
"strip-ansi": "6.0.0",
"ts-jest": "26.5.0",
"typescript": "4.1.3"
"ts-jest": "26.5.1",
"typescript": "4.1.5"
},
"engines": {
"node": ">= 10.0"
......
_
\ No newline at end of file
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
exec npx --no-install commitlint --edit $1
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
exec npx --no-install lint-staged
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
# bail out on first error
set -e
......
......@@ -2,3 +2,6 @@
echo "Configure git commit.template"
git config --local commit.template ./node_modules/@html-validate/commitlint-config/gitmessage
echo "Installing husky"
npx --no-install husky install "$(dirname "$0")"