Giter Club home page Giter Club logo

grunt-bootlint's Introduction

grunt-bootlint

A Grunt wrapper for Bootlint, the HTML linter for Bootstrap projects

NPM version Build Status MIT License Dependency Status devDependency Status

Getting Started

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-bootlint --save-dev

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

grunt.loadNpmTasks('grunt-bootlint');

The "bootlint" task

Overview

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

grunt.initConfig({
  bootlint: {
    options: {
      stoponerror: false,
      relaxerror: []
    },
    files: ['path/to/file.html', 'path/to/*.html']
  }
});

Options

Usage Examples

Default Options

In this example, the default options are used to lint files for common problems in bootstrap.

grunt.initConfig({
  bootlint: {
    options: {
      relaxerror: [],
      showallerrors: false,
      stoponerror: false,
      stoponwarning: false
    },
    files: ['test/fixtures/*.html']
  }
});

Settings

options.stoponerror

  • Type: Boolean
  • Default: false

Breaks out of grunt task on first error problem ID. Use --force to force continue.

options.stoponwarning

  • Type: Boolean
  • Default: false

Breaks out of grunt task on first warning problem ID. Use --force to force continue.

options.showallerrors

  • Type: Boolean
  • Default: false

Shows all errors and warnings before stopping the task. (Overrides stoponerror and stoponwarning, above.)

options.relaxerror

  • Type: Array | Object
  • Default: []

Array of bootlint problem ID codes (Strings) to explicitly ignore.

Object of bootlint problem ID codes as keys and filepath globs as array value.

Example
relaxerror: {
  'E001': [],
  'W005': [
    'path/to/file.html',
    'file/path/*.glob'
  ]
},

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

  • 2016-04-05 - v0.10.1: Updates for Grunt 1.0.0 compatibility and adds pluralize for files/errors.
  • 2015-11-24 - v0.10.0: Updates Bootlint to v0.14.1 and adds the ability to ignore lint problems on a per-file basis using relaxerror.
  • 2015-06-01 - v0.9.1: Minor update to license metadata.
  • 2015-03-16 - v0.9.0: Updates Bootlint to v0.12.0
  • 2015-02-25 - v0.8.0: Updates Bootlint to v0.11.0
  • 2015-01-23 - v0.7.0: Updates Bootlint to v0.10.0
  • 2014-12-23 - v0.6.0: Updates Bootlint to v0.9.1
  • 2014-11-12 - v0.5.3: Fixes issue with stoponerror option
  • 2014-11-12 - v0.5.2: Fixes issue with stoponerror option This was a bad release. Please upgrade.
  • 2014-11-10 - v0.5.1: Displays message when files pass
  • 2014-11-10 - v0.5.0: Updates Bootlint, adds line/col numbers to output, quieter output.
  • 2014-11-03 - v0.4.0: Updates Bootlint dependency.
  • 2014-10-17 - v0.3.0: Basic support for Bootlint 0.5.0. Changes relaxerror to use Bootlint problem IDs
  • 2014-09-25 - v0.2.1: Removes color dependency.
  • 2014-09-25 - v0.2.0: First formal release.

License and copyright

Code released under the MIT license.

grunt-bootlint's People

Contributors

cvrebert avatar dependabot[bot] avatar freezy-sk avatar hnrch02 avatar xhmikosr avatar zacechola 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  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grunt-bootlint's Issues

Should fail on error

Right now it logs out the error as a warning, but doesn't cause a failure.

Might want to make that an option to toggle on or off.

option: stoponwarning

Add more granular controls for task failure on (non-relaxed) warnings and errors.

For example:

  • (stoponerror && stoponwarning == false): Only fail the task on errors.
  • (stoponerror && stoponwarning): Fail the task on any error or warning.

This is sort of breaking behavior for stoponerror.

Can't seem to lint pages via http

I'm trying to lint a php page generated by WordPress, with the following code:

bootlint: {  
    options: {  
        stoponerror: false,
        relaxerror: []
    },
    files: ["http://local.dev/"],
    }

I'm removing the doctype from the document at that URL so that it should trigger a Bootlint error, but all I get is "no Bootlint errors" so I don't believe that the page is actually getting scanned. When I point at a sample page that's mapped via the file system (i.e. files: ["path/file.php"]) then Bootlint does trigger errors as expected.

Since I'm using a CMS only linting the rendered pages make sense. (Sorry for having misfiled this earlier under the main bootlint project instead of here, and thanks for doing this!)

Tweak description?

Could you tweak the description in package.json so that it mentions grunt?
Right now the description is exactly the same as that of Bootlint itself (except for "An "), which is slightly confusing.

Ignore templating code

<div class="row">
  <div class="col-xs-11"></div>
  <% if (condition) { %>
    <div class="col-xs-1"></div>
  <% } %>
</div>

This code raises errors E013 and E014 and I don't want to relax those errors on the entire project.
Is it possible to have bootlint ignore templating code?

Stop on error

Provide option to stop linting on first error found.

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.