Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add all rules to the HTMLHint.defaultRuleset (but set non-enabled ones to false) #868

Open
pdehaan opened this issue Jan 14, 2022 · 1 comment
Labels
keep-unstale The issue will not be marked as stale by the stale-bot

Comments

@pdehaan
Copy link

pdehaan commented Jan 14, 2022

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.

@stale
Copy link

stale bot commented Mar 17, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the bot:stale Issue marked as stale because there was no activity label Mar 17, 2022
@thedaviddias thedaviddias added keep-unstale The issue will not be marked as stale by the stale-bot and removed bot:stale Issue marked as stale because there was no activity labels Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keep-unstale The issue will not be marked as stale by the stale-bot
Projects
None yet
Development

No branches or pull requests

2 participants