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

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

Closed
dinuish94 opened this issue Jan 16, 2018 · 5 comments
Closed

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

dinuish94 opened this issue Jan 16, 2018 · 5 comments
Labels
bot:stale Issue marked as stale because there was no activity enhancement Functionality that enhances existing features triage An HTMLHint team member will look at this issue

Comments

@dinuish94
Copy link

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?

@Shinigami92
Copy link
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

@scipper
Copy link

scipper commented Jun 8, 2018

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.

@thedaviddias thedaviddias added enhancement Functionality that enhances existing features triage An HTMLHint team member will look at this issue labels Aug 22, 2018
@AbdealiLoKo
Copy link

AbdealiLoKo commented May 2, 2019

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
}

NewFuture added a commit to New-Future/HTMLHint that referenced this issue May 25, 2019
RegExp and regex string can be used in whitelist now!
related to htmlhint#228 htmlhint#183 microsoft/vscode-htmlhint#34
thedaviddias pushed a commit that referenced this issue Sep 2, 2019
RegExp and regex string can be used in whitelist now!
related to #228 #183 microsoft/vscode-htmlhint#34
thedaviddias pushed a commit that referenced this issue Feb 1, 2020
RegExp and regex string can be used in whitelist now!
related to #228 #183 microsoft/vscode-htmlhint#34
thedaviddias added a commit that referenced this issue May 13, 2020
* fix: missing test cases (#327)

**Fixes**: #325 

- [x] Check the commit's or even all commits' message styles matches our requested structure.
- [x] Check your code additions will fail neither code linting checks nor unit test.

#### Short description of what this resolves:
In the original pull request some of the test cases were missing. Added --recursive option for mocha to check for all individual rules.

* feat(htmlhint): add new rule for whitespace in attributes (#310) (#322)

* 0.10.3

* feat(htmlhint): add new rule for whitespace in attributes (#310)

* fix(htmlhint): removed unnecessary code (#310)

* 0.11.0

* Revert "Merge branch 'develop' into attr-whitespace"

This reverts commit 35988c1, reversing
changes made to 981cca7.

* Revert "Revert "Merge branch 'develop' into attr-whitespace""

This reverts commit cfa794d.

* chore(htmlhint): rebuilt package.json

* chore(htmlhint): updated rule to use ES6

* 0.10.3

* 0.11.0

* fix(htmlhint): made change to test cases and index.js

* html.js (#304)

This is a new formatter which logs error messages in html format on console as well as it will generate a report file in html format

**Fixes**: #

🚨 Please review the [guidelines for contributing](CONTRIBUTING.md) and our [code of conduct](../CODE_OF_CONDUCT.md) to this repository. 🚨
**Please complete these steps and check these boxes (by putting an x inside the brackets) before filing your PR:**

- [x] Check the commit's or even all commits' message styles matches our requested structure.
- [x] Check your code additions will fail neither code linting checks nor unit test.

#### Short description of what this resolves:
New formatter

#### Proposed changes:
New formatter

## -

-

👍 Thank you!

* fix(htmlhint): added rule for special characters in tag name (#146) (#331)

**Fixes**: #

🚨 Please review the [guidelines for contributing](CONTRIBUTING.md) and our [code of conduct](../CODE_OF_CONDUCT.md) to this repository. 🚨
**Please complete these steps and check these boxes (by putting an x inside the brackets) before filing your PR:**

- [x] Check the commit's or even all commits' message styles matches our requested structure.
- [x] Check your code additions will fail neither code linting checks nor unit test.

#### Short description of what this resolves:
Added rule to check for special characters in tag name. See (#146)
#### Proposed changes:

## -

-

👍 Thank you!

* fix(htmlhint): added rule for quotes around attribute values (#147) (#333)

* fix(htmlhint): add ability to pass regexp in config (#328)

Based on #238

Add ability to pass regexp in `.htmlhintrc` file for matching attributes value.

Example:
```js
...
"id-class-value": {
    "regId": "^[a-z\\d]+([-_]+[a-z\\d]+)*$",
    "message": "The id and class attribute values must be in lowercase and split by dash or underscore"
},
...
```

Problem was in parsing config file by `JSON.parse`. We can not correct pass `regexp` into json schema. Only `string`. And this `string` after parsing is `string` too.

I just check input data. If it is not regexp then create `new RegExp` instance from input string.

**Fixes**: #

🚨 Please review the [guidelines for contributing](CONTRIBUTING.md) and our [code of conduct](../CODE_OF_CONDUCT.md) to this repository. 🚨
**Please complete these steps and check these boxes (by putting an x inside the brackets) before filing your PR:**

- [ ] Check the commit's or even all commits' message styles matches our requested structure.
- [ ] Check your code additions will fail neither code linting checks nor unit test.

#### Short description of what this resolves:

#### Proposed changes:

## -

-

👍 Thank you!

* feat(htmlhint): added attribute sorting (#309) (#332)

**Fixes**: #

🚨 Please review the [guidelines for contributing](CONTRIBUTING.md) and our [code of conduct](../CODE_OF_CONDUCT.md) to this repository. 🚨
**Please complete these steps and check these boxes (by putting an x inside the brackets) before filing your PR:**

- [ ] Check the commit's or even all commits' message styles matches our requested structure.
- [ ] Check your code additions will fail neither code linting checks nor unit test.

#### Short description of what this resolves:
Added sort feature for tag attributes.
#### Proposed changes:
-
## -

-

👍 Thank you!

* Used Object.keys instead of Object.values (#344)

Used Object.keys instead of Object.values because it is not supported by nodejs before v8.

* Create FUNDING.yml (#350)

* updates URLs in repository and bugs in package.json (#354)

* chore: update commitizen and semantic release (#357)

* feat(htmlhint): add RegExp and regex string (#346)

RegExp and regex string can be used in whitelist now!
related to #228 #183 microsoft/vscode-htmlhint#34

* update links back to htmlhint.com (#359)

Co-authored-by: Zhixing Zhang <account@neoto.xin>
Co-authored-by: Daman Mulye <dmulye2@illinois.edu>
Co-authored-by: nmanupuri <39561219+nmanupuri@users.noreply.github.com>
Co-authored-by: orangewit3 <43012690+orangewit3@users.noreply.github.com>
Co-authored-by: meetDeveloper <32453612+meetDeveloper@users.noreply.github.com>
Co-authored-by: Christian Oliff <christianoliff@yahoo.com>
Co-authored-by: New Future <NewFuture@users.noreply.github.com>
@stale
Copy link

stale bot commented May 14, 2020

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 May 14, 2020
@stale stale bot closed this as completed May 28, 2020
@WuglyakBolgoink
Copy link

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
Labels
bot:stale Issue marked as stale because there was no activity enhancement Functionality that enhances existing features triage An HTMLHint team member will look at this issue
Projects
None yet
Development

No branches or pull requests

6 participants