Giter Club home page Giter Club logo

grunt-htmlhint's Introduction


Grunt HTMLHint

Lint HTML files with HTMLHint

Travis Build Status Codecov NPM count MIT Licence Chat Chat

  How To UseContributingRoadmapWebsite

Table of Contents

Getting Started

This plugin requires Grunt ~0.4.1

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-htmlhint --save-dev

One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-htmlhint');

Usage

Overview

In your project's Gruntfile, add a section named htmlhint to the data object passed into grunt.initConfig().

Options

See all rules here: https://github.com/htmlhint/HTMLHint/wiki/Rules

If options is empty, task will scan nothing.

options.htmlhintrc

Type: String Default value: null

If this filename is specified, options and globals defined therein will be used. Task and target options override the options within the htmlhintrc file. The htmlhintrc file must be valid JSON and looks something like this:

{
  "tag-pair": true,
}

options.force

Type: Boolean Default value: false

Report HTMLHint errors but dont fail the task

Usage Examples

Direct options

htmlhint: {
  html1: {
    options: {
      'tag-pair': true
    },
    src: ['path/to/**/*.html']
  },
  html2: {
    options: {
      'tag-pair': true
    },
    src: ['path/to/**/*.html']
  }
}

Config file

htmlhint: {
  options: {
    htmlhintrc: '.htmlhintrc'
  },
  html1: {
    src: ['path/to/**/*.html']
  },
  html2: {
    src: ['path/to/**/*.html']
  }
}

Licence

Project initially created by @yaniswang and transferred to the HTMLHint organization.

Logo HTMLHint

MIT License

grunt-htmlhint's People

Contributors

coliff avatar dependabot[bot] avatar mobilemind avatar mrmlnc avatar nwhite89 avatar shinigami92 avatar thedaviddias avatar yaniswang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

grunt-htmlhint's Issues

reasonable defaults

Related to #2, wouldn't it make sense to make most of these options true by default? I could understand making certain options default to false (specifically those which might be considered a bit extreme). But to have all options default to false makes the grunt task completely ineffectual out of the box.

Is this repo even supported?

When I look at the issues, there hasn't been a single response by the author. So: Is this plugin supported? If not: Would you consider handing it over to someone else who likes to maintain it?

Task failed

When running grunt htmlhint and it reports an error Grunt believes that the task has failed however, it's actually that an error with the HTML was reported.

Releases & Tags

There are no formal releases or tags for this repository (github tab is empty). It would be very handy to add them.

Thanks!

Travis-CI build fails with `grunt --force` as of Oct 26, 2018

Describe the bug
Travis-CI build fails with grunt --force
See Travis build status https://travis-ci.org/htmlhint/grunt-htmlhint/jobs/445465000

To Reproduce
Steps to reproduce the behavior:

  1. Review Travis-CI build errors, https://travis-ci.org/htmlhint/grunt-htmlhint/jobs/445465000

NOTE: See use of grunt versus the package.json settings:

  "scripts": {
    "test": "grunt --force"
  },

Per my testing, it seems like it could be fixed by using:

  "scripts": {
    "test": "grunt -f"
  },

Expected behavior
Successful Travis-CI build.

能否说明一下默认设置?

我用到grunt中,发现都不报错的。

自己配置了

'tag-pair': true,
'attr-value-double-quotes':true

之后才报这两个的检查错误,请问默认设置是怎么样的?难道全部是false的?

options w/ true/false vs true/not-present

Would you consider changing your options list implementation to acting on an
option_name: false,
setting ?

Right now, it appears to accept settings of either true or false as an indication to apply the option. Mere presence in the list - not the true/false setting - causes the rule to be applied.

...or, update the documentation to more strongly indicate that an option should be left off the list if its application is not desired. Expanding on the current statement,

If options is empty, task will scan nothing.

would be very helpful.

Getting Peer Warning

I keep receiving the following warning whenever I do anything with NPM after installing grunt-htmlhint:

npm WARN [email protected] requires a peer of grunt@~0.4.1 but none was installed.

OS: Windows 10.0.10586
Grunt CLI: v1.2.0
Grunt: v1.0.1

