Add all rules to the HTMLHint.defaultRuleset (but set non-enabled ones to false)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 3.3k
- Forks
- 474
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 12
Description
Is your feature request related to a problem? Please describe.
Just started playing w/ this library today and this caused a bit of confusion (although admittedly I'm probably not using the library in the recommended way; API).
console.log(JSON.stringify(HTMLHint.defaultRuleset, null, 2));
Gives me the following output:
{
"attr-lowercase": true,
"attr-no-duplication": true,
"attr-value-double-quotes": true,
"doctype-first": true,
"id-unique": true,
"spec-char-escape": true,
"src-not-empty": true,
"tag-pair": true,
"tagname-lowercase": true,
"title-require": true
}
Not all rules seem to be documented, and I was looking for a stricter set of rules so there was some trial and error. I ended up coming up w/ this solution which seems a bit, sketchy:
const DISABLED_RULES = [
"attr-sorted",
"attr-value-not-empty",
"attr-value-single-quotes",
"attr-whitespace",
"empty-tag-not-self-closed",
"head-script-disabled",
"href-abs-or-rel",
"script-disabled",
"space-tab-mixed-disabled",
"tag-self-close",
"tags-check",
];
const allRules = Object.keys(HTMLHint.rules).sort().reduce((obj={}, name="") => {
obj[name] = !DISABLED_RULES.includes(name);
return obj;
}, {});
OUTPUT
{
"alt-require": true,
"attr-lowercase": true,
"attr-no-duplication": true,
"attr-no-unnecessary-whitespace": true,
"attr-sorted": false,
"attr-unsafe-chars": true,
"attr-value-double-quotes": true,
"attr-value-not-empty": false,
"attr-value-single-quotes": false,
"attr-whitespace": false,
"doctype-first": true,
"doctype-html5": true,
"empty-tag-not-self-closed": false,
"head-script-disabled": false,
"href-abs-or-rel": false,
"html-lang-require": true,
"id-class-ad-disabled": true,
"id-class-value": true,
"id-unique": true,
"inline-script-disabled": true,
"inline-style-disabled": true,
"input-requires-label": true,
"script-disabled": false,
"space-tab-mixed-disabled": false,
"spec-char-escape": true,
"src-not-empty": true,
"style-disabled": true,
"tag-pair": true,
"tag-self-close": false,
"tagname-lowercase": true,
"tagname-specialchars": true,
"tags-check": false,
"title-require": true
}
Describe the solution you'd like
Should the HTMLHint.defaultRuleset property return ALL properties and only set true for the enabled default properties but include all the rest of the properties set to false? Wouldn't change the default behavior, but might make it easier for people to save the defaultRuleset value to a config file and change 1-2 values instead of having to build the .htmlhintrc config file manually.
Describe alternatives you've considered
See above, but I ended up just scraping ALL the rules and then selectively turning conflicting/unwanted rules off.
const DISABLED_RULES = [
"attr-sorted",
"attr-value-not-empty",
"attr-value-single-quotes",
"attr-whitespace",
"empty-tag-not-self-closed",
"head-script-disabled",
"href-abs-or-rel",
"script-disabled",
"space-tab-mixed-disabled",
"tag-self-close",
"tags-check",
];
const allRules = Object.keys(HTMLHint.rules)
.sort()
.reduce((obj={}, name="") => {
obj[name] = !DISABLED_RULES.includes(name);
return obj;
}, {});
Additional context
Add any other context or screenshots about the feature request here.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the HTMLHint.defaultRuleset and HTMLHint.rules entry points, then compare the registered rules with the currently enabled defaults. The change is done when defaultRuleset includes every rule, preserves current behavior, and marks non-enabled rules false; verify the existing project checks afterward.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100