As a frontend project, twbs/bootlint has picked up 2.4k stars on GitHub (JavaScript). HTML linter for Bootstrap projects
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
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 or grunt-html.
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.
Via Gulp
If you want to use Bootlint with Gulp, there is an unofficial Gulp plugin: gulp-bootlint
This will output the lint warnings applicable to each file.
The CLI also accepts a --disable (or -d) option to disable certain lint checks. --disable takes a comma-separated list of lint problem IDs. Here's an example:
Bootlint can run directly in the browser! This is accomplished by using a bookmarklet, which appends bootlint to the body of the active page. There are a few nice benefits of running bootlint directly in the browser. They include:
Evaluating page markup after AJAX requests complete.
Evaluating pages that are dynamically created server-side (ex: CMS).
Evaluating pages/sites that do not have a build script.
How to install the bookmarklet
Please follow the instructions below to get up and running:
Create a new bookmark in your browser
Set the name/title equal to something that is easy to remember. Ex: Run Bootlint
Note: The snippet above will ensure you are always running the latest version of bootlint. If you want to reference a specific version of bootlint please see the BootstrapCDN. Copy the URL and update s.src="PASTE-ME-HERE".
How to use the bookmarklet
Click the bookmark you created above
A popup will appear informing you if issues were detected
If issues exist, please open the developer tools and select the console tab
Alternative Options
Browser ready script
You can manually download the browser-ready version of Bootlint.
Lint problem explanations
For detailed explanations of each lint problem, look up the IDs (for example, E001 or W002) in our wiki.
API Documentation
Bootlint is a CommonJS module.
Bootlint represents the lint problems it reports using the LintError and LintWarning classes:
LintWarning
Represents a potential error. It may have false-positives.
Constructor: LintWarning(id, message, elements)
Properties:
id - Unique string ID for this type of lint problem. Of the form "W###" (e.g. "W123").
message - Human-readable string describing the problem
elements - jQuery or Cheerio collection of referenced DOM elements pointing to all problem locations in the document
(Only available under Node.js): When available from the underlying HTML parser (which is most of the time), the DOM elements in the collection will have a .startLocation property that is a Location (see below) indicating the location of the element in the document's HTML source
LintError
Represents an error. Under the assumptions explained in the above "Caveats" section, it should never have any false-positives.
Constructor: LintError(id, message, elements)
Properties:
id - Unique string ID for this type of lint problem. Of the form "E###" (e.g. "E123").
message - Human-readable string describing the problem
elements - jQuery or Cheerio collection of referenced DOM elements pointing to all problem locations in the document
(Only available under Node.js): When available from the underlying HTML parser (which is most of the time), the DOM elements in the collection will have a .startLocation property that is a Location (see below) indicating the location of the element in the document's HTML source
Bootlint defines the following public utility class:
Location (Only available under Node.js)
Represents a location in the HTML source
Constructor: Location(line, column)
Properties:
line - 0-based line number
column - 0-based column number
A reporter is a function that accepts exactly 1 argument of type LintWarning or LintError. Its return value is ignored. It should somehow record the problem or display it to the user.
Browser
Bootlint exports a bootlint property on the global window object.
In a browser environment, the following public APIs are available:
bootlint.lintCurrentDocument(reporter, disabledIds): Lints the HTML of the current document and calls the reporter() function repeatedly with each lint problem as an argument.
reporter is a reporter function (see above for a definition). It will be called repeatedly with each lint problem as an argument.
disabledIds is an array of string linter IDs to disable
Returns nothing (i.e. undefined)
bootlint.showLintReportForCurrentDocument(disabledIds, alertOpts): Lints the HTML of the current document and reports the linting results to the user. Each warning will be output individually using console.warn().
disabledIds is an array of string linter IDs to disable
alertOpts is an optional options object with the following properties:
hasProblems (type: boolean; default: true) - window.alert() a single general notification message to the user if there are any lint problems?
problemFree (type: boolean; default: true) - window.alert() a notification message to the user if the document has no lint problems?
Returns nothing (i.e. undefined)
Node.js
Example:
var bootlint = require('bootlint');
function reporter(lint) {
console.log(lint.id, lint.message);
}
bootlint.lintHtml("<!DOCTYPE html><html>...", reporter, []); // calls reporter() repeatedly with each lint problem as an argument
In a Node.js environment, Bootlint exposes the following public API:
bootlint.lintHtml(html, reporter, disabledIds): Lints the given HTML for a webpage and returns the linting results.
html is the HTML to lint, as a string
reporter is a reporter function (see above for a definition). It will be called repeatedly with each lint problem as an argument.
disabledIds is an array of string linter IDs to disable
Returns nothing (i.e. undefined)
HTTP API
Bootlint can also be run as an HTTP server that exposes a very simple API. See https://github.com/twbs/bootlint-server.
Contributing
The project's coding style is laid out in the ESLint configuration. Add unit tests for any new or changed functionality. Lint and test your code using the npm scripts.
Also, please don't edit files in the "dist" subdirectory as they are generated via npm run dist. You'll find the source code in the "src" subdirectory!
Release History
See the GitHub Releases page for detailed changelogs.
(next release) - master
2015-11-25 - v0.14.2: Fix critical CLI bug introduced in v0.14.0 and add tests to prevent its recurrence. Update current Bootstrap version to v3.3.6.
2015-11-16 - v0.14.1: Forgot to regenerate browser version when tagging v0.14.0
2015-11-16 - v0.14.0: Adds 3 new lint checks.
2015-11-15 - v0.13.0: Removes E036. Adds a few new checks. Bumps dependency versions.
2015-03-16 - v0.12.0: Adds warning if Bootstrap v4 is detected (since Bootlint is currently only compatible with Bootstrap v3). Minor fixes to some existing lint checks.
2015-02-23 - v0.11.0: Adds several new lint checks. Improves stdin handling. Bumps dependency versions.
2015-01-21 - v0.10.0: By default, the in-browser version now alert()s when no lint problems are found. Adds validity check for carousel control & indicator targets.
2015-01-07 - v0.9.2: Fixes a problem when using the CLI via node's child_process.exec.
2014-12-19 - v0.9.1: Fixes a W013 false positive.
2014-12-18 - v0.9.0: Fixes several small bugs and tweaks a few existing checks. Adds 4 new lint checks.
2014-11-07 - v0.8.0: When in a Node.js environment, report the locations of the HTML source code of problematic elements.
2014-10-31 - v0.6.0: Fixes crash bug. Adds some new lint checks. Adds HTTP API.
2014-10-16 - v0.5.0: Adds several new features. Adds official bookmarklet. Disables auto-lint-on-load in browser. Tweaks some checks. Not backward compatible
2014-10-07 - v0.4.0: Adds checks for correct Glyphicon usage and correct modal DOM structure; fixes .panel-footer false positive
2014-09-26 - v0.3.0: Several bug fixes and enhancements. Not backward compatible
2014-09-23 - v0.2.0: First formal release. Announcement: https://blog.getbootstrap.com/2014/09/23/bootlint/
License
Copyright (c) 2014-2019 The Bootlint Authors. Licensed under the MIT License.
How does twbs/bootlint compare to other Frontend projects?
twbs/bootlint is tracked by TopGit in the Frontend category, with 2.4k GitHub stars and written in JavaScript. Browse the Frontend topic page on TopGit to compare it against similar projects by stars and activity.
Is twbs/bootlint open source?
Yes — twbs/bootlint ships under the MIT license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/twbs/bootlint.
What else is in the Frontend space?
twbs/bootlint is tracked by TopGit under the Frontend category, alongside 5 GitHub-tagged topics. Trending and Topics pages list peer repositories of comparable stars and language.
What is twbs/bootlint?
twbs/bootlint (twbs/bootlint) is a JavaScript project on GitHub. From the project's own README: HTML linter for Bootstrap projects
Where do I read more about twbs/bootlint?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/twbs/bootlint is the definitive source.
Why is twbs/bootlint categorized under Frontend?
TopGit places twbs/bootlint in the Frontend category based on its GitHub topics and description (tagged: "bookmarklet", "bootlint", "bootstrap"). Categories are assigned from real repository metadata, not editorial guesswork.
Read full README in the tab above.
Still deciding about bootlint?
One click hands the question to an AI along with this page — see what it says about bootlint.