[Pkg-javascript-commits] [less.js] 03/58: initial warnings

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:28:21 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag v2.3.0
in repository less.js.

commit 0f29c4f094dd48a654f9462ff48e9fc5a68bc4c7
Author: Luke Page <luke.a.page at gmail.com>
Date:   Fri Nov 28 19:48:16 2014 +0000

    initial warnings
---
 lib/less/visitors/extend-visitor.js | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/lib/less/visitors/extend-visitor.js b/lib/less/visitors/extend-visitor.js
index 6d17db2..06f37c5 100644
--- a/lib/less/visitors/extend-visitor.js
+++ b/lib/less/visitors/extend-visitor.js
@@ -1,5 +1,6 @@
 var tree = require("../tree"),
-    Visitor = require("./visitor");
+    Visitor = require("./visitor"),
+    logger = require("../logger");
 
 /*jshint loopfunc:true */
 
@@ -98,7 +99,20 @@ ProcessExtendsVisitor.prototype = {
         if (!extendFinder.foundExtends) { return root; }
         root.allExtends = root.allExtends.concat(this.doExtendChaining(root.allExtends, root.allExtends));
         this.allExtendsStack = [root.allExtends];
-        return this._visitor.visit(root);
+        var newRoot = this._visitor.visit(root);
+        this.checkExtendsForNonMatched(root.allExtends);
+        return newRoot;
+    },
+    checkExtendsForNonMatched: function(extendList) {
+        extendList.filter(function(extend) {
+            return !extend.hasFoundMatches;
+        }).forEach(function(extend) {
+                var selector = "_unknown_";
+                try {
+                    selector = extend.selector.toCSS({});
+                }catch(_){}
+                logger.warn("extend '"+selector+"' has no matches");
+            });
     },
     doExtendChaining: function (extendsList, extendsListTarget, iterationCount) {
         //
@@ -135,6 +149,8 @@ ProcessExtendsVisitor.prototype = {
 
                 if (matches.length) {
 
+                    extend.hasFoundMatches = true;
+
                     // we found a match, so for each self selector..
                     extend.selfSelectors.forEach(function(selfSelector) {
 
@@ -218,6 +234,7 @@ ProcessExtendsVisitor.prototype = {
                 matches = this.findMatch(allExtends[extendIndex], selectorPath);
 
                 if (matches.length) {
+                    allExtends[extendIndex].hasFoundMatches = true;
 
                     allExtends[extendIndex].selfSelectors.forEach(function(selfSelector) {
                         selectorsToAdd.push(extendVisitor.extendSelector(matches, selectorPath, selfSelector));
@@ -403,7 +420,9 @@ ProcessExtendsVisitor.prototype = {
         this.allExtendsStack.push(newAllExtends);
     },
     visitMediaOut: function (mediaNode) {
-        this.allExtendsStack.length = this.allExtendsStack.length - 1;
+        var lastIndex = this.allExtendsStack.length - 1;
+        this.checkExtendsForNonMatched(this.allExtendsStack[lastIndex]);
+        this.allExtendsStack.length = lastIndex;
     },
     visitDirective: function (directiveNode, visitArgs) {
         var newAllExtends = directiveNode.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length-1]);
@@ -411,7 +430,9 @@ ProcessExtendsVisitor.prototype = {
         this.allExtendsStack.push(newAllExtends);
     },
     visitDirectiveOut: function (directiveNode) {
-        this.allExtendsStack.length = this.allExtendsStack.length - 1;
+        var lastIndex = this.allExtendsStack.length - 1;
+        this.checkExtendsForNonMatched(this.allExtendsStack[lastIndex]);
+        this.allExtendsStack.length = lastIndex;
     }
 };
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git



More information about the Pkg-javascript-commits mailing list