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

Rewrite configuration structure #279

Open
5 of 8 tasks
Shinigami92 opened this issue Aug 28, 2018 · 8 comments · Fixed by #445, #447 or #476 · May be fixed by #489
Open
5 of 8 tasks

Rewrite configuration structure #279

Shinigami92 opened this issue Aug 28, 2018 · 8 comments · Fixed by #445, #447 or #476 · May be fixed by #489
Assignees
Labels
feature request Functionality that introduces a new feature keep-unstale The issue will not be marked as stale by the stale-bot

Comments

@Shinigami92
Copy link
Contributor

Shinigami92 commented Aug 28, 2018

Is your feature request related to a problem? Please describe.

Today's tools are characterized by a much better style of configuration file
It's much more extensible and supports things like defaultSeverity and presets that load before its own configuration

Describe the solution you'd like

We will rewrite the configuration in eslint-style, see #279 (comment)

TODOs


Old proposal
We should rewrite the configuration file into something like this:

{
    "extends": ["htmlhint:recommended"],
    "defaultSeverity": "error",
    "htmlVersion": "html5",
    "rules": {
        "attr-no-duplication": true,
        "attr-unsafe-chars": true,
        "attr-value-double-quotes": true,
        "doctype-first": false,
        "doctype-html5": true,
        "id-class-ad-disabled": true,
        "id-class-value": ["dash", { "severity": "warning" }],
        "id-unique": true,
        "inline-style-disabled": false,
        "space-tab-mixed-disabled": ["tab", { "severity": "warning" }],
        "spec-char-escape": true,
        "src-not-empty": true,
        "style-disabled": [true, { "severity": "warning" }],
        "tag-pair": true,
        "tag-self-close": false,
        "tagname-lowercase": [
            true,
            {
                "exceptions": ["linearGradient"]
            }
        ],
        "title-require": true,
        "stylelint": [
            true,
            {
                "extends": "stylelint-config-standard",
                "rules": {
                    "block-no-empty": null,
                    "color-no-invalid-hex": true
                }
            }
        ],
        "eslint": [
            true,
            {
                "configFile": "./.eslintrc.json"
            }
        ]
    },
    "exclude": ["test/**/*.html"]
}
@thedaviddias thedaviddias added #status: accepted 👍 feature request Functionality that introduces a new feature labels Aug 28, 2018
@Shinigami92
Copy link
Contributor Author

We will rewrite the configuration structure in eslint-style

{
    "extends": ["htmlhint:recommended"],
    "defaultSeverity": "error",
    "htmlVersion": "html5",
    "rules": {},
    "exclude": ["test/**/*.html"]
}

Rules

alt-require

The alt attribute of an <img> element must be present and alt attribute of area[href] and input[type=image] must have a value.

{ "alt-require": "off" }
{ "alt-require": "error" }
{ "alt-require": "warn" }
{ "alt-require": ["off"] }
{ "alt-require": ["error"] }
{ "alt-require": ["warn"] }

attr-lowercase

All attribute names must be in lowercase.

{ "attr-lowercase": "off" }
{ "attr-lowercase": "error" }
{ "attr-lowercase": "warn" }
{ "attr-lowercase": ["off"] }
{ "attr-lowercase": ["error", { "exceptions": ["viewBox"] }] }
{ "attr-lowercase": ["warn", { "exceptions": ["viewBox"] }] }

htmlhint:recommended

attr-no-duplication

Elements cannot have duplicate attributes.

{ "attr-no-duplication": "off" }
{ "attr-no-duplication": "error" }
{ "attr-no-duplication": "warn" }
{ "attr-no-duplication": ["off"] }
{ "attr-no-duplication": ["error"] }
{ "attr-no-duplication": ["warn"] }

htmlhint:recommended

attr-unsafe-chars

Attribute values cannot contain unsafe chars.

{ "attr-unsafe-chars": "off" }
{ "attr-unsafe-chars": "error" }
{ "attr-unsafe-chars": "warn" }
{ "attr-unsafe-chars": ["off"] }
{ "attr-unsafe-chars": ["error"] }
{ "attr-unsafe-chars": ["warn"] }

attr-value-double-quotes

Attribute values must be in double quotes.

{ "attr-value-double-quotes": "off" }
{ "attr-value-double-quotes": "error" }
{ "attr-value-double-quotes": "warn" }
{ "attr-value-double-quotes": ["off"] }
{ "attr-value-double-quotes": ["error"] }
{ "attr-value-double-quotes": ["warn"] }