Task doesn't fail on lint errors

When running the task, I would expect the task to fail when any error is found within the html. (according to the validation rules I made up).

In my case, there are errors in the markup, which are also shown in the task results, but the task itself does not fail.

Here is my task setup

{
    options : {
        htmlhintrc : 'config/.htmlhintrc'
    },
    raw : [
        '<%= config.dev.data.raw_html %>/**/*.html'
    ]
}

which runs fine and results in the following output:

Running "htmlhint:raw" (htmlhint) task
   dev/data/raw/brand/de/stada.html
      L3 |</div>
          ^ Tag must be paired, missing: [ </h1> ], start tag match failed [ <h1> ] on line 2. (tag-pair)

   dev/data/raw/brand/en/stada.html
      L3 |</div>
          ^ Tag must be paired, missing: [ </h1> ], start tag match failed [ <h1> ] on line 2. (tag-pair)

>> 14 files lint free.

Done, without errors.

But there are errors! And 2 of 14 files are not lint free.

Shouldn't the task fail? Is it a bug?

I am using [email protected] and [email protected]

description on readme is misleading

The readme says this utility is to "Validate html files with htmlhint". It took some research before I discovered that's htmlhint is not a validator at all, but a linter. (Or more precisely a code style checker.)

I would expect something that bills itself as an HTML validator to ensure spec-compliant HTML. This is a great tool in addition to an HTML validator. But it is not, itself, one.

I think the readme ought to be updated to read something along the lines of "Lint html files with htmlhint" or "Check for HTML code-style violations with htmlhint" or similar.

'Head script disabled' shows error if <script> tag is outside of the <body> tag

I have some .PHP files that have <script>tags that, doesn't have a <head> or <body> tag, because they are just included in another .PHP file. So, when i run the task 'htmlhint' with the option 'Head script disabled' activate, it shows some errors, because it dont find these mentioned tags. But actually, this is not an error. The error must be showed only if there is a <script>tag inside the tag <head>. Please, include an option to ignore it if no tag is founded.

P.S.: (Sorry about the english=))

Warning on non-printable character

Hello,

any chance that htmlhint could detect non-printable characters? Got a link with invisible non-printable characters, which was thus 404 whereas it seemed ok for a human eye.

Thanks :-)

Add option to log into file

It would be great to have an option to log into file not only console.
Similar option exists in "jshint" and is called reporter. It also has checkstyle option.

Thanks in advance.

security warnings from `npm audit` with current release as of Oct, 26 2018

Describe the bug
npm audit generates security warnings

To Reproduce
Steps to reproduce the behavior:

  1. npm install
  2. npm audit
  3. See warnings:
found 8 vulnerabilities (5 low, 3 high) in 264 scanned packages
  run `npm audit fix` to fix 6 of them.
  2 vulnerabilities require semver-major dependency updates.

Expected behavior
No high risk vulnerabilities and few, if any, low risk vulnerabilities.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: macOS 10.14
  • node 11.0.0
  • npm 6.4.1

Feature Request: being able to pass it a list of url's

Since a lot of people are using grunt to validate source code —and not built files, such as minified javascript— it would be nice if grunt-htmlhint would also support linting url's, instead of only files.

Say you're using a local node.js server with a template engine like Swig, and you'd want to check your html before the build, so you can fail the build if necessary. Like refusing to optimize require.js with r.js if there are JSHint errors. frntndr is an example of such a project. Who has the full html for a single page inside one file nowadays?

For this to work, I'd be nice if grunt-htmlhint could validate url's as well. Since running htmlhint over swig files will naturally fail, there needs to be a way of validating combined html from several template files. Like the grunt-htmllint-http plugin does. But ideally you wouldn't want another grunt plugin for that if you ask me.

I could see an example config like this:

htmlhint: {
  options: {
    'tag-pair': true
  },
  dist: {
    src: [
      'http://localhost/',
      'http://localhost/articles.html'
    ]
  }
}

But this is of course only a proposal, maybe a different way of specifying url's makes more sense?

Edit: I could help with the development of this feature, if you agree this would be a nice addition.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.