2014-07-26 08:48:19 +04:00
# grunt-bootlint
2019-10-06 13:44:05 +03:00
> A Grunt wrapper for [Bootlint](https://www.npmjs.org/package/bootlint), the HTML linter for [Bootstrap](https://getbootstrap.com/) projects
2014-09-25 21:44:51 +04:00
2015-11-18 23:03:46 +03:00
[![NPM version ](https://img.shields.io/npm/v/grunt-bootlint.svg )](https://www.npmjs.com/package/grunt-bootlint)
2019-10-06 13:44:05 +03:00
[![Build Status ](https://github.com/twbs/grunt-bootlint/workflows/Tests/badge.svg )](https://github.com/twbs/grunt-bootlint/actions?workflow=Tests)
2018-12-28 18:50:34 +03:00
[![MIT License ](https://img.shields.io/npm/l/grunt-bootlint.svg )](https://github.com/twbs/grunt-bootlint/blob/master/LICENSE)
2015-11-18 23:03:46 +03:00
[![Dependency Status ](https://img.shields.io/david/twbs/grunt-bootlint.svg )](https://david-dm.org/twbs/grunt-bootlint)
2019-07-28 12:22:18 +03:00
[![devDependency Status ](https://img.shields.io/david/dev/twbs/grunt-bootlint.svg )](https://david-dm.org/twbs/grunt-bootlint?type=dev)
2014-07-26 08:48:19 +04:00
## Getting Started
2019-07-28 12:23:32 +03:00
If you haven't used [Grunt ](https://gruntjs.com/ ) before, be sure to check out the [Getting Started ](https://gruntjs.com/getting-started ) guide, as it explains how to create a [Gruntfile ](https://gruntjs.com/sample-gruntfile ) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
2014-07-26 08:48:19 +04:00
```shell
npm install grunt-bootlint --save-dev
```
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
```js
grunt.loadNpmTasks('grunt-bootlint');
```
## The "bootlint" task
### Overview
2017-02-20 00:12:52 +03:00
2014-07-26 08:48:19 +04:00
In your project's Gruntfile, add a section named `bootlint` to the data object passed into `grunt.initConfig()` .
```js
grunt.initConfig({
bootlint: {
options: {
2014-07-29 00:31:20 +04:00
stoponerror: false,
relaxerror: []
2014-07-26 08:48:19 +04:00
},
2015-02-25 02:49:06 +03:00
files: ['path/to/file.html', 'path/to/*.html']
}
2014-07-26 08:48:19 +04:00
});
```
### Options
### Usage Examples
#### Default Options
2015-02-25 02:49:06 +03:00
2015-03-03 16:59:14 +03:00
In this example, the default options are used to lint files for common problems in bootstrap.
2014-07-26 08:48:19 +04:00
```js
grunt.initConfig({
bootlint: {
2014-08-19 23:02:14 +04:00
options: {
2015-02-25 02:49:06 +03:00
relaxerror: [],
showallerrors: false,
2014-08-19 23:02:14 +04:00
stoponerror: false,
2015-02-25 02:49:06 +03:00
stoponwarning: false
2014-08-19 23:02:14 +04:00
},
2015-02-25 02:49:06 +03:00
files: ['test/fixtures/*.html']
}
2014-08-19 23:02:14 +04:00
});
```
### Settings
#### options.stoponerror
* Type: `Boolean`
* Default: `false`
2014-11-15 00:03:15 +03:00
Breaks out of grunt task on first error problem ID. Use `--force` to force continue.
2014-12-31 05:06:54 +03:00
#### options.stoponwarning
2014-11-15 00:03:15 +03:00
* Type: `Boolean`
* Default: `false`
Breaks out of grunt task on first warning problem ID. Use `--force` to force continue.
2015-02-25 02:49:06 +03:00
#### options.showallerrors
2014-12-31 18:29:44 +03:00
* Type: `Boolean`
* Default: `false`
Shows all errors and warnings before stopping the task. (Overrides `stoponerror` and `stoponwarning` , above.)
2014-08-19 23:02:14 +04:00
#### options.relaxerror
2017-02-20 00:12:52 +03:00
* Type: `Array` | `Object`
2014-08-19 23:02:14 +04:00
* Default: `[]`
2015-08-27 20:55:43 +03:00
Array of [bootlint problem ID codes][] (`String`s) to explicitly ignore.
2015-11-25 10:55:06 +03:00
Object of [bootlint problem ID codes][] as **keys** and filepath globs as array **value** .
2015-08-27 20:55:43 +03:00
##### Example
2017-02-20 00:12:52 +03:00
```js
2015-08-27 20:55:43 +03:00
relaxerror: {
'E001': [],
'W005': [
2015-11-16 18:59:55 +03:00
'path/to/file.html',
2015-11-25 10:55:06 +03:00
'file/path/*.glob'
2015-08-27 20:55:43 +03:00
]
},
```
2014-08-19 23:02:14 +04:00
2014-07-26 08:48:19 +04:00
## Contributing
2015-02-25 02:49:06 +03:00
2019-07-28 12:23:32 +03:00
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 ](https://gruntjs.com/ ).
2014-07-26 08:48:19 +04:00
## Release History
2014-09-25 21:33:47 +04:00
2017-02-20 00:12:52 +03:00
* 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.
2015-03-03 16:59:14 +03:00
## License and copyright
2018-12-28 18:50:34 +03:00
Code released under [the MIT license ](https://github.com/twbs/grunt-bootlint/blob/master/LICENSE ).
2015-03-16 22:38:58 +03:00
2015-08-27 20:55:43 +03:00
[bootlint problem ID codes]: https://github.com/twbs/bootlint/wiki