-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathhtmlhint.node_cli.txt
More file actions
112 lines (97 loc) · 5.94 KB
/
htmlhint.node_cli.txt
File metadata and controls
112 lines (97 loc) · 5.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
┏━━━━━━━━━━━━━━┓
┃ HTMLHINT ┃
┗━━━━━━━━━━━━━━┛
VERSION ==> #0.9.12
CONFIG ==> #Syntax:
# - CONF_OBJ is { 'RULE': VAL, ... }
# - CONF_FILE contains CONF_OBJ
# - CONF is RULE[=VAL],...
#Config can be:
# - [../[../...]]./.htmlhintrc CONF_FILE
# - --config CONF_FILE
# - --rules CONF
# - <!-- CONF -->
htmlhint DIR|FILE... #Lint HTML: print errors with exit code
--ignore GLOB #
--format STR #Among:
# - console: default, compact, unix
# - markdown
# - json
# - junit (XML)
# - checkstyle (XML)
HTMLHint #Is HTMLHINT|WINDOW.HTMLHint, as Node module or in the browser.
HTMLHint.verify
('HTML', CONF_OBJ)->STR #
┌───────────┐
│ RULES │
└───────────┘
RULES ==> #Are BOOL unless specified otherwise
#Right side shows forbidden syntax
#Rules defaulting to true are marked as -#
ERRORS ==> #
tag-pair -#<tag><tag2></tag></tag2>
attr-no-duplication -#<tag attr attr>
id-unique -#<tag id="ID"><tag2 id="ID">
src-not-empty -#Missing|empty src|href
spec-char-escape -#HTML escape < >
attr-unsafe-chars #Using weird Unicode chars
LINTING ==> #
space-tab-mix-disabled #Indentation, among: 'space', 'tab', false
tagname-lowercase -#<TAG>
attr-lowercase -#<tag ATTR="VAL">
attr-value-double-quotes -#<tag attr='VAL'>
attr-value-not-empty #<tag attr>
tag-self-close #<tag />
id-class-value #Classname case among:
# - 'underline': 'my_class'
# - 'dash': 'my-class'
# - 'hump': 'myClass'
# - false
href-abs-or-rel #URL, among: 'abs', 'rel', false
OTHER LINTING ==> #
csslint #Lint <style> content with csslint. VAL is csslint OPTS
jshint #Lint <script> with jshint. VAL is jshint OPTS
RECOMMENDED TAGS/ATTRIBUTES ==> #
doctype-html5 #<!DOCTYPE HTML>
doctype-first -#
title-require -#Missing|empty <title>
head-script-disabled #<script> in <body> not in <head>
inline-script-disabled #Do not use onEVENT="" nor javascript:...
style-disabled #Do not use <style>
inline-style-disabled #Do not use style=""
id-class-ad-disabled #Do not use class|id="ad-..." (blocked by ad blocker)
alt-require #Use alt on <img>, <input type="image">, <area>
┌──────────────────┐
│ CUSTOM RULES │
└──────────────────┘
htmlhint --rulesdir DIR #Load custom rules.
#Must be FUNC(HTMLHINT) exported Node module and calling HTMLHINT.addRule()
HTMLHint.addRule(RULE) #Add custom RULE:
# - id 'RULE'
# - description STR
# - init(PARSER, REPORTER, RULE_VAL)
#PARSER:
# - addListener("all|EVENT[ ...]", FUNC(EVENT)), with events:
# - all have EVENT:
# - line|col NUM, pos NUM
# - all except start|end have EVENT:
# - raw 'HTML'
# - "start|end": of parsing
# - "text": text node
# - "comment": text node, with EVENT:
# - content 'STR'
# - long BOOL
# - "cdata": CDATA, with EVENT: tagName, attrs (like tagstart)
# - "tagstart": element node, with EVENT:
# - tagName 'tag|TAG'
# - attrs OBJ_ARR:
# - name 'ATTR'
# - value 'VAL'
# - quote " or '
# - index NUM: must be added to EVENT.col to get COL_NUM
# - raw 'ATTR="VAL"'
# - can use PARSER.getMapAttrs(OBJ_ARR)->{NAME: VALUE}
# - close '' or '/'
# - "tagend": element node, with EVENT: tagName 'tag|TAG'
#REPORTER:
# - info|warn|error(STR, LINE_NUM, COL_NUM, RULE, 'HTML')