Set up rules
Create a configuration file
Create a file named .markuplintrc
to the project directory that there is package.json
.
And add some rules to the rules
property of this file.
{
"rules": {
"rule-name": "value" // Add to here or more
}
}
This file is loaded automatically when CLI executes or open a target file through the VSCode extension.
{
"rules": {
"attr-duplication": true,
"character-reference": true,
"deprecated-attr": true,
"deprecated-element": true,
"doctype": true,
"id-duplication": true,
"permitted-contents": true,
"required-attr": true,
"invalid-attr": true,
"landmark-roles": true,
"required-h1": true,
"class-naming": false,
"attr-equal-space-after": false,
"attr-equal-space-before": false,
"attr-spacing": false,
"attr-value-quotes": false,
"case-sensitive-attr-name": false,
"case-sensitive-tag-name": false,
"indentation": false,
"wai-aria": true
}
}
This is the default setting. If you never used it, you should probably copy it to your configuration file then customize you like.
Scoped Rules
If you want the part of structures only to apply some rule then set the tag name or the selector to nodeRules
or childNodeRules
.
nodeRules
affect only the target element. And childNodeRules
affect child (includes descendants if set to inheritance
) elements of the target element.
{
"nodeRules": [
{
"tagName": "main",
"rules": {
"class-naming": "/[a-z]+(__[a-z]+)?/"
}
},
{
"selector": ".some-class-name",
"rules": {
"required-attr": true
}
}
],
"childNodeRules": [
{
"selector": ".ignoreClass",
"inheritance": true,
"rules": {
"character-reference": true
}
}
]
}
Rules
The detail of Each rule is said from the Rules page.