HTML linter for Bootstrap projects
Перейти к файлу
Chris Rebert 99eaa68b4c Merge pull request #97 from twbs/form-control-feedback-ancestor
`.form-control-feedback` must have a `.form-group.has-feedback` ancestor
2014-09-25 15:54:16 -07:00
dist/browser nicer banner format for browserfy'd version 2014-09-23 17:37:49 -07:00
src `.form-control-feedback` must have a `.form-group.has-feedback` ancestor 2014-09-26 00:48:30 +02:00
test `.form-control-feedback` must have a `.form-group.has-feedback` ancestor 2014-09-26 00:48:30 +02:00
.editorconfig add editorconfig via yeoman 2014-07-11 01:24:21 -07:00
.eslintrc Follow-up to #79: Fix ESLint complaints 2014-09-25 21:57:10 +02:00
.gitattributes Enforce Unix line endings. 2014-09-25 11:26:58 +03:00
.gitignore adding vim swap files to ignore 2014-09-10 12:31:00 -05:00
.jscsrc fix/integrate JSCS 2014-07-11 03:11:31 -07:00
.jshintrc get initial browserify'd version working 2014-07-20 16:59:14 -07:00
.travis.yml Make Bootstrap docs+examples test more comprehensive 2014-09-25 15:41:25 -07:00
CONTRIBUTING.md Welcome to the Twbs family, Bootlint! 2014-09-23 15:24:19 -07:00
Gruntfile.js increase QUnit/PhantomJS timeout 2014-09-25 14:38:11 -07:00
LICENSE Update LICENSE 2014-07-12 21:07:06 -07:00
README.md add grunt-bootlint to Getting Started section of README 2014-09-25 10:52:14 -07:00
package.json Integrate ESLint. 2014-09-25 20:26:02 +03:00

README.md

Bootlint

NPM version Build Status Dependency Status devDependency Status

An HTML linter for Bootstrap projects

What's Bootlint?

Bootlint is a tool that checks for several common HTML mistakes in webpages that are using Bootstrap in a fairly "vanilla" way. Vanilla Bootstrap's components/widgets require their parts of the DOM to conform to certain structures. Bootlint checks that instances of Bootstrap components have correctly-structured HTML. Optimal usage of Bootstrap also requires that your pages include certain <meta> tags, an HTML5 doctype declaration, etc.; Bootlint checks that these are present.

Caveats

Bootlint assumes that your webpage is already valid HTML5. If you need to check HTML5 validity, we recommend tools like vnu.jar, grunt-html, or grunt-html-validation.

Bootlint assumes that you are using Bootstrap's default class names in your webpage, as opposed to taking advantage of the "mixins" functionality of Less or Sass to map them to custom class names. If you are using mixins, Bootlint may report some false-positive warnings. However, there are some Bootlint checks that are applicable even if you are using mixins pervasively.

Getting Started

Via Grunt

To use Bootlint with Grunt, use the official Grunt plugin: grunt-bootlint

On the command line

Install the module with: npm install -g bootlint

Run it on some HTML files:

$ bootlint /path/to/some/webpage.html another_webpage.html [...]

This will output the lint warnings applicable to each file.

In the browser

Download the code.

In your webpage:

<script src="dist/browser/bootlint.js"></script>

Then check the JavaScript console for lint warning messages.

API Documentation

Bootlint is a CommonJS module.

Browser

Bootlint exports a bootlint property on the global window object. In a browser environment, the following public APIs are available:

  • bootlint.lintCurrentDocument(): Lints the HTML of the current document and returns the linting results.
    • Returns an array of lint warning strings
  • bootlint.showLintReportForCurrentDocument(): Lints the HTML of the current document and reports the linting results to the user.
    • If there are any lint warnings, one general notification message will be window.alert()-ed to the user. Each warning will be output individually using console.warn().
    • Returns nothing (i.e. undefined)

Node.js

Example:

var bootlint = require('bootlint');
bootlint.lintHtml("<!DOCTYPE html><html>..."); // returns list of lint warning messages

In a Node.js environment, Bootlint exposes the following public API:

  • bootlint.lintHtml(html): Lints the given HTML for a webpage and returns the linting results.
    • Has 1 required parameter: the HTML to lint, as a string
    • Returns an array of lint warning strings

Contributing

The project's coding style is laid out in the JSHint, ESLint, and JSCS configurations. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Also, please don't edit files in the "dist" subdirectory as they are generated via Grunt. You'll find source code in the "src" subdirectory!

Release History

License

Copyright (c) 2014 Christopher Rebert. Licensed under the MIT license.