htmlhint:recommended

  • option to use single or double quotes

attr-value-not-empty

All attributes must have values.

{ "attr-value-not-empty": "off" }
{ "attr-value-not-empty": "error" }
{ "attr-value-not-empty": "warn" }
{ "attr-value-not-empty": ["off"] }
{ "attr-value-not-empty": ["error"] }
{ "attr-value-not-empty": ["warn"] }

csslint

Scan css with csslint.

// check for .csslintrc
{ "csslint": "off" }
{ "csslint": "error" }
{ "csslint": "warn" }
{ "csslint": ["off"] }
// pass csslint config
{ "csslint": ["error", { "vendor-prefix": true }] }
{ "csslint": ["warn", { "vendor-prefix": true }] }
  • needs rewrite to support reading .csslintrc

doctype-first

Doctype must be declared first.

{ "doctype-first": "off" }
{ "doctype-first": "error" }
{ "doctype-first": "warn" }
{ "doctype-first": ["off"] }
{ "doctype-first": ["error"] }
{ "doctype-first": ["warn"] }

htmlhint:recommended

  • option to check only root index.html

doctype-html5

Invalid doctype. Use: "<!DOCTYPE html>"

{ "doctype-html5": "off" }
{ "doctype-html5": "error" }
{ "doctype-html5": "warn" }
{ "doctype-html5": ["off"] }
{ "doctype-html5": ["error"] }
{ "doctype-html5": ["warn"] }
  • needs to be more generic (html4, html5 xhtml)

head-script-disabled

The <script> tag cannot be used in a <head> tag.

{ "head-script-disabled": "off" }
{ "head-script-disabled": "error" }
{ "head-script-disabled": "warn" }
{ "head-script-disabled": ["off"] }
{ "head-script-disabled": ["error"] }
{ "head-script-disabled": ["warn"] }

href-abs-or-rel

An href attribute must be either absolute or relative.

{ "href-abs-or-rel": "off" }
{ "href-abs-or-rel": ["off"] }
{ "href-abs-or-rel": ["error", { "mode": "absolute" }] }
{ "href-abs-or-rel": ["warn", { "mode": "relative" }] }
  • needs rewrite

id-class-ad-disabled

The id and class attributes cannot use the ad keyword, it will be blocked by adblock software.

{ "id-class-ad-disabled": "off" }
{ "id-class-ad-disabled": "error" }
{ "id-class-ad-disabled": "warn" }
{ "id-class-ad-disabled": ["off"] }
{ "id-class-ad-disabled": ["error"] }
{ "id-class-ad-disabled": ["warn"] }

id-class-value

The id and class attribute values must meet the specified rules.

{ "id-class-value": "off" }
{ "id-class-value": ["off"] }
{ "id-class-value": ["error", { "mode": "underline" }] }
{ "id-class-value": ["warn", { "mode": "dash" }] }
{ "id-class-value": ["warn", { "mode": "hump" }] }
  • needs rewrite

id-unique

The value of id attributes must be unique.

{ "id-unique": "off" }
{ "id-unique": "error" }
{ "id-unique": "warn" }
{ "id-unique": ["off"] }
{ "id-unique": ["error"] }
{ "id-unique": ["warn"] }

htmlhint:recommended

inline-script-disabled

Inline script cannot be used.

{ "inline-script-disabled": "off" }
{ "inline-script-disabled": "error" }
{ "inline-script-disabled": "warn" }
{ "inline-script-disabled": ["off"] }
{ "inline-script-disabled": ["error"] }
{ "inline-script-disabled": ["warn"] }

inline-style-disabled

Inline style cannot be used.

{ "inline-style-disabled": "off" }
{ "inline-style-disabled": "error" }
{ "inline-style-disabled": "warn" }
{ "inline-style-disabled": ["off"] }
{ "inline-style-disabled": ["error"] }
{ "inline-style-disabled": ["warn"] }

jshint

Scan script with jshint.

// check for .jshintrc
{ "jshint": "off" }
{ "jshint": "error" }
{ "jshint": "warn" }
{ "jshint": ["off"] }
// pass jshint config
{ "jshint": ["error", { "curly": true }] }
{ "jshint": ["warn", { "curly": true }] }
  • needs rewrite to support reading .jshintrc

space-tab-mixed-disabled

Do not mix tabs and spaces for indentation.

