From 44632cede38522dc39c652fa3e1e2364a557d33e Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Wed, 3 Jun 2020 19:33:34 +0200 Subject: [PATCH 01/32] docs: new configuration structure for alt-require --- docs/user-guide/rules/alt-require.md | 42 ++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/docs/user-guide/rules/alt-require.md b/docs/user-guide/rules/alt-require.md index eb45ab853..fdb9a6979 100644 --- a/docs/user-guide/rules/alt-require.md +++ b/docs/user-guide/rules/alt-require.md @@ -7,25 +7,41 @@ keywords: - accessiblity --- -Alt of img must be present and alt of area[href] and input[type=image] must be set value. +`alt` of `img` must be present and `alt` of `area[href]` and `input[type=image]` must be set value. + +## Possible Configuration Values + +```json +{ + "alt-require": "off", + "alt-require": "warn", + "alt-require": "error", + "alt-require": ["off"], + "alt-require": ["warn"], + "alt-require": ["error"] +} +``` + +## Default -Level: warning +```json +{ "alt-require": "off" } +``` -## Config value +--- -1. true: enable rule -2. false: disable rule +## Examples -The following pattern are **not** considered violations: +Examples of **correct** code for this rule: ```html test test -``` +```` -The following pattern is considered violation: +Examples of **incorrect** code for this rule: ```html @@ -33,3 +49,13 @@ The following pattern is considered violation: ``` + +--- + +## When Not To Use It + +If your project will not use `alt` on images + +## Version + +This rule was introduced in HTMLHint `v0.9.1`. From f544ca155012828dbf6ce612b536b86c2fc43cf6 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Wed, 3 Jun 2020 19:45:33 +0200 Subject: [PATCH 02/32] docs: new configuration structure for attr-lowercase --- docs/user-guide/rules/alt-require.md | 4 +-- docs/user-guide/rules/attr-lowercase.md | 45 +++++++++++++++++++++---- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/docs/user-guide/rules/alt-require.md b/docs/user-guide/rules/alt-require.md index fdb9a6979..7a1a90967 100644 --- a/docs/user-guide/rules/alt-require.md +++ b/docs/user-guide/rules/alt-require.md @@ -39,7 +39,7 @@ Examples of **correct** code for this rule: test test -```` +``` Examples of **incorrect** code for this rule: @@ -54,7 +54,7 @@ Examples of **incorrect** code for this rule: ## When Not To Use It -If your project will not use `alt` on images +If your project will not use `alt` on images. ## Version diff --git a/docs/user-guide/rules/attr-lowercase.md b/docs/user-guide/rules/attr-lowercase.md index 343b90f4a..e1df17932 100644 --- a/docs/user-guide/rules/attr-lowercase.md +++ b/docs/user-guide/rules/attr-lowercase.md @@ -5,24 +5,55 @@ title: attr-lowercase Attribute name must be lowercase. -Level: `error` +## Possible Configuration Values + +```json +{ + "attr-lowercase": "off", + "attr-lowercase": "warn", + "attr-lowercase": "error", + "attr-lowercase": ["off"], + "attr-lowercase": ["warn", { "exceptions": ["viewBox", "test"] }], + "attr-lowercase": ["error", { "exceptions": ["viewBox", "test"] }] +} +``` + +## Default + +```json +{ "attr-lowercase": "error" } +``` + +## Options + +This rule has an object option: + +- `"exceptions": ["viewBox", "test"]` ignore attributes `viewBox` and `test`. -## Config value +--- -1. true: enable rule -2. false: disable rule -3. ['viewBox', 'test']: Ignore some attr name +## Examples -The following pattern are **not** considered violations: +Examples of **correct** code for this rule: ```html test ``` -The following pattern is considered violation: +Examples of **incorrect** code for this rule: ```html test ``` + +--- + +## When Not To Use It + +If your project will use `camelCase` attributes. + +## Version + +This rule was introduced in HTMLHint `v0.9.1`. From 1d0ba5db3f588208a6aed48db16023beb2cae491 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Wed, 3 Jun 2020 19:49:41 +0200 Subject: [PATCH 03/32] docs: new configuration structure for attr-no-duplication --- docs/user-guide/rules/attr-no-duplication.md | 38 ++++++++++++++++---- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/docs/user-guide/rules/attr-no-duplication.md b/docs/user-guide/rules/attr-no-duplication.md index 239777839..7d9529297 100644 --- a/docs/user-guide/rules/attr-no-duplication.md +++ b/docs/user-guide/rules/attr-no-duplication.md @@ -5,23 +5,49 @@ title: attr-no-duplication The same attribute can't be specified twice. -Level: `error` +## Possible Configuration Values + +```json +{ + "attr-no-duplication": "off", + "attr-no-duplication": "warn", + "attr-no-duplication": "error", + "attr-no-duplication": ["off"], + "attr-no-duplication": ["warn"], + "attr-no-duplication": ["error"] +} +``` + +## Default + +```json +{ "attr-no-duplication": "error" } +``` -## Config value +--- -1. true: enable rule -2. false: disable rule +## Examples -The following pattern are **not** considered violations: +Examples of **correct** code for this rule: ```html ``` -The following pattern is considered violation: +Examples of **incorrect** code for this rule: ```html ``` + +--- + +## When Not To Use It + +You always want to use this rule. + +## Version + +This rule was introduced in HTMLHint `v0.9.6`. From 851e8145455aa0abca3af59626faf3a21a47823b Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Wed, 3 Jun 2020 19:55:42 +0200 Subject: [PATCH 04/32] docs: new configuration structure for attr-no-unnecessary-whitespace --- .../rules/attr-no-unnecessary-whitespace.md | 44 ++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/docs/user-guide/rules/attr-no-unnecessary-whitespace.md b/docs/user-guide/rules/attr-no-unnecessary-whitespace.md index 9af443849..030194b5f 100644 --- a/docs/user-guide/rules/attr-no-unnecessary-whitespace.md +++ b/docs/user-guide/rules/attr-no-unnecessary-whitespace.md @@ -5,21 +5,43 @@ title: attr-no-unnecessary-whitespace No spaces between attribute names and values. -Level: `error` +## Possible Configuration Values + +```json +{ + "attr-no-unnecessary-whitespace": "off", + "attr-no-unnecessary-whitespace": "warn", + "attr-no-unnecessary-whitespace": "error", + "attr-no-unnecessary-whitespace": ["off"], + "attr-no-unnecessary-whitespace": ["warn", { "exceptions": ["test"] }], + "attr-no-unnecessary-whitespace": ["error", { "exceptions": ["test"] }] +} +``` + +## Default + +```json +{ "attr-no-unnecessary-whitespace": "error" } +``` + +## Options + +This rule has an object option: + +- `"exceptions": ['test']` ignore some attribute names. -## Config value +--- -1. true: enable rule -2. false: disable rule +## Examples -The following pattern are **not** considered violations: +Examples of **correct** code for this rule: ```html
``` -The following pattern is considered violation: +Examples of **incorrect** code for this rule: ```html @@ -27,3 +49,13 @@ The following pattern is considered violation:
``` + +--- + +## When Not To Use It + +If your project will use spaces between attribute names and values. + +## Version + +This rule was introduced in HTMLHint `v0.13.0`. From 0ef9e6bcf099d959f3574685f9a48f0ba6d7dac5 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Wed, 3 Jun 2020 20:21:27 +0200 Subject: [PATCH 05/32] docs: update getting started --- docs/user-guide/getting-started.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/user-guide/getting-started.mdx b/docs/user-guide/getting-started.mdx index dee1d3f6f..c8616d440 100644 --- a/docs/user-guide/getting-started.mdx +++ b/docs/user-guide/getting-started.mdx @@ -38,11 +38,11 @@ yarn add --dev htmlhint ```shell { - "attr-value-not-empty": false + "attr-value-not-empty": "off" } ``` -3\. Run HTMLHint on, for example, all the CSS files in your project: +3\. Run HTMLHint on, for example, all the HTML files in your project: ```shell npx htmlhint "**/*.html" From 7a0c42248923bcbbe6e8015d82605ecc7e8e9d39 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Wed, 3 Jun 2020 20:22:10 +0200 Subject: [PATCH 06/32] docs: add missing rules --- docs/user-guide/rules/attr-sorted.md | 0 docs/user-guide/rules/attr-value-single-quotes.md | 0 docs/user-guide/rules/attr-whitespace.md | 0 docs/user-guide/rules/input-requires-label.md | 0 docs/user-guide/rules/script-disabled.md | 0 docs/user-guide/rules/tagname-specialchars.md | 0 website/sidebars.js | 13 +++++++++++-- 7 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 docs/user-guide/rules/attr-sorted.md create mode 100644 docs/user-guide/rules/attr-value-single-quotes.md create mode 100644 docs/user-guide/rules/attr-whitespace.md create mode 100644 docs/user-guide/rules/input-requires-label.md create mode 100644 docs/user-guide/rules/script-disabled.md create mode 100644 docs/user-guide/rules/tagname-specialchars.md diff --git a/docs/user-guide/rules/attr-sorted.md b/docs/user-guide/rules/attr-sorted.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/user-guide/rules/attr-value-single-quotes.md b/docs/user-guide/rules/attr-value-single-quotes.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/user-guide/rules/attr-whitespace.md b/docs/user-guide/rules/attr-whitespace.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/user-guide/rules/input-requires-label.md b/docs/user-guide/rules/input-requires-label.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/user-guide/rules/script-disabled.md b/docs/user-guide/rules/script-disabled.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/user-guide/rules/tagname-specialchars.md b/docs/user-guide/rules/tagname-specialchars.md new file mode 100644 index 000000000..e69de29bb diff --git a/website/sidebars.js b/website/sidebars.js index d82bdf703..a8937e429 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -9,13 +9,17 @@ module.exports = { { 'Individual rules': [ 'user-guide/rules/alt-require', - 'user-guide/rules/attr-no-duplication', 'user-guide/rules/attr-lowercase', + 'user-guide/rules/attr-no-duplication', + 'user-guide/rules/attr-no-unnecessary-whitespace', + 'user-guide/rules/attr-sorted', 'user-guide/rules/attr-unsafe-chars', 'user-guide/rules/attr-value-double-quotes', 'user-guide/rules/attr-value-not-empty', + 'user-guide/rules/attr-value-single-quotes', + 'user-guide/rules/attr-whitespace', 'user-guide/rules/doctype-first', - 'user-guide/rules/empty-tag-not-self-closed', + 'user-guide/rules/doctype-html5', 'user-guide/rules/head-script-disabled', 'user-guide/rules/href-abs-or-rel', 'user-guide/rules/id-class-ad-disabled', @@ -23,12 +27,17 @@ module.exports = { 'user-guide/rules/id-unique', 'user-guide/rules/inline-script-disabled', 'user-guide/rules/inline-style-disabled', + 'user-guide/rules/input-requires-label', + 'user-guide/rules/script-disabled', 'user-guide/rules/space-tab-mixed-disabled', 'user-guide/rules/spec-char-escape', 'user-guide/rules/src-not-empty', 'user-guide/rules/style-disabled', 'user-guide/rules/tag-pair', + 'user-guide/rules/tag-self-close', 'user-guide/rules/tagname-lowercase', + 'user-guide/rules/tagname-specialchars', + 'user-guide/rules/tags-check', 'user-guide/rules/title-require', ], }, From 637a24de85ad8aedf48b109b4a5a57dfa2f8f0e3 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Wed, 3 Jun 2020 20:22:39 +0200 Subject: [PATCH 07/32] docs: fix broken links --- docs/user-guide/list-rules.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/user-guide/list-rules.md b/docs/user-guide/list-rules.md index c94f46f1c..63323651c 100644 --- a/docs/user-guide/list-rules.md +++ b/docs/user-guide/list-rules.md @@ -17,15 +17,15 @@ title: List of rules - [`attr-lowercase`](/docs/user-guide/rules/attr-lowercase): All attribute names must be in lowercase. - [`attr-no-duplication`](/docs/user-guide/rules/attr-no-duplication): Elements cannot have duplicate attributes. -- [`attr-no-unnecessary-whitespace`](/docs/user-guide/rules/attr-no-unnecessary-whitespace.md): No spaces between attribute names and values. +- [`attr-no-unnecessary-whitespace`](/docs/user-guide/rules/attr-no-unnecessary-whitespace): No spaces between attribute names and values. - [`attr-unsafe-chars`](/docs/user-guide/rules/attr-unsafe-chars): Attribute values cannot contain unsafe chars. - [`attr-value-double-quotes`](/docs/user-guide/rules/attr-value-double-quotes): Attribute values must be in double quotes. -- [`attr-value-not-empty`](/docs/user-guide/rules/attr-not-empty): All attributes must have values. +- [`attr-value-not-empty`](/docs/user-guide/rules/attr-value-not-empty): All attributes must have values. - [`alt-require`](/docs/user-guide/rules/alt-require): The alt attribute of an element must be present and alt attribute of area[href] and input[type=image] must have a value. ### Tags -- [`tags-check`](/docs/user-guide/rules/tags-check.md): Allowing specify rules for any tag and validate that +- [`tags-check`](/docs/user-guide/rules/tags-check): Allowing specify rules for any tag and validate that - [`tag-pair`](/docs/user-guide/rules/tag-pair): Tag must be paired. - [`tag-self-close`](/docs/user-guide/rules/tag-self-close): Empty tags must be self closed. - [`tagname-lowercase`](/docs/user-guide/rules/tagname-lowercase): All html element names must be in lowercase. From 0998bf7c724aca809c5f9b8b5a9f4960f12a372a Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Wed, 3 Jun 2020 20:28:47 +0200 Subject: [PATCH 08/32] docs: new configuration structure for attr-sorted --- docs/user-guide/rules/attr-sorted.md | 51 ++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/docs/user-guide/rules/attr-sorted.md b/docs/user-guide/rules/attr-sorted.md index e69de29bb..9c2df5bd2 100644 --- a/docs/user-guide/rules/attr-sorted.md +++ b/docs/user-guide/rules/attr-sorted.md @@ -0,0 +1,51 @@ +--- +id: attr-sorted +title: attr-sorted +--- + +Attributes must be sorted. + +## Possible Configuration Values + +```json +{ + "attr-sorted": "off", + "attr-sorted": "warn", + "attr-sorted": "error", + "attr-sorted": ["off"], + "attr-sorted": ["warn"], + "attr-sorted": ["error"] +} +``` + +## Default + +```json +{ "attr-sorted": "off" } +``` + +--- + +## Examples + +Examples of **correct** code for this rule: + +```html +test +``` + +Examples of **incorrect** code for this rule: + +```html +test +``` + +--- + +## When Not To Use It + +If your project will use attributes in an unsorted order. + +## Version + +This rule was introduced in HTMLHint `v0.11.0`. From a4683652904957fa94ca1b000155fb2f2b9e44e6 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Wed, 3 Jun 2020 20:34:54 +0200 Subject: [PATCH 09/32] docs: remove unnecessary prettier-ignore --- docs/user-guide/rules/alt-require.md | 2 -- docs/user-guide/rules/attr-lowercase.md | 2 -- docs/user-guide/rules/attr-no-duplication.md | 2 -- docs/user-guide/rules/attr-no-unnecessary-whitespace.md | 1 - 4 files changed, 7 deletions(-) diff --git a/docs/user-guide/rules/alt-require.md b/docs/user-guide/rules/alt-require.md index 7a1a90967..46b077b81 100644 --- a/docs/user-guide/rules/alt-require.md +++ b/docs/user-guide/rules/alt-require.md @@ -34,7 +34,6 @@ keywords: Examples of **correct** code for this rule: - ```html test @@ -43,7 +42,6 @@ Examples of **correct** code for this rule: Examples of **incorrect** code for this rule: - ```html diff --git a/docs/user-guide/rules/attr-lowercase.md b/docs/user-guide/rules/attr-lowercase.md index e1df17932..727d0faa6 100644 --- a/docs/user-guide/rules/attr-lowercase.md +++ b/docs/user-guide/rules/attr-lowercase.md @@ -36,14 +36,12 @@ This rule has an object option: Examples of **correct** code for this rule: - ```html test ``` Examples of **incorrect** code for this rule: - ```html test ``` diff --git a/docs/user-guide/rules/attr-no-duplication.md b/docs/user-guide/rules/attr-no-duplication.md index 7d9529297..c260ac656 100644 --- a/docs/user-guide/rules/attr-no-duplication.md +++ b/docs/user-guide/rules/attr-no-duplication.md @@ -30,14 +30,12 @@ The same attribute can't be specified twice. Examples of **correct** code for this rule: - ```html ``` Examples of **incorrect** code for this rule: - ```html ``` diff --git a/docs/user-guide/rules/attr-no-unnecessary-whitespace.md b/docs/user-guide/rules/attr-no-unnecessary-whitespace.md index 030194b5f..bec4785ae 100644 --- a/docs/user-guide/rules/attr-no-unnecessary-whitespace.md +++ b/docs/user-guide/rules/attr-no-unnecessary-whitespace.md @@ -36,7 +36,6 @@ This rule has an object option: Examples of **correct** code for this rule: - ```html
``` From 3d25cc8fc1dacf8ad7f35b874f23544063d3cd46 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Wed, 3 Jun 2020 20:36:35 +0200 Subject: [PATCH 10/32] docs: new configuration structure for attr-unsafe-chars --- docs/user-guide/rules/attr-unsafe-chars.md | 48 ++++++++++++++++------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/docs/user-guide/rules/attr-unsafe-chars.md b/docs/user-guide/rules/attr-unsafe-chars.md index 8def0dc0c..14900ae56 100644 --- a/docs/user-guide/rules/attr-unsafe-chars.md +++ b/docs/user-guide/rules/attr-unsafe-chars.md @@ -5,35 +5,59 @@ title: attr-unsafe-chars Attribute value cannot use unsafe chars. -regexp: `/[\u0000-\u0009\u000b\u000c\u000e-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/` +Checks against regexp pattern: `/[\u0000-\u0009\u000b\u000c\u000e-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/` + +## Possible Configuration Values + +```json +{ + "attr-unsafe-chars": "off", + "attr-unsafe-chars": "warn", + "attr-unsafe-chars": "error", + "attr-unsafe-chars": ["off"], + "attr-unsafe-chars": ["warn"], + "attr-unsafe-chars": ["error"] +} +``` -Level: `warning` +## Default -## Config value +```json +{ "attr-unsafe-chars": "off" } +``` -1. true: enable rule -2. false: disable rule +--- -The following pattern are **not** considered violations: +## Examples + +Examples of **correct** code for this rule: - ```html
  • Sud Web 2012
  • ``` -The following pattern is considered violation: +Examples of **incorrect** code for this rule: - ```html
  • - Sud Web 2012 + + Sud Web 2012 +
  • ``` :::tip The unsafe chars is in the tail of the href attribute. ::: + +--- + +## When Not To Use It + +If your project will use unsafe chars. + +## Version + +This rule was introduced in HTMLHint `v0.9.6`. From b64533446cac2a004e8623c62dde49bd92eb9943 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Wed, 3 Jun 2020 20:40:09 +0200 Subject: [PATCH 11/32] docs: new configuration structure for attr-value-double-quotes --- .../rules/attr-value-double-quotes.md | 41 +++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/docs/user-guide/rules/attr-value-double-quotes.md b/docs/user-guide/rules/attr-value-double-quotes.md index 4a99cb47e..dbc90b091 100644 --- a/docs/user-guide/rules/attr-value-double-quotes.md +++ b/docs/user-guide/rules/attr-value-double-quotes.md @@ -5,23 +5,48 @@ title: attr-value-double-quotes Attribute value must closed by double quotes. -Level: `error` +## Possible Configuration Values + +```json +{ + "attr-value-double-quotes": "off", + "attr-value-double-quotes": "warn", + "attr-value-double-quotes": "error", + "attr-value-double-quotes": ["off"], + "attr-value-double-quotes": ["warn"], + "attr-value-double-quotes": ["error"] +} +``` -## Config value +## Default -1. true: enable rule -2. false: disable rule +```json +{ "attr-value-double-quotes": "error" } +``` -The following pattern are **not** considered violations: +--- + +## Examples + +Examples of **correct** code for this rule: - ```html ``` -The following pattern is considered violation: +Examples of **incorrect** code for this rule: ```html - + ``` + +--- + +## When Not To Use It + +If your project will use single quotes for attribute values. + +## Version + +This rule was introduced in HTMLHint `v0.9.1`. From 5200a02011a21929de25aa9614e4e277e1273775 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Wed, 3 Jun 2020 20:43:26 +0200 Subject: [PATCH 12/32] docs: new configuration structure for attr-value-not-empty --- docs/user-guide/rules/attr-value-not-empty.md | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/docs/user-guide/rules/attr-value-not-empty.md b/docs/user-guide/rules/attr-value-not-empty.md index 203d46126..51f035d05 100644 --- a/docs/user-guide/rules/attr-value-not-empty.md +++ b/docs/user-guide/rules/attr-value-not-empty.md @@ -5,23 +5,47 @@ title: attr-value-not-empty Attribute must set value. -Level: `warning` +## Possible Configuration Values + +```json +{ + "attr-value-not-empty": "off", + "attr-value-not-empty": "warn", + "attr-value-not-empty": "error", + "attr-value-not-empty": ["off"], + "attr-value-not-empty": ["warn"], + "attr-value-not-empty": ["error"] +} +``` + +## Default + +```json +{ "attr-lowercase": "off" } +``` -## Config value +--- -1. true: enable rule -2. false: disable rule +## Examples -The following pattern are **not** considered violations: +Examples of **correct** code for this rule: - ```html ``` -The following pattern is considered violation: +Examples of **incorrect** code for this rule: - ```html ``` + +--- + +## When Not To Use It + +If your project will use attributes that doesn't need a value. + +## Version + +This rule was introduced in HTMLHint `v0.9.1`. From 290194382f55e4816e7d2d283917d357418d7166 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Thu, 4 Jun 2020 17:12:06 +0200 Subject: [PATCH 13/32] docs: use texts from rules --- docs/user-guide/rules/alt-require.md | 2 +- docs/user-guide/rules/attr-lowercase.md | 2 +- docs/user-guide/rules/attr-no-duplication.md | 2 +- docs/user-guide/rules/attr-sorted.md | 2 +- docs/user-guide/rules/attr-unsafe-chars.md | 2 +- docs/user-guide/rules/attr-value-double-quotes.md | 2 +- docs/user-guide/rules/attr-value-not-empty.md | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/user-guide/rules/alt-require.md b/docs/user-guide/rules/alt-require.md index 46b077b81..40d978699 100644 --- a/docs/user-guide/rules/alt-require.md +++ b/docs/user-guide/rules/alt-require.md @@ -7,7 +7,7 @@ keywords: - accessiblity --- -`alt` of `img` must be present and `alt` of `area[href]` and `input[type=image]` must be set value. +The `alt` attribute of an `` element must be present and `alt` attribute of `area[href]` and `input[type=image]` must have a value. ## Possible Configuration Values diff --git a/docs/user-guide/rules/attr-lowercase.md b/docs/user-guide/rules/attr-lowercase.md index 727d0faa6..e8b80075e 100644 --- a/docs/user-guide/rules/attr-lowercase.md +++ b/docs/user-guide/rules/attr-lowercase.md @@ -3,7 +3,7 @@ id: attr-lowercase title: attr-lowercase --- -Attribute name must be lowercase. +All attribute names must be in lowercase. ## Possible Configuration Values diff --git a/docs/user-guide/rules/attr-no-duplication.md b/docs/user-guide/rules/attr-no-duplication.md index c260ac656..f42f36009 100644 --- a/docs/user-guide/rules/attr-no-duplication.md +++ b/docs/user-guide/rules/attr-no-duplication.md @@ -3,7 +3,7 @@ id: attr-no-duplication title: attr-no-duplication --- -The same attribute can't be specified twice. +Elements cannot have duplicate attributes. ## Possible Configuration Values diff --git a/docs/user-guide/rules/attr-sorted.md b/docs/user-guide/rules/attr-sorted.md index 9c2df5bd2..2f7d8c163 100644 --- a/docs/user-guide/rules/attr-sorted.md +++ b/docs/user-guide/rules/attr-sorted.md @@ -3,7 +3,7 @@ id: attr-sorted title: attr-sorted --- -Attributes must be sorted. +Attribute tags must be in proper order. ## Possible Configuration Values diff --git a/docs/user-guide/rules/attr-unsafe-chars.md b/docs/user-guide/rules/attr-unsafe-chars.md index 14900ae56..e7c916184 100644 --- a/docs/user-guide/rules/attr-unsafe-chars.md +++ b/docs/user-guide/rules/attr-unsafe-chars.md @@ -3,7 +3,7 @@ id: attr-unsafe-chars title: attr-unsafe-chars --- -Attribute value cannot use unsafe chars. +Attribute values cannot contain unsafe chars. Checks against regexp pattern: `/[\u0000-\u0009\u000b\u000c\u000e-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/` diff --git a/docs/user-guide/rules/attr-value-double-quotes.md b/docs/user-guide/rules/attr-value-double-quotes.md index dbc90b091..5486d36b2 100644 --- a/docs/user-guide/rules/attr-value-double-quotes.md +++ b/docs/user-guide/rules/attr-value-double-quotes.md @@ -3,7 +3,7 @@ id: attr-value-double-quotes title: attr-value-double-quotes --- -Attribute value must closed by double quotes. +Attribute values must be in double quotes. ## Possible Configuration Values diff --git a/docs/user-guide/rules/attr-value-not-empty.md b/docs/user-guide/rules/attr-value-not-empty.md index 51f035d05..d0f7dfe47 100644 --- a/docs/user-guide/rules/attr-value-not-empty.md +++ b/docs/user-guide/rules/attr-value-not-empty.md @@ -3,7 +3,7 @@ id: attr-value-not-empty title: attr-value-not-empty --- -Attribute must set value. +All attributes must have values. ## Possible Configuration Values From f56af6c47af89f2ef6fe16e9b9c09f9d6d0b0a9a Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Thu, 4 Jun 2020 17:12:53 +0200 Subject: [PATCH 14/32] docs: new configuration structure for attr-value-single-quotes --- .../rules/attr-value-single-quotes.md | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/docs/user-guide/rules/attr-value-single-quotes.md b/docs/user-guide/rules/attr-value-single-quotes.md index e69de29bb..26aae62e8 100644 --- a/docs/user-guide/rules/attr-value-single-quotes.md +++ b/docs/user-guide/rules/attr-value-single-quotes.md @@ -0,0 +1,52 @@ +--- +id: attr-value-single-quotes +title: attr-value-single-quotes +--- + +Attribute values must be in single quotes. + +## Possible Configuration Values + +```json +{ + "attr-value-single-quotes": "off", + "attr-value-single-quotes": "warn", + "attr-value-single-quotes": "error", + "attr-value-single-quotes": ["off"], + "attr-value-single-quotes": ["warn"], + "attr-value-single-quotes": ["error"] +} +``` + +## Default + +```json +{ "attr-value-single-quotes": "off" } +``` + +--- + +## Examples + +Examples of **correct** code for this rule: + +```html + +``` + +Examples of **incorrect** code for this rule: + + +```html + +``` + +--- + +## When Not To Use It + +If your project will use double quotes for attribute values. + +## Version + +This rule was introduced in HTMLHint `v0.9.1`. From d1c55e343d7b1576ec740de04c5ac974b81d3817 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Thu, 4 Jun 2020 17:18:50 +0200 Subject: [PATCH 15/32] docs: new configuration structure for attr-whitespace --- docs/user-guide/rules/attr-whitespace.md | 57 ++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/docs/user-guide/rules/attr-whitespace.md b/docs/user-guide/rules/attr-whitespace.md index e69de29bb..c01a32438 100644 --- a/docs/user-guide/rules/attr-whitespace.md +++ b/docs/user-guide/rules/attr-whitespace.md @@ -0,0 +1,57 @@ +--- +id: attr-whitespace +title: attr-whitespace +--- + +All attributes should be separated by only one space and not have leading/trailing whitespace. + +## Possible Configuration Values + +```json +{ + "attr-whitespace": "off", + "attr-whitespace": "warn", + "attr-whitespace": "error", + "attr-whitespace": ["off"], + "attr-whitespace": ["warn", { "exceptions": ["???", "???"] }], + "attr-whitespace": ["error", { "exceptions": ["???", "???"] }] +} +``` + +## Default + +```json +{ "attr-whitespace": "off" } +``` + +## Options + +This rule has an object option: + +- `"exceptions": ["???", "???"]` ignore attributes `???` and `???`. + +--- + +## Examples + +Examples of **correct** code for this rule: + +```html +??? +``` + +Examples of **incorrect** code for this rule: + +```html +??? +``` + +--- + +## When Not To Use It + +If your project ???. + +## Version + +This rule was introduced in HTMLHint `v0.9.1`. From df9e8dcc84f4d9d44dd9bc42549bea2a4b2704a4 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Thu, 4 Jun 2020 17:23:06 +0200 Subject: [PATCH 16/32] docs: new configuration structure for doctype-first --- docs/user-guide/rules/doctype-first.md | 45 +++++++++++++++++++------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/docs/user-guide/rules/doctype-first.md b/docs/user-guide/rules/doctype-first.md index af4dc5fe1..47f497f96 100644 --- a/docs/user-guide/rules/doctype-first.md +++ b/docs/user-guide/rules/doctype-first.md @@ -3,33 +3,56 @@ id: doctype-first title: doctype-first --- -Doctype must be first. +Doctype must be declared first. + +## Possible Configuration Values + +```json +{ + "doctype-first": "off", + "doctype-first": "warn", + "doctype-first": "error", + "doctype-first": ["off"], + "doctype-first": ["warn"], + "doctype-first": ["error"] +} +``` + +## Default -Level: `error` +```json +{ "doctype-first": "error" } +``` -## Config value +--- -1. true: enable rule -2. false: disable rule +## Examples -The following pattern are **not** considered violations: +Examples of **correct** code for this rule: - ```html ``` - +Examples of **incorrect** code for this rule: + ```html ``` -The following pattern is considered violation: - - ```html ``` + +--- + +## When Not To Use It + +If your project will use a framework. + +## Version + +This rule was introduced in HTMLHint `v0.9.1`. From e2c53974774bfc7fec6db700e556a0c53c13b5e3 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Thu, 4 Jun 2020 17:29:40 +0200 Subject: [PATCH 17/32] docs: new configuration structure for doctype-html5 --- docs/user-guide/rules/doctype-html5.md | 48 +++++++++++++++++++++----- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/docs/user-guide/rules/doctype-html5.md b/docs/user-guide/rules/doctype-html5.md index d7e1a3019..e282fd408 100644 --- a/docs/user-guide/rules/doctype-html5.md +++ b/docs/user-guide/rules/doctype-html5.md @@ -1,22 +1,52 @@ --- id: doctype-html5 -title: Doctype HTML5 +title: doctype-html5 --- -Rule ID: `doctype-html5` - Doctype must be html5. -Level: `warning` +```json +{ + "doctype-html5": "off", + "doctype-html5": "warn", + "doctype-html5": "error", + "doctype-html5": ["off"], + "doctype-html5": ["warn"], + "doctype-html5": ["error"] +} +``` + +## Default + +```json +{ "doctype-html5": "off" } +``` -## Config value +--- -1. true: enable rule -2. false: disable rule +## Examples -The following pattern are **not** considered violations: +Examples of **correct** code for this rule: ```html - + + +``` + +Examples of **incorrect** code for this rule: + +```html + + ``` + +--- + +## When Not To Use It + +If your project will use `html4` or `xhtml`. + +## Version + +This rule was introduced in HTMLHint `v0.9.1`. From 3cbcd426848b93563d3295b74e5e17ab0fe88a7c Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Thu, 4 Jun 2020 17:33:26 +0200 Subject: [PATCH 18/32] docs: remove empty-tag-not-self-closed --- docs/user-guide/list-rules.md | 1 - .../rules/empty-tag-not-self-closed.md | 27 ------------------- 2 files changed, 28 deletions(-) delete mode 100644 docs/user-guide/rules/empty-tag-not-self-closed.md diff --git a/docs/user-guide/list-rules.md b/docs/user-guide/list-rules.md index 63323651c..70ae4a18e 100644 --- a/docs/user-guide/list-rules.md +++ b/docs/user-guide/list-rules.md @@ -29,7 +29,6 @@ title: List of rules - [`tag-pair`](/docs/user-guide/rules/tag-pair): Tag must be paired. - [`tag-self-close`](/docs/user-guide/rules/tag-self-close): Empty tags must be self closed. - [`tagname-lowercase`](/docs/user-guide/rules/tagname-lowercase): All html element names must be in lowercase. -- [`empty-tag-not-self-closed`](/docs/user-guide/rules/empty-tag-not-self-closed): The empty tag should not be closed by self. - [`src-not-empty`](/docs/user-guide/rules/src-not-empty): The src attribute of an img(script,link) must have a value. - [`href-abs-or-rel`](/docs/user-guide/rules/href-abs-or-rel): An href attribute must be either absolute or relative. diff --git a/docs/user-guide/rules/empty-tag-not-self-closed.md b/docs/user-guide/rules/empty-tag-not-self-closed.md deleted file mode 100644 index 4426b8ab8..000000000 --- a/docs/user-guide/rules/empty-tag-not-self-closed.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -id: empty-tag-not-self-closed -title: empty-tag-not-self-closed ---- - -The empty tag should not be closed by self. - -Level: `warning` - -## Config value - -1. true: enable rule -2. false: disable rule - -The following pattern are **not** considered violations: - - -```html -
    -``` - -The following pattern is considered violation: - - -```html -
    -``` From 76689fd94b9700c4cc32caab6dc2d0eba5e88aae Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Thu, 4 Jun 2020 17:36:10 +0200 Subject: [PATCH 19/32] docs: new configuration structure for head-script-disabled --- docs/user-guide/rules/head-script-disabled.md | 42 +++++++++++++++---- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/docs/user-guide/rules/head-script-disabled.md b/docs/user-guide/rules/head-script-disabled.md index 9324366b2..921abc5fa 100644 --- a/docs/user-guide/rules/head-script-disabled.md +++ b/docs/user-guide/rules/head-script-disabled.md @@ -3,29 +3,53 @@ id: head-script-disabled title: head-script-disabled --- -The script tag can not be used in head. +The ` ``` -The following pattern is considered violation: +Examples of **incorrect** code for this rule: - ```html ``` + +--- + +## When Not To Use It + +If your project will use `script` tags in `head`. + +## Version + +This rule was introduced in HTMLHint `v0.9.1`. From 4d5b7d4a1297155415190ceb85fb00ec896b0f67 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Thu, 4 Jun 2020 17:46:05 +0200 Subject: [PATCH 20/32] docs: new configuration structure for href-abs-or-rel --- docs/user-guide/rules/href-abs-or-rel.md | 60 ++++++++++++++++++++---- 1 file changed, 50 insertions(+), 10 deletions(-) diff --git a/docs/user-guide/rules/href-abs-or-rel.md b/docs/user-guide/rules/href-abs-or-rel.md index dfb7c0f4a..a26cf48a6 100644 --- a/docs/user-guide/rules/href-abs-or-rel.md +++ b/docs/user-guide/rules/href-abs-or-rel.md @@ -3,21 +3,61 @@ id: href-abs-or-rel title: href-abs-or-rel --- -Href must be absolute or relative. +An href attribute must be either absolute or relative. -Level: `warning` +## Possible Configuration Values -## Config value +```json +{ + "href-abs-or-rel": "off", + "href-abs-or-rel": "warn", + "href-abs-or-rel": "error", + "href-abs-or-rel": ["off"], + "href-abs-or-rel": ["warn", { "mode": "absolute" }], + "href-abs-or-rel": ["warn", { "mode": "relative" }], + "href-abs-or-rel": ["error", { "mode": "absolute" }], + "href-abs-or-rel": ["error", { "mode": "relative" }] +} +``` -1. abs: absolute mode -2. rel: relative mode -3. false: disable rule +## Default -The following pattern are **not** considered violations: +```json +{ "attr-lowercase": ["off", { "mode": "absolute" }] } +``` + +## Options + +This rule has an object option: + +- `"mode": "absolute"` (default) only allow absolut urls. +- `"mode": "relative"` only allow relative urls. + +--- + +## Examples + +Examples of **correct** code for mode `absolut`: - ```html -abs: test1 test2 -rel: test1 test2 +test1 +test2 +``` + +Examples of **correct** code for mode `relative`: + +```html +test1 +test2 ``` + +--- + +## When Not To Use It + +If your project will use both `relative` and `absolute`. + +## Version + +This rule was introduced in HTMLHint `v0.9.6`. From 98168da677a5bad2b36e2584fdb5b9f0841134e5 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Thu, 4 Jun 2020 17:49:48 +0200 Subject: [PATCH 21/32] docs: new configuration structure for id-class-ad-disabled --- docs/user-guide/rules/id-class-ad-disabled.md | 42 +++++++++++++++---- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/docs/user-guide/rules/id-class-ad-disabled.md b/docs/user-guide/rules/id-class-ad-disabled.md index 707dee39d..16c94f61c 100644 --- a/docs/user-guide/rules/id-class-ad-disabled.md +++ b/docs/user-guide/rules/id-class-ad-disabled.md @@ -3,26 +3,50 @@ id: id-class-ad-disabled title: id-class-ad-disabled --- -Id and class can not use ad keyword, it will blocked by adblock software. +The `id` and `class` attributes cannot use the "ad" keyword, it will be blocked by adblock software. + +## Possible Configuration Values + +```json +{ + "id-class-ad-disabled": "off", + "id-class-ad-disabled": "warn", + "id-class-ad-disabled": "error", + "id-class-ad-disabled": ["off"], + "id-class-ad-disabled": ["warn"], + "id-class-ad-disabled": ["error"] +} +``` -Level: `warning` +## Default -## Config value +```json +{ "id-class-ad-disabled": "off" } +``` -1. true: enable rule -2. false: disable rule +--- -The following pattern are **not** considered violations: +## Examples + +Examples of **correct** code for this rule: - ```html
    ``` -The following pattern is considered violation: +Examples of **incorrect** code for this rule: - ```html
    ``` + +--- + +## When Not To Use It + +If your project will use ads. + +## Version + +This rule was introduced in HTMLHint `v0.9.6`. From 2647d4b13b28e7577b3f9c9082d945f4b4661d05 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Fri, 5 Jun 2020 16:59:00 +0200 Subject: [PATCH 22/32] docs: new configuration structure for id-class-value --- docs/user-guide/rules/id-class-value.md | 71 ++++++++++++++++++++----- 1 file changed, 59 insertions(+), 12 deletions(-) diff --git a/docs/user-guide/rules/id-class-value.md b/docs/user-guide/rules/id-class-value.md index 8733f5a34..fafa5091c 100644 --- a/docs/user-guide/rules/id-class-value.md +++ b/docs/user-guide/rules/id-class-value.md @@ -3,23 +3,70 @@ id: id-class-value title: id-class-value --- -Id and class value must meet some rules: underline, dash, hump. +The id and class attribute values must meet the specified rules. -Level: `warning` +## Possible Configuration Values -## Config value +```json +{ + "id-class-value": "off", + "id-class-value": "warn", + "id-class-value": "error", + "id-class-value": ["off"], + "id-class-value": ["warn", { "mode": "underline" }], + "id-class-value": ["warn", { "mode": "dash" }], + "id-class-value": ["warn", { "mode": "hump" }], + "id-class-value": ["warn", { "regId": RegExp, "message": "Message" }], + "id-class-value": ["error", { "mode": "underline" }], + "id-class-value": ["error", { "mode": "dash" }], + "id-class-value": ["error", { "mode": "hump" }], + "id-class-value": ["error", { "regId": RegExp, "message": "Message" }] +} +``` + +## Default + +```json +{ "id-class-value": "off" } +``` + +## Options + +This rule has an object option: + +- `"mode": "underline"` The id and class attribute values must be in lowercase and split by an underscore. +- `"mode": "dash"` The id and class attribute values must be in lowercase and split by a dash. +- `"mode": "hump"` The id and class attribute values must meet the camelCase style. +- `"regId": RegExp` Custom message. + +--- + +## Examples + +Examples of **correct** code for mode `underline`: -1. underline: underline mode ( aaa_bb ) -2. dash: enable rule ( aaa-bbb ) -3. hump: enable rule ( aaaBbb ) -4. false: disable rule +```html +
    +``` -The following pattern are **not** considered violations: +Examples of **correct** code for mode `dash`: - ```html -underline:
    -dash:
    -hump:
    +
    +``` +Examples of **correct** code for mode `hump`: + +```html +
    ``` + +--- + +## When Not To Use It + +If your project will use mixed cased `id` values. + +## Version + +This rule was introduced in HTMLHint `v0.9.1`. From 3750806e748b613eb201b5b08b9677b61264dc30 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Fri, 5 Jun 2020 17:06:10 +0200 Subject: [PATCH 23/32] docs: new configuration structure for id-unique --- docs/user-guide/rules/id-unique.md | 48 +++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/docs/user-guide/rules/id-unique.md b/docs/user-guide/rules/id-unique.md index 9f87d3e14..3c23975c2 100644 --- a/docs/user-guide/rules/id-unique.md +++ b/docs/user-guide/rules/id-unique.md @@ -3,25 +3,51 @@ id: id-unique title: id-unique --- -ID attributes must be unique in the document. +The value of id attributes must be unique. + +## Possible Configuration Values + +```json +{ + "id-unique": "off", + "id-unique": "warn", + "id-unique": "error", + "id-unique": ["off"], + "id-unique": ["warn"], + "id-unique": ["error"] +} +``` -Level: `error` +## Default -## Config value +```json +{ "id-unique": "error" } +``` -1. true: enable rule -2. false: disable rule +--- -The following pattern are **not** considered violations: +## Examples + +Examples of **correct** code for this rule: - ```html -
    +
    +
    ``` -The following pattern is considered violation: +Examples of **incorrect** code for this rule: - ```html -
    +
    +
    ``` + +--- + +## When Not To Use It + +If your project will use the same `id` multiple times. + +## Version + +This rule was introduced in HTMLHint `v0.9.2`. From 93489cb73ad2064e7af5d0c4cf46db19e3b7c2e6 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Fri, 5 Jun 2020 17:11:19 +0200 Subject: [PATCH 24/32] docs: new configuration structure for inline-script-disabled --- .../rules/inline-script-disabled.md | 43 +++++++++++++++---- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/docs/user-guide/rules/inline-script-disabled.md b/docs/user-guide/rules/inline-script-disabled.md index 7f34b6805..04cea8186 100644 --- a/docs/user-guide/rules/inline-script-disabled.md +++ b/docs/user-guide/rules/inline-script-disabled.md @@ -3,20 +3,45 @@ id: inline-script-disabled title: inline-script-disabled --- -Inline script cannot be use. +Inline script cannot be used. -Level: `warning` +## Possible Configuration Values -## Config value +```json +{ + "inline-script-disabled": "off", + "inline-script-disabled": "warn", + "inline-script-disabled": "error", + "inline-script-disabled": ["off"], + "inline-script-disabled": ["warn"], + "inline-script-disabled": ["error"] +} +``` + +## Default + +```json +{ "inline-script-disabled": "off" } +``` + +--- -1. true: enable rule -2. false: disable rule +## Examples -The following pattern are considered violations: +Examples of **incorrect** code for this rule: - ```html - - + + test1 ``` + +--- + +## When Not To Use It + +If your project will use inline scripts. + +## Version + +This rule was introduced in HTMLHint `v0.9.10`. From 24a83d2c093b250c114f1f5e75034a1a6f4fcd7a Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Fri, 5 Jun 2020 17:14:40 +0200 Subject: [PATCH 25/32] docs: new configuration structure for inline-style-disabled --- .../user-guide/rules/inline-style-disabled.md | 39 +++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/docs/user-guide/rules/inline-style-disabled.md b/docs/user-guide/rules/inline-style-disabled.md index 0911221c5..34990d589 100644 --- a/docs/user-guide/rules/inline-style-disabled.md +++ b/docs/user-guide/rules/inline-style-disabled.md @@ -3,18 +3,43 @@ id: inline-style-disabled title: inline-style-disabled --- -Inline style cannot be use. +Inline style cannot be used. -Level: `warning` +## Possible Configuration Values -## Config value +```json +{ + "inline-style-disabled": "off", + "inline-style-disabled": "warn", + "inline-style-disabled": "error", + "inline-style-disabled": ["off"], + "inline-style-disabled": ["warn"], + "inline-style-disabled": ["error"] +} +``` + +## Default + +```json +{ "inline-style-disabled": "error" } +``` + +--- -1. true: enable rule -2. false: disable rule +## Examples -The following pattern are considered violations: +Examples of **incorrect** code for this rule: - ```html
    ``` + +--- + +## When Not To Use It + +If your project will use inline styles. + +## Version + +This rule was introduced in HTMLHint `v0.9.10`. From d33544b97aa5d8635ecf34d31edee55ee5c55d6f Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Fri, 5 Jun 2020 17:20:57 +0200 Subject: [PATCH 26/32] docs: new configuration structure for input-requires-label --- docs/user-guide/rules/input-requires-label.md | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/docs/user-guide/rules/input-requires-label.md b/docs/user-guide/rules/input-requires-label.md index e69de29bb..457d6a0d8 100644 --- a/docs/user-guide/rules/input-requires-label.md +++ b/docs/user-guide/rules/input-requires-label.md @@ -0,0 +1,53 @@ +--- +id: input-requires-label +title: input-requires-label +--- + +All `input` tags must have a corresponding `label` tag. + +## Possible Configuration Values + +```json +{ + "input-requires-label": "off", + "input-requires-label": "warn", + "input-requires-label": "error", + "input-requires-label": ["off"], + "input-requires-label": ["warn"], + "input-requires-label": ["error"] +} +``` + +## Default + +```json +{ "input-requires-label": "off" } +``` + +--- + +## Examples + +Examples of **correct** code for this rule: + + +```html + + +``` + +Examples of **incorrect** code for this rule: + +```html + +``` + +--- + +## When Not To Use It + +If your project will use not use labels. + +## Version + +This rule was introduced in HTMLHint `v0.13.0`. From 5cb389a1f8339980e24c56d22bf224850a8fe6ec Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Fri, 5 Jun 2020 22:57:57 +0200 Subject: [PATCH 27/32] docs: new configuration structure --- docs/user-guide/rules/script-disabled.md | 47 ++++++++++ .../rules/space-tab-mixed-disabled.md | 52 +++++++++-- docs/user-guide/rules/spec-char-escape.md | 40 ++++++-- docs/user-guide/rules/src-not-empty.md | 40 ++++++-- docs/user-guide/rules/style-disabled.md | 47 ++++++++-- docs/user-guide/rules/tag-pair.md | 43 +++++++-- docs/user-guide/rules/tag-self-close.md | 52 +++++++++++ docs/user-guide/rules/tagname-lowercase.md | 47 ++++++++-- docs/user-guide/rules/tagname-specialchars.md | 51 ++++++++++ docs/user-guide/rules/tags-check.md | 92 ++++++++++++++++++- docs/user-guide/rules/title-require.md | 63 ++++++++++--- 11 files changed, 509 insertions(+), 65 deletions(-) diff --git a/docs/user-guide/rules/script-disabled.md b/docs/user-guide/rules/script-disabled.md index e69de29bb..46c4111ea 100644 --- a/docs/user-guide/rules/script-disabled.md +++ b/docs/user-guide/rules/script-disabled.md @@ -0,0 +1,47 @@ +--- +id: script-disabled +title: script-disabled +--- + +The ` + +``` + +--- + +## When Not To Use It + +If your project will use `script` tags. + +## Version + +This rule was introduced in HTMLHint `v0.9.1`. diff --git a/docs/user-guide/rules/space-tab-mixed-disabled.md b/docs/user-guide/rules/space-tab-mixed-disabled.md index 1cee5cde0..e56b1eb7b 100644 --- a/docs/user-guide/rules/space-tab-mixed-disabled.md +++ b/docs/user-guide/rules/space-tab-mixed-disabled.md @@ -3,18 +3,42 @@ id: space-tab-mixed-disabled title: space-tab-mixed-disabled --- -Spaces and tabs can not mixed in front of line. +Do not mix tabs and spaces for indentation. -Level: `warning` +## Possible Configuration Values -## Config value +```json +{ + "space-tab-mixed-disabled": "off", + "space-tab-mixed-disabled": "warn", + "space-tab-mixed-disabled": "error", + "space-tab-mixed-disabled": ["off"], + "space-tab-mixed-disabled": ["warn", { "mode": "tab" }], + "space-tab-mixed-disabled": ["warn", { "mode": "space", "size": 2 }], + "space-tab-mixed-disabled": ["error", { "mode": "tab" }], + "space-tab-mixed-disabled": ["error", { "mode": "space", "size": 2 }] +} +``` + +## Default + +```json +{ "space-tab-mixed-disabled": ["off", { "mode": "nomix", "space": 4 }] } +``` -1. space: space mode (only space for indentation) -2. space4: space mode and require length -3. tab: tab mode (only tab for indentation) -4. false: disable rule +## Options + +This rule has an object option: + +- `"mode": "tab"` use tabs as indentation. +- `"mode": "space"` use spaces as indentation. +- `"size": 0-8` count of spaces. + +--- -The following pattern are **not** considered violations: +## Examples + +Examples of **correct** code for this rule: ```html @@ -22,7 +46,7 @@ The following pattern are **not** considered violations: ········ ``` -The following pattern is considered violation: +Examples of **incorrect** code for this rule: ```html @@ -33,3 +57,13 @@ The following pattern is considered violation: :::note In the examples above, spaces and tabs are represented by `·` and `→`, respectively, to make the difference visible. ::: + +--- + +## When Not To Use It + +If your project will use mixed indentation. + +## Version + +This rule was introduced in HTMLHint `v0.9.6`. diff --git a/docs/user-guide/rules/spec-char-escape.md b/docs/user-guide/rules/spec-char-escape.md index b94658651..5db53f869 100644 --- a/docs/user-guide/rules/spec-char-escape.md +++ b/docs/user-guide/rules/spec-char-escape.md @@ -5,23 +5,47 @@ title: spec-char-escape Special characters must be escaped. -Level: `error` +## Possible Configuration Values + +```json +{ + "spec-char-escape": "off", + "spec-char-escape": "warn", + "spec-char-escape": "error", + "spec-char-escape": ["off"], + "spec-char-escape": ["warn"], + "spec-char-escape": ["error"] +} +``` + +## Default + +```json +{ "spec-char-escape": "error" } +``` -## Config value +--- -1. true: enable rule -2. false: disable rule +## Examples -The following pattern are **not** considered violations: +Examples of **correct** code for this rule: - ```html aaa>bbb<ccc ``` -The following pattern is considered violation: +Examples of **incorrect** code for this rule: - ```html aaa>bbb ``` + +--- + +## When Not To Use It + +Always use this rule. + +## Version + +This rule was introduced in HTMLHint `v0.9.1`. diff --git a/docs/user-guide/rules/src-not-empty.md b/docs/user-guide/rules/src-not-empty.md index 87956d206..0aca04e7f 100644 --- a/docs/user-guide/rules/src-not-empty.md +++ b/docs/user-guide/rules/src-not-empty.md @@ -3,18 +3,32 @@ id: src-not-empty title: src-not-empty --- -Src of img(script, link) must set value. +The `src` attribute of an `img`, `script` or `link` must have a value. -Emtpy of src will visit current page twice. +## Possible Configuration Values -Level: `error` +```json +{ + "src-not-empty": "off", + "src-not-empty": "warn", + "src-not-empty": "error", + "src-not-empty": ["off"], + "src-not-empty": ["warn"], + "src-not-empty": ["error"] +} +``` + +## Default + +```json +{ "src-not-empty": "error" } +``` -## Config value +--- -1. true: enable rule -2. false: disable rule +## Examples -The following pattern are **not** considered violations: +Examples of **correct** code for this rule: ```html @@ -27,7 +41,7 @@ The following pattern are **not** considered violations: ``` -The following patterns are considered violations: +Examples of **incorrect** code for this rule: ```html @@ -45,3 +59,13 @@ The following patterns are considered violations: ``` + +--- + +## When Not To Use It + +If your project will use tags without `src`. + +## Version + +This rule was introduced in HTMLHint `v0.9.4`. diff --git a/docs/user-guide/rules/style-disabled.md b/docs/user-guide/rules/style-disabled.md index 0cc2e70f9..717daab7e 100644 --- a/docs/user-guide/rules/style-disabled.md +++ b/docs/user-guide/rules/style-disabled.md @@ -3,19 +3,48 @@ id: style-disabled title: style-disabled --- -Style tag can not be use. +` - + + + + + + ``` + +--- + +## When Not To Use It + +If your project will use `style` tags. + +## Version + +This rule was introduced in HTMLHint `v0.9.1`. diff --git a/docs/user-guide/rules/tag-pair.md b/docs/user-guide/rules/tag-pair.md index e67116be6..78e4447a8 100644 --- a/docs/user-guide/rules/tag-pair.md +++ b/docs/user-guide/rules/tag-pair.md @@ -5,24 +5,51 @@ title: tag-pair Tag must be paired. -Level: `error` +## Possible Configuration Values + +```json +{ + "tag-pair": "off", + "tag-pair": "warn", + "tag-pair": "error", + "tag-pair": ["off"], + "tag-pair": ["warn"], + "tag-pair": ["error"] +} +``` + +## Default + +```json +{ "tag-pair": "error" } +``` -## Config value +--- -1. true: enable rule -2. false: disable rule +## Examples -The following pattern are **not** considered violations: +Examples of **correct** code for this rule: - ```html -
    +
      +
    • +
    ``` -The following pattern is considered violation: +Examples of **incorrect** code for this rule: ```html
      ``` + +--- + +## When Not To Use It + +Always use this rule. + +## Version + +This rule was introduced in HTMLHint `v0.9.1`. diff --git a/docs/user-guide/rules/tag-self-close.md b/docs/user-guide/rules/tag-self-close.md index e69de29bb..5306b3f72 100644 --- a/docs/user-guide/rules/tag-self-close.md +++ b/docs/user-guide/rules/tag-self-close.md @@ -0,0 +1,52 @@ +--- +id: tag-self-close +title: tag-self-close +--- + +Empty tags must be self closed. + +## Possible Configuration Values + +```json +{ + "tag-self-close": "off", + "tag-self-close": "warn", + "tag-self-close": "error", + "tag-self-close": ["off"], + "tag-self-close": ["warn"], + "tag-self-close": ["error"] +} +``` + +## Default + +```json +{ "tag-self-close": "off" } +``` + +--- + +## Examples + +Examples of **correct** code for this rule: + +```html +
      +``` + +Examples of **incorrect** code for this rule: + + +```html +
      +``` + +--- + +## When Not To Use It + +If your project will use tags without self closing tags. + +## Version + +This rule was introduced in HTMLHint `v0.9.1`. diff --git a/docs/user-guide/rules/tagname-lowercase.md b/docs/user-guide/rules/tagname-lowercase.md index 0fa98cd54..09b7ba2ff 100644 --- a/docs/user-guide/rules/tagname-lowercase.md +++ b/docs/user-guide/rules/tagname-lowercase.md @@ -3,26 +3,57 @@ id: tagname-lowercase title: tagname-lowercase --- -Tagname must be lowercase. +All html element names must be in lowercase. + +## Possible Configuration Values + +```json +{ + "tagname-lowercase": "off", + "tagname-lowercase": "warn", + "tagname-lowercase": "error", + "tagname-lowercase": ["off"], + "tagname-lowercase": ["warn", { "exceptions": ["clipPath", "test"] }], + "tagname-lowercase": ["error", { "exceptions": ["clipPath", "test"] }] +} +``` + +## Default + +```json +{ "tagname-lowercase": "error" } +``` -Level: `error` +## Options -## Config value +This rule has an object option: + +- `"exceptions": ["clipPath", "test"]` ignore tagnames `clipPath` and `test`. + +--- -1. true: enable rule -2. false: disable rule -3. ['clipPath', 'test']: Ignore some tagname name +## Examples -The following pattern are **not** considered violations: +Examples of **correct** code for this rule: ```html
      ``` -The following pattern is considered violation: +Examples of **incorrect** code for this rule: ```html
      ``` + +--- + +## When Not To Use It + +If your project will not use lower case tagnames. + +## Version + +This rule was introduced in HTMLHint `v0.9.1`. diff --git a/docs/user-guide/rules/tagname-specialchars.md b/docs/user-guide/rules/tagname-specialchars.md index e69de29bb..761a64bc1 100644 --- a/docs/user-guide/rules/tagname-specialchars.md +++ b/docs/user-guide/rules/tagname-specialchars.md @@ -0,0 +1,51 @@ +--- +id: tagname-specialchars +title: tagname-specialchars +--- + +All html element names must be in lowercase. + +## Possible Configuration Values + +```json +{ + "tagname-specialchars": "off", + "tagname-specialchars": "warn", + "tagname-specialchars": "error", + "tagname-specialchars": ["off"], + "tagname-specialchars": ["warn"], + "tagname-specialchars": ["error"] +} +``` + +## Default + +```json +{ "tagname-specialchars": "off" } +``` + +--- + +## Examples + +Examples of **correct** code for this rule: + +```html +
      +``` + +Examples of **incorrect** code for this rule: + +```html + +``` + +--- + +## When Not To Use It + +Always use this rule. + +## Version + +This rule was introduced in HTMLHint `v0.9.1`. diff --git a/docs/user-guide/rules/tags-check.md b/docs/user-guide/rules/tags-check.md index 8ca6ef827..36ba9fcff 100644 --- a/docs/user-guide/rules/tags-check.md +++ b/docs/user-guide/rules/tags-check.md @@ -3,9 +3,85 @@ id: tags-check title: tags-check --- -Allowing specify rules for any tag and validate that +Checks html tags. -The following pattern are **not** considered violations: +## Possible Configuration Values + +```json +{ + "tags-check": "off", + "tags-check": "warn", + "tags-check": "error", + "tags-check": ["off"], + "tags-check": [ + "warn", + { + "img": { + "selfclosing": true, + "attrsRequired": ["src", "alt", "title"] + } + } + ], + "tags-check": [ + "error", + { + "a": { + "selfclosing": false, + "attrsRequired": ["href", "title"], + "redundantAttrs": ["alt"] + } + } + ] +} +``` + +## Default + +```json +{ + "tags-check": [ + "off", + { + "a": { + "selfclosing": false, + "attrsRequired": ["href", "title"], + "redundantAttrs": ["alt"] + }, + "div": { + "selfclosing": false + }, + "main": { + "selfclosing": false, + "redundantAttrs": ["role"] + }, + "nav": { + "selfclosing": false, + "redundantAttrs": ["role"] + }, + "script": { + "attrsOptional": [ + ["async", "async"], + ["defer", "defer"] + ] + }, + "img": { + "selfclosing": true, + "attrsRequired": ["src", "alt", "title"] + } + } + ] +} +``` + +## Options + +This rule has an object option. + +--- + +## Examples + +Examples of **correct** code for this rule: ```html @@ -15,7 +91,7 @@ The following pattern are **not** considered violations: asd ``` -The following pattern is considered violation: +Examples of **incorrect** code for this rule: ```html @@ -24,3 +100,13 @@ The following pattern is considered violation: asd ``` + +--- + +## When Not To Use It + +???. + +## Version + +This rule was introduced in HTMLHint `v0.11.0`. diff --git a/docs/user-guide/rules/title-require.md b/docs/user-guide/rules/title-require.md index 7defb1f00..8a0fbecc3 100644 --- a/docs/user-guide/rules/title-require.md +++ b/docs/user-guide/rules/title-require.md @@ -5,25 +5,64 @@ title: title-require `` must be present in `<head>` tag. -Level: `error` +## Possible Configuration Values -## Config value +```json +{ + "title-require": "off", + "title-require": "warn", + "title-require": "error", + "title-require": ["off"], + "title-require": ["warn"], + "title-require": ["error"] +} +``` + +## Default -1. true: enable rule -2. false: disable rule +```json +{ "title-require": "error" } +``` -The following pattern are **not** considered violations: +--- + +## Examples + +Examples of **correct** code for this rule: -<!-- prettier-ignore --> ```html -<html><head><title>test + + + test + + ``` -The following pattern is considered violation: +Examples of **incorrect** code for this rule: - ```html - - - + + + + + + + + + + + + + + ``` + +--- + +## When Not To Use It + +If your project will not use a `title` tag. + +## Version + +This rule was introduced in HTMLHint `v0.9.8`. From 5b74ee254c5d999a17c6ea29f774b8a9c2cd1b9b Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Sat, 6 Jun 2020 09:19:39 +0200 Subject: [PATCH 28/32] docs: update doc attr-whitespace --- docs/user-guide/rules/attr-whitespace.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/docs/user-guide/rules/attr-whitespace.md b/docs/user-guide/rules/attr-whitespace.md index c01a32438..bbfa3ad98 100644 --- a/docs/user-guide/rules/attr-whitespace.md +++ b/docs/user-guide/rules/attr-whitespace.md @@ -13,22 +13,22 @@ All attributes should be separated by only one space and not have leading/traili "attr-whitespace": "warn", "attr-whitespace": "error", "attr-whitespace": ["off"], - "attr-whitespace": ["warn", { "exceptions": ["???", "???"] }], - "attr-whitespace": ["error", { "exceptions": ["???", "???"] }] + "attr-whitespace": ["warn", { "exceptions": ["test"] }], + "attr-whitespace": ["error", { "exceptions": ["test"] }] } ``` ## Default ```json -{ "attr-whitespace": "off" } +{ "attr-whitespace": ["off", { "exceptions": [] }] } ``` ## Options This rule has an object option: -- `"exceptions": ["???", "???"]` ignore attributes `???` and `???`. +- `"exceptions": ["test"]` ignore attribute `test`. --- @@ -37,20 +37,24 @@ This rule has an object option: Examples of **correct** code for this rule: ```html -??? +

      +

      +

      ``` Examples of **incorrect** code for this rule: ```html -??? +

      +

      +

      ``` --- ## When Not To Use It -If your project ???. +If your project will use attributes with multiple whitespaces. ## Version From b030fda40643ec47a31639b651d7bfbea95fe579 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Sat, 6 Jun 2020 09:21:45 +0200 Subject: [PATCH 29/32] docs: update doc tags-check --- docs/user-guide/rules/tags-check.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/rules/tags-check.md b/docs/user-guide/rules/tags-check.md index 36ba9fcff..294f80f14 100644 --- a/docs/user-guide/rules/tags-check.md +++ b/docs/user-guide/rules/tags-check.md @@ -105,7 +105,7 @@ Examples of **incorrect** code for this rule: ## When Not To Use It -???. +If your project doesn't need custom checks for tags. ## Version From f5f914ec42e490e222b68d3230a7455b76039c17 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Sat, 6 Jun 2020 09:23:24 +0200 Subject: [PATCH 30/32] docs: update doc tagname-specialchars --- docs/user-guide/rules/tagname-specialchars.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/user-guide/rules/tagname-specialchars.md b/docs/user-guide/rules/tagname-specialchars.md index 761a64bc1..ba86b9c3d 100644 --- a/docs/user-guide/rules/tagname-specialchars.md +++ b/docs/user-guide/rules/tagname-specialchars.md @@ -31,13 +31,13 @@ All html element names must be in lowercase. Examples of **correct** code for this rule: ```html -
      +
      test ``` Examples of **incorrect** code for this rule: ```html - +<@ href="link"><$pan>aab ``` --- From 8e9656f6ecd64ce72cc5eda4d0bb10c419f34140 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Sat, 6 Jun 2020 09:28:37 +0200 Subject: [PATCH 31/32] docs: update doc --- docs/user-guide/rules/doctype-html5.md | 3 +-- docs/user-guide/rules/space-tab-mixed-disabled.md | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/user-guide/rules/doctype-html5.md b/docs/user-guide/rules/doctype-html5.md index e282fd408..035628182 100644 --- a/docs/user-guide/rules/doctype-html5.md +++ b/docs/user-guide/rules/doctype-html5.md @@ -28,7 +28,6 @@ Doctype must be html5. Examples of **correct** code for this rule: - ```html @@ -37,7 +36,7 @@ Examples of **correct** code for this rule: Examples of **incorrect** code for this rule: ```html - + ``` diff --git a/docs/user-guide/rules/space-tab-mixed-disabled.md b/docs/user-guide/rules/space-tab-mixed-disabled.md index e56b1eb7b..c8afff77c 100644 --- a/docs/user-guide/rules/space-tab-mixed-disabled.md +++ b/docs/user-guide/rules/space-tab-mixed-disabled.md @@ -32,7 +32,7 @@ This rule has an object option: - `"mode": "tab"` use tabs as indentation. - `"mode": "space"` use spaces as indentation. -- `"size": 0-8` count of spaces. + - `"size": 0-8` count of spaces. --- From 57517a25050cbf58d91c4bc77338650f3fadae69 Mon Sep 17 00:00:00 2001 From: Christopher Quadflieg Date: Thu, 25 Jun 2020 20:08:26 +0200 Subject: [PATCH 32/32] ci: trigger major bump BREAKING CHANGE: Rules have a new structure