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

New/Update Rule - Warn on excessive whitespace #92

Closed
jamesspittal opened this issue Jun 6, 2017 · 2 comments
Closed

New/Update Rule - Warn on excessive whitespace #92

jamesspittal opened this issue Jun 6, 2017 · 2 comments

Comments

@jamesspittal
Copy link

We currently use the following custom rule-set:

{
    "asset-type": true,                     // true: Default value of attribute "type" (<link>/<style>/<script>) should not be set
    "attr-lowercase": true,                 // true: Attribute name must be lowercase
    "attr-no-duplication": true,            // true: Attribute name can not been duplication
    "attr-value-double-quotes": true,       // true: Attribute value must be closed by double quotes
    "bool-attribute-value": true,           // true: Value of boolean attributes (allowfullscreen, async, autofocus, ...) should not be set
    "button-name": true,                    // true: Attribute "name" of <button> should not be set
    "button-type": true,                    // true: Attribute "type" of <button> should be set
    "charset": true,                        // true: <meta charset> required
    "css-in-head": true,                    // true: Css contents (link[rel=stylesheet], style) should to be in <head>
    "doctype": "upper",                     // true: DOCTYPE required, "upper": must be uppercase
    "html-lang": true,                      // true: Attribute "lang" of <html> should be set
    "id-class-ad-disabled": true,           // true: Id and class can not use ad-relative keyword, it will be blocked by adblock software
    "ie-edge": true,                        // true: <meta http-equiv="X-UA-Compatible" content="IE=Edge"> required
    "img-alt": true,                        // true: Attribute "alt" of <img> should be set
    "img-src": true,                        // true: Attribute "src" of <img> should not be empty
    "img-title": false,                     // true: Attribute "title" of <img> should not be set
    "img-width-height": false,               // true: Attribute "width" & "height" of <img> should be set
    "indent-char": "space-2",               // "space-2": Line should indent with 2 spaces. Default is 'space-4'.
    "lowercase-class-with-hyphen": true,    // true: ClassName should be lowercase words connected with hyphens
    "lowercase-id-with-hyphen": true,       // true: Id should be lowercase words connected with hyphens
    "multiple-stylesheets": true,           // true: More than one style-sheet is included (combining all style-sheets into one neat CSS file would be cleaner)
    "nest": true,                           // true: Elements should be nested abiding by specific rules
    "new-line-for-blocks": true,            // true: There should be a new line for every block, list, or table element
    "no-space-before-tag-end": false,       // false: There should be no whitespaces before tag end
    "protocol-omitted-in-href": false,      // false: Protocol (http:// or https://) should be omitted from href attribute (there should be "//" instead)
    "rel-stylesheet": true,                 // true: Attribute "rel" of imported css (<link>) should be set as "stylesheet"
    "script-content": true,                 // true: Content of <script> must meet standard
    "script-in-tail": false,                // true: Js contents (script:not([type]), script[type="text/javascript"]) should be in the tail of <body>
    "self-close": "no-close",               // "no-close": Void tags should not close themeselves  with "/"
    "spec-char-escape": true,               // true: Special characters must be escaped
    "style-content": true,                  // true: Content of <style> must meet standard
    "style-disabled": true,                 // true: Style tag can not be used
    "tag-pair": true,                       // true: Tag must be paired
    "tagname-lowercase": true,              // true: Tagname must be lowercase
    "title-required": true,                 // true: <title> required
    "unique-id": true,                      // true: Id should be unique in page
    "unnecessary-whitespace-in-text": true, // true: Unnecessary usage of a trailing white-space in text
    "no-duplication-id-and-name": true,     // true: Id and name should be not duplication in difference elements
    "viewport": true,                       // true: <meta name="viewport" content="..."> required
    "label-for-input": true,                // true: input should be associate with label
    "no-meta-css": {
        "threshold": 3,
        "minlen": 3
    },
    "no-hook-class": {
        "keys": ["/[-_#](?:js|hook)[-_#]/"]
    },
    "no-bom": true,

    "max-len": 0,                           // max length of line, 0 means no limit

    "max-error": 0,                         // max num of errors, 0 means no limit
    "format": {},                           // basic options for format
    "linters": {},                          // extra linters ('scipt', 'style')
    "default": true                         // flag for unit test
}

Whilst running this on some HTML, I found the following code-block did not trigger a warning (despite having unnecessary-whitespace-in-text set to true:

                                                </div>
                                                <p>We offer a Free Mini-Bar to all guests who book direct through                                                   us
                                                </p>

I think this is bad, and should actually produce a warning (probably unnecessary-whitespace-in-text should be updated to also trigger warnings on this, not just on trailing text).

Rather, this should be written as:

                                                </div>
                                                <p>We offer a Free Mini-Bar to all guests who book direct through us
                                                </p>

In other words, the unnecessary white-space through and us should be removed.

@olegkrivtsov
Copy link
Contributor

@jamesspittal I've fixed that.

@jamesspittal
Copy link
Author

Thanks @olegkrivtsov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants