From ca920c09943aaf4867c8cb38153f70810668d43a Mon Sep 17 00:00:00 2001 From: Zac Echola Date: Fri, 14 Nov 2014 20:13:57 -0600 Subject: [PATCH 1/3] Warn about .pull-right or .pull-left within a navbar Closes #188 --- dist/browser/bootlint.js | 69 +++++++++++++++++++++--- src/bootlint.js | 6 +++ test/bootlint_test.js | 13 +++++ test/fixtures/navbar/navbar-classes.html | 33 ++++++++++++ test/fixtures/navbar/pull-classes.html | 34 ++++++++++++ 5 files changed, 148 insertions(+), 7 deletions(-) create mode 100644 test/fixtures/navbar/navbar-classes.html create mode 100644 test/fixtures/navbar/pull-classes.html diff --git a/dist/browser/bootlint.js b/dist/browser/bootlint.js index 31493585..56b1d890 100644 --- a/dist/browser/bootlint.js +++ b/dist/browser/bootlint.js @@ -10332,6 +10332,7 @@ if (typeof define === 'function' && define.amd) /*eslint-env node */ var cheerio = require('cheerio'); +var parseUrl = require('url').parse; var semver = require('semver'); var _location = require('./location'); var LocationIndex = _location.LocationIndex; @@ -10683,10 +10684,8 @@ var LocationIndex = _location.LocationIndex; // check for jQuery + + + + + + + + +
+
+ + + diff --git a/test/fixtures/navbar/pull-classes.html b/test/fixtures/navbar/pull-classes.html new file mode 100644 index 00000000..38eb2e4c --- /dev/null +++ b/test/fixtures/navbar/pull-classes.html @@ -0,0 +1,34 @@ + + + + + + + Test + + + + + + + + + + +
+
    +
  1. +
+ + From 4a2c6e71858d20bdcae8fdaa9fdfc978df7a7baa Mon Sep 17 00:00:00 2001 From: Zac Echola Date: Fri, 16 Jan 2015 08:47:36 -0600 Subject: [PATCH 2/3] rename function --- src/bootlint.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootlint.js b/src/bootlint.js index b0280780..9ccb9a75 100644 --- a/src/bootlint.js +++ b/src/bootlint.js @@ -780,7 +780,7 @@ var LocationIndex = _location.LocationIndex; reporter('Using `.pull-left` or `.pull-right` as part of the media object component is deprecated as of Bootstrap v3.3.0. Use `.media-left` or `.media-right` instead.', mediaPulls); } }); - addLinter("W011", function lintMediaPulls($, reporter) { + addLinter("W011", function lintPullsInNavbar($, reporter) { var mediaPulls = $('.navbar .pull-left, .navbar .pull-right'); if (mediaPulls.length) { reporter('To align components in navbars with utility classes, use `.navbar-left` or `.navbar-right` instead.', mediaPulls); From b4cb245251f557532cfc1fb78f2106cd88b1fe0d Mon Sep 17 00:00:00 2001 From: Zac Echola Date: Mon, 6 Apr 2015 12:26:22 -0500 Subject: [PATCH 3/3] More explicitly targeting components Quick floats can be used within components that are within a navbar, but not on individual components. See this [comment](https://github.com/twbs/bootlint/pull/189#discussion_r22958457) Add brand to list and adjust test --- src/bootlint.js | 13 +++++++++---- test/fixtures/navbar/pull-classes.html | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/bootlint.js b/src/bootlint.js index 9ccb9a75..065252ab 100644 --- a/src/bootlint.js +++ b/src/bootlint.js @@ -781,10 +781,15 @@ var LocationIndex = _location.LocationIndex; } }); addLinter("W011", function lintPullsInNavbar($, reporter) { - var mediaPulls = $('.navbar .pull-left, .navbar .pull-right'); - if (mediaPulls.length) { - reporter('To align components in navbars with utility classes, use `.navbar-left` or `.navbar-right` instead.', mediaPulls); - } + var navComponents = '.navbar-nav, .navbar-text, .navbar-btn, .navbar-link, .navbar-brand'; + var pulls = ['pull-right', 'pull-left']; + $(navComponents).each(function () { + pulls.forEach(function(pull) { + if ($(this).hasClass(pull)) { + reporter('To align components in navbars with utility classes, use `.navbar-left` or `.navbar-right` instead.', $(this)); + } + }, this); + }); }); exports._lint = function ($, reporter, disabledIdList, html) { diff --git a/test/fixtures/navbar/pull-classes.html b/test/fixtures/navbar/pull-classes.html index 38eb2e4c..b6e09e93 100644 --- a/test/fixtures/navbar/pull-classes.html +++ b/test/fixtures/navbar/pull-classes.html @@ -19,7 +19,7 @@