{ "space-tab-mixed-disabled": "off" }
{ "space-tab-mixed-disabled": ["off"] }
{ "space-tab-mixed-disabled": ["error", { "mode": "tab" }] }
{ "space-tab-mixed-disabled": ["warn", { "mode": "space" }] }
{ "space-tab-mixed-disabled": ["warn", { "mode": "space4" }] }
  • needs rewrite
  • option to pass number for spaces

spec-char-escape

Special characters must be escaped.

{ "spec-char-escape": "off" }
{ "spec-char-escape": "error" }
{ "spec-char-escape": "warn" }
{ "spec-char-escape": ["off"] }
{ "spec-char-escape": ["error"] }
{ "spec-char-escape": ["warn"] }

htmlhint:recommended

src-not-empty

The src attribute of an img(script,link) must have a value.

{ "src-not-empty": "off" }
{ "src-not-empty": "error" }
{ "src-not-empty": "warn" }
{ "src-not-empty": ["off"] }
{ "src-not-empty": ["error"] }
{ "src-not-empty": ["warn"] }

htmlhint:recommended

style-disabled

<style> tags cannot be used.

{ "style-disabled": "off" }
{ "style-disabled": "error" }
{ "style-disabled": "warn" }
{ "style-disabled": ["off"] }
{ "style-disabled": ["error"] }
{ "style-disabled": ["warn"] }

tag-pair

Tag must be paired.

{ "tag-pair": "off" }
{ "tag-pair": "error" }
{ "tag-pair": "warn" }
{ "tag-pair": ["off"] }
{ "tag-pair": ["error"] }
{ "tag-pair": ["warn"] }

htmlhint:recommended

tag-self-close

Empty tags must be self closed.

{ "tag-self-close": "off" }
{ "tag-self-close": "error" }
{ "tag-self-close": "warn" }
{ "tag-self-close": ["off"] }
{ "tag-self-close": ["error"] }
{ "tag-self-close": ["warn"] }

tagname-lowercase

All html element names must be in lowercase.

{ "tagname-lowercase": "off" }
{ "tagname-lowercase": "error" }
{ "tagname-lowercase": "warn" }
{ "tagname-lowercase": ["off"] }
{ "tagname-lowercase": ["error"] }
{ "tagname-lowercase": ["warn"] }

htmlhint:recommended

title-require

<title> must be present in <head> tag.

{ "title-require": "off" }
{ "title-require": "error" }
{ "title-require": "warn" }
{ "title-require": ["off"] }
{ "title-require": ["error"] }
{ "title-require": ["warn"] }

htmlhint:recommended

Type Definition

export type RuleSeverity = 'off' | 'error' | 'warn';
export type RuleConfig = RuleSeverity | [RuleSeverity, { [key: string]: any } | undefined];

notacouch added a commit to notacouch/mws-restaurant-stage-1 that referenced this issue Oct 3, 2018
… working bc of lowercase b in viewbox

This was in part due to HTML linter. It only has error level severity, eslint style warn severity support is in the works,
see: htmlhint/HTMLHint#279 (comment)

The other part was XML vs HTML fragment, latter's attributes are always set as lowercase! Which broke the SVG! Reference for fix is found in inline comment in code.
@dreamalligator
Copy link

This is such a good idea.

@thedaviddias thedaviddias added the keep-unstale The issue will not be marked as stale by the stale-bot label May 14, 2020
@Shinigami92 Shinigami92 self-assigned this May 16, 2020
@Shinigami92 Shinigami92 linked a pull request May 16, 2020 that will close this issue
2 tasks
@Shinigami92
Copy link
Contributor Author

We may later think about using cosmiconfig

@thedaviddias
Copy link
Member

@Shinigami92 seems a great idea.

@Shinigami92 Shinigami92 linked a pull request Jul 6, 2020 that will close this issue
@Shinigami92 Shinigami92 pinned this issue Jul 6, 2020
@Shinigami92 Shinigami92 linked a pull request Jul 8, 2020 that will close this issue
5 tasks
@Shinigami92
Copy link
Contributor Author

All unresolved tasks have been extracted into their own issues

@openjck
Copy link

openjck commented May 2, 2021

It looks like #489 is marked as completed here, but it didn't merge and there isn't another open issue about it.

@github-actions github-actions bot removed the accepted label Jun 11, 2021
@gitrequests
Copy link

What with merge configuration (#489), still unavailable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment