Skip to content

Can HTMLHint be used with angular and other frameworks? #228

Closed

Description

@dinuish94

When I ran the the HTMLHint tool on an angular project, it gave an issue saying "ng-app must be in double quotes". Does this mean that HTMLHint can only be run for pure HTML files?

Activity

  1. Shinigami92 commented on Jan 16, 2018

    @Shinigami92
    Contributor

    Here my .htmlhintrc for AngularJS projects

    {
    	"attr-lowercase": true,
    	"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",
    	"id-unique": true,
    	"inline-style-disabled": false,
    	"space-tab-mixed-disabled": "tab",
    	"spec-char-escape": true,
    	"src-not-empty": true,
    	"style-disabled": true,
    	"tag-pair": true,
    	"tag-self-close": false,
    	"tagname-lowercase": true,
    	"title-require": true,
    	"csslint": {
    		"display-property-grouping": true,
    		"known-properties": true
    	},
    	"jshint": {}
    }

    Just put this content in an .htmlhintrc in your project's directory
    Maybe install a plugin for your IDE/Editor and it will recognize this file

  2. scipper commented on Jun 8, 2018

    @scipper

    what about expressions in id for example? When I lint this code:

    <div id="{{ navigationItem.id }}"></div>

    the error

    The id value [ {{ navigationItem.id }} ] must be unique. [error/id-unique]

    is thrown. When I have an expression like:

    <span>{{ $ctrl.timer > 0 ? 'A' : 'B' }}</span>

    I get

    Special characters must be escaped : [ > ]. [error/spec-char-escape]

    This is really annoying, because it's valid AngularJs.

  3. added
    enhancement
    triage
    on Aug 22, 2018
  4. AbdealiLoKo commented on May 2, 2019

    @AbdealiLoKo

    I just evaluated this on a angular project I have and based on the false positives I saw, the following works for me:

    {
        "attr-lowercase": false,  // cannot handle - `<ng-template [ngIf]="isVisible">`
        "attr-no-duplication": true,
        "attr-unsafe-chars": true,
        "attr-value-double-quotes": true,
        "doctype-first": false,  // Unable to handle HTML templates for components
        "doctype-html5": true,
        "id-class-ad-disabled": true,
        "id-class-value": false, // cannot handle - `<div class="{{card.css}}"></div>`
        "id-unique": false, // cannot handle -
                            // <li *ngIf="isEdit"> <a id="id1">id1</a> </li>
                            // <li *ngIf="!isEdit"> <span id="id1">id1</span> </li>
        "inline-style-disabled": true,
        "space-tab-mixed-disabled": "space2",
        "spec-char-escape": true,
        "src-not-empty": true,
        "style-disabled": true,
        "tag-pair": true,
        "tag-self-close": true,
        "tagname-lowercase": true,
        "title-require": true
    }
  5. added a commit that references this issue on May 13, 2020
  6. stale commented on May 14, 2020

    @stale

    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.

  7. added
    bot:stale
    on May 14, 2020
  8. WuglyakBolgoink commented on Jan 11, 2021

    @WuglyakBolgoink

    Hallo @AbdealiJK

    since last month I have some problems with spec-char-escape

    line 8   col 46  Special characters must be escaped : [  &  ].
    line 26  col 41  Special characters must be escaped : [  &  ].
    

    and in my template we have something like this

    <div class="legend-users">Max & Clara</div>
    

    do u have the same problems now?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bot:staleenhancementtriage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions